2 Copyright (C) 2019-2021 Free Software Foundation, Inc.
3 Contributed by David Malcolm <dmalcolm@redhat.com>.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
12 GCC is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
23 #include "coretypes.h"
25 #include "diagnostic-core.h"
26 #include "gimple-pretty-print.h"
28 #include "basic-block.h"
30 #include "gimple-iterator.h"
31 #include "diagnostic-core.h"
36 #include "stringpool.h"
39 #include "fold-const.h"
40 #include "tree-pretty-print.h"
41 #include "diagnostic-color.h"
42 #include "diagnostic-metadata.h"
48 #include "analyzer/analyzer.h"
49 #include "analyzer/analyzer-logging.h"
50 #include "ordered-hash-map.h"
55 #include "analyzer/supergraph.h"
57 #include "analyzer/call-string.h"
58 #include "analyzer/program-point.h"
59 #include "analyzer/store.h"
60 #include "analyzer/region.h"
61 #include "analyzer/region-model.h"
67 /* class region and its various subclasses. */
73 delete m_cached_offset
;
76 /* Compare REG1 and REG2 by id. */
79 region::cmp_ids (const region
*reg1
, const region
*reg2
)
81 return (long)reg1
->get_id () - (long)reg2
->get_id ();
84 /* Determine the base region for this region: when considering bindings
85 for this region, the base region is the ancestor which identifies
86 which cluster they should be partitioned into.
87 Regions within the same struct/union/array are in the same cluster.
88 Different decls are in different clusters. */
91 region::get_base_region () const
93 const region
*iter
= this;
96 switch (iter
->get_kind ())
101 iter
= iter
->get_parent_region ();
104 iter
= iter
->dyn_cast_cast_region ()->get_original_region ();
113 /* Return true if get_base_region() == this for this region. */
116 region::base_region_p () const
120 /* Region kinds representing a descendent of a base region. */
132 /* Return true if this region is ELDER or one of its descendents. */
135 region::descendent_of_p (const region
*elder
) const
137 const region
*iter
= this;
142 if (iter
->get_kind () == RK_CAST
)
143 iter
= iter
->dyn_cast_cast_region ()->get_original_region ();
145 iter
= iter
->get_parent_region ();
150 /* If this region is a frame_region, or a descendent of one, return it.
151 Otherwise return NULL. */
154 region::maybe_get_frame_region () const
156 const region
*iter
= this;
159 if (const frame_region
*frame_reg
= iter
->dyn_cast_frame_region ())
161 if (iter
->get_kind () == RK_CAST
)
162 iter
= iter
->dyn_cast_cast_region ()->get_original_region ();
164 iter
= iter
->get_parent_region ();
169 /* If this region is a decl_region, return the decl.
170 Otherwise return NULL. */
173 region::maybe_get_decl () const
175 if (const decl_region
*decl_reg
= dyn_cast_decl_region ())
176 return decl_reg
->get_decl ();
180 /* Get the region_offset for this region (calculating it on the
181 first call and caching it internally). */
184 region::get_offset () const
187 m_cached_offset
= new region_offset (calc_offset ());
188 return *m_cached_offset
;
191 /* If the size of this region (in bytes) is known statically, write it to *OUT
193 Otherwise return false. */
196 region::get_byte_size (byte_size_t
*out
) const
198 tree type
= get_type ();
200 /* Bail out e.g. for heap-allocated regions. */
204 HOST_WIDE_INT bytes
= int_size_in_bytes (type
);
211 /* If the size of this region (in bits) is known statically, write it to *OUT
213 Otherwise return false. */
216 region::get_bit_size (bit_size_t
*out
) const
218 byte_size_t byte_size
;
219 if (!get_byte_size (&byte_size
))
221 *out
= byte_size
* BITS_PER_UNIT
;
225 /* Get the field within RECORD_TYPE at BIT_OFFSET. */
228 get_field_at_bit_offset (tree record_type
, bit_offset_t bit_offset
)
230 gcc_assert (TREE_CODE (record_type
) == RECORD_TYPE
);
234 /* Find the first field that has an offset > BIT_OFFSET,
235 then return the one preceding it.
236 Skip other trees within the chain, such as FUNCTION_DECLs. */
237 tree last_field
= NULL_TREE
;
238 for (tree iter
= TYPE_FIELDS (record_type
); iter
!= NULL_TREE
;
239 iter
= DECL_CHAIN (iter
))
241 if (TREE_CODE (iter
) == FIELD_DECL
)
243 int iter_field_offset
= int_bit_position (iter
);
244 if (bit_offset
< iter_field_offset
)
252 /* Populate *OUT with descendent regions of type TYPE that match
253 RELATIVE_BIT_OFFSET and SIZE_IN_BITS within this region. */
256 region::get_subregions_for_binding (region_model_manager
*mgr
,
257 bit_offset_t relative_bit_offset
,
258 bit_size_t size_in_bits
,
260 auto_vec
<const region
*> *out
) const
262 if (get_type () == NULL_TREE
|| type
== NULL_TREE
)
264 if (relative_bit_offset
== 0
265 && types_compatible_p (get_type (), type
))
267 out
->safe_push (this);
270 switch (TREE_CODE (get_type ()))
274 tree element_type
= TREE_TYPE (get_type ());
275 HOST_WIDE_INT hwi_byte_size
= int_size_in_bytes (element_type
);
276 if (hwi_byte_size
> 0)
278 HOST_WIDE_INT bits_per_element
279 = hwi_byte_size
<< LOG2_BITS_PER_UNIT
;
280 HOST_WIDE_INT element_index
281 = (relative_bit_offset
.to_shwi () / bits_per_element
);
282 tree element_index_cst
283 = build_int_cst (integer_type_node
, element_index
);
284 HOST_WIDE_INT inner_bit_offset
285 = relative_bit_offset
.to_shwi () % bits_per_element
;
286 const region
*subregion
= mgr
->get_element_region
288 mgr
->get_or_create_constant_svalue (element_index_cst
));
289 subregion
->get_subregions_for_binding (mgr
, inner_bit_offset
,
290 size_in_bits
, type
, out
);
296 /* The bit offset might be *within* one of the fields (such as
297 with nested structs).
298 So we want to find the enclosing field, adjust the offset,
300 if (tree field
= get_field_at_bit_offset (get_type (),
301 relative_bit_offset
))
303 int field_bit_offset
= int_bit_position (field
);
304 const region
*subregion
= mgr
->get_field_region (this, field
);
305 subregion
->get_subregions_for_binding
306 (mgr
, relative_bit_offset
- field_bit_offset
,
307 size_in_bits
, type
, out
);
313 for (tree field
= TYPE_FIELDS (get_type ()); field
!= NULL_TREE
;
314 field
= DECL_CHAIN (field
))
316 if (TREE_CODE (field
) != FIELD_DECL
)
318 const region
*subregion
= mgr
->get_field_region (this, field
);
319 subregion
->get_subregions_for_binding (mgr
,
333 /* Walk from this region up to the base region within its cluster, calculating
334 the offset relative to the base region, either as an offset in bits,
335 or a symbolic offset. */
338 region::calc_offset () const
340 const region
*iter_region
= this;
341 bit_offset_t accum_bit_offset
= 0;
345 switch (iter_region
->get_kind ())
349 const field_region
*field_reg
350 = (const field_region
*)iter_region
;
351 iter_region
= iter_region
->get_parent_region ();
353 /* Compare with e.g. gimple-fold.c's
354 fold_nonarray_ctor_reference. */
355 tree field
= field_reg
->get_field ();
356 tree byte_offset
= DECL_FIELD_OFFSET (field
);
357 if (TREE_CODE (byte_offset
) != INTEGER_CST
)
358 return region_offset::make_symbolic (iter_region
);
359 tree field_offset
= DECL_FIELD_BIT_OFFSET (field
);
360 /* Compute bit offset of the field. */
362 = (wi::to_offset (field_offset
)
363 + (wi::to_offset (byte_offset
) << LOG2_BITS_PER_UNIT
));
364 accum_bit_offset
+= bitoffset
;
370 const element_region
*element_reg
371 = (const element_region
*)iter_region
;
372 iter_region
= iter_region
->get_parent_region ();
375 = element_reg
->get_index ()->maybe_get_constant ())
377 gcc_assert (TREE_CODE (idx_cst
) == INTEGER_CST
);
379 tree elem_type
= element_reg
->get_type ();
380 offset_int element_idx
= wi::to_offset (idx_cst
);
382 /* First, use int_size_in_bytes, to reject the case where we
383 have an incomplete type, or a non-constant value. */
384 HOST_WIDE_INT hwi_byte_size
= int_size_in_bytes (elem_type
);
385 if (hwi_byte_size
> 0)
387 offset_int element_bit_size
388 = hwi_byte_size
<< LOG2_BITS_PER_UNIT
;
389 offset_int element_bit_offset
390 = element_idx
* element_bit_size
;
391 accum_bit_offset
+= element_bit_offset
;
395 return region_offset::make_symbolic (iter_region
);
401 const offset_region
*offset_reg
402 = (const offset_region
*)iter_region
;
403 iter_region
= iter_region
->get_parent_region ();
405 if (tree byte_offset_cst
406 = offset_reg
->get_byte_offset ()->maybe_get_constant ())
408 gcc_assert (TREE_CODE (byte_offset_cst
) == INTEGER_CST
);
409 /* Use a signed value for the byte offset, to handle
411 HOST_WIDE_INT byte_offset
412 = wi::to_offset (byte_offset_cst
).to_shwi ();
413 HOST_WIDE_INT bit_offset
= byte_offset
* BITS_PER_UNIT
;
414 accum_bit_offset
+= bit_offset
;
417 return region_offset::make_symbolic (iter_region
);
423 const cast_region
*cast_reg
424 = as_a
<const cast_region
*> (iter_region
);
425 iter_region
= cast_reg
->get_original_region ();
430 return region_offset::make_concrete (iter_region
, accum_bit_offset
);
433 return region_offset::make_concrete (iter_region
, accum_bit_offset
);
436 /* Copy from SRC_REG to DST_REG, using CTXT for any issues that occur. */
439 region_model::copy_region (const region
*dst_reg
, const region
*src_reg
,
440 region_model_context
*ctxt
)
442 gcc_assert (dst_reg
);
443 gcc_assert (src_reg
);
444 if (dst_reg
== src_reg
)
447 const svalue
*sval
= get_store_value (src_reg
);
448 set_value (dst_reg
, sval
, ctxt
);
451 /* Dump a description of this region to stderr. */
454 region::dump (bool simple
) const
457 pp_format_decoder (&pp
) = default_tree_printer
;
458 pp_show_color (&pp
) = pp_show_color (global_dc
->printer
);
459 pp
.buffer
->stream
= stderr
;
460 dump_to_pp (&pp
, simple
);
465 /* Return a new json::string describing the region. */
468 region::to_json () const
470 label_text desc
= get_desc (true);
471 json::value
*reg_js
= new json::string (desc
.m_buffer
);
476 /* Generate a description of this region. */
478 DEBUG_FUNCTION label_text
479 region::get_desc (bool simple
) const
482 pp_format_decoder (&pp
) = default_tree_printer
;
483 dump_to_pp (&pp
, simple
);
484 return label_text::take (xstrdup (pp_formatted_text (&pp
)));
487 /* Base implementation of region::accept vfunc.
488 Subclass implementations should chain up to this. */
491 region::accept (visitor
*v
) const
493 v
->visit_region (this);
495 m_parent
->accept (v
);
498 /* Return true if this is a symbolic region for deferencing an
500 We shouldn't attempt to bind values for this region (but
501 can unbind values for other regions). */
504 region::symbolic_for_unknown_ptr_p () const
506 if (const symbolic_region
*sym_reg
= dyn_cast_symbolic_region ())
507 if (sym_reg
->get_pointer ()->get_kind () == SK_UNKNOWN
)
514 region::region (complexity c
, unsigned id
, const region
*parent
, tree type
)
515 : m_complexity (c
), m_id (id
), m_parent (parent
), m_type (type
),
516 m_cached_offset (NULL
)
518 gcc_assert (type
== NULL_TREE
|| TYPE_P (type
));
521 /* Comparator for use by vec<const region *>::qsort,
522 using their IDs to order them. */
525 region::cmp_ptr_ptr (const void *p1
, const void *p2
)
527 const region
* const *reg1
= (const region
* const *)p1
;
528 const region
* const *reg2
= (const region
* const *)p2
;
530 return cmp_ids (*reg1
, *reg2
);
533 /* Determine if a pointer to this region must be non-NULL.
535 Generally, pointers to regions must be non-NULL, but pointers
536 to symbolic_regions might, in fact, be NULL.
538 This allows us to simulate functions like malloc and calloc with:
539 - only one "outcome" from each statement,
540 - the idea that the pointer is on the heap if non-NULL
541 - the possibility that the pointer could be NULL
542 - the idea that successive values returned from malloc are non-equal
543 - to be able to zero-fill for calloc. */
546 region::non_null_p () const
553 /* Are we within a symbolic_region? If so, it could be NULL, and we
554 have to fall back on the constraints. */
556 case RK_HEAP_ALLOCATED
:
561 /* Comparator for trees to impose a deterministic ordering on
565 tree_cmp (const_tree t1
, const_tree t2
)
570 /* Test tree codes first. */
571 if (TREE_CODE (t1
) != TREE_CODE (t2
))
572 return TREE_CODE (t1
) - TREE_CODE (t2
);
574 /* From this point on, we know T1 and T2 have the same tree code. */
578 if (DECL_NAME (t1
) && DECL_NAME (t2
))
579 return strcmp (IDENTIFIER_POINTER (DECL_NAME (t1
)),
580 IDENTIFIER_POINTER (DECL_NAME (t2
)));
585 else if (DECL_NAME (t2
))
588 return DECL_UID (t1
) - DECL_UID (t2
);
592 switch (TREE_CODE (t1
))
596 if (SSA_NAME_VAR (t1
) && SSA_NAME_VAR (t2
))
598 int var_cmp
= tree_cmp (SSA_NAME_VAR (t1
), SSA_NAME_VAR (t2
));
601 return SSA_NAME_VERSION (t1
) - SSA_NAME_VERSION (t2
);
605 if (SSA_NAME_VAR (t1
))
607 else if (SSA_NAME_VAR (t2
))
610 return SSA_NAME_VERSION (t1
) - SSA_NAME_VERSION (t2
);
616 return tree_int_cst_compare (t1
, t2
);
620 const real_value
*rv1
= TREE_REAL_CST_PTR (t1
);
621 const real_value
*rv2
= TREE_REAL_CST_PTR (t2
);
622 if (real_compare (UNORDERED_EXPR
, rv1
, rv2
))
624 /* Impose an arbitrary order on NaNs relative to other NaNs
626 if (int cmp_isnan
= real_isnan (rv1
) - real_isnan (rv2
))
628 if (int cmp_issignaling_nan
629 = real_issignaling_nan (rv1
) - real_issignaling_nan (rv2
))
630 return cmp_issignaling_nan
;
631 return real_isneg (rv1
) - real_isneg (rv2
);
633 if (real_compare (LT_EXPR
, rv1
, rv2
))
635 if (real_compare (GT_EXPR
, rv1
, rv2
))
641 return strcmp (TREE_STRING_POINTER (t1
),
642 TREE_STRING_POINTER (t2
));
654 /* qsort comparator for trees to impose a deterministic ordering on
658 tree_cmp (const void *p1
, const void *p2
)
660 const_tree t1
= *(const_tree
const *)p1
;
661 const_tree t2
= *(const_tree
const *)p2
;
663 return tree_cmp (t1
, t2
);
666 /* class frame_region : public space_region. */
668 frame_region::~frame_region ()
670 for (map_t::iterator iter
= m_locals
.begin ();
671 iter
!= m_locals
.end ();
673 delete (*iter
).second
;
677 frame_region::accept (visitor
*v
) const
681 m_calling_frame
->accept (v
);
684 /* Implementation of region::dump_to_pp vfunc for frame_region. */
687 frame_region::dump_to_pp (pretty_printer
*pp
, bool simple
) const
690 pp_printf (pp
, "frame: %qs@%i", function_name (m_fun
), get_stack_depth ());
692 pp_printf (pp
, "frame_region(%qs, index: %i, depth: %i)",
693 function_name (m_fun
), m_index
, get_stack_depth ());
697 frame_region::get_region_for_local (region_model_manager
*mgr
,
700 // TODO: could also check that VAR_DECLs are locals
701 gcc_assert (TREE_CODE (expr
) == PARM_DECL
702 || TREE_CODE (expr
) == VAR_DECL
703 || TREE_CODE (expr
) == SSA_NAME
704 || TREE_CODE (expr
) == RESULT_DECL
);
706 /* Ideally we'd use mutable here. */
707 map_t
&mutable_locals
= const_cast <map_t
&> (m_locals
);
709 if (decl_region
**slot
= mutable_locals
.get (expr
))
712 = new decl_region (mgr
->alloc_region_id (), this, expr
);
713 mutable_locals
.put (expr
, reg
);
717 /* class globals_region : public space_region. */
719 /* Implementation of region::dump_to_pp vfunc for globals_region. */
722 globals_region::dump_to_pp (pretty_printer
*pp
, bool simple
) const
725 pp_string (pp
, "::");
727 pp_string (pp
, "globals");
730 /* class code_region : public map_region. */
732 /* Implementation of region::dump_to_pp vfunc for code_region. */
735 code_region::dump_to_pp (pretty_printer
*pp
, bool simple
) const
738 pp_string (pp
, "code region");
740 pp_string (pp
, "code_region()");
743 /* class function_region : public region. */
745 /* Implementation of region::dump_to_pp vfunc for function_region. */
748 function_region::dump_to_pp (pretty_printer
*pp
, bool simple
) const
752 dump_quoted_tree (pp
, m_fndecl
);
756 pp_string (pp
, "function_region(");
757 dump_quoted_tree (pp
, m_fndecl
);
762 /* class label_region : public region. */
764 /* Implementation of region::dump_to_pp vfunc for label_region. */
767 label_region::dump_to_pp (pretty_printer
*pp
, bool simple
) const
771 dump_quoted_tree (pp
, m_label
);
775 pp_string (pp
, "label_region(");
776 dump_quoted_tree (pp
, m_label
);
781 /* class stack_region : public region. */
783 /* Implementation of region::dump_to_pp vfunc for stack_region. */
786 stack_region::dump_to_pp (pretty_printer
*pp
, bool simple
) const
789 pp_string (pp
, "stack region");
791 pp_string (pp
, "stack_region()");
794 /* class heap_region : public region. */
796 /* Implementation of region::dump_to_pp vfunc for heap_region. */
799 heap_region::dump_to_pp (pretty_printer
*pp
, bool simple
) const
802 pp_string (pp
, "heap region");
804 pp_string (pp
, "heap_region()");
807 /* class root_region : public region. */
809 /* root_region's ctor. */
811 root_region::root_region (unsigned id
)
812 : region (complexity (1, 1), id
, NULL
, NULL_TREE
)
816 /* Implementation of region::dump_to_pp vfunc for root_region. */
819 root_region::dump_to_pp (pretty_printer
*pp
, bool simple
) const
822 pp_string (pp
, "root region");
824 pp_string (pp
, "root_region()");
827 /* class symbolic_region : public map_region. */
829 /* symbolic_region's ctor. */
831 symbolic_region::symbolic_region (unsigned id
, region
*parent
,
832 const svalue
*sval_ptr
)
833 : region (complexity::from_pair (parent
, sval_ptr
), id
, parent
,
834 TREE_TYPE (sval_ptr
->get_type ())),
835 m_sval_ptr (sval_ptr
)
839 /* Implementation of region::accept vfunc for symbolic_region. */
842 symbolic_region::accept (visitor
*v
) const
845 m_sval_ptr
->accept (v
);
848 /* Implementation of region::dump_to_pp vfunc for symbolic_region. */
851 symbolic_region::dump_to_pp (pretty_printer
*pp
, bool simple
) const
855 pp_string (pp
, "(*");
856 m_sval_ptr
->dump_to_pp (pp
, simple
);
861 pp_string (pp
, "symbolic_region(");
862 get_parent_region ()->dump_to_pp (pp
, simple
);
863 pp_string (pp
, ", ");
864 print_quoted_type (pp
, get_type ());
865 pp_string (pp
, ", ");
866 m_sval_ptr
->dump_to_pp (pp
, simple
);
871 /* class decl_region : public region. */
873 /* Implementation of region::dump_to_pp vfunc for decl_region. */
876 decl_region::dump_to_pp (pretty_printer
*pp
, bool simple
) const
879 pp_printf (pp
, "%E", m_decl
);
882 pp_string (pp
, "decl_region(");
883 get_parent_region ()->dump_to_pp (pp
, simple
);
884 pp_string (pp
, ", ");
885 print_quoted_type (pp
, get_type ());
886 pp_printf (pp
, ", %qE)", m_decl
);
890 /* Get the stack depth for the frame containing this decl, or 0
894 decl_region::get_stack_depth () const
896 if (get_parent_region () == NULL
)
898 if (const frame_region
*frame_reg
899 = get_parent_region ()->dyn_cast_frame_region ())
900 return frame_reg
->get_stack_depth ();
904 /* If the underlying decl is in the global constant pool,
905 return an svalue representing the constant value.
906 Otherwise return NULL. */
909 decl_region::maybe_get_constant_value (region_model_manager
*mgr
) const
911 if (TREE_CODE (m_decl
) == VAR_DECL
912 && DECL_IN_CONSTANT_POOL (m_decl
)
913 && DECL_INITIAL (m_decl
)
914 && TREE_CODE (DECL_INITIAL (m_decl
)) == CONSTRUCTOR
)
915 return get_svalue_for_constructor (DECL_INITIAL (m_decl
), mgr
);
919 /* Get an svalue for CTOR, a CONSTRUCTOR for this region's decl. */
922 decl_region::get_svalue_for_constructor (tree ctor
,
923 region_model_manager
*mgr
) const
925 gcc_assert (!TREE_CLOBBER_P (ctor
));
927 /* Create a binding map, applying ctor to it, using this
928 decl_region as the base region when building child regions
929 for offset calculations. */
931 if (!map
.apply_ctor_to_region (this, ctor
, mgr
))
932 return mgr
->get_or_create_unknown_svalue (get_type ());
934 /* Return a compound svalue for the map we built. */
935 return mgr
->get_or_create_compound_svalue (get_type (), map
);
938 /* For use on decl_regions for global variables.
940 Get an svalue for the initial value of this region at entry to
941 "main" (either based on DECL_INITIAL, or implicit initialization to
944 Return NULL if there is a problem. */
947 decl_region::get_svalue_for_initializer (region_model_manager
*mgr
) const
949 tree init
= DECL_INITIAL (m_decl
);
952 /* If we have an "extern" decl then there may be an initializer in
954 if (DECL_EXTERNAL (m_decl
))
957 /* Implicit initialization to zero; use a compound_svalue for it.
958 Doing so requires that we have a concrete binding for this region,
959 which can fail if we have a region with unknown size
960 (e.g. "extern const char arr[];"). */
961 const binding_key
*binding
962 = binding_key::make (mgr
->get_store_manager (), this, BK_direct
);
963 if (binding
->symbolic_p ())
966 binding_cluster
c (this);
967 c
.zero_fill_region (mgr
->get_store_manager (), this);
968 return mgr
->get_or_create_compound_svalue (TREE_TYPE (m_decl
),
972 /* LTO can write out error_mark_node as the DECL_INITIAL for simple scalar
973 values (to avoid writing out an extra section). */
974 if (init
== error_mark_node
)
977 if (TREE_CODE (init
) == CONSTRUCTOR
)
978 return get_svalue_for_constructor (init
, mgr
);
980 /* Reuse the get_rvalue logic from region_model. */
981 region_model
m (mgr
);
982 return m
.get_rvalue (path_var (init
, 0), NULL
);
985 /* class field_region : public region. */
987 /* Implementation of region::dump_to_pp vfunc for field_region. */
990 field_region::dump_to_pp (pretty_printer
*pp
, bool simple
) const
994 get_parent_region ()->dump_to_pp (pp
, simple
);
996 pp_printf (pp
, "%E", m_field
);
1000 pp_string (pp
, "field_region(");
1001 get_parent_region ()->dump_to_pp (pp
, simple
);
1002 pp_string (pp
, ", ");
1003 print_quoted_type (pp
, get_type ());
1004 pp_printf (pp
, ", %qE)", m_field
);
1008 /* class element_region : public region. */
1010 /* Implementation of region::accept vfunc for element_region. */
1013 element_region::accept (visitor
*v
) const
1016 m_index
->accept (v
);
1019 /* Implementation of region::dump_to_pp vfunc for element_region. */
1022 element_region::dump_to_pp (pretty_printer
*pp
, bool simple
) const
1026 //pp_string (pp, "(");
1027 get_parent_region ()->dump_to_pp (pp
, simple
);
1028 pp_string (pp
, "[");
1029 m_index
->dump_to_pp (pp
, simple
);
1030 pp_string (pp
, "]");
1031 //pp_string (pp, ")");
1035 pp_string (pp
, "element_region(");
1036 get_parent_region ()->dump_to_pp (pp
, simple
);
1037 pp_string (pp
, ", ");
1038 print_quoted_type (pp
, get_type ());
1039 pp_string (pp
, ", ");
1040 m_index
->dump_to_pp (pp
, simple
);
1041 pp_printf (pp
, ")");
1045 /* class offset_region : public region. */
1047 /* Implementation of region::accept vfunc for offset_region. */
1050 offset_region::accept (visitor
*v
) const
1053 m_byte_offset
->accept (v
);
1056 /* Implementation of region::dump_to_pp vfunc for offset_region. */
1059 offset_region::dump_to_pp (pretty_printer
*pp
, bool simple
) const
1063 //pp_string (pp, "(");
1064 get_parent_region ()->dump_to_pp (pp
, simple
);
1065 pp_string (pp
, "+");
1066 m_byte_offset
->dump_to_pp (pp
, simple
);
1067 //pp_string (pp, ")");
1071 pp_string (pp
, "offset_region(");
1072 get_parent_region ()->dump_to_pp (pp
, simple
);
1073 pp_string (pp
, ", ");
1074 print_quoted_type (pp
, get_type ());
1075 pp_string (pp
, ", ");
1076 m_byte_offset
->dump_to_pp (pp
, simple
);
1077 pp_printf (pp
, ")");
1081 /* class cast_region : public region. */
1083 /* Implementation of region::accept vfunc for cast_region. */
1086 cast_region::accept (visitor
*v
) const
1089 m_original_region
->accept (v
);
1092 /* Implementation of region::dump_to_pp vfunc for cast_region. */
1095 cast_region::dump_to_pp (pretty_printer
*pp
, bool simple
) const
1099 pp_string (pp
, "CAST_REG(");
1100 print_quoted_type (pp
, get_type ());
1101 pp_string (pp
, ", ");
1102 m_original_region
->dump_to_pp (pp
, simple
);
1103 pp_string (pp
, ")");
1107 pp_string (pp
, "cast_region(");
1108 m_original_region
->dump_to_pp (pp
, simple
);
1109 pp_string (pp
, ", ");
1110 print_quoted_type (pp
, get_type ());
1111 pp_printf (pp
, ")");
1115 /* class heap_allocated_region : public region. */
1117 /* Implementation of region::dump_to_pp vfunc for heap_allocated_region. */
1120 heap_allocated_region::dump_to_pp (pretty_printer
*pp
, bool simple
) const
1123 pp_printf (pp
, "HEAP_ALLOCATED_REGION(%i)", get_id ());
1125 pp_printf (pp
, "heap_allocated_region(%i)", get_id ());
1128 /* class alloca_region : public region. */
1130 /* Implementation of region::dump_to_pp vfunc for alloca_region. */
1133 alloca_region::dump_to_pp (pretty_printer
*pp
, bool simple
) const
1136 pp_string (pp
, "ALLOCA_REGION");
1138 pp_string (pp
, "alloca_region()");
1141 /* class string_region : public region. */
1143 /* Implementation of region::dump_to_pp vfunc for string_region. */
1146 string_region::dump_to_pp (pretty_printer
*pp
, bool simple
) const
1149 dump_tree (pp
, m_string_cst
);
1152 pp_string (pp
, "string_region(");
1153 dump_tree (pp
, m_string_cst
);
1154 if (!flag_dump_noaddr
)
1156 pp_string (pp
, " (");
1157 pp_pointer (pp
, m_string_cst
);
1158 pp_string (pp
, "))");
1163 /* class unknown_region : public region. */
1165 /* Implementation of region::dump_to_pp vfunc for unknown_region. */
1168 unknown_region::dump_to_pp (pretty_printer
*pp
, bool /*simple*/) const
1170 pp_string (pp
, "UNKNOWN_REGION");
1175 #endif /* #if ENABLE_ANALYZER */