GCC Middle and Back End API Reference
region.h
Go to the documentation of this file.
1/* Regions of memory.
2 Copyright (C) 2019-2024 Free Software Foundation, Inc.
3 Contributed by David Malcolm <dmalcolm@redhat.com>.
4
5This file is part of GCC.
6
7GCC is free software; you can redistribute it and/or modify it
8under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 3, or (at your option)
10any later version.
11
12GCC is distributed in the hope that it will be useful, but
13WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with GCC; see the file COPYING3. If not see
19<http://www.gnu.org/licenses/>. */
20
21#ifndef GCC_ANALYZER_REGION_H
22#define GCC_ANALYZER_REGION_H
23
24#include "analyzer/symbol.h"
25#include "text-art/widget.h"
26
27namespace ana {
28
29/* An enum for identifying different spaces within memory. */
30
42
43/* An enum for discriminating between the different concrete subclasses
44 of region. */
45
73
74/* Region and its subclasses.
75
76 The class hierarchy looks like this (using indentation to show
77 inheritance, and with region_kinds shown for the concrete subclasses):
78
79 region
80 space_region
81 frame_region (RK_FRAME): a function frame on the stack
82 globals_region (RK_GLOBALS): holds globals variables (data and bss)
83 code_region (RK_CODE): represents the code segment, containing functions
84 stack_region (RK_STACK): a stack, containing all stack frames
85 heap_region (RK_HEAP): the heap, containing heap_allocated_regions
86 thread_local_region (RK_THREAD_LOCAL): thread-local data for the thread
87 being analyzed
88 root_region (RK_ROOT): the top-level region
89 function_region (RK_FUNCTION): the code for a particular function
90 label_region (RK_LABEL): a particular label within a function
91 symbolic_region (RK_SYMBOLIC): dereferencing a symbolic pointer
92 decl_region (RK_DECL): the memory occupied by a particular global, local,
93 or SSA name
94 field_region (RK_FIELD): the memory occupied by a field within a struct
95 or union
96 element_region (RK_ELEMENT): an element within an array
97 offset_region (RK_OFFSET): a byte-offset within another region, for
98 handling pointer arithmetic as a region
99 sized_region (RK_SIZED): a subregion of symbolic size (in bytes)
100 within its parent
101 cast_region (RK_CAST): a region that views another region using a
102 different type
103 heap_allocated_region (RK_HEAP_ALLOCATED): an untyped region dynamically
104 allocated on the heap via
105 "malloc" or similar
106 alloca_region (RK_ALLOCA): an untyped region dynamically allocated on the
107 stack via "alloca"
108 string_region (RK_STRING): a region for a STRING_CST
109 bit_range_region (RK_BIT_RANGE): a region for a specific range of bits
110 within another region
111 var_arg_region (RK_VAR_ARG): a region for the N-th vararg within a
112 frame_region for a variadic call
113 errno_region (RK_ERRNO): a region for holding "errno"
114 private_region (RK_PRIVATE): a region for internal state of an API
115 unknown_region (RK_UNKNOWN): for handling unimplemented tree codes. */
116
117/* Abstract base class for representing ways of accessing chunks of memory.
118
119 Regions form a tree-like hierarchy, with a root region at the base,
120 with memory space regions within it, representing the stack and
121 globals, with frames within the stack, and regions for variables
122 within the frames and the "globals" region. Regions for structs
123 can have subregions for fields. */
124
125class region : public symbol
126{
127public:
128 virtual ~region ();
129
130 virtual enum region_kind get_kind () const = 0;
131 virtual const frame_region *
132 dyn_cast_frame_region () const { return NULL; }
133 virtual const function_region *
134 dyn_cast_function_region () const { return NULL; }
135 virtual const symbolic_region *
136 dyn_cast_symbolic_region () const { return NULL; }
137 virtual const decl_region *
138 dyn_cast_decl_region () const { return NULL; }
139 virtual const field_region *
140 dyn_cast_field_region () const { return NULL; }
141 virtual const element_region *
142 dyn_cast_element_region () const { return NULL; }
143 virtual const offset_region *
144 dyn_cast_offset_region () const { return NULL; }
145 virtual const sized_region *
146 dyn_cast_sized_region () const { return NULL; }
147 virtual const cast_region *
148 dyn_cast_cast_region () const { return NULL; }
149 virtual const string_region *
150 dyn_cast_string_region () const { return NULL; }
151 virtual const bit_range_region *
152 dyn_cast_bit_range_region () const { return NULL; }
153 virtual const var_arg_region *
154 dyn_cast_var_arg_region () const { return NULL; }
155
156 virtual void accept (visitor *v) const;
157
158 const region *get_parent_region () const { return m_parent; }
159 const region *get_base_region () const;
160 bool base_region_p () const;
161 bool descendent_of_p (const region *elder) const;
166
168
169 tree get_type () const { return m_type; }
170
171 void print (const region_model &model,
172 pretty_printer *pp) const;
173 label_text get_desc (bool simple=true) const;
174
175 virtual void dump_to_pp (pretty_printer *pp, bool simple) const = 0;
176 void dump (bool simple) const;
177 void dump () const;
178
179 std::unique_ptr<json::value> to_json () const;
180
181
183 const region_model &model) const;
184
185 std::unique_ptr<text_art::tree_widget>
186 make_dump_widget (const text_art::dump_widget_info &dwi,
187 const char *prefix = nullptr) const;
188
189 bool non_null_p () const;
190
191 static int cmp_ptr_ptr (const void *, const void *);
192
193 bool involves_p (const svalue *sval) const;
194
197
198 /* Attempt to get the size of this region as a concrete number of bytes.
199 If successful, return true and write the size to *OUT.
200 Otherwise return false.
201 This is the accessed size, not necessarily the size that's valid to
202 access. */
203 virtual bool get_byte_size (byte_size_t *out) const;
204
205 /* Attempt to get the size of this region as a concrete number of bits.
206 If successful, return true and write the size to *OUT.
207 Otherwise return false.
208 This is the accessed size, not necessarily the size that's valid to
209 access. */
210 virtual bool get_bit_size (bit_size_t *out) const;
211
212 /* Get a symbolic value describing the size of this region in bytes
213 (which could be "unknown").
214 This is the accessed size, not necessarily the size that's valid to
215 access. */
216 virtual const svalue *get_byte_size_sval (region_model_manager *mgr) const;
217
218 /* Get a symbolic value describing the size of this region in bits
219 (which could be "unknown").
220 This is the accessed size, not necessarily the size that's valid to
221 access. */
222 virtual const svalue *get_bit_size_sval (region_model_manager *mgr) const;
223
224 /* Attempt to get the offset in bits of this region relative to its parent.
225 If successful, return true and write to *OUT.
226 Otherwise return false. */
228
229 /* Get the offset in bytes of this region relative to its parent as a svalue.
230 Might return an unknown_svalue. */
231 virtual const svalue *
233
234 /* Attempt to get the position and size of this region expressed as a
235 concrete range of bytes relative to its parent.
236 If successful, return true and write to *OUT.
237 Otherwise return false. */
239
240 void
242 bit_offset_t start_bit_offset,
243 bit_size_t size_in_bits,
244 tree type,
245 auto_vec <const region *> *out) const;
246
248
249 bool symbolic_p () const;
250
251 /* For most base regions it makes sense to track the bindings of the region
252 within the store. As an optimization, some are not tracked (to avoid
253 bloating the store object with redundant binding clusters). */
254 virtual bool tracked_p () const { return true; }
255
256 bool is_named_decl_p (const char *decl_name) const;
257
258 bool empty_p () const;
259
260 protected:
261 region (complexity c, symbol::id_t id, const region *parent, tree type);
262
263 private:
266
267 virtual void
269 virtual void
270 add_dump_widget_children (text_art::tree_widget &,
271 const text_art::dump_widget_info &dwi) const;
272
275
277
278 /* For regions within a global decl, a cache of the svalue for the initial
279 value of this region when the program starts. */
281};
282
283} // namespace ana
284
285template <>
286template <>
287inline bool
289{
290 return true;
291}
292
293namespace ana {
294
295/* Abstract subclass of region, for regions that represent an untyped
296 space within memory, such as the stack or the heap. */
297
298class space_region : public region
299{
300protected:
301 space_region (symbol::id_t id, const region *parent)
302 : region (complexity (parent), id, parent, NULL_TREE)
303 {}
304};
305
306/* Concrete space_region subclass, representing a function frame on the stack,
307 to contain the locals.
308 The parent is the stack region; there's also a hierarchy of call-stack
309 prefixes expressed via m_calling_frame.
310 For example, given "oldest" calling "middle" called "newest" we would have
311 - a stack depth of 3
312 - frame (A) for "oldest" with index 0 for depth 1, calling_frame == NULL
313 - frame (B) for "middle" with index 1 for depth 2, calling_frame == (A)
314 - frame (C) for "newest" with index 2 for depth 3, calling_frame == (B)
315 where the parent region for each of the frames is the "stack" region.
316 The index is the count of frames earlier than this in the stack. */
317
319{
320public:
321 /* A support class for uniquifying instances of frame_region. */
322 struct key_t
323 {
324 key_t (const frame_region *calling_frame, const function &fun)
325 : m_calling_frame (calling_frame), m_fun (&fun)
326 {
327 /* calling_frame can be NULL. */
328 }
329
330 hashval_t hash () const
331 {
332 inchash::hash hstate;
333 hstate.add_ptr (m_calling_frame);
334 hstate.add_ptr (m_fun);
335 return hstate.end ();
336 }
337
338 bool operator== (const key_t &other) const
339 {
340 return (m_calling_frame == other.m_calling_frame
341 && m_fun == other.m_fun);
342 }
343
344 void mark_deleted () { m_fun = reinterpret_cast<function *> (1); }
345 void mark_empty () { m_fun = NULL; }
346 bool is_deleted () const
347 {
348 return m_fun == reinterpret_cast<function *> (1);
349 }
350 bool is_empty () const { return m_fun == NULL; }
351
354 };
355
356 frame_region (symbol::id_t id, const region *parent,
357 const frame_region *calling_frame,
358 const function &fun, int index)
359 : space_region (id, parent), m_calling_frame (calling_frame),
360 m_fun (fun), m_index (index)
361 {}
363
364 /* region vfuncs. */
365 enum region_kind get_kind () const final override { return RK_FRAME; }
366 const frame_region * dyn_cast_frame_region () const final override
367 {
368 return this;
369 }
370 void accept (visitor *v) const final override;
371 void dump_to_pp (pretty_printer *pp, bool simple) const final override;
372
373 void print_dump_widget_label (pretty_printer *pp) const final override;
374
375 /* Accessors. */
377 const function &get_function () const { return m_fun; }
378 tree get_fndecl () const { return get_function ().decl; }
379 int get_index () const { return m_index; }
380 int get_stack_depth () const { return m_index + 1; }
381
382 const decl_region *
384 tree expr,
385 const region_model_context *ctxt) const;
386
387 unsigned get_num_locals () const { return m_locals.elements (); }
388
389 /* Implemented in region-model-manager.cc. */
391
392 private:
396
397 /* The regions for the decls within this frame are managed by this
398 object, rather than the region_model_manager, to make it a simple
399 lookup by tree. */
402};
403
404} // namespace ana
405
406template <>
407template <>
408inline bool
410{
411 return reg->get_kind () == RK_FRAME;
412}
413
414template <> struct default_hash_traits<frame_region::key_t>
415: public member_function_hash_traits<frame_region::key_t>
416{
417 static const bool empty_zero_p = true;
418};
419
420namespace ana {
421
422/* Concrete space_region subclass, to hold global variables (data and bss). */
423
425{
426 public:
428 : space_region (id, parent)
429 {}
430
431 /* region vfuncs. */
432 enum region_kind get_kind () const final override { return RK_GLOBALS; }
433 void dump_to_pp (pretty_printer *pp, bool simple) const final override;
434 void print_dump_widget_label (pretty_printer *pp) const final override;
435};
436
437} // namespace ana
438
439template <>
440template <>
441inline bool
443{
444 return reg->get_kind () == RK_GLOBALS;
445}
446
447namespace ana {
448
449/* Concrete space_region subclass, representing the code segment
450 containing functions. */
451
453{
454public:
455 code_region (symbol::id_t id, const region *parent)
456 : space_region (id, parent)
457 {}
458
459 /* region vfuncs. */
460 void dump_to_pp (pretty_printer *pp, bool simple) const final override;
461 void print_dump_widget_label (pretty_printer *pp) const final override;
462 enum region_kind get_kind () const final override { return RK_CODE; }
463};
464
465} // namespace ana
466
467template <>
468template <>
469inline bool
471{
472 return reg->get_kind () == RK_CODE;
473}
474
475namespace ana {
476
477/* Concrete region subclass. A region representing the code for
478 a particular function. */
479
481{
482public:
483 function_region (symbol::id_t id, const code_region *parent, tree fndecl)
484 : region (complexity (parent), id, parent, TREE_TYPE (fndecl)),
485 m_fndecl (fndecl)
486 {
488 }
489
490 /* region vfuncs. */
491 void dump_to_pp (pretty_printer *pp, bool simple) const final override;
492 void print_dump_widget_label (pretty_printer *pp) const final override;
493
494 enum region_kind get_kind () const final override { return RK_FUNCTION; }
495 const function_region *
496 dyn_cast_function_region () const final override{ return this; }
497
498 tree get_fndecl () const { return m_fndecl; }
499
500private:
502};
503
504} // namespace ana
505
506template <>
507template <>
508inline bool
510{
511 return reg->get_kind () == RK_FUNCTION;
512}
513
514namespace ana {
515
516/* Concrete region subclass. A region representing a particular label
517 within a function. */
518
519class label_region : public region
520{
521public:
523 : region (complexity (parent), id, parent, NULL_TREE), m_label (label)
524 {
525 gcc_assert (TREE_CODE (label) == LABEL_DECL);
526 }
527
528 /* region vfuncs. */
529 void dump_to_pp (pretty_printer *pp, bool simple) const final override;
530 void print_dump_widget_label (pretty_printer *pp) const final override;
531 enum region_kind get_kind () const final override { return RK_LABEL; }
532
533 tree get_label () const { return m_label; }
534
535private:
537};
538
539} // namespace ana
540
541template <>
542template <>
543inline bool
545{
546 return reg->get_kind () == RK_LABEL;
547}
548
549namespace ana {
550
551/* Concrete space_region subclass representing a stack, containing all stack
552 frames. */
553
555{
556public:
558 : space_region (id, parent)
559 {}
560
561 void dump_to_pp (pretty_printer *pp, bool simple) const final override;
562 void print_dump_widget_label (pretty_printer *pp) const final override;
563
564 enum region_kind get_kind () const final override { return RK_STACK; }
565};
566
567} // namespace ana
568
569template <>
570template <>
571inline bool
573{
574 return reg->get_kind () == RK_STACK;
575}
576
577namespace ana {
578
579/* Concrete space_region subclass: a region within which regions can be
580 dynamically allocated. */
581
583{
584public:
586 : space_region (id, parent)
587 {}
588
589 enum region_kind get_kind () const final override { return RK_HEAP; }
590 void dump_to_pp (pretty_printer *pp, bool simple) const final override;
591 void print_dump_widget_label (pretty_printer *pp) const final override;
592};
593
594} // namespace ana
595
596template <>
597template <>
598inline bool
600{
601 return reg->get_kind () == RK_HEAP;
602}
603
604namespace ana {
605
606/* Concrete space_region subclass: thread-local data for the thread
607 being analyzed. */
608
610{
611public:
613 : space_region (id, parent)
614 {}
615
616 enum region_kind get_kind () const final override { return RK_THREAD_LOCAL; }
617 void dump_to_pp (pretty_printer *pp, bool simple) const final override;
618 void print_dump_widget_label (pretty_printer *pp) const final override;
619};
620
621} // namespace ana
622
623template <>
624template <>
625inline bool
627{
628 return reg->get_kind () == RK_THREAD_LOCAL;
629}
630
631namespace ana {
632
633/* Concrete region subclass. The root region, containing all regions
634 (either directly, or as descendents).
635 Unique within a region_model_manager. */
636
637class root_region : public region
638{
639public:
641
642 enum region_kind get_kind () const final override { return RK_ROOT; }
643 void dump_to_pp (pretty_printer *pp, bool simple) const final override;
644 void print_dump_widget_label (pretty_printer *pp) const final override;
645};
646
647} // namespace ana
648
649template <>
650template <>
651inline bool
653{
654 return reg->get_kind () == RK_ROOT;
655}
656
657namespace ana {
658
659/* Concrete region subclass: a region to use when dereferencing an unknown
660 pointer. */
661
663{
664public:
665 /* A support class for uniquifying instances of symbolic_region. */
666 struct key_t
667 {
668 key_t (const region *parent, const svalue *sval_ptr)
669 : m_parent (parent), m_sval_ptr (sval_ptr)
670 {
671 gcc_assert (sval_ptr);
672 }
673
674 hashval_t hash () const
675 {
676 inchash::hash hstate;
677 hstate.add_ptr (m_parent);
678 hstate.add_ptr (m_sval_ptr);
679 return hstate.end ();
680 }
681
682 bool operator== (const key_t &other) const
683 {
684 return (m_parent == other.m_parent && m_sval_ptr == other.m_sval_ptr);
685 }
686
687 void mark_deleted () { m_sval_ptr = reinterpret_cast<const svalue *> (1); }
689 bool is_deleted () const
690 {
691 return m_sval_ptr == reinterpret_cast<const svalue *> (1);
692 }
693 bool is_empty () const { return m_sval_ptr == NULL; }
694
697 };
698
699 symbolic_region (symbol::id_t id, region *parent, const svalue *sval_ptr);
700
701 const symbolic_region *
702 dyn_cast_symbolic_region () const final override { return this; }
703
704 enum region_kind get_kind () const final override { return RK_SYMBOLIC; }
705 void accept (visitor *v) const final override;
706 void dump_to_pp (pretty_printer *pp, bool simple) const final override;
707 void print_dump_widget_label (pretty_printer *pp) const final override;
708 void
709 add_dump_widget_children (text_art::tree_widget &w,
710 const text_art::dump_widget_info &dwi)
711 const final override;
712
713 const svalue *get_pointer () const { return m_sval_ptr; }
714
715private:
717};
718
719} // namespace ana
720
721template <>
722template <>
723inline bool
725{
726 return reg->get_kind () == RK_SYMBOLIC;
727}
728
729template <> struct default_hash_traits<symbolic_region::key_t>
730: public member_function_hash_traits<symbolic_region::key_t>
731{
732 static const bool empty_zero_p = true;
733};
734
735namespace ana {
736
737/* Concrete region subclass representing the memory occupied by a
738 variable (whether for a global or a local).
739 Also used for representing SSA names, as if they were locals. */
740
741class decl_region : public region
742{
743public:
745 : region (complexity (parent), id, parent, TREE_TYPE (decl)), m_decl (decl),
748 {}
749
750 enum region_kind get_kind () const final override { return RK_DECL; }
751 const decl_region *
752 dyn_cast_decl_region () const final override { return this; }
753
754 void dump_to_pp (pretty_printer *pp, bool simple) const final override;
755
756 void
757 print_dump_widget_label (pretty_printer *pp) const final override;
758
759 bool tracked_p () const final override { return m_tracked; }
760
761 tree get_decl () const { return m_decl; }
762 int get_stack_depth () const;
763
766 region_model_manager *mgr) const;
768
769private:
771 region_model_manager *mgr) const;
772 static bool calc_tracked_p (tree decl);
773
775
776 /* Cached result of calc_tracked_p, so that we can quickly determine when
777 we don't to track a binding_cluster for this decl (to avoid bloating
778 store objects).
779 This can be debugged using -fdump-analyzer-untracked. */
781
782 /* Cached result of get_svalue_for_constructor. */
783 mutable const svalue *m_ctor_svalue;
784};
785
786} // namespace ana
787
788template <>
789template <>
790inline bool
792{
793 return reg->get_kind () == RK_DECL;
794}
795
796namespace ana {
797
798/* Concrete region subclass representing the memory occupied by a
799 field within a struct or union. */
800
801class field_region : public region
802{
803public:
804 /* A support class for uniquifying instances of field_region. */
805 struct key_t
806 {
807 key_t (const region *parent, tree field)
808 : m_parent (parent), m_field (field)
809 {
810 gcc_assert (field);
811 }
812
813 hashval_t hash () const
814 {
815 inchash::hash hstate;
816 hstate.add_ptr (m_parent);
817 hstate.add_ptr (m_field);
818 return hstate.end ();
819 }
820
821 bool operator== (const key_t &other) const
822 {
823 return (m_parent == other.m_parent && m_field == other.m_field);
824 }
825
826 void mark_deleted () { m_field = reinterpret_cast<tree> (1); }
828 bool is_deleted () const { return m_field == reinterpret_cast<tree> (1); }
829 bool is_empty () const { return m_field == NULL_TREE; }
830
833 };
834
835 field_region (symbol::id_t id, const region *parent, tree field)
836 : region (complexity (parent), id, parent, TREE_TYPE (field)),
837 m_field (field)
838 {}
839
840 enum region_kind get_kind () const final override { return RK_FIELD; }
841
842 void dump_to_pp (pretty_printer *pp, bool simple) const final override;
843 void print_dump_widget_label (pretty_printer *pp) const final override;
844
845 const field_region *
846 dyn_cast_field_region () const final override { return this; }
847
848 tree get_field () const { return m_field; }
849
850 bool get_relative_concrete_offset (bit_offset_t *out) const final override;
852 const final override;
853
854private:
856};
857
858} // namespace ana
859
860template <>
861template <>
862inline bool
864{
865 return reg->get_kind () == RK_FIELD;
866}
867
868template <> struct default_hash_traits<field_region::key_t>
869: public member_function_hash_traits<field_region::key_t>
870{
871 static const bool empty_zero_p = true;
872};
873
874namespace ana {
875
876/* An element within an array. */
877
878class element_region : public region
879{
880public:
881 /* A support class for uniquifying instances of element_region. */
882 struct key_t
883 {
884 key_t (const region *parent, tree element_type, const svalue *index)
885 : m_parent (parent), m_element_type (element_type), m_index (index)
886 {
887 gcc_assert (index);
888 }
889
890 hashval_t hash () const
891 {
892 inchash::hash hstate;
893 hstate.add_ptr (m_parent);
894 hstate.add_ptr (m_element_type);
895 hstate.add_ptr (m_index);
896 return hstate.end ();
897 }
898
899 bool operator== (const key_t &other) const
900 {
901 return (m_parent == other.m_parent
903 && m_index == other.m_index);
904 }
905
906 void mark_deleted () { m_index = reinterpret_cast<const svalue *> (1); }
907 void mark_empty () { m_index = NULL; }
908 bool is_deleted () const
909 {
910 return m_index == reinterpret_cast<const svalue *> (1);
911 }
912 bool is_empty () const { return m_index == NULL; }
913
917 };
918
919 element_region (symbol::id_t id, const region *parent, tree element_type,
920 const svalue *index)
921 : region (complexity::from_pair (parent, index), id, parent, element_type),
922 m_index (index)
923 {}
924
925 enum region_kind get_kind () const final override { return RK_ELEMENT; }
926 const element_region *
927 dyn_cast_element_region () const final override { return this; }
928
929 void accept (visitor *v) const final override;
930
931 void dump_to_pp (pretty_printer *pp, bool simple) const final override;
932
933 void
934 print_dump_widget_label (pretty_printer *pp) const final override;
935 void
936 add_dump_widget_children (text_art::tree_widget &,
937 const text_art::dump_widget_info &dwi)
938 const final override;
939
940 const svalue *get_index () const { return m_index; }
941
942 virtual bool
943 get_relative_concrete_offset (bit_offset_t *out) const final override;
945 const final override;
946
947private:
949};
950
951} // namespace ana
952
953template <>
954template <>
955inline bool
957{
958 return reg->get_kind () == RK_ELEMENT;
959}
960
961template <> struct default_hash_traits<element_region::key_t>
962: public member_function_hash_traits<element_region::key_t>
963{
964 static const bool empty_zero_p = true;
965};
966
967namespace ana {
968
969/* A byte-offset within another region, for handling pointer arithmetic
970 as a region. */
971
972class offset_region : public region
973{
974public:
975 /* A support class for uniquifying instances of offset_region. */
976 struct key_t
977 {
978 key_t (const region *parent, tree element_type, const svalue *byte_offset)
979 : m_parent (parent), m_element_type (element_type), m_byte_offset (byte_offset)
980 {
981 gcc_assert (byte_offset);
982 }
983
984 hashval_t hash () const
985 {
986 inchash::hash hstate;
987 hstate.add_ptr (m_parent);
988 hstate.add_ptr (m_element_type);
989 hstate.add_ptr (m_byte_offset);
990 return hstate.end ();
991 }
992
993 bool operator== (const key_t &other) const
994 {
995 return (m_parent == other.m_parent
997 && m_byte_offset == other.m_byte_offset);
998 }
999
1000 void mark_deleted () { m_byte_offset = reinterpret_cast<const svalue *> (1); }
1002 bool is_deleted () const
1003 {
1004 return m_byte_offset == reinterpret_cast<const svalue *> (1);
1005 }
1006 bool is_empty () const { return m_byte_offset == NULL; }
1007
1011 };
1012
1014 const svalue *byte_offset)
1015 : region (complexity::from_pair (parent, byte_offset), id, parent, type),
1016 m_byte_offset (byte_offset)
1017 {}
1018
1019 enum region_kind get_kind () const final override { return RK_OFFSET; }
1020 const offset_region *
1021 dyn_cast_offset_region () const final override { return this; }
1022
1023 void accept (visitor *v) const final override;
1024
1025 void dump_to_pp (pretty_printer *pp, bool simple) const final override;
1026
1027 void
1028 print_dump_widget_label (pretty_printer *pp) const final override;
1029 void
1030 add_dump_widget_children (text_art::tree_widget &,
1031 const text_art::dump_widget_info &dwi)
1032 const final override;
1033
1034 const svalue *get_byte_offset () const { return m_byte_offset; }
1036
1037 bool get_relative_concrete_offset (bit_offset_t *out) const final override;
1039 const final override;
1040
1041private:
1043};
1044
1045} // namespace ana
1046
1047template <>
1048template <>
1049inline bool
1051{
1052 return reg->get_kind () == RK_OFFSET;
1053}
1054
1055template <> struct default_hash_traits<offset_region::key_t>
1056: public member_function_hash_traits<offset_region::key_t>
1057{
1058 static const bool empty_zero_p = true;
1059};
1060
1061namespace ana {
1062
1063/* A region that is size BYTES_SIZE_SVAL in size within its parent
1064 region (or possibly larger, which would lead to an overflow. */
1065
1066class sized_region : public region
1067{
1068public:
1069 /* A support class for uniquifying instances of sized_region. */
1070 struct key_t
1071 {
1072 key_t (const region *parent, tree element_type,
1073 const svalue *byte_size_sval)
1074 : m_parent (parent), m_element_type (element_type),
1075 m_byte_size_sval (byte_size_sval)
1076 {
1077 gcc_assert (byte_size_sval);
1078 }
1079
1080 hashval_t hash () const
1081 {
1082 inchash::hash hstate;
1083 hstate.add_ptr (m_parent);
1084 hstate.add_ptr (m_element_type);
1085 hstate.add_ptr (m_byte_size_sval);
1086 return hstate.end ();
1087 }
1088
1089 bool operator== (const key_t &other) const
1090 {
1091 return (m_parent == other.m_parent
1092 && m_element_type == other.m_element_type
1094 }
1095
1096 void mark_deleted () { m_byte_size_sval = reinterpret_cast<const svalue *> (1); }
1098 bool is_deleted () const
1099 {
1100 return m_byte_size_sval == reinterpret_cast<const svalue *> (1);
1101 }
1102 bool is_empty () const { return m_byte_size_sval == NULL; }
1103
1108 };
1109
1111 const svalue *byte_size_sval)
1112 : region (complexity::from_pair (parent, byte_size_sval),
1113 id, parent, type),
1114 m_byte_size_sval (byte_size_sval)
1115 {}
1116
1117 enum region_kind get_kind () const final override { return RK_SIZED; }
1118 const sized_region *
1119 dyn_cast_sized_region () const final override { return this; }
1120
1121 void accept (visitor *v) const final override;
1122
1123 void dump_to_pp (pretty_printer *pp, bool simple) const final override;
1124 void
1125 print_dump_widget_label (pretty_printer *pp) const final override;
1126 void
1127 add_dump_widget_children (text_art::tree_widget &,
1128 const text_art::dump_widget_info &dwi)
1129 const final override;
1130
1131 bool get_byte_size (byte_size_t *out) const final override;
1132 bool get_bit_size (bit_size_t *out) const final override;
1133
1134 const svalue *
1136 {
1137 return m_byte_size_sval;
1138 }
1139
1140 const svalue *
1141 get_bit_size_sval (region_model_manager *) const final override;
1142
1143private:
1145};
1146
1147} // namespace ana
1148
1149template <>
1150template <>
1151inline bool
1153{
1154 return reg->get_kind () == RK_SIZED;
1155}
1156
1157template <> struct default_hash_traits<sized_region::key_t>
1158: public member_function_hash_traits<sized_region::key_t>
1159{
1160 static const bool empty_zero_p = true;
1161};
1162
1163namespace ana {
1164
1165/* A region that views another region using a different type. */
1166
1167class cast_region : public region
1168{
1169public:
1170 /* A support class for uniquifying instances of cast_region. */
1171 struct key_t
1172 {
1173 key_t (const region *parent, tree type)
1174 : m_parent (parent), m_type (type)
1175 {
1176 gcc_assert (parent);
1177 }
1178
1179 hashval_t hash () const
1180 {
1181 inchash::hash hstate;
1182 hstate.add_ptr (m_parent);
1183 hstate.add_ptr (m_type);
1184 return hstate.end ();
1185 }
1186
1187 bool operator== (const key_t &other) const
1188 {
1189 return (m_parent == other.m_parent
1190 && m_type == other.m_type);
1191 }
1192
1194 {
1195 m_parent = reinterpret_cast<const region *> (1);
1196 }
1197 void mark_empty () { m_parent = nullptr; }
1198 bool is_deleted () const
1199 {
1200 return m_parent == reinterpret_cast<const region *> (1);
1201 }
1202 bool is_empty () const { return m_parent == nullptr; }
1203
1206 };
1207
1209 : region (complexity (parent), id,
1210 parent, type)
1211 {}
1212
1213 enum region_kind get_kind () const final override { return RK_CAST; }
1214 const cast_region *
1215 dyn_cast_cast_region () const final override { return this; }
1216 void dump_to_pp (pretty_printer *pp, bool simple) const final override;
1217 void
1218 print_dump_widget_label (pretty_printer *pp) const final override;
1219
1220 bool get_relative_concrete_offset (bit_offset_t *out) const final override;
1221};
1222
1223} // namespace ana
1224
1225template <>
1226template <>
1227inline bool
1229{
1230 return reg->get_kind () == RK_CAST;
1231}
1232
1233template <> struct default_hash_traits<cast_region::key_t>
1234: public member_function_hash_traits<cast_region::key_t>
1235{
1236 static const bool empty_zero_p = true;
1237};
1238
1239namespace ana {
1240
1241/* An untyped region dynamically allocated on the heap via "malloc"
1242 or similar. */
1243
1245{
1246public:
1248 : region (complexity (parent), id, parent, NULL_TREE)
1249 {}
1250
1251 enum region_kind
1252 get_kind () const final override { return RK_HEAP_ALLOCATED; }
1253
1254 void dump_to_pp (pretty_printer *pp, bool simple) const final override;
1255 void print_dump_widget_label (pretty_printer *pp) const final override;
1256};
1257
1258/* An untyped region dynamically allocated on the stack via "alloca". */
1259
1260class alloca_region : public region
1261{
1262public:
1264 : region (complexity (parent), id, parent, NULL_TREE)
1265 {}
1266
1267 enum region_kind get_kind () const final override { return RK_ALLOCA; }
1268
1269 void dump_to_pp (pretty_printer *pp, bool simple) const final override;
1270 void print_dump_widget_label (pretty_printer *pp) const final override;
1271};
1272
1273/* A region for a STRING_CST. */
1274
1275class string_region : public region
1276{
1277public:
1278 string_region (symbol::id_t id, const region *parent, tree string_cst)
1279 : region (complexity (parent), id, parent, TREE_TYPE (string_cst)),
1280 m_string_cst (string_cst)
1281 {}
1282
1283 const string_region *
1284 dyn_cast_string_region () const final override { return this; }
1285
1286 enum region_kind get_kind () const final override { return RK_STRING; }
1287
1288 void dump_to_pp (pretty_printer *pp, bool simple) const final override;
1289 void print_dump_widget_label (pretty_printer *pp) const final override;
1290
1291 /* We assume string literals are immutable, so we don't track them in
1292 the store. */
1293 bool tracked_p () const final override { return false; }
1294
1295 tree get_string_cst () const { return m_string_cst; }
1296
1297private:
1299};
1300
1301} // namespace ana
1302
1303template <>
1304template <>
1305inline bool
1307{
1308 return reg->get_kind () == RK_STRING;
1309}
1310
1311namespace ana {
1312
1313/* A region for a specific range of bits within another region. */
1314
1316{
1317public:
1318 /* A support class for uniquifying instances of bit_range_region. */
1319 struct key_t
1320 {
1321 key_t (const region *parent, tree type, const bit_range &bits)
1322 : m_parent (parent), m_type (type), m_bits (bits)
1323 {
1324 gcc_assert (parent);
1325 }
1326
1327 hashval_t hash () const
1328 {
1329 inchash::hash hstate;
1330 hstate.add_ptr (m_parent);
1331 hstate.add_ptr (m_type);
1334 return hstate.end ();
1335 }
1336
1337 bool operator== (const key_t &other) const
1338 {
1339 return (m_parent == other.m_parent
1340 && m_type == other.m_type
1341 && m_bits == other.m_bits);
1342 }
1343
1344 void mark_deleted () { m_parent = reinterpret_cast<const region *> (1); }
1345 void mark_empty () { m_parent = NULL; }
1346 bool is_deleted () const
1347 {
1348 return m_parent == reinterpret_cast<const region *> (1);
1349 }
1350 bool is_empty () const { return m_parent == NULL; }
1351
1355 };
1356
1358 const bit_range &bits)
1359 : region (complexity (parent), id, parent, type),
1360 m_bits (bits)
1361 {}
1362
1363 const bit_range_region *
1364 dyn_cast_bit_range_region () const final override { return this; }
1365
1366 enum region_kind get_kind () const final override { return RK_BIT_RANGE; }
1367
1368 void dump_to_pp (pretty_printer *pp, bool simple) const final override;
1369 void print_dump_widget_label (pretty_printer *pp) const final override;
1370
1371 const bit_range &get_bits () const { return m_bits; }
1372
1373 bool get_byte_size (byte_size_t *out) const final override;
1374 bool get_bit_size (bit_size_t *out) const final override;
1375 const svalue *get_byte_size_sval (region_model_manager *mgr) const final override;
1376 const svalue *get_bit_size_sval (region_model_manager *mgr) const final override;
1377 bool get_relative_concrete_offset (bit_offset_t *out) const final override;
1379 const final override;
1380
1381private:
1383};
1384
1385} // namespace ana
1386
1387template <>
1388template <>
1389inline bool
1391{
1392 return reg->get_kind () == RK_BIT_RANGE;
1393}
1394
1395template <> struct default_hash_traits<bit_range_region::key_t>
1396: public member_function_hash_traits<bit_range_region::key_t>
1397{
1398 static const bool empty_zero_p = true;
1399};
1400
1401namespace ana {
1402
1403/* A region for the N-th vararg within a frame_region for a variadic call. */
1404
1406{
1407public:
1408 /* A support class for uniquifying instances of var_arg_region. */
1409 struct key_t
1410 {
1411 key_t (const frame_region *parent, unsigned idx)
1412 : m_parent (parent), m_idx (idx)
1413 {
1414 gcc_assert (parent);
1415 }
1416
1417 hashval_t hash () const
1418 {
1419 inchash::hash hstate;
1420 hstate.add_ptr (m_parent);
1421 hstate.add_int (m_idx);
1422 return hstate.end ();
1423 }
1424
1425 bool operator== (const key_t &other) const
1426 {
1427 return (m_parent == other.m_parent
1428 && m_idx == other.m_idx);
1429 }
1430
1432 {
1433 m_parent = reinterpret_cast<const frame_region *> (1);
1434 }
1435 void mark_empty () { m_parent = NULL; }
1436 bool is_deleted () const
1437 {
1438 return m_parent == reinterpret_cast<const frame_region *> (1);
1439 }
1440 bool is_empty () const { return m_parent == NULL; }
1441
1443 unsigned m_idx;
1444 };
1445
1447 unsigned idx)
1448 : region (complexity (parent), id, parent, NULL_TREE),
1449 m_idx (idx)
1450 {}
1451
1452 const var_arg_region *
1453 dyn_cast_var_arg_region () const final override { return this; }
1454
1455 enum region_kind get_kind () const final override { return RK_VAR_ARG; }
1456
1457 void dump_to_pp (pretty_printer *pp, bool simple) const final override;
1458 void print_dump_widget_label (pretty_printer *pp) const final override;
1459
1461 unsigned get_index () const { return m_idx; }
1462
1463private:
1464 unsigned m_idx;
1465};
1466
1467} // namespace ana
1468
1469template <>
1470template <>
1471inline bool
1473{
1474 return reg->get_kind () == RK_VAR_ARG;
1475}
1476
1477template <> struct default_hash_traits<var_arg_region::key_t>
1478: public member_function_hash_traits<var_arg_region::key_t>
1479{
1480 static const bool empty_zero_p = true;
1481};
1482
1483namespace ana {
1484
1485/* A region for errno for the current thread. */
1486
1487class errno_region : public region
1488{
1489public:
1491 : region (complexity (parent), id, parent, integer_type_node)
1492 {}
1493
1494 enum region_kind get_kind () const final override { return RK_ERRNO; }
1495
1496 void dump_to_pp (pretty_printer *pp, bool simple) const final override;
1497 void print_dump_widget_label (pretty_printer *pp) const final override;
1498};
1499
1500} // namespace ana
1501
1502template <>
1503template <>
1504inline bool
1506{
1507 return reg->get_kind () == RK_ERRNO;
1508}
1509
1510namespace ana {
1511
1512/* Similar to a decl region, but we don't have the decl.
1513 For implementing e.g. static buffers of known_functions,
1514 or other internal state of an API.
1515
1516 These are owned by known_function instances, rather than the
1517 region_model_manager. */
1518
1520{
1521public:
1522 private_region (unsigned id, const region *parent, tree type,
1523 const char *desc)
1524 : region (complexity (parent), id, parent, type),
1525 m_desc (desc)
1526 {}
1527
1528 enum region_kind get_kind () const final override { return RK_PRIVATE; }
1529
1530 void dump_to_pp (pretty_printer *pp, bool simple) const final override;
1531 void print_dump_widget_label (pretty_printer *pp) const final override;
1532
1533private:
1534 const char *m_desc;
1535};
1536
1537} // namespace ana
1538
1539template <>
1540template <>
1541inline bool
1543{
1544 return reg->get_kind () == RK_PRIVATE;
1545}
1546
1547namespace ana {
1548
1549/* An unknown region, for handling unimplemented tree codes. */
1550
1552{
1553public:
1555 : region (complexity (parent), id, parent, type)
1556 {}
1557
1558 enum region_kind get_kind () const final override { return RK_UNKNOWN; }
1559
1560 void dump_to_pp (pretty_printer *pp, bool simple) const final override;
1561 void print_dump_widget_label (pretty_printer *pp) const final override;
1562};
1563
1564} // namespace ana
1565
1566#endif /* GCC_ANALYZER_REGION_H */
Definition region.h:1261
void print_dump_widget_label(pretty_printer *pp) const final override
alloca_region(symbol::id_t id, const frame_region *parent)
Definition region.h:1263
void dump_to_pp(pretty_printer *pp, bool simple) const final override
enum region_kind get_kind() const final override
Definition region.h:1267
Definition region.h:1316
bool get_relative_concrete_offset(bit_offset_t *out) const final override
bit_range_region(symbol::id_t id, const region *parent, tree type, const bit_range &bits)
Definition region.h:1357
enum region_kind get_kind() const final override
Definition region.h:1366
bool get_byte_size(byte_size_t *out) const final override
const svalue * get_bit_size_sval(region_model_manager *mgr) const final override
const bit_range_region * dyn_cast_bit_range_region() const final override
Definition region.h:1364
bool get_bit_size(bit_size_t *out) const final override
bit_range m_bits
Definition region.h:1382
const svalue * get_byte_size_sval(region_model_manager *mgr) const final override
const svalue * get_relative_symbolic_offset(region_model_manager *mgr) const final override
void dump_to_pp(pretty_printer *pp, bool simple) const final override
const bit_range & get_bits() const
Definition region.h:1371
void print_dump_widget_label(pretty_printer *pp) const final override
Definition region.h:1168
void dump_to_pp(pretty_printer *pp, bool simple) const final override
void print_dump_widget_label(pretty_printer *pp) const final override
const cast_region * dyn_cast_cast_region() const final override
Definition region.h:1215
enum region_kind get_kind() const final override
Definition region.h:1213
cast_region(symbol::id_t id, const region *parent, tree type)
Definition region.h:1208
bool get_relative_concrete_offset(bit_offset_t *out) const final override
Definition region.h:453
code_region(symbol::id_t id, const region *parent)
Definition region.h:455
void print_dump_widget_label(pretty_printer *pp) const final override
enum region_kind get_kind() const final override
Definition region.h:462
void dump_to_pp(pretty_printer *pp, bool simple) const final override
Definition region.h:742
void print_dump_widget_label(pretty_printer *pp) const final override
const decl_region * dyn_cast_decl_region() const final override
Definition region.h:752
const svalue * get_svalue_for_initializer(region_model_manager *mgr) const
const svalue * get_svalue_for_constructor(tree ctor, region_model_manager *mgr) const
decl_region(symbol::id_t id, const region *parent, tree decl)
Definition region.h:744
tree m_decl
Definition region.h:774
static bool calc_tracked_p(tree decl)
const svalue * maybe_get_constant_value(region_model_manager *mgr) const
const svalue * calc_svalue_for_constructor(tree ctor, region_model_manager *mgr) const
bool m_tracked
Definition region.h:780
enum region_kind get_kind() const final override
Definition region.h:750
int get_stack_depth() const
void dump_to_pp(pretty_printer *pp, bool simple) const final override
const svalue * m_ctor_svalue
Definition region.h:783
bool tracked_p() const final override
Definition region.h:759
tree get_decl() const
Definition region.h:761
Definition region.h:879
const svalue * m_index
Definition region.h:948
const element_region * dyn_cast_element_region() const final override
Definition region.h:927
element_region(symbol::id_t id, const region *parent, tree element_type, const svalue *index)
Definition region.h:919
void print_dump_widget_label(pretty_printer *pp) const final override
void accept(visitor *v) const final override
const svalue * get_index() const
Definition region.h:940
void dump_to_pp(pretty_printer *pp, bool simple) const final override
void add_dump_widget_children(text_art::tree_widget &, const text_art::dump_widget_info &dwi) const final override
virtual bool get_relative_concrete_offset(bit_offset_t *out) const final override
const svalue * get_relative_symbolic_offset(region_model_manager *mgr) const final override
enum region_kind get_kind() const final override
Definition region.h:925
Definition region.h:1488
enum region_kind get_kind() const final override
Definition region.h:1494
void print_dump_widget_label(pretty_printer *pp) const final override
errno_region(symbol::id_t id, const thread_local_region *parent)
Definition region.h:1490
void dump_to_pp(pretty_printer *pp, bool simple) const final override
Definition region.h:802
tree get_field() const
Definition region.h:848
void dump_to_pp(pretty_printer *pp, bool simple) const final override
enum region_kind get_kind() const final override
Definition region.h:840
tree m_field
Definition region.h:855
const svalue * get_relative_symbolic_offset(region_model_manager *mgr) const final override
bool get_relative_concrete_offset(bit_offset_t *out) const final override
void print_dump_widget_label(pretty_printer *pp) const final override
const field_region * dyn_cast_field_region() const final override
Definition region.h:846
field_region(symbol::id_t id, const region *parent, tree field)
Definition region.h:835
Definition region.h:319
int get_index() const
Definition region.h:379
void accept(visitor *v) const final override
const function & m_fun
Definition region.h:394
unsigned get_num_locals() const
Definition region.h:387
enum region_kind get_kind() const final override
Definition region.h:365
const frame_region * m_calling_frame
Definition region.h:393
const decl_region * get_region_for_local(region_model_manager *mgr, tree expr, const region_model_context *ctxt) const
const frame_region * dyn_cast_frame_region() const final override
Definition region.h:366
const frame_region * get_calling_frame() const
Definition region.h:376
map_t m_locals
Definition region.h:401
void dump_untracked_regions() const
tree get_fndecl() const
Definition region.h:378
hash_map< tree, decl_region * > map_t
Definition region.h:400
const function & get_function() const
Definition region.h:377
void print_dump_widget_label(pretty_printer *pp) const final override
void dump_to_pp(pretty_printer *pp, bool simple) const final override
frame_region(symbol::id_t id, const region *parent, const frame_region *calling_frame, const function &fun, int index)
Definition region.h:356
int m_index
Definition region.h:395
int get_stack_depth() const
Definition region.h:380
Definition region.h:481
function_region(symbol::id_t id, const code_region *parent, tree fndecl)
Definition region.h:483
tree m_fndecl
Definition region.h:501
const function_region * dyn_cast_function_region() const final override
Definition region.h:496
void print_dump_widget_label(pretty_printer *pp) const final override
enum region_kind get_kind() const final override
Definition region.h:494
tree get_fndecl() const
Definition region.h:498
void dump_to_pp(pretty_printer *pp, bool simple) const final override
Definition region.h:425
enum region_kind get_kind() const final override
Definition region.h:432
void dump_to_pp(pretty_printer *pp, bool simple) const final override
globals_region(symbol::id_t id, const region *parent)
Definition region.h:427
void print_dump_widget_label(pretty_printer *pp) const final override
Definition region.h:1245
enum region_kind get_kind() const final override
Definition region.h:1252
heap_allocated_region(symbol::id_t id, const region *parent)
Definition region.h:1247
void dump_to_pp(pretty_printer *pp, bool simple) const final override
void print_dump_widget_label(pretty_printer *pp) const final override
Definition region.h:583
void print_dump_widget_label(pretty_printer *pp) const final override
void dump_to_pp(pretty_printer *pp, bool simple) const final override
enum region_kind get_kind() const final override
Definition region.h:589
heap_region(symbol::id_t id, region *parent)
Definition region.h:585
Definition region.h:520
label_region(symbol::id_t id, const function_region *parent, tree label)
Definition region.h:522
tree get_label() const
Definition region.h:533
void dump_to_pp(pretty_printer *pp, bool simple) const final override
void print_dump_widget_label(pretty_printer *pp) const final override
tree m_label
Definition region.h:536
enum region_kind get_kind() const final override
Definition region.h:531
Definition region.h:973
bool get_relative_concrete_offset(bit_offset_t *out) const final override
enum region_kind get_kind() const final override
Definition region.h:1019
const svalue * get_relative_symbolic_offset(region_model_manager *mgr) const final override
const svalue * get_byte_offset() const
Definition region.h:1034
void dump_to_pp(pretty_printer *pp, bool simple) const final override
void print_dump_widget_label(pretty_printer *pp) const final override
void accept(visitor *v) const final override
const svalue * get_bit_offset(region_model_manager *mgr) const
const svalue * m_byte_offset
Definition region.h:1042
void add_dump_widget_children(text_art::tree_widget &, const text_art::dump_widget_info &dwi) const final override
const offset_region * dyn_cast_offset_region() const final override
Definition region.h:1021
offset_region(symbol::id_t id, const region *parent, tree type, const svalue *byte_offset)
Definition region.h:1013
Definition region.h:1520
void print_dump_widget_label(pretty_printer *pp) const final override
enum region_kind get_kind() const final override
Definition region.h:1528
void dump_to_pp(pretty_printer *pp, bool simple) const final override
private_region(unsigned id, const region *parent, tree type, const char *desc)
Definition region.h:1522
const char * m_desc
Definition region.h:1534
Definition region-model.h:718
Definition region-model-manager.h:32
Definition region-model.h:263
Definition analyzer.h:192
Definition region.h:126
virtual const var_arg_region * dyn_cast_var_arg_region() const
Definition region.h:154
bool maybe_print_for_user(pretty_printer *pp, const region_model &model) const
bool is_named_decl_p(const char *decl_name) const
bool symbolic_for_unknown_ptr_p() const
region_offset calc_offset(region_model_manager *mgr) const
void get_subregions_for_binding(region_model_manager *mgr, bit_offset_t start_bit_offset, bit_size_t size_in_bits, tree type, auto_vec< const region * > *out) const
virtual void add_dump_widget_children(text_art::tree_widget &, const text_art::dump_widget_info &dwi) const
bool involves_p(const svalue *sval) const
virtual const offset_region * dyn_cast_offset_region() const
Definition region.h:144
virtual const frame_region * dyn_cast_frame_region() const
Definition region.h:132
virtual const string_region * dyn_cast_string_region() const
Definition region.h:150
bool non_null_p() const
virtual const symbolic_region * dyn_cast_symbolic_region() const
Definition region.h:136
const frame_region * maybe_get_frame_region() const
bool can_have_initial_svalue_p() const
virtual const sized_region * dyn_cast_sized_region() const
Definition region.h:146
const region * get_base_region() const
static int cmp_ptr_ptr(const void *, const void *)
bool descendent_of_p(const region *elder) const
tree get_type() const
Definition region.h:169
virtual bool tracked_p() const
Definition region.h:254
virtual ~region()
const region * m_parent
Definition region.h:273
const svalue * calc_initial_value_at_main(region_model_manager *mgr) const
virtual bool get_relative_concrete_offset(bit_offset_t *out) const
const region * get_parent_region() const
Definition region.h:158
virtual const svalue * get_byte_size_sval(region_model_manager *mgr) const
region_offset get_offset(region_model_manager *mgr) const
bool base_region_p() const
virtual const element_region * dyn_cast_element_region() const
Definition region.h:142
virtual const field_region * dyn_cast_field_region() const
Definition region.h:140
std::unique_ptr< json::value > to_json() const
virtual bool get_byte_size(byte_size_t *out) const
enum memory_space get_memory_space() const
void print(const region_model &model, pretty_printer *pp) const
virtual const svalue * get_relative_symbolic_offset(region_model_manager *mgr) const
std::unique_ptr< text_art::tree_widget > make_dump_widget(const text_art::dump_widget_info &dwi, const char *prefix=nullptr) const
region(complexity c, symbol::id_t id, const region *parent, tree type)
virtual enum region_kind get_kind() const =0
const svalue * get_initial_value_at_main(region_model_manager *mgr) const
label_text get_desc(bool simple=true) const
tree maybe_get_decl() const
bool empty_p() const
virtual const decl_region * dyn_cast_decl_region() const
Definition region.h:138
virtual void accept(visitor *v) const
const svalue * m_cached_init_sval_at_main
Definition region.h:280
virtual const function_region * dyn_cast_function_region() const
Definition region.h:134
virtual const svalue * get_bit_size_sval(region_model_manager *mgr) const
void dump() const
bool symbolic_p() const
region_offset * m_cached_offset
Definition region.h:276
virtual void print_dump_widget_label(pretty_printer *pp) const =0
tree m_type
Definition region.h:274
virtual void dump_to_pp(pretty_printer *pp, bool simple) const =0
virtual bool get_bit_size(bit_size_t *out) const
virtual const bit_range_region * dyn_cast_bit_range_region() const
Definition region.h:152
virtual const cast_region * dyn_cast_cast_region() const
Definition region.h:148
void dump(bool simple) const
region_offset get_next_offset(region_model_manager *mgr) const
bool get_relative_concrete_byte_range(byte_range *out) const
Definition region.h:638
void print_dump_widget_label(pretty_printer *pp) const final override
enum region_kind get_kind() const final override
Definition region.h:642
void dump_to_pp(pretty_printer *pp, bool simple) const final override
root_region(symbol::id_t id)
Definition region.h:1067
const svalue * m_byte_size_sval
Definition region.h:1144
bool get_bit_size(bit_size_t *out) const final override
bool get_byte_size(byte_size_t *out) const final override
const sized_region * dyn_cast_sized_region() const final override
Definition region.h:1119
const svalue * get_byte_size_sval(region_model_manager *) const final override
Definition region.h:1135
void add_dump_widget_children(text_art::tree_widget &, const text_art::dump_widget_info &dwi) const final override
enum region_kind get_kind() const final override
Definition region.h:1117
void print_dump_widget_label(pretty_printer *pp) const final override
sized_region(symbol::id_t id, const region *parent, tree type, const svalue *byte_size_sval)
Definition region.h:1110
const svalue * get_bit_size_sval(region_model_manager *) const final override
void dump_to_pp(pretty_printer *pp, bool simple) const final override
void accept(visitor *v) const final override
Definition region.h:299
space_region(symbol::id_t id, const region *parent)
Definition region.h:301
Definition region.h:555
void dump_to_pp(pretty_printer *pp, bool simple) const final override
void print_dump_widget_label(pretty_printer *pp) const final override
stack_region(symbol::id_t id, region *parent)
Definition region.h:557
enum region_kind get_kind() const final override
Definition region.h:564
Definition region.h:1276
const string_region * dyn_cast_string_region() const final override
Definition region.h:1284
bool tracked_p() const final override
Definition region.h:1293
tree get_string_cst() const
Definition region.h:1295
enum region_kind get_kind() const final override
Definition region.h:1286
void print_dump_widget_label(pretty_printer *pp) const final override
void dump_to_pp(pretty_printer *pp, bool simple) const final override
tree m_string_cst
Definition region.h:1298
string_region(symbol::id_t id, const region *parent, tree string_cst)
Definition region.h:1278
Definition svalue.h:92
Definition symbol.h:31
unsigned id_t
Definition symbol.h:33
Definition region.h:663
void dump_to_pp(pretty_printer *pp, bool simple) const final override
void print_dump_widget_label(pretty_printer *pp) const final override
symbolic_region(symbol::id_t id, region *parent, const svalue *sval_ptr)
const svalue * get_pointer() const
Definition region.h:713
const symbolic_region * dyn_cast_symbolic_region() const final override
Definition region.h:702
enum region_kind get_kind() const final override
Definition region.h:704
const svalue * m_sval_ptr
Definition region.h:716
void accept(visitor *v) const final override
void add_dump_widget_children(text_art::tree_widget &w, const text_art::dump_widget_info &dwi) const final override
Definition region.h:610
void print_dump_widget_label(pretty_printer *pp) const final override
void dump_to_pp(pretty_printer *pp, bool simple) const final override
thread_local_region(symbol::id_t id, region *parent)
Definition region.h:612
enum region_kind get_kind() const final override
Definition region.h:616
Definition region.h:1552
void print_dump_widget_label(pretty_printer *pp) const final override
enum region_kind get_kind() const final override
Definition region.h:1558
void dump_to_pp(pretty_printer *pp, bool simple) const final override
unknown_region(symbol::id_t id, const region *parent, tree type)
Definition region.h:1554
Definition region.h:1406
unsigned m_idx
Definition region.h:1464
var_arg_region(symbol::id_t id, const frame_region *parent, unsigned idx)
Definition region.h:1446
const var_arg_region * dyn_cast_var_arg_region() const final override
Definition region.h:1453
const frame_region * get_frame_region() const
void dump_to_pp(pretty_printer *pp, bool simple) const final override
void print_dump_widget_label(pretty_printer *pp) const final override
enum region_kind get_kind() const final override
Definition region.h:1455
unsigned get_index() const
Definition region.h:1461
Definition region-model.h:222
Definition genmatch.cc:1496
Definition hash-map.h:40
size_t elements() const
Definition hash-map.h:247
Definition inchash.h:38
void add_int(unsigned v)
Definition inchash.h:55
hashval_t end() const
Definition inchash.h:49
void add_wide_int(const generic_wide_int< T > &x)
Definition inchash.h:84
void add_ptr(const void *ptr)
Definition inchash.h:94
Definition pretty-print.h:241
union tree_node * tree
Definition coretypes.h:97
void final(rtx_insn *first, FILE *file, int optimize_p)
Definition final.cc:2004
Definition access-diagram.h:30
offset_int byte_size_t
Definition analyzer.h:182
offset_int bit_offset_t
Definition analyzer.h:179
offset_int bit_size_t
Definition analyzer.h:180
region_kind
Definition region.h:47
@ RK_UNKNOWN
Definition region.h:71
@ RK_STACK
Definition region.h:53
@ RK_PRIVATE
Definition region.h:70
@ RK_LABEL
Definition region.h:52
@ RK_CAST
Definition region.h:63
@ RK_FIELD
Definition region.h:59
@ RK_FRAME
Definition region.h:48
@ RK_DECL
Definition region.h:58
@ RK_ERRNO
Definition region.h:69
@ RK_ELEMENT
Definition region.h:60
@ RK_SYMBOLIC
Definition region.h:57
@ RK_BIT_RANGE
Definition region.h:67
@ RK_ALLOCA
Definition region.h:65
@ RK_SIZED
Definition region.h:62
@ RK_HEAP_ALLOCATED
Definition region.h:64
@ RK_THREAD_LOCAL
Definition region.h:55
@ RK_CODE
Definition region.h:50
@ RK_GLOBALS
Definition region.h:49
@ RK_OFFSET
Definition region.h:61
@ RK_ROOT
Definition region.h:56
@ RK_FUNCTION
Definition region.h:51
@ RK_HEAP
Definition region.h:54
@ RK_VAR_ARG
Definition region.h:68
@ RK_STRING
Definition region.h:66
memory_space
Definition region.h:32
@ MEMSPACE_GLOBALS
Definition region.h:35
@ MEMSPACE_READONLY_DATA
Definition region.h:38
@ MEMSPACE_HEAP
Definition region.h:37
@ MEMSPACE_PRIVATE
Definition region.h:40
@ MEMSPACE_THREAD_LOCAL
Definition region.h:39
@ MEMSPACE_STACK
Definition region.h:36
@ MEMSPACE_CODE
Definition region.h:34
@ MEMSPACE_UNKNOWN
Definition region.h:33
Definition region.h:1320
void mark_deleted()
Definition region.h:1344
bit_range m_bits
Definition region.h:1354
const region * m_parent
Definition region.h:1352
bool is_empty() const
Definition region.h:1350
hashval_t hash() const
Definition region.h:1327
bool is_deleted() const
Definition region.h:1346
key_t(const region *parent, tree type, const bit_range &bits)
Definition region.h:1321
void mark_empty()
Definition region.h:1345
tree m_type
Definition region.h:1353
bool operator==(const key_t &other) const
Definition region.h:1337
Definition store.h:233
bit_size_t m_size_in_bits
Definition store.h:303
bit_offset_t m_start_bit_offset
Definition store.h:302
Definition store.h:309
Definition region.h:1172
void mark_empty()
Definition region.h:1197
bool is_deleted() const
Definition region.h:1198
const region * m_parent
Definition region.h:1204
key_t(const region *parent, tree type)
Definition region.h:1173
tree m_type
Definition region.h:1205
bool operator==(const key_t &other) const
Definition region.h:1187
bool is_empty() const
Definition region.h:1202
hashval_t hash() const
Definition region.h:1179
void mark_deleted()
Definition region.h:1193
Definition complexity.h:31
Definition region.h:883
bool operator==(const key_t &other) const
Definition region.h:899
const svalue * m_index
Definition region.h:916
void mark_empty()
Definition region.h:907
bool is_deleted() const
Definition region.h:908
const region * m_parent
Definition region.h:914
key_t(const region *parent, tree element_type, const svalue *index)
Definition region.h:884
tree m_element_type
Definition region.h:915
bool is_empty() const
Definition region.h:912
void mark_deleted()
Definition region.h:906
hashval_t hash() const
Definition region.h:890
Definition region.h:806
void mark_deleted()
Definition region.h:826
hashval_t hash() const
Definition region.h:813
bool is_deleted() const
Definition region.h:828
const region * m_parent
Definition region.h:831
bool is_empty() const
Definition region.h:829
bool operator==(const key_t &other) const
Definition region.h:821
tree m_field
Definition region.h:832
key_t(const region *parent, tree field)
Definition region.h:807
void mark_empty()
Definition region.h:827
Definition region.h:323
key_t(const frame_region *calling_frame, const function &fun)
Definition region.h:324
bool is_empty() const
Definition region.h:350
bool is_deleted() const
Definition region.h:346
void mark_empty()
Definition region.h:345
bool operator==(const key_t &other) const
Definition region.h:338
void mark_deleted()
Definition region.h:344
hashval_t hash() const
Definition region.h:330
const frame_region * m_calling_frame
Definition region.h:352
const function * m_fun
Definition region.h:353
Definition region.h:977
key_t(const region *parent, tree element_type, const svalue *byte_offset)
Definition region.h:978
const region * m_parent
Definition region.h:1008
bool is_empty() const
Definition region.h:1006
bool operator==(const key_t &other) const
Definition region.h:993
hashval_t hash() const
Definition region.h:984
tree m_element_type
Definition region.h:1009
bool is_deleted() const
Definition region.h:1002
void mark_empty()
Definition region.h:1001
const svalue * m_byte_offset
Definition region.h:1010
void mark_deleted()
Definition region.h:1000
Definition region.h:1071
const svalue * m_end_offset
Definition region.h:1107
key_t(const region *parent, tree element_type, const svalue *byte_size_sval)
Definition region.h:1072
const region * m_parent
Definition region.h:1104
void mark_deleted()
Definition region.h:1096
bool is_empty() const
Definition region.h:1102
bool operator==(const key_t &other) const
Definition region.h:1089
const svalue * m_byte_size_sval
Definition region.h:1106
tree m_element_type
Definition region.h:1105
hashval_t hash() const
Definition region.h:1080
void mark_empty()
Definition region.h:1097
bool is_deleted() const
Definition region.h:1098
Definition region.h:667
const svalue * m_sval_ptr
Definition region.h:696
bool is_empty() const
Definition region.h:693
const region * m_parent
Definition region.h:695
void mark_deleted()
Definition region.h:687
void mark_empty()
Definition region.h:688
hashval_t hash() const
Definition region.h:674
key_t(const region *parent, const svalue *sval_ptr)
Definition region.h:668
bool operator==(const key_t &other) const
Definition region.h:682
bool is_deleted() const
Definition region.h:689
Definition region.h:1410
bool is_deleted() const
Definition region.h:1436
const frame_region * m_parent
Definition region.h:1442
unsigned m_idx
Definition region.h:1443
bool operator==(const key_t &other) const
Definition region.h:1425
bool is_empty() const
Definition region.h:1440
void mark_empty()
Definition region.h:1435
void mark_deleted()
Definition region.h:1431
hashval_t hash() const
Definition region.h:1417
key_t(const frame_region *parent, unsigned idx)
Definition region.h:1411
Definition genautomata.cc:499
Definition hash-traits.h:466
Definition function.h:249
tree decl
Definition function.h:280
Definition collect2.cc:168
static bool test(U *p)
Definition analyzer.h:508
Definition gengtype.h:252
#define NULL
Definition system.h:50
#define gcc_assert(EXPR)
Definition system.h:814
#define TREE_CODE(NODE)
Definition tree.h:324
#define FUNC_OR_METHOD_TYPE_P(NODE)
Definition tree.h:721
#define TREE_TYPE(NODE)
Definition tree.h:512
#define NULL_TREE
Definition tree.h:317
#define integer_type_node
Definition tree.h:4681