https://gcc.gnu.org/g:452ab7f34b622041e05837cfee90e294b793499f
commit r17-6243-g452ab7f34b622041e05837cfee90e294b793499f Author: David Malcolm <[email protected]> Date: Fri Nov 13 16:26:07 2026 -0500 analyzer: rename symbol to symbolic::node No functional change intended. gcc/ChangeLog: * Makefile.in (ANALYZER_OBJS): Replace analyzer/symbol.o with analyzer/symbolic-nodes.o. gcc/analyzer/ChangeLog: * common.h (class symbolic::node): New forward decl. * complexity.cc: Update comment. * complexity.h: Likewise. * kf.cc: Update for renaming of region_model_manager::alloc_symbol_id to region_model_manager::alloc_node_id. * region-model-manager.cc: Update for renaming of region_model_manager::alloc_symbol_id to region_model_manager::alloc_node_id, and m_next_symbol_id to m_next_node_id. * region-model-manager.h (region_model_manager::get_num_symbols): Rename to... (region_model_manager::get_num_nodes): ...this. (region_model_manager::alloc_symbol_id): Rename to... (region_model_manager::alloc_node_id): ...this. (region_model_manager::m_next_symbol_id): Rename to... (region_model_manager::m_next_node_id): ...this. * region-model.cc: Update for renaming of region_model_manager::alloc_symbol_id to region_model_manager::alloc_node_id. * region.cc: Likewise. Rename "symbol" to "symbolic::node" throughout. * region.h: Likewise. Replace include of "analyzer/symbol.h" with "analyzer/symbolic-nodes.h". * svalue.cc: Likewise. * svalue.h: Likewise. * symbol.cc: Rename to... * symbolic-nodes.cc: .. .this. Replace include of "analyzer/symbol.h" with "analyzer/symbolic-nodes.h". Rename "symbol" to "symbolic::node" throughout. * symbol.h: Rename to... * symbolic-nodes.h: ...this, updating include guards. (class symbol): Rename to... (symbolic::node): ...this. Flesh out leading comment somewhat. Modernize "id_t" to Use "using" rather than "typedef". Add virtual dtor. Signed-off-by: David Malcolm <[email protected]> Diff: --- gcc/Makefile.in | 2 +- gcc/analyzer/common.h | 5 ++ gcc/analyzer/complexity.cc | 2 +- gcc/analyzer/complexity.h | 6 +- gcc/analyzer/kf.cc | 2 +- gcc/analyzer/region-model-manager.cc | 92 +++++++++++++-------------- gcc/analyzer/region-model-manager.h | 6 +- gcc/analyzer/region-model.cc | 14 ++-- gcc/analyzer/region.cc | 10 +-- gcc/analyzer/region.h | 54 ++++++++-------- gcc/analyzer/svalue.cc | 38 +++++------ gcc/analyzer/svalue.h | 46 +++++++------- gcc/analyzer/{symbol.cc => symbolic-nodes.cc} | 8 +-- gcc/analyzer/{symbol.h => symbolic-nodes.h} | 27 +++++--- 14 files changed, 164 insertions(+), 148 deletions(-) diff --git a/gcc/Makefile.in b/gcc/Makefile.in index 962debed4429..38460282f43c 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -1407,7 +1407,7 @@ ANALYZER_OBJS = \ analyzer/supergraph-simplify.o \ analyzer/supergraph-sorting.o \ analyzer/svalue.o \ - analyzer/symbol.o \ + analyzer/symbolic-nodes.o \ analyzer/trimmed-graph.o \ analyzer/varargs.o \ analyzer/write-to-const-diagnostics.o \ diff --git a/gcc/analyzer/common.h b/gcc/analyzer/common.h index 3ffcebd69c03..04abf1dd0ff4 100644 --- a/gcc/analyzer/common.h +++ b/gcc/analyzer/common.h @@ -54,6 +54,11 @@ class supergraph; class supernode; class superedge; +namespace symbolic +{ + class node; +} + class svalue; class region_svalue; class constant_svalue; diff --git a/gcc/analyzer/complexity.cc b/gcc/analyzer/complexity.cc index c00b52048e37..f77b3a1a3f2a 100644 --- a/gcc/analyzer/complexity.cc +++ b/gcc/analyzer/complexity.cc @@ -1,4 +1,4 @@ -/* Measuring the complexity of svalues/regions. +/* Measuring the complexity of symbolic nodes. Copyright (C) 2020-2026 Free Software Foundation, Inc. Contributed by David Malcolm <[email protected]>. diff --git a/gcc/analyzer/complexity.h b/gcc/analyzer/complexity.h index dc5790ed6cdd..41a241f4659c 100644 --- a/gcc/analyzer/complexity.h +++ b/gcc/analyzer/complexity.h @@ -1,4 +1,4 @@ -/* Measuring the complexity of svalues/regions. +/* Measuring the complexity of symbolic nodes. Copyright (C) 2020-2026 Free Software Foundation, Inc. Contributed by David Malcolm <[email protected]>. @@ -23,7 +23,7 @@ along with GCC; see the file COPYING3. If not see namespace ana { -/* A measurement of the complexity of an svalue or region, so that +/* A measurement of the complexity of a symbolic node, so that we can impose bounds on the growth of these tree-like structures and thus avoid infinite chains of analysis. */ @@ -38,7 +38,7 @@ struct complexity static complexity from_pair (const complexity &c1, const complexity &c); static complexity from_vec_svalue (const vec<const svalue *> &vec); - /* The total number of svalues and regions in the tree of this + /* The total number of nodes in the tree of this entity, including the entity itself. */ unsigned m_num_nodes; diff --git a/gcc/analyzer/kf.cc b/gcc/analyzer/kf.cc index a9f69d039877..89bcce8d0fb7 100644 --- a/gcc/analyzer/kf.cc +++ b/gcc/analyzer/kf.cc @@ -2795,7 +2795,7 @@ public: }; // class strtok_call_info kf_strtok (region_model_manager &mgr) - : m_private_reg (mgr.alloc_symbol_id (), + : m_private_reg (mgr.alloc_node_id (), mgr.get_root_region (), get_region_type (), "strtok buffer") diff --git a/gcc/analyzer/region-model-manager.cc b/gcc/analyzer/region-model-manager.cc index 8899a4c8dcb2..fd5d91c8ee42 100644 --- a/gcc/analyzer/region-model-manager.cc +++ b/gcc/analyzer/region-model-manager.cc @@ -44,20 +44,20 @@ namespace ana { region_model_manager::region_model_manager (logger *logger) : m_logger (logger), - m_next_symbol_id (0), + m_next_node_id (0), m_empty_call_string (), - m_root_region (alloc_symbol_id ()), - m_stack_region (alloc_symbol_id (), &m_root_region), - m_heap_region (alloc_symbol_id (), &m_root_region), + m_root_region (alloc_node_id ()), + m_stack_region (alloc_node_id (), &m_root_region), + m_heap_region (alloc_node_id (), &m_root_region), m_unknown_NULL (nullptr), m_checking_feasibility (false), m_max_complexity (0, 0), - m_code_region (alloc_symbol_id (), &m_root_region), + m_code_region (alloc_node_id (), &m_root_region), m_fndecls_map (), m_labels_map (), - m_globals_region (alloc_symbol_id (), &m_root_region), + m_globals_region (alloc_node_id (), &m_root_region), m_globals_map (), - m_thread_local_region (alloc_symbol_id (), &m_root_region), - m_errno_region (alloc_symbol_id (), &m_thread_local_region), + m_thread_local_region (alloc_node_id (), &m_root_region), + m_errno_region (alloc_node_id (), &m_thread_local_region), m_store_mgr (this), m_range_mgr (new bounded_ranges_manager ()), m_known_fn_mgr (logger) @@ -215,7 +215,7 @@ region_model_manager::get_or_create_constant_svalue (tree type, tree cst_expr) if (iter != m_constants_map.end ()) return iter->second; constant_svalue *cst_sval - = new constant_svalue (alloc_symbol_id (), type, cst_expr); + = new constant_svalue (alloc_node_id (), type, cst_expr); RETURN_UNKNOWN_IF_TOO_COMPLEX (cst_sval); m_constants_map.insert ({key, cst_sval}); return cst_sval; @@ -277,14 +277,14 @@ region_model_manager::get_or_create_unknown_svalue (tree type) if (type == NULL_TREE) { if (!m_unknown_NULL) - m_unknown_NULL = new unknown_svalue (alloc_symbol_id (), type); + m_unknown_NULL = new unknown_svalue (alloc_node_id (), type); return m_unknown_NULL; } auto iter = m_unknowns_map.find (type); if (iter != m_unknowns_map.end ()) return iter->second; - unknown_svalue *sval = new unknown_svalue (alloc_symbol_id (), type); + unknown_svalue *sval = new unknown_svalue (alloc_node_id (), type); m_unknowns_map.insert ({type, sval}); return sval; } @@ -294,7 +294,7 @@ region_model_manager::get_or_create_unknown_svalue (tree type) const svalue * region_model_manager::create_unique_svalue (tree type) { - svalue *sval = new placeholder_svalue (alloc_symbol_id (), type, "unique"); + svalue *sval = new placeholder_svalue (alloc_node_id (), type, "unique"); m_managed_dynamic_svalues.safe_push (sval); return sval; } @@ -345,7 +345,7 @@ region_model_manager::get_or_create_initial_value (const region *reg, if (iter != m_initial_values_map.end ()) return iter->second; initial_svalue *initial_sval - = new initial_svalue (alloc_symbol_id (), reg->get_type (), reg); + = new initial_svalue (alloc_node_id (), reg->get_type (), reg); RETURN_UNKNOWN_IF_TOO_COMPLEX (initial_sval); m_initial_values_map.insert ({reg, initial_sval}); return initial_sval; @@ -362,7 +362,7 @@ region_model_manager::get_or_create_setjmp_svalue (const setjmp_record &r, auto iter = m_setjmp_values_map.find (key); if (iter != m_setjmp_values_map.end ()) return iter->second; - setjmp_svalue *setjmp_sval = new setjmp_svalue (r, alloc_symbol_id (), type); + setjmp_svalue *setjmp_sval = new setjmp_svalue (r, alloc_node_id (), type); RETURN_UNKNOWN_IF_TOO_COMPLEX (setjmp_sval); m_setjmp_values_map.insert ({key, setjmp_sval}); return setjmp_sval; @@ -380,7 +380,7 @@ region_model_manager::get_or_create_poisoned_svalue (enum poison_kind kind, if (iter != m_poisoned_values_map.end ()) return iter->second; poisoned_svalue *poisoned_sval - = new poisoned_svalue (kind, alloc_symbol_id (), type); + = new poisoned_svalue (kind, alloc_node_id (), type); RETURN_UNKNOWN_IF_TOO_COMPLEX (poisoned_sval); m_poisoned_values_map.insert ( {key, poisoned_sval} ); return poisoned_sval; @@ -403,7 +403,7 @@ region_model_manager::get_ptr_svalue (tree ptr_type, const region *pointee) if (iter != m_pointer_values_map.end ()) return iter->second; region_svalue *sval - = new region_svalue (alloc_symbol_id (), ptr_type, pointee); + = new region_svalue (alloc_node_id (), ptr_type, pointee); RETURN_UNKNOWN_IF_TOO_COMPLEX (sval); m_pointer_values_map.insert ({key, sval}); return sval; @@ -568,7 +568,7 @@ region_model_manager::get_or_create_unaryop (tree type, enum tree_code op, if (iter != m_unaryop_values_map.end ()) return iter->second; unaryop_svalue *unaryop_sval - = new unaryop_svalue (alloc_symbol_id (), type, op, arg); + = new unaryop_svalue (alloc_node_id (), type, op, arg); RETURN_UNKNOWN_IF_TOO_COMPLEX (unaryop_sval); m_unaryop_values_map.insert ({key, unaryop_sval}); return unaryop_sval; @@ -1001,7 +1001,7 @@ region_model_manager::get_or_create_binop (tree type, enum tree_code op, if (iter != m_binop_values_map.end ()) return iter->second; binop_svalue *binop_sval - = new binop_svalue (alloc_symbol_id (), type, op, arg0, arg1); + = new binop_svalue (alloc_node_id (), type, op, arg0, arg1); RETURN_UNKNOWN_IF_TOO_COMPLEX (binop_sval); m_binop_values_map.insert ({key, binop_sval}); return binop_sval; @@ -1115,7 +1115,7 @@ region_model_manager::get_or_create_sub_svalue (tree type, if (iter != m_sub_values_map.end ()) return iter->second; sub_svalue *sub_sval - = new sub_svalue (alloc_symbol_id (), type, parent_svalue, subregion); + = new sub_svalue (alloc_node_id (), type, parent_svalue, subregion); RETURN_UNKNOWN_IF_TOO_COMPLEX (sub_sval); m_sub_values_map.insert ({key, sub_sval}); return sub_sval; @@ -1178,7 +1178,7 @@ region_model_manager::get_or_create_repeated_svalue (tree type, if (iter != m_repeated_values_map.end ()) return iter->second; repeated_svalue *repeated_sval - = new repeated_svalue (alloc_symbol_id (), type, outer_size, inner_svalue); + = new repeated_svalue (alloc_node_id (), type, outer_size, inner_svalue); RETURN_UNKNOWN_IF_TOO_COMPLEX (repeated_sval); m_repeated_values_map.insert ({key, repeated_sval}); return repeated_sval; @@ -1372,7 +1372,7 @@ region_model_manager::get_or_create_bits_within (tree type, if (iter != m_bits_within_values_map.end ()) return iter->second; bits_within_svalue *bits_within_sval - = new bits_within_svalue (alloc_symbol_id (), type, bits, inner_svalue); + = new bits_within_svalue (alloc_node_id (), type, bits, inner_svalue); RETURN_UNKNOWN_IF_TOO_COMPLEX (bits_within_sval); m_bits_within_values_map.insert ({key, bits_within_sval}); return bits_within_sval; @@ -1391,7 +1391,7 @@ region_model_manager::get_or_create_unmergeable (const svalue *arg) if (iter != m_unmergeable_values_map.end ()) return iter->second; unmergeable_svalue *unmergeable_sval - = new unmergeable_svalue (alloc_symbol_id (), arg); + = new unmergeable_svalue (alloc_node_id (), arg); RETURN_UNKNOWN_IF_TOO_COMPLEX (unmergeable_sval); m_unmergeable_values_map.insert ({arg, unmergeable_sval}); return unmergeable_sval; @@ -1414,7 +1414,7 @@ get_or_create_widening_svalue (tree type, if (iter != m_widening_values_map.end ()) return iter->second; widening_svalue *widening_sval - = new widening_svalue (alloc_symbol_id (), type, snode, base_sval, + = new widening_svalue (alloc_node_id (), type, snode, base_sval, iter_sval); RETURN_UNKNOWN_IF_TOO_COMPLEX (widening_sval); m_widening_values_map.insert ({key, widening_sval}); @@ -1433,7 +1433,7 @@ region_model_manager::get_or_create_compound_svalue (tree type, if (iter != m_compound_values_map.end ()) return iter->second; compound_svalue *compound_sval - = new compound_svalue (alloc_symbol_id (), type, std::move (map)); + = new compound_svalue (alloc_node_id (), type, std::move (map)); RETURN_UNKNOWN_IF_TOO_COMPLEX (compound_sval); /* Use make_key rather than reusing the key, so that we use a ptr to compound_sval's binding_map, rather than the MAP param. */ @@ -1453,7 +1453,7 @@ region_model_manager::get_or_create_compound_svalue (tree type, if (iter != m_compound_values_map.end ()) return iter->second; compound_svalue *compound_sval - = new compound_svalue (alloc_symbol_id (), type, map); + = new compound_svalue (alloc_node_id (), type, map); RETURN_UNKNOWN_IF_TOO_COMPLEX (compound_sval); /* Use make_key rather than reusing the key, so that we use a ptr to compound_sval's binding_map, rather than the MAP param. */ @@ -1497,7 +1497,7 @@ region_model_manager::get_or_create_conjured_svalue (tree type, return sval; } conjured_svalue *conjured_sval - = new conjured_svalue (alloc_symbol_id (), type, stmt, id_reg, idx); + = new conjured_svalue (alloc_node_id (), type, stmt, id_reg, idx); RETURN_UNKNOWN_IF_TOO_COMPLEX (conjured_sval); m_conjured_values_map.insert ({key, conjured_sval}); return conjured_sval; @@ -1543,7 +1543,7 @@ get_or_create_asm_output_svalue (tree type, if (iter != m_asm_output_values_map.end ()) return iter->second; asm_output_svalue *asm_output_sval - = new asm_output_svalue (alloc_symbol_id (), type, asm_string, output_idx, + = new asm_output_svalue (alloc_node_id (), type, asm_string, output_idx, noutputs, inputs); RETURN_UNKNOWN_IF_TOO_COMPLEX (asm_output_sval); m_asm_output_values_map.insert ({key, asm_output_sval}); @@ -1573,7 +1573,7 @@ get_or_create_asm_output_svalue (tree type, if (iter != m_asm_output_values_map.end ()) return iter->second; asm_output_svalue *asm_output_sval - = new asm_output_svalue (alloc_symbol_id (), type, asm_string, output_idx, + = new asm_output_svalue (alloc_node_id (), type, asm_string, output_idx, num_outputs, inputs); RETURN_UNKNOWN_IF_TOO_COMPLEX (asm_output_sval); m_asm_output_values_map.insert ({key, asm_output_sval}); @@ -1599,7 +1599,7 @@ get_or_create_const_fn_result_svalue (tree type, if (iter != m_const_fn_result_values_map.end ()) return iter->second; const_fn_result_svalue *const_fn_result_sval - = new const_fn_result_svalue (alloc_symbol_id (), type, fndecl, inputs); + = new const_fn_result_svalue (alloc_node_id (), type, fndecl, inputs); RETURN_UNKNOWN_IF_TOO_COMPLEX (const_fn_result_sval); m_const_fn_result_values_map.insert ({key, const_fn_result_sval}); return const_fn_result_sval; @@ -1708,7 +1708,7 @@ region_model_manager::get_region_for_fndecl (tree fndecl) if (iter != m_fndecls_map.end ()) return iter->second; function_region *reg - = new function_region (alloc_symbol_id (), &m_code_region, fndecl); + = new function_region (alloc_node_id (), &m_code_region, fndecl); m_fndecls_map.insert ({fndecl, reg}); return reg; } @@ -1729,7 +1729,7 @@ region_model_manager::get_region_for_label (tree label) const function_region *func_reg = get_region_for_fndecl (fndecl); label_region *reg - = new label_region (alloc_symbol_id (), func_reg, label); + = new label_region (alloc_node_id (), func_reg, label); m_labels_map.insert ({label, reg}); return reg; } @@ -1746,7 +1746,7 @@ region_model_manager::get_region_for_global (tree expr) return iter->second; decl_region *reg - = new decl_region (alloc_symbol_id (), &m_globals_region, expr); + = new decl_region (alloc_node_id (), &m_globals_region, expr); m_globals_map.insert ({expr, reg}); return reg; } @@ -1783,7 +1783,7 @@ region_model_manager::get_field_region (const region *parent, tree field) return reg; field_region *field_reg - = new field_region (alloc_symbol_id (), parent, field); + = new field_region (alloc_node_id (), parent, field); m_field_regions.put (key, field_reg); return field_reg; } @@ -1805,7 +1805,7 @@ region_model_manager::get_element_region (const region *parent, return reg; element_region *element_reg - = new element_region (alloc_symbol_id (), parent, element_type, index); + = new element_region (alloc_node_id (), parent, element_type, index); m_element_regions.put (key, element_reg); return element_reg; } @@ -1845,7 +1845,7 @@ region_model_manager::get_offset_region (const region *parent, return reg; offset_region *offset_reg - = new offset_region (alloc_symbol_id (), parent, type, byte_offset); + = new offset_region (alloc_node_id (), parent, type, byte_offset); m_offset_regions.put (key, offset_reg); return offset_reg; } @@ -1880,7 +1880,7 @@ region_model_manager::get_sized_region (const region *parent, return reg; sized_region *sized_reg - = new sized_region (alloc_symbol_id (), parent, type, byte_size_sval); + = new sized_region (alloc_node_id (), parent, type, byte_size_sval); m_sized_regions.put (key, sized_reg); return sized_reg; } @@ -1904,7 +1904,7 @@ region_model_manager::get_cast_region (const region *original_region, return reg; cast_region *cast_reg - = new cast_region (alloc_symbol_id (), original_region, type); + = new cast_region (alloc_node_id (), original_region, type); m_cast_regions.put (key, cast_reg); return cast_reg; } @@ -1923,7 +1923,7 @@ region_model_manager::get_frame_region (const frame_region *calling_frame, return reg; frame_region *frame_reg - = new frame_region (alloc_symbol_id (), &m_stack_region, calling_frame, + = new frame_region (alloc_node_id (), &m_stack_region, calling_frame, fun, index); m_frame_regions.put (key, frame_reg); return frame_reg; @@ -1940,7 +1940,7 @@ region_model_manager::get_symbolic_region (const svalue *sval) return reg; symbolic_region *symbolic_reg - = new symbolic_region (alloc_symbol_id (), &m_root_region, sval); + = new symbolic_region (alloc_node_id (), &m_root_region, sval); m_symbolic_regions.put (key, symbolic_reg); return symbolic_reg; } @@ -1958,7 +1958,7 @@ region_model_manager::get_region_for_string (tree string_cst) return iter->second; string_region *reg - = new string_region (alloc_symbol_id (), &m_root_region, string_cst); + = new string_region (alloc_node_id (), &m_root_region, string_cst); m_string_map.insert ({string_cst, reg}); return reg; } @@ -1980,7 +1980,7 @@ region_model_manager::get_bit_range (const region *parent, tree type, return reg; bit_range_region *bit_range_reg - = new bit_range_region (alloc_symbol_id (), parent, type, bits); + = new bit_range_region (alloc_node_id (), parent, type, bits); m_bit_range_regions.put (key, bit_range_reg); return bit_range_reg; } @@ -1999,7 +1999,7 @@ region_model_manager::get_var_arg_region (const frame_region *parent_frame, return reg; var_arg_region *var_arg_reg - = new var_arg_region (alloc_symbol_id (), parent_frame, idx); + = new var_arg_region (alloc_node_id (), parent_frame, idx); m_var_arg_regions.put (key, var_arg_reg); return var_arg_reg; } @@ -2019,7 +2019,7 @@ get_region_for_unexpected_tree_code (region_model_context *ctxt, { tree type = TYPE_P (t) ? t : TREE_TYPE (t); region *new_reg - = new unknown_region (alloc_symbol_id (), &m_root_region, type); + = new unknown_region (alloc_node_id (), &m_root_region, type); if (ctxt) ctxt->on_unexpected_tree_code (t, loc); return new_reg; @@ -2042,7 +2042,7 @@ get_or_create_region_for_heap_alloc (const bitmap &base_regs_in_use) /* All existing ones (if any) are in use; create a new one. */ region *reg - = new heap_allocated_region (alloc_symbol_id (), &m_heap_region); + = new heap_allocated_region (alloc_node_id (), &m_heap_region); m_managed_dynamic_regions.safe_push (reg); return reg; } @@ -2053,7 +2053,7 @@ const region * region_model_manager::create_region_for_alloca (const frame_region *frame) { gcc_assert (frame); - region *reg = new alloca_region (alloc_symbol_id (), frame); + region *reg = new alloca_region (alloc_node_id (), frame); m_managed_dynamic_regions.safe_push (reg); return reg; } @@ -2158,7 +2158,7 @@ region_model_manager::log_stats (logger *logger, bool show_objs) const LOG_SCOPE (logger); logger->log ("call string consolidation"); m_empty_call_string.recursive_log (logger); - logger->log ("next symbol id: %i", m_next_symbol_id); + logger->log ("next node id: %i", m_next_node_id); logger->log ("svalue consolidation"); log_uniq_map (logger, show_objs, "constant_svalue", m_constants_map); log_uniq_map (logger, show_objs, "unknown_svalue", m_unknowns_map); diff --git a/gcc/analyzer/region-model-manager.h b/gcc/analyzer/region-model-manager.h index 6e3e38e57c9d..6e6cbe747003 100644 --- a/gcc/analyzer/region-model-manager.h +++ b/gcc/analyzer/region-model-manager.h @@ -34,8 +34,8 @@ public: region_model_manager (logger *logger = nullptr); ~region_model_manager (); - unsigned get_num_symbols () const { return m_next_symbol_id; } - unsigned alloc_symbol_id () { return m_next_symbol_id++; } + unsigned get_num_nodes () const { return m_next_node_id; } + unsigned alloc_node_id () { return m_next_node_id++; } /* call_string consolidation. */ const call_string &get_empty_call_string () const @@ -205,7 +205,7 @@ private: logger *m_logger; - unsigned m_next_symbol_id; + unsigned m_next_node_id; const call_string m_empty_call_string; diff --git a/gcc/analyzer/region-model.cc b/gcc/analyzer/region-model.cc index 361b06073474..60e80a9e69e5 100644 --- a/gcc/analyzer/region-model.cc +++ b/gcc/analyzer/region-model.cc @@ -7895,7 +7895,7 @@ test_get_representative_tree () tree tlen = size_int (10); tree arr_type = build_array_type (char_type_node, build_index_type (tlen)); tree a = build_global_decl ("a", arr_type); - placeholder_svalue test_sval (mgr.alloc_symbol_id (), + placeholder_svalue test_sval (mgr.alloc_node_id (), char_type_node, "test value"); /* Value of a[3]. */ @@ -7941,7 +7941,7 @@ test_get_representative_tree () { region_model m (&mgr); const region *c_x_reg = m.get_lvalue (c_x, &ctxt); - placeholder_svalue test_sval_x (mgr.alloc_symbol_id (), + placeholder_svalue test_sval_x (mgr.alloc_node_id (), integer_type_node, "test x val"); m.set_value (c_x_reg, &test_sval_x, &ctxt); tree rep = m.get_representative_tree (&test_sval_x); @@ -7952,7 +7952,7 @@ test_get_representative_tree () { region_model m (&mgr); const region *c_y_reg = m.get_lvalue (c_y, &ctxt); - placeholder_svalue test_sval_y (mgr.alloc_symbol_id (), + placeholder_svalue test_sval_y (mgr.alloc_node_id (), integer_type_node, "test y val"); m.set_value (c_y_reg, &test_sval_y, &ctxt); tree rep = m.get_representative_tree (&test_sval_y); @@ -8197,7 +8197,7 @@ test_binop_svalue_folding () const svalue *sval_false = mgr.get_or_create_int_cst (boolean_type_node, 0); const svalue *sval_unknown = mgr.get_or_create_unknown_svalue (boolean_type_node); - const placeholder_svalue sval_placeholder (mgr.alloc_symbol_id (), + const placeholder_svalue sval_placeholder (mgr.alloc_node_id (), boolean_type_node, "v"); for (auto op : {BIT_IOR_EXPR, TRUTH_OR_EXPR}) { @@ -8816,7 +8816,7 @@ test_state_merging () model1.push_frame (*DECL_STRUCT_FUNCTION (test_fndecl), nullptr, nullptr, &ctxt); - placeholder_svalue test_sval (mgr.alloc_symbol_id (), + placeholder_svalue test_sval (mgr.alloc_node_id (), integer_type_node, "test sval"); model0.set_value (model0.get_lvalue (a, &ctxt), &test_sval, &ctxt); model1.set_value (model1.get_lvalue (a, &ctxt), &test_sval, &ctxt); @@ -8836,7 +8836,7 @@ test_state_merging () region_model model0 (&mgr); region_model model1 (&mgr); - placeholder_svalue test_sval (mgr.alloc_symbol_id (), + placeholder_svalue test_sval (mgr.alloc_node_id (), integer_type_node, "test sval"); model0.set_value (model0.get_lvalue (x, &ctxt), &test_sval, &ctxt); model1.set_value (model1.get_lvalue (x, &ctxt), &test_sval, &ctxt); @@ -8984,7 +8984,7 @@ test_state_merging () { test_region_model_context ctxt; region_model model0 (&mgr); - placeholder_svalue placeholder_sval (mgr.alloc_symbol_id (), + placeholder_svalue placeholder_sval (mgr.alloc_node_id (), integer_type_node, "test"); model0.set_value (model0.get_lvalue (x, &ctxt), &placeholder_sval, &ctxt); diff --git a/gcc/analyzer/region.cc b/gcc/analyzer/region.cc index 6f9e49468cda..4bb96119c93f 100644 --- a/gcc/analyzer/region.cc +++ b/gcc/analyzer/region.cc @@ -1275,8 +1275,8 @@ region::is_named_decl_p (const char *decl_name) const /* region's ctor. */ -region::region (complexity c, symbol::id_t id, const region *parent, tree type) -: symbol (c, id), +region::region (complexity c, symbolic::node::id_t id, const region *parent, tree type) +: symbolic::node (c, id), m_parent (parent), m_type (type), m_cached_offset (nullptr), m_cached_init_sval_at_main (nullptr) { @@ -1534,7 +1534,7 @@ frame_region::get_region_for_local (region_model_manager *mgr, if (decl_region **slot = mutable_locals.get (expr)) return *slot; decl_region *reg - = new decl_region (mgr->alloc_symbol_id (), this, expr); + = new decl_region (mgr->alloc_node_id (), this, expr); mutable_locals.put (expr, reg); return reg; } @@ -1673,7 +1673,7 @@ heap_region::print_dump_widget_label (pretty_printer *pp) const /* root_region's ctor. */ -root_region::root_region (symbol::id_t id) +root_region::root_region (symbolic::node::id_t id) : region (complexity (1, 1), id, nullptr, NULL_TREE) { } @@ -1716,7 +1716,7 @@ thread_local_region::print_dump_widget_label (pretty_printer *pp) const /* symbolic_region's ctor. */ -symbolic_region::symbolic_region (symbol::id_t id, region *parent, +symbolic_region::symbolic_region (symbolic::node::id_t id, region *parent, const svalue *sval_ptr) : region (complexity::from_pair (parent, sval_ptr), id, parent, (sval_ptr->get_type () diff --git a/gcc/analyzer/region.h b/gcc/analyzer/region.h index c852f7f51afd..3ead50a418c8 100644 --- a/gcc/analyzer/region.h +++ b/gcc/analyzer/region.h @@ -21,7 +21,7 @@ along with GCC; see the file COPYING3. If not see #ifndef GCC_ANALYZER_REGION_H #define GCC_ANALYZER_REGION_H -#include "analyzer/symbol.h" +#include "analyzer/symbolic-nodes.h" #include "analyzer/store.h" #include "text-art/tree-widget.h" @@ -123,7 +123,7 @@ enum region_kind within the frames and the "globals" region. Regions for structs can have subregions for fields. */ -class region : public symbol +class region : public symbolic::node { public: virtual ~region (); @@ -259,7 +259,7 @@ public: bool empty_p () const; protected: - region (complexity c, symbol::id_t id, const region *parent, tree type); + region (complexity c, symbolic::node::id_t id, const region *parent, tree type); private: region_offset calc_offset (region_model_manager *mgr) const; @@ -299,7 +299,7 @@ namespace ana { class space_region : public region { protected: - space_region (symbol::id_t id, const region *parent) + space_region (symbolic::node::id_t id, const region *parent) : region (complexity (parent), id, parent, NULL_TREE) {} }; @@ -354,7 +354,7 @@ public: const function *m_fun; }; - frame_region (symbol::id_t id, const region *parent, + frame_region (symbolic::node::id_t id, const region *parent, const frame_region *calling_frame, const function &fun, int index) : space_region (id, parent), m_calling_frame (calling_frame), @@ -425,7 +425,7 @@ namespace ana { class globals_region : public space_region { public: - globals_region (symbol::id_t id, const region *parent) + globals_region (symbolic::node::id_t id, const region *parent) : space_region (id, parent) {} @@ -453,7 +453,7 @@ namespace ana { class code_region : public space_region { public: - code_region (symbol::id_t id, const region *parent) + code_region (symbolic::node::id_t id, const region *parent) : space_region (id, parent) {} @@ -481,7 +481,7 @@ namespace ana { class function_region : public region { public: - function_region (symbol::id_t id, const code_region *parent, tree fndecl) + function_region (symbolic::node::id_t id, const code_region *parent, tree fndecl) : region (complexity (parent), id, parent, TREE_TYPE (fndecl)), m_fndecl (fndecl) { @@ -520,7 +520,7 @@ namespace ana { class label_region : public region { public: - label_region (symbol::id_t id, const function_region *parent, tree label) + label_region (symbolic::node::id_t id, const function_region *parent, tree label) : region (complexity (parent), id, parent, NULL_TREE), m_label (label) { gcc_assert (TREE_CODE (label) == LABEL_DECL); @@ -555,7 +555,7 @@ namespace ana { class stack_region : public space_region { public: - stack_region (symbol::id_t id, region *parent) + stack_region (symbolic::node::id_t id, region *parent) : space_region (id, parent) {} @@ -583,7 +583,7 @@ namespace ana { class heap_region : public space_region { public: - heap_region (symbol::id_t id, region *parent) + heap_region (symbolic::node::id_t id, region *parent) : space_region (id, parent) {} @@ -610,7 +610,7 @@ namespace ana { class thread_local_region : public space_region { public: - thread_local_region (symbol::id_t id, region *parent) + thread_local_region (symbolic::node::id_t id, region *parent) : space_region (id, parent) {} @@ -638,7 +638,7 @@ namespace ana { class root_region : public region { public: - root_region (symbol::id_t id); + root_region (symbolic::node::id_t id); enum region_kind get_kind () const final override { return RK_ROOT; } void dump_to_pp (pretty_printer *pp, bool simple) const final override; @@ -697,7 +697,7 @@ public: const svalue *m_sval_ptr; }; - symbolic_region (symbol::id_t id, region *parent, const svalue *sval_ptr); + symbolic_region (symbolic::node::id_t id, region *parent, const svalue *sval_ptr); const symbolic_region * dyn_cast_symbolic_region () const final override { return this; } @@ -742,7 +742,7 @@ namespace ana { class decl_region : public region { public: - decl_region (symbol::id_t id, const region *parent, tree decl) + decl_region (symbolic::node::id_t id, const region *parent, tree decl) : region (complexity (parent), id, parent, TREE_TYPE (decl)), m_decl (decl), m_tracked (calc_tracked_p (decl)), m_ctor_svalue (nullptr) @@ -833,7 +833,7 @@ public: tree m_field; }; - field_region (symbol::id_t id, const region *parent, tree field) + field_region (symbolic::node::id_t id, const region *parent, tree field) : region (complexity (parent), id, parent, TREE_TYPE (field)), m_field (field) {} @@ -917,7 +917,7 @@ public: const svalue *m_index; }; - element_region (symbol::id_t id, const region *parent, tree element_type, + element_region (symbolic::node::id_t id, const region *parent, tree element_type, const svalue *index) : region (complexity::from_pair (parent, index), id, parent, element_type), m_index (index) @@ -1011,7 +1011,7 @@ public: const svalue *m_byte_offset; }; - offset_region (symbol::id_t id, const region *parent, tree type, + offset_region (symbolic::node::id_t id, const region *parent, tree type, const svalue *byte_offset) : region (complexity::from_pair (parent, byte_offset), id, parent, type), m_byte_offset (byte_offset) @@ -1108,7 +1108,7 @@ public: const svalue *m_end_offset; }; - sized_region (symbol::id_t id, const region *parent, tree type, + sized_region (symbolic::node::id_t id, const region *parent, tree type, const svalue *byte_size_sval) : region (complexity::from_pair (parent, byte_size_sval), id, parent, type), @@ -1206,7 +1206,7 @@ public: tree m_type; }; - cast_region (symbol::id_t id, const region *parent, tree type) + cast_region (symbolic::node::id_t id, const region *parent, tree type) : region (complexity (parent), id, parent, type) {} @@ -1245,7 +1245,7 @@ namespace ana { class heap_allocated_region : public region { public: - heap_allocated_region (symbol::id_t id, const region *parent) + heap_allocated_region (symbolic::node::id_t id, const region *parent) : region (complexity (parent), id, parent, NULL_TREE) {} @@ -1261,7 +1261,7 @@ public: class alloca_region : public region { public: - alloca_region (symbol::id_t id, const frame_region *parent) + alloca_region (symbolic::node::id_t id, const frame_region *parent) : region (complexity (parent), id, parent, NULL_TREE) {} @@ -1276,7 +1276,7 @@ public: class string_region : public region { public: - string_region (symbol::id_t id, const region *parent, tree string_cst) + string_region (symbolic::node::id_t id, const region *parent, tree string_cst) : region (complexity (parent), id, parent, TREE_TYPE (string_cst)), m_string_cst (string_cst) {} @@ -1355,7 +1355,7 @@ public: bit_range m_bits; }; - bit_range_region (symbol::id_t id, const region *parent, tree type, + bit_range_region (symbolic::node::id_t id, const region *parent, tree type, const bit_range &bits) : region (complexity (parent), id, parent, type), m_bits (bits) @@ -1444,7 +1444,7 @@ public: unsigned m_idx; }; - var_arg_region (symbol::id_t id, const frame_region *parent, + var_arg_region (symbolic::node::id_t id, const frame_region *parent, unsigned idx) : region (complexity (parent), id, parent, NULL_TREE), m_idx (idx) @@ -1488,7 +1488,7 @@ namespace ana { class errno_region : public region { public: - errno_region (symbol::id_t id, const thread_local_region *parent) + errno_region (symbolic::node::id_t id, const thread_local_region *parent) : region (complexity (parent), id, parent, integer_type_node) {} @@ -1552,7 +1552,7 @@ namespace ana { class unknown_region : public region { public: - unknown_region (symbol::id_t id, const region *parent, tree type) + unknown_region (symbolic::node::id_t id, const region *parent, tree type) : region (complexity (parent), id, parent, type) {} diff --git a/gcc/analyzer/svalue.cc b/gcc/analyzer/svalue.cc index e6a682efd757..cde7c66f45be 100644 --- a/gcc/analyzer/svalue.cc +++ b/gcc/analyzer/svalue.cc @@ -47,7 +47,7 @@ static int cmp_csts_and_types (const_tree cst1, const_tree cst2); /* class svalue. */ -/* Dump a tree-like representation of this svalue and its constituent symbols +/* Dump a tree-like representation of this svalue and its constituent symbolic::nodes to stderr, using global_dc's colorization and theming options. For example: @@ -1487,7 +1487,7 @@ unaryop_svalue::key_t::operator< (const key_t &other) const return c < 0; if (int c = cmp_types (m_type, other.m_type)) return c < 0; - if (int c = symbol::cmp_ids (m_arg, other.m_arg)) + if (int c = symbolic::node::cmp_ids (m_arg, other.m_arg)) return c < 0; return false; } @@ -1631,9 +1631,9 @@ binop_svalue::key_t::operator< (const key_t &other) const return c < 0; if (int c = cmp_types (m_type, other.m_type)) return c < 0; - if (int c = symbol::cmp_ids (m_arg0, other.m_arg0)) + if (int c = symbolic::node::cmp_ids (m_arg0, other.m_arg0)) return c < 0; - if (int c = symbol::cmp_ids (m_arg1, other.m_arg1)) + if (int c = symbolic::node::cmp_ids (m_arg1, other.m_arg1)) return c < 0; return false; } @@ -1743,16 +1743,16 @@ sub_svalue::key_t::operator< (const key_t &other) const { if (int c = cmp_types (m_type, other.m_type)) return c < 0; - if (int c = symbol::cmp_ids (m_parent_svalue, other.m_parent_svalue)) + if (int c = symbolic::node::cmp_ids (m_parent_svalue, other.m_parent_svalue)) return c < 0; - if (int c = symbol::cmp_ids (m_subregion, other.m_subregion)) + if (int c = symbolic::node::cmp_ids (m_subregion, other.m_subregion)) return c < 0; return false; } /* sub_svalue'c ctor. */ -sub_svalue::sub_svalue (symbol::id_t id, +sub_svalue::sub_svalue (symbolic::node::id_t id, tree type, const svalue *parent_svalue, const region *subregion) : svalue (complexity::from_pair (parent_svalue->get_complexity (), @@ -1868,16 +1868,16 @@ repeated_svalue::key_t::operator< (const key_t &other) const { if (int c = cmp_types (m_type, other.m_type)) return c < 0; - if (int c = symbol::cmp_ids (m_outer_size, other.m_outer_size)) + if (int c = symbolic::node::cmp_ids (m_outer_size, other.m_outer_size)) return c < 0; - if (int c = symbol::cmp_ids (m_inner_svalue, other.m_inner_svalue)) + if (int c = symbolic::node::cmp_ids (m_inner_svalue, other.m_inner_svalue)) return c < 0; return false; } /* repeated_svalue'c ctor. */ -repeated_svalue::repeated_svalue (symbol::id_t id, +repeated_svalue::repeated_svalue (symbolic::node::id_t id, tree type, const svalue *outer_size, const svalue *inner_svalue) @@ -2031,14 +2031,14 @@ bits_within_svalue::key_t::operator< (const key_t &other) const return c < 0; if (int c = bit_range::cmp (m_bits, other.m_bits)) return c < 0; - if (int c = symbol::cmp_ids (m_inner_svalue, other.m_inner_svalue)) + if (int c = symbolic::node::cmp_ids (m_inner_svalue, other.m_inner_svalue)) return c < 0; return false; } /* bits_within_svalue'c ctor. */ -bits_within_svalue::bits_within_svalue (symbol::id_t id, +bits_within_svalue::bits_within_svalue (symbolic::node::id_t id, tree type, const bit_range &bits, const svalue *inner_svalue) @@ -2148,9 +2148,9 @@ widening_svalue::key_t::operator< (const key_t &other) const return c < 0; if (int c = m_snode->m_id - other.m_snode->m_id) return c < 0; - if (int c = symbol::cmp_ids (m_base_sval, other.m_base_sval)) + if (int c = symbolic::node::cmp_ids (m_base_sval, other.m_base_sval)) return c < 0; - if (int c = symbol::cmp_ids (m_iter_sval, other.m_iter_sval)) + if (int c = symbolic::node::cmp_ids (m_iter_sval, other.m_iter_sval)) return c < 0; return false; } @@ -2444,7 +2444,7 @@ compound_svalue::key_t::operator< (const key_t &other) const return false; } -compound_svalue::compound_svalue (symbol::id_t id, +compound_svalue::compound_svalue (symbolic::node::id_t id, tree type, concrete_binding_map &&map) : svalue (map.calc_complexity (), id, type), m_map (std::move (map)) @@ -2459,7 +2459,7 @@ compound_svalue::compound_svalue (symbol::id_t id, #endif } -compound_svalue::compound_svalue (symbol::id_t id, +compound_svalue::compound_svalue (symbolic::node::id_t id, tree type, const concrete_binding_map &map) : svalue (map.calc_complexity (), id, type), m_map (map) @@ -2604,7 +2604,7 @@ conjured_svalue::key_t::operator< (const key_t &other) const return c < 0; if (int c = m_stmt->uid - other.m_stmt->uid) return c < 0; - if (int c = symbol::cmp_ids (m_id_reg, other.m_id_reg)) + if (int c = symbolic::node::cmp_ids (m_id_reg, other.m_id_reg)) return c < 0; if (int c = m_idx == other.m_idx) return c < 0; @@ -2697,7 +2697,7 @@ asm_output_svalue::key_t::operator< (const key_t &other) const if (int c = (int)m_num_inputs - (int)other.m_num_inputs) return c < 0; for (unsigned i = 0; i < m_num_inputs; i++) - if (int c = symbol::cmp_ids (m_input_arr[i], other.m_input_arr[i])) + if (int c = symbolic::node::cmp_ids (m_input_arr[i], other.m_input_arr[i])) return c < 0; return false; } @@ -2806,7 +2806,7 @@ const_fn_result_svalue::key_t::operator< (const key_t &other) const if (int c = (int)m_num_inputs - (int)other.m_num_inputs) return c < 0; for (unsigned i = 0; i < m_num_inputs; i++) - if (int c = symbol::cmp_ids (m_input_arr[i], other.m_input_arr[i])) + if (int c = symbolic::node::cmp_ids (m_input_arr[i], other.m_input_arr[i])) return c < 0; return false; } diff --git a/gcc/analyzer/svalue.h b/gcc/analyzer/svalue.h index 9322ae90b1f4..a5f1b1e9f4c5 100644 --- a/gcc/analyzer/svalue.h +++ b/gcc/analyzer/svalue.h @@ -21,7 +21,7 @@ along with GCC; see the file COPYING3. If not see #ifndef GCC_ANALYZER_SVALUE_H #define GCC_ANALYZER_SVALUE_H -#include "analyzer/symbol.h" +#include "analyzer/symbolic-nodes.h" #include "analyzer/store.h" #include "analyzer/program-point.h" #include "text-art/widget.h" @@ -88,7 +88,7 @@ enum svalue_kind /* An abstract base class representing a value held by a region of memory. */ -class svalue : public symbol +class svalue : public symbolic::node { public: virtual ~svalue () {} @@ -204,8 +204,8 @@ public: } protected: - svalue (complexity c, symbol::id_t id, tree type) - : symbol (c, id), m_type (type) + svalue (complexity c, symbolic::node::id_t id, tree type) + : symbolic::node (c, id), m_type (type) {} void print_svalue_node_label (pretty_printer *pp) const; @@ -245,7 +245,7 @@ public: const region *m_reg; }; - region_svalue (symbol::id_t id, tree type, const region *reg) + region_svalue (symbolic::node::id_t id, tree type, const region *reg) : svalue (complexity (reg), id, type), m_reg (reg) { @@ -316,7 +316,7 @@ public: tree m_cst; }; - constant_svalue (symbol::id_t id, tree type, tree cst_expr) + constant_svalue (symbolic::node::id_t id, tree type, tree cst_expr) : svalue (complexity (1, 1), id, type), m_cst_expr (cst_expr) { @@ -379,7 +379,7 @@ namespace ana { class unknown_svalue : public svalue { public: - unknown_svalue (symbol::id_t id, tree type) + unknown_svalue (symbolic::node::id_t id, tree type) : svalue (complexity (1, 1), id, type) {} @@ -456,7 +456,7 @@ public: tree m_type; }; - poisoned_svalue (enum poison_kind kind, symbol::id_t id, tree type) + poisoned_svalue (enum poison_kind kind, symbolic::node::id_t id, tree type) : svalue (complexity (1, 1), id, type), m_kind (kind) {} enum svalue_kind get_kind () const final override { return SK_POISONED; } @@ -551,7 +551,7 @@ public: }; setjmp_svalue (const setjmp_record &setjmp_record, - symbol::id_t id, + symbolic::node::id_t id, tree type) : svalue (complexity (1, 1), id, type), m_setjmp_record (setjmp_record) {} @@ -601,7 +601,7 @@ namespace ana { class initial_svalue : public svalue { public: - initial_svalue (symbol::id_t id, tree type, const region *reg) + initial_svalue (symbolic::node::id_t id, tree type, const region *reg) : svalue (complexity (reg), id, type), m_reg (reg) { gcc_assert (m_reg != nullptr); @@ -669,7 +669,7 @@ public: const svalue *m_arg; }; - unaryop_svalue (symbol::id_t id, tree type, enum tree_code op, + unaryop_svalue (symbolic::node::id_t id, tree type, enum tree_code op, const svalue *arg) : svalue (complexity (arg), id, type), m_op (op), m_arg (arg) { @@ -748,7 +748,7 @@ public: const svalue *m_arg1; }; - binop_svalue (symbol::id_t id, tree type, enum tree_code op, + binop_svalue (symbolic::node::id_t id, tree type, enum tree_code op, const svalue *arg0, const svalue *arg1) : svalue (complexity::from_pair (arg0->get_complexity (), arg1->get_complexity ()), @@ -828,7 +828,7 @@ public: const svalue *m_parent_svalue; const region *m_subregion; }; - sub_svalue (symbol::id_t id, tree type, const svalue *parent_svalue, + sub_svalue (symbolic::node::id_t id, tree type, const svalue *parent_svalue, const region *subregion); enum svalue_kind get_kind () const final override { return SK_SUB; } @@ -897,7 +897,7 @@ public: const svalue *m_outer_size; const svalue *m_inner_svalue; }; - repeated_svalue (symbol::id_t id, + repeated_svalue (symbolic::node::id_t id, tree type, const svalue *outer_size, const svalue *inner_svalue); @@ -974,7 +974,7 @@ public: bit_range m_bits; const svalue *m_inner_svalue; }; - bits_within_svalue (symbol::id_t id, + bits_within_svalue (symbolic::node::id_t id, tree type, const bit_range &bits, const svalue *inner_svalue); @@ -1037,7 +1037,7 @@ namespace ana { class unmergeable_svalue : public svalue { public: - unmergeable_svalue (symbol::id_t id, const svalue *arg) + unmergeable_svalue (symbolic::node::id_t id, const svalue *arg) : svalue (complexity (arg), id, arg->get_type ()), m_arg (arg) { } @@ -1084,7 +1084,7 @@ namespace ana { class placeholder_svalue : public svalue { public: - placeholder_svalue (symbol::id_t id, tree type, const char *name) + placeholder_svalue (symbolic::node::id_t id, tree type, const char *name) : svalue (complexity (1, 1), id, type), m_name (name) { } @@ -1163,7 +1163,7 @@ public: DIR_UNKNOWN }; - widening_svalue (symbol::id_t id, tree type, const supernode *snode, + widening_svalue (symbolic::node::id_t id, tree type, const supernode *snode, const svalue *base_sval, const svalue *iter_sval) : svalue (complexity::from_pair (base_sval->get_complexity (), iter_sval->get_complexity ()), @@ -1257,8 +1257,8 @@ public: const concrete_binding_map *m_map_ptr; }; - compound_svalue (symbol::id_t id, tree type, concrete_binding_map &&map); - compound_svalue (symbol::id_t id, tree type, const concrete_binding_map &map); + compound_svalue (symbolic::node::id_t id, tree type, concrete_binding_map &&map); + compound_svalue (symbolic::node::id_t id, tree type, const concrete_binding_map &map); enum svalue_kind get_kind () const final override { return SK_COMPOUND; } const compound_svalue *dyn_cast_compound_svalue () const final override @@ -1373,7 +1373,7 @@ public: unsigned m_idx; }; - conjured_svalue (symbol::id_t id, tree type, const gimple *stmt, + conjured_svalue (symbolic::node::id_t id, tree type, const gimple *stmt, const region *id_reg, unsigned idx) : svalue (complexity (id_reg), id, type), m_stmt (stmt), m_id_reg (id_reg), m_idx (idx) @@ -1469,7 +1469,7 @@ public: const svalue *m_input_arr[MAX_INPUTS]; }; - asm_output_svalue (symbol::id_t id, + asm_output_svalue (symbolic::node::id_t id, tree type, const char *asm_string, unsigned output_idx, @@ -1586,7 +1586,7 @@ public: const svalue *m_input_arr[MAX_INPUTS]; }; - const_fn_result_svalue (symbol::id_t id, + const_fn_result_svalue (symbolic::node::id_t id, tree type, tree fndecl, const vec<const svalue *> &inputs) diff --git a/gcc/analyzer/symbol.cc b/gcc/analyzer/symbolic-nodes.cc similarity index 82% rename from gcc/analyzer/symbol.cc rename to gcc/analyzer/symbolic-nodes.cc index 63419fdcd285..2c45feb5144b 100644 --- a/gcc/analyzer/symbol.cc +++ b/gcc/analyzer/symbolic-nodes.cc @@ -20,18 +20,18 @@ along with GCC; see the file COPYING3. If not see #include "analyzer/common.h" -#include "analyzer/symbol.h" +#include "analyzer/symbolic-nodes.h" #if ENABLE_ANALYZER namespace ana { -/* Compare SYM1 and SYM2 by id. */ +/* Compare N1 and N2 by id. */ int -symbol::cmp_ids (const symbol *sym1, const symbol *sym2) +symbolic::node::cmp_ids (const symbolic::node *n1, const symbolic::node *n2) { - return (long)sym1->get_id () - (long)sym2->get_id (); + return (long)n1->get_id () - (long)n2->get_id (); } } // namespace ana diff --git a/gcc/analyzer/symbol.h b/gcc/analyzer/symbolic-nodes.h similarity index 63% rename from gcc/analyzer/symbol.h rename to gcc/analyzer/symbolic-nodes.h index 2a209e49f5b8..990d7c6cb6ac 100644 --- a/gcc/analyzer/symbol.h +++ b/gcc/analyzer/symbolic-nodes.h @@ -18,27 +18,36 @@ You should have received a copy of the GNU General Public License along with GCC; see the file COPYING3. If not see <http://www.gnu.org/licenses/>. */ -#ifndef GCC_ANALYZER_SYMBOL_H -#define GCC_ANALYZER_SYMBOL_H +#ifndef GCC_ANALYZER_SYMBOLIC_NODES_H +#define GCC_ANALYZER_SYMBOLIC_NODES_H #include "analyzer/complexity.h" namespace ana { +namespace symbolic { -/* Base class for svalues and regions: has a complexity and a numeric ID. */ +/* Abstract base class for the various tree-like purely-functional + data structures we use during symbolic execution. -class symbol + Instances are owned by a manager and reused, with memoization/caching + (compare to "hash consing" and value numbering). + + Instances have a complexity and a numeric ID. */ + +class node { public: - typedef unsigned id_t; + using id_t = unsigned; + + virtual ~node () = default; const complexity &get_complexity () const { return m_complexity; } id_t get_id () const { return m_id; } - static int cmp_ids (const symbol *s1, const symbol *s2); + static int cmp_ids (const symbolic::node *s1, const symbolic::node *s2); protected: - symbol (complexity c, unsigned id) + node (complexity c, unsigned id) : m_complexity (c), m_id (id) {} @@ -48,6 +57,8 @@ class symbol id_t m_id; // for deterministic sorting at this stage, for dumps }; +} // namespace symbolic + } // namespace ana -#endif /* GCC_ANALYZER_SYMBOL_H */ +#endif /* GCC_ANALYZER_SYMBOLIC_NODES_H */
