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