From deba3572a1469be405751f26cf6ccaacfe28c34b Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Mon, 24 Jun 2019 12:06:13 -0400 Subject: [PATCH 038/108] FIXME: cleanups to sm.h --- gcc/analyzer/impl-2.cc | 3 ++- gcc/analyzer/impl-3.cc | 3 ++- gcc/analyzer/impl-4.cc | 5 +++-- gcc/analyzer/sm.h | 23 +++++++++++------------ 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/gcc/analyzer/impl-2.cc b/gcc/analyzer/impl-2.cc index 23a587b..1f04787 100644 --- a/gcc/analyzer/impl-2.cc +++ b/gcc/analyzer/impl-2.cc @@ -1393,7 +1393,8 @@ public: engine_sm_context (engine *e, const backtrace &b, sm_instance *sm_inst, const sm_instance *old_sm_inst, checker_path *path, path_state *ps) - : m_engine (e), m_backtrace (b), + : sm_context (e->m_sm), + m_engine (e), m_backtrace (b), m_sm_inst (sm_inst), m_old_sm_inst (old_sm_inst), m_path (path), m_ps (ps) {} diff --git a/gcc/analyzer/impl-3.cc b/gcc/analyzer/impl-3.cc index 3d55344..91b79ae 100644 --- a/gcc/analyzer/impl-3.cc +++ b/gcc/analyzer/impl-3.cc @@ -772,7 +772,8 @@ class engine_sm_context : public sm_context { public: engine_sm_context (engine *e, checker3_path *path) - : m_engine (e), m_path (path) + : sm_context (e->m_sm), + m_engine (e), m_path (path) { reset_baseline_states (); } diff --git a/gcc/analyzer/impl-4.cc b/gcc/analyzer/impl-4.cc index 43e7e08..5ff3c04 100644 --- a/gcc/analyzer/impl-4.cc +++ b/gcc/analyzer/impl-4.cc @@ -2459,7 +2459,9 @@ public: sm_state_map *new_smap, stmt_finder *stmt_finder = NULL) - : log_user (eg.get_logger ()), m_eg (eg), m_sm (sm), m_enode (enode), + : sm_context (sm), + log_user (eg.get_logger ()), + m_eg (eg), m_enode (enode), m_new_state (new_state), m_old_smap (old_smap), m_new_smap (new_smap), m_stmt_finder (stmt_finder) @@ -2550,7 +2552,6 @@ public: } exploded_graph &m_eg; - const state_machine &m_sm; const exploded_node *m_enode; program_state *m_new_state; const sm_state_map *m_old_smap; diff --git a/gcc/analyzer/sm.h b/gcc/analyzer/sm.h index 775813a..a6d0122 100644 --- a/gcc/analyzer/sm.h +++ b/gcc/analyzer/sm.h @@ -109,35 +109,34 @@ start_start_p (state_machine::state_t state) class sm_context { public: - // sm_context (const state_machine &sm) : m_sm (sm) {} virtual ~sm_context () {} - // Stuff used by impl 1: - virtual void on_transition (const supernode *node, const gimple *stmt, + /* Called by state_machine in response to pattern matches: + if VAR is in state FROM, transition it to state TO, potentially + recording the "origin" of the state as ORIGIN. + Use NODE and STMT for location information. */ + virtual void on_transition (const supernode *node, const gimple *stmt, tree var, state_machine::state_t from, state_machine::state_t to, tree origin = NULL_TREE) = 0; - // Stuff used by impl 2: - - //virtual state_machine::state_t get_state (tree var) = 0; - //virtual void transition (tree var, state_machine::state_t to) = 0; + /* Called by state_machine in response to pattern matches: + issue a diagnostic D if VAR is in state STATE, using NODE and STMT + for location information. */ virtual void warn_for_state (const supernode *node, const gimple *stmt, tree var, state_machine::state_t state, pending_diagnostic *d) = 0; - // etc, what else? - - // FIXME: - virtual tree get_readable_tree (tree expr) { return expr; } protected: - //const state_machine &m_sm; + sm_context (const state_machine &sm) : m_sm (sm) {} + + const state_machine &m_sm; }; -- 1.8.5.3