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
25#include "analyzer/store.h"
30
31namespace ana {
32
33/* An enum for identifying different spaces within memory. */
34
46
47extern const char *
49
50/* An enum for discriminating between the different concrete subclasses
51 of region. */
52
76
77/* Region and its subclasses.
78
79 The class hierarchy looks like this (using indentation to show
80 inheritance, and with region_kinds shown for the concrete subclasses):
81
82 region
83 frame_region (RK_FRAME): a function frame on the stack
84 memory_space_region (RK_MEMORY_SPACE): a region for a particular
85 memory_space
86 root_region (RK_ROOT): the top-level region
87 cluster_region
88 alloca_region (RK_ALLOCA): an untyped region dynamically allocated on the
89 stack via "alloca"
90 decl_region (RK_DECL): the memory occupied by a particular global, local,
91 or SSA name
92 errno_region (RK_ERRNO): a region for holding "errno"
93 function_region (RK_FUNCTION): the code for a particular function
94 heap_allocated_region (RK_HEAP_ALLOCATED): an untyped region dynamically
95 allocated on the heap via
96 "malloc" or similar
97 label_region (RK_LABEL): a particular label within a function
98 private_region (RK_PRIVATE): a region for internal state of an API
99 string_region (RK_STRING): a region for a STRING_CST
100 symbolic_region (RK_SYMBOLIC): dereferencing a symbolic pointer
101 var_arg_region (RK_VAR_ARG): a region for the N-th vararg within a
102 frame_region for a variadic call
103 unknown_region (RK_UNKNOWN): for handling unimplemented tree codes.
104 field_region (RK_FIELD): the memory occupied by a field within a struct
105 or union
106 element_region (RK_ELEMENT): an element within an array
107 offset_region (RK_OFFSET): a byte-offset within another region, for
108 handling pointer arithmetic as a region
109 sized_region (RK_SIZED): a subregion of symbolic size (in bytes)
110 within its parent
111 cast_region (RK_CAST): a region that views another region using a
112 different type
113 bit_range_region (RK_BIT_RANGE): a region for a specific range of bits
114 within another region.
115
116 For this example code:
117
118 . extern int arr[10];
119 . void foo ()
120 . {
121 . int .p = (int .)malloc (sizeof (int));
122 . [...etc...].
123
124 the *object* hierarchy, in terms of the ancestry expressed by the
125 get_parent () pointers of region *instances*, might look something like
126 this:
127
128 . root (RK_ROOT)
129 . +- memory_space_region for memory_space::globals (RK_MEMORY_SPACE)
130 . | | (all descendents have m_mem_space == memory_space::globals)
131 . | `- [C] decl_region for 'arr[10]' (RK_DECL)
132 . | `- element_region for 'arr[3]' (RK_ELEMENT)
133 . +- memory_space_region for memory_space::heap (RK_MEMORY_SPACE)
134 . | | (all descendents have m_mem_space == memory_space::heap)
135 . | `- [C] heap_allocated_region for '*p'
136 . +- memory_space_region for memory_space::stack (RK_MEMORY_SPACE)
137 . | | (all descendents have m_mem_space == memory_space::stack)
138 . | +- frame_region (RK_FRAME)
139 . | +- frame_region (RK_FRAME)
140 . | `- frame_region (RK_FRAME)
141 . | `- [C] decl_region for 'p' (RK_DECL)
142
143 where [C] denotes a cluster region. */
144
145/* Abstract base class for representing ways of accessing chunks of memory.
146
147 Regions form a tree-like hierarchy, with a root region at the base,
148 with memory space regions within it, representing the stack and
149 globals, with frames within the stack, and regions for variables
150 within the frames and the "globals" region. Regions for structs
151 can have subregions for fields. */
152
153class region : public symbolic::node
154{
155public:
158
159 virtual ~region ();
160
161 virtual enum region_kind get_kind () const = 0;
162 virtual const frame_region *
163 dyn_cast_frame_region () const { return nullptr; }
164 virtual const function_region *
165 dyn_cast_function_region () const { return nullptr; }
166 virtual const symbolic_region *
167 dyn_cast_symbolic_region () const { return nullptr; }
168 virtual const decl_region *
169 dyn_cast_decl_region () const { return nullptr; }
170 virtual const field_region *
171 dyn_cast_field_region () const { return nullptr; }
172 virtual const element_region *
173 dyn_cast_element_region () const { return nullptr; }
174 virtual const offset_region *
175 dyn_cast_offset_region () const { return nullptr; }
176 virtual const sized_region *
177 dyn_cast_sized_region () const { return nullptr; }
178 virtual const cast_region *
179 dyn_cast_cast_region () const { return nullptr; }
180 virtual const string_region *
181 dyn_cast_string_region () const { return nullptr; }
182 virtual const bit_range_region *
183 dyn_cast_bit_range_region () const { return nullptr; }
184 virtual const var_arg_region *
185 dyn_cast_var_arg_region () const { return nullptr; }
186
187 void print_dump_widget_label (pretty_printer *pp) const final override;
189 void
191 symbolic::node_dump_state &nds) const final override;
192 const char *
193 get_any_dump_color () const override { return "region"; }
194
195 virtual void accept (visitor *v) const;
196
197 const region *get_parent_region () const { return m_parent; }
198 const cluster_region *get_base_region () const { return m_cluster_reg; }
200 bool base_region_p () const;
201 bool descendent_of_p (const region *elder) const;
206
208
209 tree get_type () const { return m_type; }
210
211 void print (const region_model &model,
212 pretty_printer *pp) const;
213 label_text get_desc (bool simple=true) const;
214
215 virtual void dump_to_pp (pretty_printer *pp, bool simple) const = 0;
216 void dump (bool simple) const;
217 void dump () const;
218
220 const region_model &model) const;
221
222 bool non_null_p () const;
223
224 static int cmp_ptr_ptr (const void *, const void *);
225
228
231
234
235 /* Attempt to get the size of this region in bytes.
236 This is the accessed size, not necessarily the size that's valid to
237 access. */
238 virtual const symbolic_byte_size *
240
241 /* Attempt to get the size of this region in bits.
242 This is the accessed size, not necessarily the size that's valid to
243 access. */
244 virtual const symbolic_bit_size *
246
247 /* Get a symbolic value describing the size of this region in bytes
248 (which could be "unknown").
249 This is the accessed size, not necessarily the size that's valid to
250 access. */
252
253 virtual const symbolic_bit_count *
255
256 virtual const symbolic_byte_count *
258
259 void
261 concrete_bit_range relative_bit_range,
262 tree type,
263 auto_vec <const region *> *out) const;
264
266
267 bool symbolic_p () const;
268
269 /* For most base regions it makes sense to track the bindings of the region
270 within the store. As an optimization, some are not tracked (to avoid
271 bloating the store object with redundant binding clusters). */
272 virtual bool tracked_p () const { return true; }
273
274 bool is_named_decl_p (const char *decl_name) const;
275
276 bool empty_p (region_model_manager &mgr) const;
277
278 protected:
281 const region *parent,
282 const cluster_region *cluster_reg,
283 memory_space mem_space,
284 tree type);
285
286 std::unique_ptr<json::object>
287 make_json_obj (const char *type_name) const;
288
289 private:
292
295
298
300
301 virtual void
303 symbolic::node_dump_state &nds) const;
304
305 /* The immediate parent (if any) of this node. */
307
308 /* The region within the ancestry of this region that identifies which
309 cluster (if any) they should be partitioned into within the store.
310
311 (This is sometimes called the "base region" in existing code, but that
312 term is confusing so I'm deprecating it)
313
314 Regions within the same struct/union/array are in the same cluster.
315 Different decls are in different clusters.
316 Instances of cluster_region have "this" as their m_cluster_reg.
317 Nodes above the level of clusters (e.g. memory_space_region) have
318 nullptr for their m_cluster_reg. */
320
322
324
325 mutable std::unique_ptr<symbolic::memory_offset> m_cached_memory_offset;
326 mutable std::unique_ptr<symbolic::memory_range> m_cached_memory_range;
327 mutable std::unique_ptr<symbolic::pointer> m_cached_pointer;
328
329 /* For regions within a global decl, a cache of the svalue for the initial
330 value of this region when the program starts. */
332};
333
334} // namespace ana
335
336template <>
337template <>
338inline bool
340{
341 return true;
342}
343
344namespace ana {
345
346/* Concrete subclass of region, for regions that represent an untyped
347 space within memory, such as the stack or the heap.
348 Child regions "inherit" its memory_space value. */
349
351{
352public:
354 memory_space mem_space)
355 : region (complexity (parent), id, parent,
356 nullptr, // no cluster
357 mem_space,
358 NULL_TREE) // no type
359 {}
360
361 /* region vfuncs. */
362 enum region_kind
363 get_kind () const final override { return RK_MEMORY_SPACE; }
364
365 void
366 dump_to_pp (pretty_printer *pp, bool simple) const final override;
367
368 void
370
371 void
373
374 std::unique_ptr<json::object>
375 to_json () const final override;
376
377 std::unique_ptr<diagnostics::markup::node>
378 make_markup_node (symbolic::markup_context &markup_ctxt) const final override;
379};
380
381} // namespace ana
382
383template <>
384template <>
385inline bool
387{
388 return reg->get_kind () == RK_MEMORY_SPACE;
389}
390
391namespace ana {
392
393/* Concrete region subclass, representing a function frame on the stack,
394 to contain the locals.
395 The parent is the stack region; there's also a hierarchy of call-stack
396 prefixes expressed via m_calling_frame.
397 For example, given "oldest" calling "middle" called "newest" we would have
398 - a stack depth of 3
399 - frame (A) for "oldest" with index 0 for depth 1, calling_frame == NULL
400 - frame (B) for "middle" with index 1 for depth 2, calling_frame == (A)
401 - frame (C) for "newest" with index 2 for depth 3, calling_frame == (B)
402 where the parent region for each of the frames is the "stack" region.
403 The index is the count of frames earlier than this in the stack. */
404
405class frame_region : public region
406{
407public:
408 /* A support class for uniquifying instances of frame_region. */
409 struct key_t
410 {
411 key_t (const frame_region *calling_frame, const function &fun)
412 : m_calling_frame (calling_frame), m_fun (&fun)
413 {
414 /* calling_frame can be nullptr. */
415 }
416
417 hashval_t hash () const
418 {
419 inchash::hash hstate;
420 hstate.add_ptr (m_calling_frame);
421 hstate.add_ptr (m_fun);
422 return hstate.end ();
423 }
424
425 bool operator== (const key_t &other) const
426 {
427 return (m_calling_frame == other.m_calling_frame
428 && m_fun == other.m_fun);
429 }
430
431 void mark_deleted () { m_fun = reinterpret_cast<function *> (1); }
432 void mark_empty () { m_fun = nullptr; }
433 bool is_deleted () const
434 {
435 return m_fun == reinterpret_cast<function *> (1);
436 }
437 bool is_empty () const { return m_fun == nullptr; }
438
441 };
442
444 const region &parent,
445 const frame_region *calling_frame,
446 const function &fun,
447 int index)
448 : region (complexity (&parent),
449 id,
450 &parent,
451 nullptr, // no cluster
452 parent.get_memory_space (),
453 NULL_TREE),
454 m_calling_frame (calling_frame),
455 m_fun (fun), m_index (index)
456 {}
458
459 /* region vfuncs. */
460 enum region_kind get_kind () const final override { return RK_FRAME; }
461 const frame_region * dyn_cast_frame_region () const final override
462 {
463 return this;
464 }
465 void accept (visitor *v) const final override;
466 void dump_to_pp (pretty_printer *pp, bool simple) const final override;
467
468 void print_region_for_dump_widget_label (pretty_printer *pp) const final override;
469 void
471
472 std::unique_ptr<json::object>
473 to_json () const final override;
474
475 std::unique_ptr<diagnostics::markup::node>
476 make_markup_node (symbolic::markup_context &markup_ctxt) const final override;
477
478 /* Accessors. */
480 const function &get_function () const { return m_fun; }
481 tree get_fndecl () const { return get_function ().decl; }
482 int get_index () const { return m_index; }
483 int get_stack_depth () const { return m_index + 1; }
484
485 const decl_region *
487 tree expr,
488 const region_model_context *ctxt) const;
489
490 unsigned get_num_locals () const { return m_locals.elements (); }
491
492 /* Implemented in region-model-manager.cc. */
494
495 private:
499
500 /* The regions for the decls within this frame are managed by this
501 object, rather than the region_model_manager, to make it a simple
502 lookup by tree. */
505};
506
507} // namespace ana
508
509template <>
510template <>
511inline bool
513{
514 return reg->get_kind () == RK_FRAME;
515}
516
518: public member_function_hash_traits<frame_region::key_t>
519{
520 static const bool empty_zero_p = true;
521};
522
523namespace ana {
524
525/* Abstract subclass of region for those regions that are the "top-level"
526 within the store and thus get their own binding_cluster.
527 All regions within the same struct/union/array are in the same cluster,
528 whereas different decls are in different clusters.
529
530 (This is sometimes called the "base region" in existing code, but that
531 term is confusing so I'm deprecating it)
532
533 A cluster_region and its descendents will all have "this" as the result
534 of their get_cluster_region (). */
535
536class cluster_region : public region
537{
538protected:
540 const region &parent, tree type)
541 : region (c, id, &parent,
542 this, // this is its own cluster_region
543 parent.get_memory_space (),
544 type)
545 {}
546};
547
548inline bool
550{
551 return m_cluster_reg == this;
552}
553
554/* Concrete cluster_region subclass. A region representing the code for
555 a particular function. */
556
558{
559public:
561 const memory_space_region &parent,
562 tree fndecl)
563 : cluster_region (complexity (&parent), id, parent,
564 TREE_TYPE (fndecl)),
565 m_fndecl (fndecl)
566 {
568 }
569
570 /* region vfuncs. */
571 void dump_to_pp (pretty_printer *pp, bool simple) const final override;
572 void print_region_for_dump_widget_label (pretty_printer *pp) const final override;
573 void
575 std::unique_ptr<json::object>
576 to_json () const final override;
577
578 std::unique_ptr<diagnostics::markup::node>
579 make_markup_node (symbolic::markup_context &markup_ctxt) const final override;
580
581 enum region_kind get_kind () const final override { return RK_FUNCTION; }
582 const function_region *
583 dyn_cast_function_region () const final override{ return this; }
584
585 tree get_fndecl () const { return m_fndecl; }
586
587private:
589};
590
591} // namespace ana
592
593template <>
594template <>
595inline bool
597{
598 return reg->get_kind () == RK_FUNCTION;
599}
600
601namespace ana {
602
603/* Concrete cluster_region subclass. A region representing a particular label
604 within a function. */
605
607{
608public:
610 const function_region &parent,
611 tree label)
612 : cluster_region (complexity (&parent), id, parent, NULL_TREE),
613 m_label (label)
614 {
615 gcc_assert (TREE_CODE (label) == LABEL_DECL);
616 }
617
618 /* region vfuncs. */
619 void dump_to_pp (pretty_printer *pp, bool simple) const final override;
620 void print_region_for_dump_widget_label (pretty_printer *pp) const final override;
621 void
623 std::unique_ptr<json::object>
624 to_json () const final override;
625 std::unique_ptr<diagnostics::markup::node>
626 make_markup_node (symbolic::markup_context &markup_ctxt) const final override;
627
628 enum region_kind get_kind () const final override { return RK_LABEL; }
629
630 tree get_label () const { return m_label; }
631
632private:
634};
635
636} // namespace ana
637
638template <>
639template <>
640inline bool
642{
643 return reg->get_kind () == RK_LABEL;
644}
645
646namespace ana {
647
648/* Concrete region subclass. The root region, containing all regions
649 (either directly, or as descendents).
650 Unique within a region_model_manager. */
651
652class root_region : public region
653{
654public:
656
657 enum region_kind get_kind () const final override { return RK_ROOT; }
658 void dump_to_pp (pretty_printer *pp, bool simple) const final override;
659 void print_region_for_dump_widget_label (pretty_printer *pp) const final override;
660
661 void
663
664 std::unique_ptr<json::object>
665 to_json () const final override;
666
667 std::unique_ptr<diagnostics::markup::node>
668 make_markup_node (symbolic::markup_context &markup_ctxt) const final override;
669};
670
671} // namespace ana
672
673template <>
674template <>
675inline bool
676is_a_helper <const root_region *>::test (const region *reg)
677{
678 return reg->get_kind () == RK_ROOT;
679}
680
681namespace ana {
682
683/* Concrete region subclass: a region to use when dereferencing an unknown
684 pointer. */
685
687{
688public:
689 /* A support class for uniquifying instances of symbolic_region. */
690 struct key_t
691 {
692 key_t (const region *parent, const svalue *sval_ptr)
693 : m_parent (parent), m_sval_ptr (sval_ptr)
694 {
695 gcc_assert (sval_ptr);
696 }
697
698 hashval_t hash () const
699 {
700 inchash::hash hstate;
701 hstate.add_ptr (m_parent);
702 hstate.add_ptr (m_sval_ptr);
703 return hstate.end ();
704 }
705
706 bool operator== (const key_t &other) const
707 {
708 return (m_parent == other.m_parent && m_sval_ptr == other.m_sval_ptr);
709 }
710
711 void mark_deleted () { m_sval_ptr = reinterpret_cast<const svalue *> (1); }
712 void mark_empty () { m_sval_ptr = nullptr; }
713 bool is_deleted () const
714 {
715 return m_sval_ptr == reinterpret_cast<const svalue *> (1);
716 }
717 bool is_empty () const { return m_sval_ptr == nullptr; }
718
721 };
722
724 const region &parent,
725 const svalue *sval_ptr);
726
727 const symbolic_region *
728 dyn_cast_symbolic_region () const final override { return this; }
729
730 enum region_kind get_kind () const final override { return RK_SYMBOLIC; }
731 void accept (visitor *v) const final override;
732 void dump_to_pp (pretty_printer *pp, bool simple) const final override;
733 void print_region_for_dump_widget_label (pretty_printer *pp) const final override;
734 void
737 const final override;
738 void
740
741 std::unique_ptr<json::object>
742 to_json () const final override;
743
744 std::unique_ptr<diagnostics::markup::node>
745 make_markup_node (symbolic::markup_context &markup_ctxt) const final override;
746
747 const svalue *get_pointer () const { return m_sval_ptr; }
748
749private:
751};
752
753} // namespace ana
754
755template <>
756template <>
757inline bool
759{
760 return reg->get_kind () == RK_SYMBOLIC;
761}
762
764: public member_function_hash_traits<symbolic_region::key_t>
765{
766 static const bool empty_zero_p = true;
767};
768
769namespace ana {
770
771/* Concrete region subclass representing the memory occupied by a
772 variable (whether for a global or a local).
773 Also used for representing SSA names, as if they were locals. */
774
776{
777public:
779 : cluster_region (complexity (&parent), id, parent, TREE_TYPE (decl)),
780 m_decl (decl),
782 m_ctor_bit_contents (nullptr)
783 {}
784
785 enum region_kind get_kind () const final override { return RK_DECL; }
786 const decl_region *
787 dyn_cast_decl_region () const final override { return this; }
788
789 void dump_to_pp (pretty_printer *pp, bool simple) const final override;
790
791 void
793
794 void
796
797 std::unique_ptr<json::object>
798 to_json () const final override;
799
800 std::unique_ptr<diagnostics::markup::node>
801 make_markup_node (symbolic::markup_context &markup_ctxt) const final override;
802
803 bool tracked_p () const final override { return m_tracked; }
804
805 tree get_decl () const { return m_decl; }
806 int get_stack_depth () const;
807
810
813 region_model_manager *mgr) const;
816 region_model_manager *mgr) const;
818
821
822private:
825 region_model_manager *mgr) const;
826 static bool calc_tracked_p (tree decl);
827
829
830 /* Cached result of calc_tracked_p, so that we can quickly determine when
831 we don't to track a binding_cluster for this decl (to avoid bloating
832 store objects).
833 This can be debugged using -fdump-analyzer-untracked. */
835
836 /* Cached result of get_bit_contents_for_constructor. */
838};
839
840} // namespace ana
841
842template <>
843template <>
844inline bool
846{
847 return reg->get_kind () == RK_DECL;
848}
849
850namespace ana {
851
852/* Concrete region subclass representing the memory occupied by a
853 field within a struct or union. */
854
855class field_region : public region
856{
857public:
858 /* A support class for uniquifying instances of field_region. */
859 struct key_t
860 {
861 key_t (const region *parent, tree field)
862 : m_parent (parent), m_field (field)
863 {
864 gcc_assert (field);
865 }
866
867 hashval_t hash () const
868 {
869 inchash::hash hstate;
870 hstate.add_ptr (m_parent);
871 hstate.add_ptr (m_field);
872 return hstate.end ();
873 }
874
875 bool operator== (const key_t &other) const
876 {
877 return (m_parent == other.m_parent && m_field == other.m_field);
878 }
879
880 void mark_deleted () { m_field = reinterpret_cast<tree> (1); }
882 bool is_deleted () const { return m_field == reinterpret_cast<tree> (1); }
883 bool is_empty () const { return m_field == NULL_TREE; }
884
887 };
888
889 field_region (symbolic::node::id_t id, const region &parent, tree field)
890 : region (complexity (&parent), id, &parent,
891 parent.get_cluster_region (),
892 parent.get_memory_space (),
893 TREE_TYPE (field)),
894 m_field (field)
895 {}
896
897 enum region_kind get_kind () const final override { return RK_FIELD; }
898
899 void dump_to_pp (pretty_printer *pp, bool simple) const final override;
900 void print_region_for_dump_widget_label (pretty_printer *pp) const final override;
901
902 void
904
905 std::unique_ptr<json::object>
906 to_json () const final override;
907
908 std::unique_ptr<diagnostics::markup::node>
909 make_markup_node (symbolic::markup_context &markup_ctxt) const final override;
910
911 const field_region *
912 dyn_cast_field_region () const final override { return this; }
913
914 tree get_field () const { return m_field; }
915
916 const symbolic_bit_count *
918 const final override;
919
920 const symbolic_byte_count *
922 const final override;
923
924private:
926};
927
928} // namespace ana
929
930template <>
931template <>
932inline bool
934{
935 return reg->get_kind () == RK_FIELD;
936}
937
939: public member_function_hash_traits<field_region::key_t>
940{
941 static const bool empty_zero_p = true;
942};
943
944namespace ana {
945
946/* An element within an array. */
947
948class element_region : public region
949{
950public:
951 /* A support class for uniquifying instances of element_region. */
952 struct key_t
953 {
954 key_t (const region *parent, tree element_type, const svalue *index)
955 : m_parent (parent), m_element_type (element_type), m_index (index)
956 {
957 gcc_assert (index);
958 }
959
960 hashval_t hash () const
961 {
962 inchash::hash hstate;
963 hstate.add_ptr (m_parent);
964 hstate.add_ptr (m_element_type);
965 hstate.add_ptr (m_index);
966 return hstate.end ();
967 }
968
969 bool operator== (const key_t &other) const
970 {
971 return (m_parent == other.m_parent
972 && m_element_type == other.m_element_type
973 && m_index == other.m_index);
974 }
975
976 void mark_deleted () { m_index = reinterpret_cast<const svalue *> (1); }
977 void mark_empty () { m_index = nullptr; }
978 bool is_deleted () const
979 {
980 return m_index == reinterpret_cast<const svalue *> (1);
981 }
982 bool is_empty () const { return m_index == nullptr; }
983
987 };
988
990 const region &parent,
991 tree element_type,
992 const svalue *index)
993 : region (complexity::from_pair (&parent, index), id, &parent,
994 parent.get_cluster_region (),
995 parent.get_memory_space (),
996 element_type),
997 m_index (index)
998 {}
999
1000 enum region_kind get_kind () const final override { return RK_ELEMENT; }
1001 const element_region *
1002 dyn_cast_element_region () const final override { return this; }
1003
1004 void accept (visitor *v) const final override;
1005
1006 void dump_to_pp (pretty_printer *pp, bool simple) const final override;
1007
1008 void
1010 void
1013 const final override;
1014
1015 void
1017
1018 std::unique_ptr<json::object>
1019 to_json () const final override;
1020
1021 std::unique_ptr<diagnostics::markup::node>
1022 make_markup_node (symbolic::markup_context &markup_ctxt) const final override;
1023
1024 const svalue *get_index () const { return m_index; }
1025
1026 const symbolic_bit_count *
1028 const final override;
1029
1030 const symbolic_byte_count *
1032 const final override;
1033
1034private:
1036};
1037
1038} // namespace ana
1039
1040template <>
1041template <>
1042inline bool
1044{
1045 return reg->get_kind () == RK_ELEMENT;
1046}
1047
1049: public member_function_hash_traits<element_region::key_t>
1050{
1051 static const bool empty_zero_p = true;
1052};
1053
1054namespace ana {
1055
1056/* A byte-offset within another region, for handling pointer arithmetic
1057 as a region. */
1058
1059class offset_region : public region
1060{
1061public:
1062 /* A support class for uniquifying instances of offset_region. */
1063 struct key_t
1064 {
1065 key_t (const region *parent, tree element_type, const svalue *byte_offset)
1066 : m_parent (parent), m_element_type (element_type), m_byte_offset (byte_offset)
1067 {
1068 gcc_assert (byte_offset);
1069 }
1070
1071 hashval_t hash () const
1072 {
1073 inchash::hash hstate;
1074 hstate.add_ptr (m_parent);
1075 hstate.add_ptr (m_element_type);
1076 hstate.add_ptr (m_byte_offset);
1077 return hstate.end ();
1078 }
1079
1080 bool operator== (const key_t &other) const
1081 {
1082 return (m_parent == other.m_parent
1083 && m_element_type == other.m_element_type
1084 && m_byte_offset == other.m_byte_offset);
1085 }
1086
1087 void mark_deleted () { m_byte_offset = reinterpret_cast<const svalue *> (1); }
1088 void mark_empty () { m_byte_offset = nullptr; }
1089 bool is_deleted () const
1090 {
1091 return m_byte_offset == reinterpret_cast<const svalue *> (1);
1092 }
1093 bool is_empty () const { return m_byte_offset == nullptr; }
1094
1098 };
1099
1101 const svalue *byte_offset)
1102 : region (complexity::from_pair (&parent, byte_offset), id, &parent,
1103 parent.get_cluster_region (),
1104 parent.get_memory_space (),
1105 type),
1106 m_byte_offset (byte_offset)
1107 {}
1108
1109 enum region_kind get_kind () const final override { return RK_OFFSET; }
1110 const offset_region *
1111 dyn_cast_offset_region () const final override { return this; }
1112
1113 void accept (visitor *v) const final override;
1114
1115 void dump_to_pp (pretty_printer *pp, bool simple) const final override;
1116
1117 void
1119 void
1122 const final override;
1123
1124 void
1126
1127 std::unique_ptr<json::object>
1128 to_json () const final override;
1129
1130 std::unique_ptr<diagnostics::markup::node>
1131 make_markup_node (symbolic::markup_context &markup_ctxt) const final override;
1132
1133 const svalue *get_byte_offset () const { return m_byte_offset; }
1135
1136 const symbolic_bit_count *
1138 const final override;
1139
1140 const symbolic_byte_count *
1142 const final override;
1143
1144private:
1146};
1147
1148} // namespace ana
1149
1150template <>
1151template <>
1152inline bool
1154{
1155 return reg->get_kind () == RK_OFFSET;
1156}
1157
1159: public member_function_hash_traits<offset_region::key_t>
1160{
1161 static const bool empty_zero_p = true;
1162};
1163
1164namespace ana {
1165
1166/* A region that is size BYTES_SIZE_SVAL in size within its parent
1167 region (or possibly larger, which would lead to an overflow. */
1168
1169class sized_region : public region
1170{
1171public:
1172 /* A support class for uniquifying instances of sized_region. */
1173 struct key_t
1174 {
1175 key_t (const region *parent, tree element_type,
1176 const svalue *byte_size_sval)
1177 : m_parent (parent), m_element_type (element_type),
1178 m_byte_size_sval (byte_size_sval)
1179 {
1180 gcc_assert (byte_size_sval);
1181 }
1182
1183 hashval_t hash () const
1184 {
1185 inchash::hash hstate;
1186 hstate.add_ptr (m_parent);
1187 hstate.add_ptr (m_element_type);
1188 hstate.add_ptr (m_byte_size_sval);
1189 return hstate.end ();
1190 }
1191
1192 bool operator== (const key_t &other) const
1193 {
1194 return (m_parent == other.m_parent
1195 && m_element_type == other.m_element_type
1196 && m_byte_size_sval == other.m_byte_size_sval);
1197 }
1198
1199 void mark_deleted () { m_byte_size_sval = reinterpret_cast<const svalue *> (1); }
1200 void mark_empty () { m_byte_size_sval = nullptr; }
1201 bool is_deleted () const
1202 {
1203 return m_byte_size_sval == reinterpret_cast<const svalue *> (1);
1204 }
1205 bool is_empty () const { return m_byte_size_sval == nullptr; }
1206
1211 };
1212
1214 const svalue *byte_size_sval)
1215 : region (complexity::from_pair (&parent, byte_size_sval),
1216 id, &parent,
1217 parent.get_cluster_region (),
1218 parent.get_memory_space (),
1219 type),
1220 m_byte_size_sval (byte_size_sval)
1221 {}
1222
1223 enum region_kind get_kind () const final override { return RK_SIZED; }
1224 const sized_region *
1225 dyn_cast_sized_region () const final override { return this; }
1226
1227 void accept (visitor *v) const final override;
1228
1229 void dump_to_pp (pretty_printer *pp, bool simple) const final override;
1230 void
1232 void
1235 const final override;
1236
1237 void
1239
1240 std::unique_ptr<json::object>
1241 to_json () const final override;
1242
1243 std::unique_ptr<diagnostics::markup::node>
1244 make_markup_node (symbolic::markup_context &markup_ctxt) const final override;
1245
1246 const symbolic_byte_size *
1247 maybe_get_byte_size (symbolic::scalar_manager<concrete_byte_size> &byte_mgr) const final override;
1248 const symbolic_bit_size *
1249 maybe_get_bit_size (symbolic::scalar_manager<concrete_bit_size> &bit_mgr) const final override;
1250
1251private:
1253};
1254
1255} // namespace ana
1256
1257template <>
1258template <>
1259inline bool
1260is_a_helper <const sized_region *>::test (const region *reg)
1261{
1262 return reg->get_kind () == RK_SIZED;
1263}
1264
1266: public member_function_hash_traits<sized_region::key_t>
1267{
1268 static const bool empty_zero_p = true;
1269};
1270
1271namespace ana {
1272
1273/* A region that views another region using a different type. */
1274
1275class cast_region : public region
1276{
1277public:
1278 /* A support class for uniquifying instances of cast_region. */
1279 struct key_t
1280 {
1281 key_t (const region *parent, tree type)
1282 : m_parent (parent), m_type (type)
1283 {
1284 gcc_assert (parent);
1285 }
1286
1287 hashval_t hash () const
1288 {
1289 inchash::hash hstate;
1290 hstate.add_ptr (m_parent);
1291 hstate.add_ptr (m_type);
1292 return hstate.end ();
1293 }
1294
1295 bool operator== (const key_t &other) const
1296 {
1297 return (m_parent == other.m_parent
1298 && m_type == other.m_type);
1299 }
1300
1302 {
1303 m_parent = reinterpret_cast<const region *> (1);
1304 }
1305 void mark_empty () { m_parent = nullptr; }
1306 bool is_deleted () const
1307 {
1308 return m_parent == reinterpret_cast<const region *> (1);
1309 }
1310 bool is_empty () const { return m_parent == nullptr; }
1311
1314 };
1315
1317 : region (complexity (&parent), id, &parent,
1318 parent.get_cluster_region (),
1319 parent.get_memory_space (),
1320 type)
1321 {}
1322
1323 enum region_kind get_kind () const final override { return RK_CAST; }
1324 const cast_region *
1325 dyn_cast_cast_region () const final override { return this; }
1326 void dump_to_pp (pretty_printer *pp, bool simple) const final override;
1327 void
1329
1330 void
1332
1333 std::unique_ptr<json::object>
1334 to_json () const final override;
1335
1336 std::unique_ptr<diagnostics::markup::node>
1337 make_markup_node (symbolic::markup_context &markup_ctxt) const final override;
1338
1339 const symbolic_bit_count *
1341 const final override;
1342
1343 const symbolic_byte_count *
1345 const final override;
1346};
1347
1348} // namespace ana
1349
1350template <>
1351template <>
1352inline bool
1353is_a_helper <const cast_region *>::test (const region *reg)
1354{
1355 return reg->get_kind () == RK_CAST;
1356}
1357
1359: public member_function_hash_traits<cast_region::key_t>
1360{
1361 static const bool empty_zero_p = true;
1362};
1363
1364namespace ana {
1365
1366/* An untyped region dynamically allocated on the heap via "malloc"
1367 or similar. */
1368
1370{
1371public:
1373 : cluster_region (complexity (parent), id, parent, NULL_TREE)
1374 {}
1375
1376 enum region_kind
1377 get_kind () const final override { return RK_HEAP_ALLOCATED; }
1378
1379 void dump_to_pp (pretty_printer *pp, bool simple) const final override;
1381
1382 void
1384
1385 std::unique_ptr<json::object>
1386 to_json () const final override;
1387
1388 std::unique_ptr<diagnostics::markup::node>
1389 make_markup_node (symbolic::markup_context &markup_ctxt) const final override;
1390};
1391
1392/* An untyped region dynamically allocated on the stack via "alloca". */
1393
1395{
1396public:
1398 : cluster_region (complexity (parent), id, parent, NULL_TREE)
1399 {}
1400
1401 enum region_kind get_kind () const final override { return RK_ALLOCA; }
1402
1403 void dump_to_pp (pretty_printer *pp, bool simple) const final override;
1405
1406 void
1408
1409 std::unique_ptr<json::object>
1410 to_json () const final override;
1411
1412 std::unique_ptr<diagnostics::markup::node>
1413 make_markup_node (symbolic::markup_context &markup_ctxt) const final override;
1414};
1415
1416/* A region for a STRING_CST. */
1417
1419{
1420public:
1421 string_region (symbolic::node::id_t id, const region &parent, tree string_cst)
1422 : cluster_region (complexity (&parent), id, parent, TREE_TYPE (string_cst)),
1423 m_string_cst (string_cst)
1424 {}
1425
1426 const string_region *
1427 dyn_cast_string_region () const final override { return this; }
1428
1429 enum region_kind get_kind () const final override { return RK_STRING; }
1430
1431 void dump_to_pp (pretty_printer *pp, bool simple) const final override;
1433 void
1435
1436 std::unique_ptr<json::object>
1437 to_json () const final override;
1438
1439 std::unique_ptr<diagnostics::markup::node>
1440 make_markup_node (symbolic::markup_context &markup_ctxt) const final override;
1441
1442 /* We assume string literals are immutable, so we don't track them in
1443 the store. */
1444 bool tracked_p () const final override { return false; }
1445
1446 tree get_string_cst () const { return m_string_cst; }
1447
1448private:
1450};
1451
1452} // namespace ana
1453
1454template <>
1455template <>
1456inline bool
1458{
1459 return reg->get_kind () == RK_STRING;
1460}
1461
1462namespace ana {
1463
1464/* A region for a specific range of bits within another region. */
1465
1467{
1468public:
1469 /* A support class for uniquifying instances of bit_range_region. */
1470 struct key_t
1471 {
1472 key_t (const region *parent, tree type, const concrete_bit_range &bits)
1473 : m_parent (parent), m_type (type), m_bits (bits)
1474 {
1475 gcc_assert (parent);
1476 }
1477
1478 hashval_t hash () const
1479 {
1480 inchash::hash hstate;
1481 hstate.add_ptr (m_parent);
1482 hstate.add_ptr (m_type);
1483 hstate.add_int (m_bits.get_start_offset ().as_long ());
1484 hstate.add_int (m_bits.get_size ().as_long ());
1485 return hstate.end ();
1486 }
1487
1488 bool operator== (const key_t &other) const
1489 {
1490 return (m_parent == other.m_parent
1491 && m_type == other.m_type
1492 && m_bits == other.m_bits);
1493 }
1494
1495 void mark_deleted () { m_parent = reinterpret_cast<const region *> (1); }
1496 void mark_empty () { m_parent = nullptr; }
1497 bool is_deleted () const
1498 {
1499 return m_parent == reinterpret_cast<const region *> (1);
1500 }
1501 bool is_empty () const { return m_parent == nullptr; }
1502
1506 };
1507
1509 const concrete_bit_range &bits)
1510 : region (complexity (&parent), id, &parent,
1511 parent.get_cluster_region (),
1512 parent.get_memory_space (),
1513 type),
1514 m_bits (bits)
1515 {}
1516
1517 const bit_range_region *
1518 dyn_cast_bit_range_region () const final override { return this; }
1519
1520 enum region_kind get_kind () const final override { return RK_BIT_RANGE; }
1521
1522 void dump_to_pp (pretty_printer *pp, bool simple) const final override;
1524 void
1526
1527 std::unique_ptr<json::object>
1528 to_json () const final override;
1529
1530 std::unique_ptr<diagnostics::markup::node>
1531 make_markup_node (symbolic::markup_context &markup_ctxt) const final override;
1532
1533 const concrete_bit_range &get_bits () const { return m_bits; }
1534
1535 const symbolic_byte_size *
1537 const final override;
1538
1539 const symbolic_bit_size *
1541 const final override;
1542
1543 const symbolic_bit_count *
1545 const final override;
1546
1547 const symbolic_byte_count *
1549 const final override;
1550
1551private:
1553};
1554
1555} // namespace ana
1556
1557template <>
1558template <>
1559inline bool
1561{
1562 return reg->get_kind () == RK_BIT_RANGE;
1563}
1564
1566: public member_function_hash_traits<bit_range_region::key_t>
1567{
1568 static const bool empty_zero_p = true;
1569};
1570
1571namespace ana {
1572
1573/* A region for the N-th vararg within a frame_region for a variadic call. */
1574
1576{
1577public:
1578 /* A support class for uniquifying instances of var_arg_region. */
1579 struct key_t
1580 {
1581 key_t (const frame_region *parent, unsigned idx)
1582 : m_parent (parent), m_idx (idx)
1583 {
1584 gcc_assert (parent);
1585 }
1586
1587 hashval_t hash () const
1588 {
1589 inchash::hash hstate;
1590 hstate.add_ptr (m_parent);
1591 hstate.add_int (m_idx);
1592 return hstate.end ();
1593 }
1594
1595 bool operator== (const key_t &other) const
1596 {
1597 return (m_parent == other.m_parent
1598 && m_idx == other.m_idx);
1599 }
1600
1602 {
1603 m_parent = reinterpret_cast<const frame_region *> (1);
1604 }
1605 void mark_empty () { m_parent = nullptr; }
1606 bool is_deleted () const
1607 {
1608 return m_parent == reinterpret_cast<const frame_region *> (1);
1609 }
1610 bool is_empty () const { return m_parent == nullptr; }
1611
1613 unsigned m_idx;
1614 };
1615
1617 unsigned idx)
1618 : cluster_region (complexity (&parent), id, parent, NULL_TREE),
1619 m_idx (idx)
1620 {}
1621
1622 const var_arg_region *
1623 dyn_cast_var_arg_region () const final override { return this; }
1624
1625 enum region_kind get_kind () const final override { return RK_VAR_ARG; }
1626
1627 void dump_to_pp (pretty_printer *pp, bool simple) const final override;
1629 void
1631
1632 std::unique_ptr<json::object>
1633 to_json () const final override;
1634
1635 std::unique_ptr<diagnostics::markup::node>
1636 make_markup_node (symbolic::markup_context &markup_ctxt) const final override;
1637
1639 unsigned get_index () const { return m_idx; }
1640
1641private:
1642 unsigned m_idx;
1643};
1644
1645} // namespace ana
1646
1647template <>
1648template <>
1649inline bool
1651{
1652 return reg->get_kind () == RK_VAR_ARG;
1653}
1654
1656: public member_function_hash_traits<var_arg_region::key_t>
1657{
1658 static const bool empty_zero_p = true;
1659};
1660
1661namespace ana {
1662
1663/* A region for errno for the current thread. */
1664
1666{
1667public:
1669 : cluster_region (complexity (&parent), id, parent, integer_type_node)
1670 {}
1671
1672 enum region_kind get_kind () const final override { return RK_ERRNO; }
1673
1674 void dump_to_pp (pretty_printer *pp, bool simple) const final override;
1676 void
1678
1679 std::unique_ptr<json::object>
1680 to_json () const final override;
1681
1682 std::unique_ptr<diagnostics::markup::node>
1683 make_markup_node (symbolic::markup_context &markup_ctxt) const final override;
1684};
1685
1686} // namespace ana
1687
1688template <>
1689template <>
1690inline bool
1691is_a_helper <const errno_region *>::test (const region *reg)
1692{
1693 return reg->get_kind () == RK_ERRNO;
1694}
1695
1696namespace ana {
1697
1698/* Similar to a decl region, but we don't have the decl.
1699 For implementing e.g. static buffers of known_functions,
1700 or other internal state of an API.
1701
1702 These are owned by known_function instances, rather than the
1703 region_model_manager. */
1704
1706{
1707public:
1708 private_region (unsigned id, const region &parent, tree type,
1709 const char *desc)
1710 : cluster_region (complexity (&parent), id, parent, type),
1711 m_desc (desc)
1712 {}
1713
1714 enum region_kind get_kind () const final override { return RK_PRIVATE; }
1715
1716 void dump_to_pp (pretty_printer *pp, bool simple) const final override;
1718 void
1720
1721 std::unique_ptr<json::object>
1722 to_json () const final override;
1723
1724 std::unique_ptr<diagnostics::markup::node>
1725 make_markup_node (symbolic::markup_context &markup_ctxt) const final override;
1726
1727private:
1728 const char *m_desc;
1729};
1730
1731} // namespace ana
1732
1733template <>
1734template <>
1735inline bool
1736is_a_helper <const private_region *>::test (const region *reg)
1737{
1738 return reg->get_kind () == RK_PRIVATE;
1739}
1740
1741namespace ana {
1742
1743/* An unknown region, for handling unimplemented tree codes. */
1744
1746{
1747public:
1749 : cluster_region (complexity (&parent), id, parent, type)
1750 {}
1751
1752 enum region_kind get_kind () const final override { return RK_UNKNOWN; }
1753
1754 void dump_to_pp (pretty_printer *pp, bool simple) const final override;
1756 void
1758
1759 std::unique_ptr<json::object>
1760 to_json () const final override;
1761
1762 std::unique_ptr<diagnostics::markup::node>
1763 make_markup_node (symbolic::markup_context &markup_ctxt) const final override;
1764};
1765
1766} // namespace ana
1767
1768#endif /* GCC_ANALYZER_REGION_H */
std::unique_ptr< diagnostics::markup::node > make_markup_node(symbolic::markup_context &markup_ctxt) const final override
void print_region_for_dump_widget_label(pretty_printer *pp) const final override
void dump_to_pp(pretty_printer *pp, bool simple) const final override
void accept_node_visitor(symbolic::node_visitor &v) const final override
std::unique_ptr< json::object > to_json() const final override
enum region_kind get_kind() const final override
Definition region.h:1401
alloca_region(symbolic::node::id_t id, const frame_region &parent)
Definition region.h:1397
Definition region.h:1467
void print_region_for_dump_widget_label(pretty_printer *pp) const final override
enum region_kind get_kind() const final override
Definition region.h:1520
const symbolic_byte_size * maybe_get_byte_size(symbolic::scalar_manager< concrete_byte_size > &byte_mgr) const final override
std::unique_ptr< json::object > to_json() const final override
const symbolic_byte_count * maybe_get_byte_offset_relative_to_parent(region_model_manager &mgr) const final override
const bit_range_region * dyn_cast_bit_range_region() const final override
Definition region.h:1518
const concrete_bit_range & get_bits() const
Definition region.h:1533
bit_range_region(symbolic::node::id_t id, const region &parent, tree type, const concrete_bit_range &bits)
Definition region.h:1508
const symbolic_bit_count * maybe_get_bit_offset_relative_to_parent(region_model_manager &mgr) const final override
std::unique_ptr< diagnostics::markup::node > make_markup_node(symbolic::markup_context &markup_ctxt) const final override
const symbolic_bit_size * maybe_get_bit_size(symbolic::scalar_manager< concrete_bit_size > &bit_mgr) const final override
void dump_to_pp(pretty_printer *pp, bool simple) const final override
concrete_bit_range m_bits
Definition region.h:1552
void accept_node_visitor(symbolic::node_visitor &v) const final override
Definition region.h:1276
void print_region_for_dump_widget_label(pretty_printer *pp) const final override
void dump_to_pp(pretty_printer *pp, bool simple) const final override
const cast_region * dyn_cast_cast_region() const final override
Definition region.h:1325
enum region_kind get_kind() const final override
Definition region.h:1323
std::unique_ptr< json::object > to_json() const final override
const symbolic_bit_count * maybe_get_bit_offset_relative_to_parent(region_model_manager &mgr) const final override
cast_region(symbolic::node::id_t id, const region &parent, tree type)
Definition region.h:1316
const symbolic_byte_count * maybe_get_byte_offset_relative_to_parent(region_model_manager &mgr) const final override
void accept_node_visitor(symbolic::node_visitor &v) const final override
std::unique_ptr< diagnostics::markup::node > make_markup_node(symbolic::markup_context &markup_ctxt) const final override
Definition region.h:537
cluster_region(complexity c, symbolic::node::id_t id, const region &parent, tree type)
Definition region.h:539
Definition region.h:776
decl_region(symbolic::node::id_t id, const region &parent, tree decl)
Definition region.h:778
const decl_region * dyn_cast_decl_region() const final override
Definition region.h:787
const symbolic::bit_contents & get_bit_contents_for_constructor(tree ctor, region_model_manager *mgr) const
const symbolic::bit_contents * m_ctor_bit_contents
Definition region.h:837
void accept_node_visitor(symbolic::node_visitor &v) const final override
const svalue * get_svalue_for_initializer(region_model_manager *mgr) const
const symbolic::bit_contents * maybe_get_bit_contents_for_initializer(region_model_manager *mgr) const
const svalue * get_svalue_for_constructor(tree ctor, region_model_manager *mgr) const
tree m_decl
Definition region.h:828
static bool calc_tracked_p(tree decl)
std::unique_ptr< json::object > to_json() const final override
const svalue * maybe_get_constant_value(region_model_manager *mgr) const
bool m_tracked
Definition region.h:834
const symbolic::bit_contents & calc_bit_contents_for_constructor(tree ctor, region_model_manager *mgr) const
std::unique_ptr< diagnostics::markup::node > make_markup_node(symbolic::markup_context &markup_ctxt) const final override
enum region_kind get_kind() const final override
Definition region.h:785
int get_stack_depth() const
void dump_to_pp(pretty_printer *pp, bool simple) const final override
void print_region_for_dump_widget_label(pretty_printer *pp) const final override
bool tracked_p() const final override
Definition region.h:803
const symbolic::bit_vector * maybe_get_bit_vector_for_initializer(symbolic::node_manager &node_mgr) const
tree get_decl() const
Definition region.h:805
Definition region.h:949
const svalue * m_index
Definition region.h:1035
void accept_node_visitor(symbolic::node_visitor &v) const final override
const element_region * dyn_cast_element_region() const final override
Definition region.h:1002
void print_region_for_dump_widget_label(pretty_printer *pp) const final override
std::unique_ptr< json::object > to_json() const final override
void accept(visitor *v) const final override
const svalue * get_index() const
Definition region.h:1024
void dump_to_pp(pretty_printer *pp, bool simple) const final override
std::unique_ptr< diagnostics::markup::node > make_markup_node(symbolic::markup_context &markup_ctxt) const final override
element_region(symbolic::node::id_t id, const region &parent, tree element_type, const svalue *index)
Definition region.h:989
const symbolic_bit_count * maybe_get_bit_offset_relative_to_parent(region_model_manager &mgr) const final override
enum region_kind get_kind() const final override
Definition region.h:1000
const symbolic_byte_count * maybe_get_byte_offset_relative_to_parent(region_model_manager &mgr) const final override
void add_dump_widget_children_for_region(text_art::tree_widget &, symbolic::node_dump_state &nds) const final override
Definition region.h:1666
enum region_kind get_kind() const final override
Definition region.h:1672
std::unique_ptr< json::object > to_json() const final override
void print_region_for_dump_widget_label(pretty_printer *pp) const final override
std::unique_ptr< diagnostics::markup::node > make_markup_node(symbolic::markup_context &markup_ctxt) const final override
void accept_node_visitor(symbolic::node_visitor &v) const final override
void dump_to_pp(pretty_printer *pp, bool simple) const final override
errno_region(symbolic::node::id_t id, const region &parent)
Definition region.h:1668
Definition region.h:856
const symbolic_byte_count * maybe_get_byte_offset_relative_to_parent(region_model_manager &mgr) const final override
tree get_field() const
Definition region.h:914
void print_region_for_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:897
tree m_field
Definition region.h:925
const symbolic_bit_count * maybe_get_bit_offset_relative_to_parent(region_model_manager &mgr) const final override
field_region(symbolic::node::id_t id, const region &parent, tree field)
Definition region.h:889
std::unique_ptr< diagnostics::markup::node > make_markup_node(symbolic::markup_context &markup_ctxt) const final override
const field_region * dyn_cast_field_region() const final override
Definition region.h:912
void accept_node_visitor(symbolic::node_visitor &v) const final override
std::unique_ptr< json::object > to_json() const final override
Definition region.h:406
int get_index() const
Definition region.h:482
void print_region_for_dump_widget_label(pretty_printer *pp) const final override
void accept_node_visitor(symbolic::node_visitor &v) const final override
void accept(visitor *v) const final override
std::unique_ptr< diagnostics::markup::node > make_markup_node(symbolic::markup_context &markup_ctxt) const final override
const function & m_fun
Definition region.h:497
std::unique_ptr< json::object > to_json() const final override
unsigned get_num_locals() const
Definition region.h:490
enum region_kind get_kind() const final override
Definition region.h:460
const frame_region * m_calling_frame
Definition region.h:496
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:461
const frame_region * get_calling_frame() const
Definition region.h:479
map_t m_locals
Definition region.h:504
void dump_untracked_regions() const
tree get_fndecl() const
Definition region.h:481
frame_region(symbolic::node::id_t id, const region &parent, const frame_region *calling_frame, const function &fun, int index)
Definition region.h:443
const function & get_function() const
Definition region.h:480
void dump_to_pp(pretty_printer *pp, bool simple) const final override
hash_map< tree, decl_region * > map_t
Definition region.h:503
int m_index
Definition region.h:498
int get_stack_depth() const
Definition region.h:483
Definition region.h:558
tree m_fndecl
Definition region.h:588
std::unique_ptr< diagnostics::markup::node > make_markup_node(symbolic::markup_context &markup_ctxt) const final override
const function_region * dyn_cast_function_region() const final override
Definition region.h:583
void print_region_for_dump_widget_label(pretty_printer *pp) const final override
std::unique_ptr< json::object > to_json() const final override
enum region_kind get_kind() const final override
Definition region.h:581
function_region(symbolic::node::id_t id, const memory_space_region &parent, tree fndecl)
Definition region.h:560
void accept_node_visitor(symbolic::node_visitor &v) const final override
tree get_fndecl() const
Definition region.h:585
void dump_to_pp(pretty_printer *pp, bool simple) const final override
heap_allocated_region(symbolic::node::id_t id, const region &parent)
Definition region.h:1372
enum region_kind get_kind() const final override
Definition region.h:1377
std::unique_ptr< json::object > to_json() const final override
void dump_to_pp(pretty_printer *pp, bool simple) const final override
void print_region_for_dump_widget_label(pretty_printer *pp) const final override
std::unique_ptr< diagnostics::markup::node > make_markup_node(symbolic::markup_context &markup_ctxt) const final override
void accept_node_visitor(symbolic::node_visitor &v) const final override
tree get_label() const
Definition region.h:630
void dump_to_pp(pretty_printer *pp, bool simple) const final override
label_region(symbolic::node::id_t id, const function_region &parent, tree label)
Definition region.h:609
std::unique_ptr< diagnostics::markup::node > make_markup_node(symbolic::markup_context &markup_ctxt) const final override
tree m_label
Definition region.h:633
std::unique_ptr< json::object > to_json() const final override
void print_region_for_dump_widget_label(pretty_printer *pp) const final override
enum region_kind get_kind() const final override
Definition region.h:628
void accept_node_visitor(symbolic::node_visitor &v) const final override
Definition region.h:351
std::unique_ptr< diagnostics::markup::node > make_markup_node(symbolic::markup_context &markup_ctxt) const final override
memory_space_region(symbolic::node::id_t id, const region *parent, memory_space mem_space)
Definition region.h:353
void print_region_for_dump_widget_label(pretty_printer *pp) const final override
void accept_node_visitor(symbolic::node_visitor &v) const final override
enum region_kind get_kind() const final override
Definition region.h:363
void dump_to_pp(pretty_printer *pp, bool simple) const final override
std::unique_ptr< json::object > to_json() const final override
Definition region.h:1060
enum region_kind get_kind() const final override
Definition region.h:1109
const svalue * get_byte_offset() const
Definition region.h:1133
void dump_to_pp(pretty_printer *pp, bool simple) const final override
void accept(visitor *v) const final override
const symbolic_byte_count * maybe_get_byte_offset_relative_to_parent(region_model_manager &mgr) const final override
void add_dump_widget_children_for_region(text_art::tree_widget &, symbolic::node_dump_state &nds) const final override
void accept_node_visitor(symbolic::node_visitor &v) const final override
std::unique_ptr< json::object > to_json() const final override
const symbolic_bit_count * maybe_get_bit_offset_relative_to_parent(region_model_manager &mgr) const final override
const svalue * get_bit_offset(region_model_manager *mgr) const
const svalue * m_byte_offset
Definition region.h:1145
offset_region(symbolic::node::id_t id, const region &parent, tree type, const svalue *byte_offset)
Definition region.h:1100
const offset_region * dyn_cast_offset_region() const final override
Definition region.h:1111
void print_region_for_dump_widget_label(pretty_printer *pp) const final override
std::unique_ptr< diagnostics::markup::node > make_markup_node(symbolic::markup_context &markup_ctxt) const final override
Definition region.h:1706
enum region_kind get_kind() const final override
Definition region.h:1714
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:1708
const char * m_desc
Definition region.h:1728
void print_region_for_dump_widget_label(pretty_printer *pp) const final override
std::unique_ptr< diagnostics::markup::node > make_markup_node(symbolic::markup_context &markup_ctxt) const final override
std::unique_ptr< json::object > to_json() const final override
void accept_node_visitor(symbolic::node_visitor &v) const final override
Definition region-model.h:840
Definition region-model-manager.h:36
Definition region-model.h:289
Definition region.h:154
virtual const var_arg_region * dyn_cast_var_arg_region() const
Definition region.h:185
bool maybe_print_for_user(pretty_printer *pp, const region_model &model) const
std::unique_ptr< symbolic::memory_offset > m_cached_memory_offset
Definition region.h:325
bool is_named_decl_p(const char *decl_name) const
symbolic::memory_offset calc_memory_offset(symbolic::node_manager &mgr) const
bool symbolic_for_unknown_ptr_p() const
virtual const symbolic_byte_size * maybe_get_byte_size(symbolic::scalar_manager< concrete_byte_size > &byte_mgr) const
virtual void add_dump_widget_children_for_region(text_art::tree_widget &, symbolic::node_dump_state &nds) const
symbolic::scalar< integer_with_unit< units::bit > > symbolic_bit_count
Definition region.h:156
symbolic::memory_range calc_memory_range(symbolic::node_manager &mgr) const
void print_dump_widget_label(pretty_printer *pp) const final override
const cluster_region * get_cluster_region() const
Definition region.h:199
memory_space m_mem_space
Definition region.h:321
virtual const offset_region * dyn_cast_offset_region() const
Definition region.h:175
virtual const frame_region * dyn_cast_frame_region() const
Definition region.h:163
symbolic::scalar< integer_with_unit< units::byte > > symbolic_byte_count
Definition region.h:157
virtual const string_region * dyn_cast_string_region() const
Definition region.h:181
virtual const symbolic_bit_count * maybe_get_bit_offset_relative_to_parent(region_model_manager &mgr) const
bool non_null_p() const
virtual const symbolic_region * dyn_cast_symbolic_region() const
Definition region.h:167
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:177
static int cmp_ptr_ptr(const void *, const void *)
bool descendent_of_p(const region *elder) const
symbolic::pointer calc_pointer(symbolic::node_manager &mgr) const
const cluster_region * get_base_region() const
Definition region.h:198
tree get_type() const
Definition region.h:209
virtual bool tracked_p() const
Definition region.h:272
std::unique_ptr< json::object > make_json_obj(const char *type_name) const
virtual ~region()
const region * m_parent
Definition region.h:306
const svalue * calc_initial_value_at_main(region_model_manager *mgr) const
virtual void print_region_for_dump_widget_label(pretty_printer *pp) const =0
const region * get_parent_region() const
Definition region.h:197
memory_space get_memory_space() const
Definition region.h:203
std::unique_ptr< symbolic::memory_range > m_cached_memory_range
Definition region.h:326
bool base_region_p() const
Definition region.h:549
virtual const element_region * dyn_cast_element_region() const
Definition region.h:173
virtual const field_region * dyn_cast_field_region() const
Definition region.h:171
symbolic::memory_range get_memory_range(region_model_manager &mgr) const
void print(const region_model &model, pretty_printer *pp) const
virtual const symbolic_bit_size * maybe_get_bit_size(symbolic::scalar_manager< concrete_bit_size > &bit_mgr) const
void add_dump_widget_children(text_art::tree_widget &, symbolic::node_dump_state &nds) const final override
std::unique_ptr< symbolic::pointer > m_cached_pointer
Definition region.h:327
virtual enum region_kind get_kind() const =0
const svalue * get_initial_value_at_main(region_model_manager *mgr) const
symbolic::pointer get_pointer(region_model_manager &mgr) const
label_text get_desc(bool simple=true) const
region(complexity c, symbolic::node::id_t id, const region *parent, const cluster_region *cluster_reg, memory_space mem_space, tree type)
tree maybe_get_decl() const
virtual const decl_region * dyn_cast_decl_region() const
Definition region.h:169
virtual void accept(visitor *v) const
const svalue * m_cached_init_sval_at_main
Definition region.h:331
virtual const function_region * dyn_cast_function_region() const
Definition region.h:165
void dump() const
bool symbolic_p() const
const char * get_any_dump_color() const override
Definition region.h:193
void get_subregions_for_bit_range(region_model_manager *mgr, concrete_bit_range relative_bit_range, tree type, auto_vec< const region * > *out) const
symbolic::memory_offset get_memory_offset(region_model_manager &mgr) const
tree m_type
Definition region.h:323
bool empty_p(region_model_manager &mgr) const
virtual void dump_to_pp(pretty_printer *pp, bool simple) const =0
virtual const symbolic_byte_count * maybe_get_byte_offset_relative_to_parent(region_model_manager &mgr) const
virtual const bit_range_region * dyn_cast_bit_range_region() const
Definition region.h:183
virtual const cast_region * dyn_cast_cast_region() const
Definition region.h:179
const svalue * get_byte_size_sval(region_model_manager *mgr) const
void dump(bool simple) const
const cluster_region * m_cluster_reg
Definition region.h:319
Definition region.h:653
std::unique_ptr< diagnostics::markup::node > make_markup_node(symbolic::markup_context &markup_ctxt) const final override
void accept_node_visitor(symbolic::node_visitor &v) const final override
enum region_kind get_kind() const final override
Definition region.h:657
void dump_to_pp(pretty_printer *pp, bool simple) const final override
void print_region_for_dump_widget_label(pretty_printer *pp) const final override
root_region(symbolic::node::id_t id)
std::unique_ptr< json::object > to_json() const final override
Definition region.h:1170
const svalue * m_byte_size_sval
Definition region.h:1252
const sized_region * dyn_cast_sized_region() const final override
Definition region.h:1225
sized_region(symbolic::node::id_t id, const region &parent, tree type, const svalue *byte_size_sval)
Definition region.h:1213
std::unique_ptr< diagnostics::markup::node > make_markup_node(symbolic::markup_context &markup_ctxt) const final override
enum region_kind get_kind() const final override
Definition region.h:1223
void add_dump_widget_children_for_region(text_art::tree_widget &, symbolic::node_dump_state &nds) const final override
void print_region_for_dump_widget_label(pretty_printer *pp) const final override
std::unique_ptr< json::object > to_json() const final override
const symbolic_bit_size * maybe_get_bit_size(symbolic::scalar_manager< concrete_bit_size > &bit_mgr) const final override
const symbolic_byte_size * maybe_get_byte_size(symbolic::scalar_manager< concrete_byte_size > &byte_mgr) const final override
void dump_to_pp(pretty_printer *pp, bool simple) const final override
void accept(visitor *v) const final override
void accept_node_visitor(symbolic::node_visitor &v) const final override
Definition region.h:1419
const string_region * dyn_cast_string_region() const final override
Definition region.h:1427
string_region(symbolic::node::id_t id, const region &parent, tree string_cst)
Definition region.h:1421
bool tracked_p() const final override
Definition region.h:1444
void accept_node_visitor(symbolic::node_visitor &v) const final override
tree get_string_cst() const
Definition region.h:1446
enum region_kind get_kind() const final override
Definition region.h:1429
void print_region_for_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:1449
std::unique_ptr< json::object > to_json() const final override
std::unique_ptr< diagnostics::markup::node > make_markup_node(symbolic::markup_context &markup_ctxt) const final override
Definition svalue.h:82
Definition symbolic-bit-contents.h:68
Definition symbolic-bit-vectors.h:107
Definition symbolic-memory-offsets.h:35
Definition symbolic-memory-ranges.h:34
Definition symbolic-nodes.h:48
Definition symbolic-nodes.h:502
Definition symbolic-nodes.h:116
unsigned id_t
Definition symbolic-nodes.h:118
Definition symbolic-pointers.h:33
Definition symbolic-scalars.h:660
Definition symbolic-scalars.h:67
Definition region.h:687
void dump_to_pp(pretty_printer *pp, bool simple) const final override
const svalue * get_pointer() const
Definition region.h:747
const symbolic_region * dyn_cast_symbolic_region() const final override
Definition region.h:728
void add_dump_widget_children_for_region(text_art::tree_widget &w, symbolic::node_dump_state &nds) const final override
enum region_kind get_kind() const final override
Definition region.h:730
symbolic_region(symbolic::node::id_t id, const region &parent, const svalue *sval_ptr)
std::unique_ptr< diagnostics::markup::node > make_markup_node(symbolic::markup_context &markup_ctxt) const final override
const svalue * m_sval_ptr
Definition region.h:750
void print_region_for_dump_widget_label(pretty_printer *pp) const final override
void accept(visitor *v) const final override
std::unique_ptr< json::object > to_json() const final override
void accept_node_visitor(symbolic::node_visitor &v) const final override
Definition type.h:29
unknown_region(symbolic::node::id_t id, const region &parent, tree type)
Definition region.h:1748
std::unique_ptr< json::object > to_json() const final override
void print_region_for_dump_widget_label(pretty_printer *pp) const final override
enum region_kind get_kind() const final override
Definition region.h:1752
void dump_to_pp(pretty_printer *pp, bool simple) const final override
void accept_node_visitor(symbolic::node_visitor &v) const final override
std::unique_ptr< diagnostics::markup::node > make_markup_node(symbolic::markup_context &markup_ctxt) const final override
Definition region.h:1576
unsigned m_idx
Definition region.h:1642
const var_arg_region * dyn_cast_var_arg_region() const final override
Definition region.h:1623
const frame_region * get_frame_region() const
void dump_to_pp(pretty_printer *pp, bool simple) const final override
void print_region_for_dump_widget_label(pretty_printer *pp) const final override
std::unique_ptr< diagnostics::markup::node > make_markup_node(symbolic::markup_context &markup_ctxt) const final override
std::unique_ptr< json::object > to_json() const final override
enum region_kind get_kind() const final override
Definition region.h:1625
void accept_node_visitor(symbolic::node_visitor &v) const final override
unsigned get_index() const
Definition region.h:1639
var_arg_region(symbolic::node::id_t id, const frame_region &parent, unsigned idx)
Definition region.h:1616
Definition region-model.h:222
Definition genmatch.cc:1627
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_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:2004
bool operator==(const nowarn_spec_t &lhs, const nowarn_spec_t &rhs)
Definition gcc-diagnostic-spec.h:131
Definition common.h:74
Definition access-diagram.h:30
symbolic::scalar< integer_with_unit< units::bit > > symbolic_bit_size
Definition symbolic-scalars.h:194
symbolic::scalar< integer_with_unit< units::byte > > symbolic_byte_size
Definition symbolic-scalars.h:197
concrete::range< integer_with_unit< units::bit > > concrete_bit_range
Definition concrete-ranges.h:117
integer_with_unit< units::bit > concrete_bit_size
Definition integer-with-unit.h:328
@ other
Definition common.h:536
const char * get_dump_name(memory_space)
integer_with_unit< units::byte > concrete_byte_size
Definition integer-with-unit.h:330
region_kind
Definition region.h:54
@ RK_UNKNOWN
Definition region.h:74
@ RK_PRIVATE
Definition region.h:73
@ RK_LABEL
Definition region.h:58
@ RK_CAST
Definition region.h:66
@ RK_FIELD
Definition region.h:62
@ RK_FRAME
Definition region.h:55
@ RK_DECL
Definition region.h:61
@ RK_ERRNO
Definition region.h:72
@ RK_ELEMENT
Definition region.h:63
@ RK_SYMBOLIC
Definition region.h:60
@ RK_BIT_RANGE
Definition region.h:70
@ RK_ALLOCA
Definition region.h:68
@ RK_SIZED
Definition region.h:65
@ RK_HEAP_ALLOCATED
Definition region.h:67
@ RK_OFFSET
Definition region.h:64
@ RK_ROOT
Definition region.h:59
@ RK_FUNCTION
Definition region.h:57
@ RK_VAR_ARG
Definition region.h:71
@ RK_MEMORY_SPACE
Definition region.h:56
@ RK_STRING
Definition region.h:69
memory_space
Definition region.h:36
@ globals
Definition region.h:39
@ heap
Definition region.h:41
@ thread_local_
Definition region.h:43
@ unknown
Definition region.h:37
@ code
Definition region.h:38
@ read_only_data
Definition region.h:42
@ stack
Definition region.h:40
@ private_
Definition region.h:44
Definition custom-sarif-properties/state-graphs.h:33
Definition cfghooks.h:26
void mark_deleted()
Definition region.h:1495
key_t(const region *parent, tree type, const concrete_bit_range &bits)
Definition region.h:1472
const region * m_parent
Definition region.h:1503
bool is_empty() const
Definition region.h:1501
hashval_t hash() const
Definition region.h:1478
bool is_deleted() const
Definition region.h:1497
void mark_empty()
Definition region.h:1496
tree m_type
Definition region.h:1504
concrete_bit_range m_bits
Definition region.h:1505
void mark_empty()
Definition region.h:1305
bool is_deleted() const
Definition region.h:1306
const region * m_parent
Definition region.h:1312
key_t(const region *parent, tree type)
Definition region.h:1281
tree m_type
Definition region.h:1313
bool is_empty() const
Definition region.h:1310
hashval_t hash() const
Definition region.h:1287
void mark_deleted()
Definition region.h:1301
Definition complexity.h:31
const svalue * m_index
Definition region.h:986
void mark_empty()
Definition region.h:977
bool is_deleted() const
Definition region.h:978
const region * m_parent
Definition region.h:984
key_t(const region *parent, tree element_type, const svalue *index)
Definition region.h:954
tree m_element_type
Definition region.h:985
bool is_empty() const
Definition region.h:982
void mark_deleted()
Definition region.h:976
hashval_t hash() const
Definition region.h:960
void mark_deleted()
Definition region.h:880
hashval_t hash() const
Definition region.h:867
bool is_deleted() const
Definition region.h:882
const region * m_parent
Definition region.h:885
bool is_empty() const
Definition region.h:883
tree m_field
Definition region.h:886
key_t(const region *parent, tree field)
Definition region.h:861
void mark_empty()
Definition region.h:881
key_t(const frame_region *calling_frame, const function &fun)
Definition region.h:411
bool is_empty() const
Definition region.h:437
bool is_deleted() const
Definition region.h:433
void mark_empty()
Definition region.h:432
bool operator==(const key_t &other) const
Definition region.h:425
void mark_deleted()
Definition region.h:431
hashval_t hash() const
Definition region.h:417
const frame_region * m_calling_frame
Definition region.h:439
const function * m_fun
Definition region.h:440
key_t(const region *parent, tree element_type, const svalue *byte_offset)
Definition region.h:1065
const region * m_parent
Definition region.h:1095
bool is_empty() const
Definition region.h:1093
hashval_t hash() const
Definition region.h:1071
tree m_element_type
Definition region.h:1096
bool is_deleted() const
Definition region.h:1089
void mark_empty()
Definition region.h:1088
const svalue * m_byte_offset
Definition region.h:1097
void mark_deleted()
Definition region.h:1087
const svalue * m_end_offset
Definition region.h:1210
key_t(const region *parent, tree element_type, const svalue *byte_size_sval)
Definition region.h:1175
const region * m_parent
Definition region.h:1207
void mark_deleted()
Definition region.h:1199
bool is_empty() const
Definition region.h:1205
const svalue * m_byte_size_sval
Definition region.h:1209
tree m_element_type
Definition region.h:1208
hashval_t hash() const
Definition region.h:1183
void mark_empty()
Definition region.h:1200
bool is_deleted() const
Definition region.h:1201
Definition symbolic-nodes.h:276
const svalue * m_sval_ptr
Definition region.h:720
bool is_empty() const
Definition region.h:717
const region * m_parent
Definition region.h:719
void mark_deleted()
Definition region.h:711
void mark_empty()
Definition region.h:712
hashval_t hash() const
Definition region.h:698
key_t(const region *parent, const svalue *sval_ptr)
Definition region.h:692
bool is_deleted() const
Definition region.h:713
bool is_deleted() const
Definition region.h:1606
const frame_region * m_parent
Definition region.h:1612
unsigned m_idx
Definition region.h:1613
bool is_empty() const
Definition region.h:1610
void mark_empty()
Definition region.h:1605
void mark_deleted()
Definition region.h:1601
hashval_t hash() const
Definition region.h:1587
key_t(const frame_region *parent, unsigned idx)
Definition region.h:1581
Definition genautomata.cc:499
static const bool empty_zero_p
Definition region.h:1568
static const bool empty_zero_p
Definition region.h:1361
static const bool empty_zero_p
Definition region.h:1051
static const bool empty_zero_p
Definition region.h:941
static const bool empty_zero_p
Definition region.h:520
static const bool empty_zero_p
Definition region.h:1161
static const bool empty_zero_p
Definition region.h:1268
static const bool empty_zero_p
Definition region.h:766
static const bool empty_zero_p
Definition region.h:1658
Definition hash-traits.h:466
Definition function.h:249
tree decl
Definition function.h:285
Definition collect2.cc:168
static bool test(const U *p)
Definition is-a.h:211
Definition is-a.h:194
static bool test(U *p)
Definition common.h:638
#define gcc_assert(EXPR)
Definition system.h:758
#define TREE_CODE(NODE)
Definition tree.h:327
#define FUNC_OR_METHOD_TYPE_P(NODE)
Definition tree.h:736
#define TREE_TYPE(NODE)
Definition tree.h:515
#define NULL_TREE
Definition tree.h:320
#define integer_type_node
Definition tree.h:5075