From c710051affd51ac630072ac0cd2c232c0bf2c265 Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Fri, 23 Oct 2020 17:21:51 +0200 Subject: [PATCH] analyzer: remove dead code gcc/analyzer/ChangeLog: * constraint-manager.cc (constraint_manager::merge): Remove unused code. * constraint-manager.h: Likewise. * program-state.cc (sm_state_map::sm_state_map): Likewise. (program_state::program_state): Likewise. (test_sm_state_map): Likewise. * program-state.h: Likewise. * region-model-reachability.cc (reachable_regions::reachable_regions): Likewise. * region-model-reachability.h: Likewise. * region-model.cc (region_model::handle_unrecognized_call): Likewise. (region_model::get_reachable_svalues): Likewise. (region_model::can_merge_with_p): Likewise. --- gcc/analyzer/constraint-manager.cc | 11 ++++------- gcc/analyzer/constraint-manager.h | 3 +-- gcc/analyzer/program-state.cc | 22 +++++++++++----------- gcc/analyzer/program-state.h | 3 +-- gcc/analyzer/region-model-reachability.cc | 5 ++--- gcc/analyzer/region-model-reachability.h | 3 +-- gcc/analyzer/region-model.cc | 7 +++---- 7 files changed, 23 insertions(+), 31 deletions(-) diff --git a/gcc/analyzer/constraint-manager.cc b/gcc/analyzer/constraint-manager.cc index 2978f1b212d..590bf322563 100644 --- a/gcc/analyzer/constraint-manager.cc +++ b/gcc/analyzer/constraint-manager.cc @@ -1790,9 +1790,8 @@ class merger_fact_visitor : public fact_visitor { public: merger_fact_visitor (const constraint_manager *cm_b, - constraint_manager *out, - const model_merger &merger) - : m_cm_b (cm_b), m_out (out), m_merger (merger) + constraint_manager *out) + : m_cm_b (cm_b), m_out (out) {} void on_fact (const svalue *lhs, enum tree_code code, const svalue *rhs) @@ -1826,7 +1825,6 @@ public: private: const constraint_manager *m_cm_b; constraint_manager *m_out; - const model_merger &m_merger; }; /* Use MERGER to merge CM_A and CM_B into *OUT. @@ -1838,14 +1836,13 @@ private: void constraint_manager::merge (const constraint_manager &cm_a, const constraint_manager &cm_b, - constraint_manager *out, - const model_merger &merger) + constraint_manager *out) { /* Merge the equivalence classes and constraints. The easiest way to do this seems to be to enumerate all of the facts in cm_a, see which are also true in cm_b, and add those to *OUT. */ - merger_fact_visitor v (&cm_b, out, merger); + merger_fact_visitor v (&cm_b, out); cm_a.for_each_fact (&v); } diff --git a/gcc/analyzer/constraint-manager.h b/gcc/analyzer/constraint-manager.h index 98960ffad84..1142b1f06e6 100644 --- a/gcc/analyzer/constraint-manager.h +++ b/gcc/analyzer/constraint-manager.h @@ -274,8 +274,7 @@ public: static void merge (const constraint_manager &cm_a, const constraint_manager &cm_b, - constraint_manager *out, - const model_merger &merger); + constraint_manager *out); void for_each_fact (fact_visitor *) const; diff --git a/gcc/analyzer/program-state.cc b/gcc/analyzer/program-state.cc index b39e55a1a1e..5c59c096d0c 100644 --- a/gcc/analyzer/program-state.cc +++ b/gcc/analyzer/program-state.cc @@ -154,8 +154,8 @@ sm_state_map::entry_t::cmp (const entry_t &entry_a, const entry_t &entry_b) /* sm_state_map's ctor. */ -sm_state_map::sm_state_map (const state_machine &sm, int sm_idx) -: m_sm (sm), m_sm_idx (sm_idx), m_map (), m_global_state (sm.get_start_state ()) +sm_state_map::sm_state_map (const state_machine &sm) +: m_sm (sm), m_map (), m_global_state (sm.get_start_state ()) { } @@ -656,7 +656,7 @@ program_state::program_state (const extrinsic_state &ext_state) const int num_states = ext_state.get_num_checkers (); for (int i = 0; i < num_states; i++) { - sm_state_map *sm = new sm_state_map (ext_state.get_sm (i), i); + sm_state_map *sm = new sm_state_map (ext_state.get_sm (i)); m_checker_states.quick_push (sm); } } @@ -1251,7 +1251,7 @@ test_sm_state_map () const svalue *y_sval = model.get_rvalue (y, NULL); const svalue *z_sval = model.get_rvalue (z, NULL); - sm_state_map map (*sm, 0); + sm_state_map map (*sm); ASSERT_TRUE (map.is_empty_p ()); ASSERT_EQ (map.get_state (x_sval, ext_state), start); @@ -1280,7 +1280,7 @@ test_sm_state_map () const svalue *y_sval = model.get_rvalue (y, NULL); const svalue *z_sval = model.get_rvalue (z, NULL); - sm_state_map map (*sm, 0); + sm_state_map map (*sm); ASSERT_TRUE (map.is_empty_p ()); ASSERT_EQ (map.get_state (x_sval, ext_state), start); ASSERT_EQ (map.get_state (y_sval, ext_state), start); @@ -1303,9 +1303,9 @@ test_sm_state_map () const svalue *y_sval = model.get_rvalue (y, NULL); const svalue *z_sval = model.get_rvalue (z, NULL); - sm_state_map map0 (*sm, 0); - sm_state_map map1 (*sm, 0); - sm_state_map map2 (*sm, 0); + sm_state_map map0 (*sm); + sm_state_map map1 (*sm); + sm_state_map map2 (*sm); ASSERT_EQ (map0.hash (), map1.hash ()); ASSERT_EQ (map0, map1); @@ -1326,9 +1326,9 @@ test_sm_state_map () const state_machine::state_t TEST_STATE_2 = &test_state_2; const state_machine::state test_state_3 ("test state 3", 3); const state_machine::state_t TEST_STATE_3 = &test_state_3; - sm_state_map map0 (*sm, 0); - sm_state_map map1 (*sm, 0); - sm_state_map map2 (*sm, 0); + sm_state_map map0 (*sm); + sm_state_map map1 (*sm); + sm_state_map map2 (*sm); ASSERT_EQ (map0.hash (), map1.hash ()); ASSERT_EQ (map0, map1); diff --git a/gcc/analyzer/program-state.h b/gcc/analyzer/program-state.h index c44fc948864..1532210f6e0 100644 --- a/gcc/analyzer/program-state.h +++ b/gcc/analyzer/program-state.h @@ -104,7 +104,7 @@ public: typedef hash_map map_t; typedef map_t::iterator iterator_t; - sm_state_map (const state_machine &sm, int m_sm_idx); + sm_state_map (const state_machine &sm); sm_state_map *clone () const; @@ -168,7 +168,6 @@ public: private: const state_machine &m_sm; - int m_sm_idx; map_t m_map; state_machine::state_t m_global_state; }; diff --git a/gcc/analyzer/region-model-reachability.cc b/gcc/analyzer/region-model-reachability.cc index 7fd89052737..9fc70d29daa 100644 --- a/gcc/analyzer/region-model-reachability.cc +++ b/gcc/analyzer/region-model-reachability.cc @@ -58,9 +58,8 @@ along with GCC; see the file COPYING3. If not see namespace ana { -reachable_regions::reachable_regions (region_model *model, - region_model_manager *mgr) -: m_model (model), m_store (model->get_store ()), m_mgr (mgr), +reachable_regions::reachable_regions (region_model *model) +: m_model (model), m_store (model->get_store ()), m_reachable_base_regs (), m_mutable_base_regs () { } diff --git a/gcc/analyzer/region-model-reachability.h b/gcc/analyzer/region-model-reachability.h index fe305b0ce78..4d30c1fdd1d 100644 --- a/gcc/analyzer/region-model-reachability.h +++ b/gcc/analyzer/region-model-reachability.h @@ -35,7 +35,7 @@ namespace ana { class reachable_regions { public: - reachable_regions (region_model *model, region_model_manager *mgr); + reachable_regions (region_model *model); /* Callback called for each cluster when initializing this object. */ static void init_cluster_cb (const region *base_reg, @@ -97,7 +97,6 @@ public: private: region_model *m_model; store *m_store; - region_model_manager *m_mgr; /* The base regions already seen. */ hash_set m_reachable_base_regs; diff --git a/gcc/analyzer/region-model.cc b/gcc/analyzer/region-model.cc index e5f027b6059..d30047b279d 100644 --- a/gcc/analyzer/region-model.cc +++ b/gcc/analyzer/region-model.cc @@ -836,7 +836,7 @@ region_model::handle_unrecognized_call (const gcall *call, { tree fndecl = get_fndecl_for_call (call, ctxt); - reachable_regions reachable_regs (this, m_mgr); + reachable_regions reachable_regs (this); /* Determine the reachable regions and their mutability. */ { @@ -904,7 +904,7 @@ void region_model::get_reachable_svalues (svalue_set *out, const svalue *extra_sval) { - reachable_regions reachable_regs (this, m_mgr); + reachable_regions reachable_regs (this); /* Add globals and regions that already escaped in previous unknown calls. */ @@ -2857,8 +2857,7 @@ region_model::can_merge_with_p (const region_model &other_model, /* Merge constraints. */ constraint_manager::merge (*m_constraints, *other_model.m_constraints, - out_model->m_constraints, - m); + out_model->m_constraints); return true; } -- 2.30.2