aboutsummaryrefslogtreecommitdiff
path: root/gcc/analyzer/engine.cc
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2020-08-28 10:10:38 -0400
committerDavid Malcolm <dmalcolm@redhat.com>2020-09-09 16:59:32 -0400
commit25ef215abb1aa701db7ab173b9f2ac653cecf634 (patch)
tree32bb13109b66be13aa99258314770b33ac8f0fde /gcc/analyzer/engine.cc
parent6d9ca8c8604e2e7c2403794baf691b260cc71fb9 (diff)
downloadgcc-25ef215abb1aa701db7ab173b9f2ac653cecf634.zip
gcc-25ef215abb1aa701db7ab173b9f2ac653cecf634.tar.gz
gcc-25ef215abb1aa701db7ab173b9f2ac653cecf634.tar.bz2
analyzer: eliminate sm_context::warn_for_state in favor of a new 'warn' vfunc
This patch is yet more preliminary work towards generalizing sm-malloc.cc beyond just malloc/free. It eliminates sm_context::warn_for_state in terms of a new sm_context::warn vfunc, guarded by sm_context::get_state calls. gcc/analyzer/ChangeLog: * diagnostic-manager.cc (null_assignment_sm_context::warn_for_state): Replace with... (null_assignment_sm_context::warn): ...this. * engine.cc (impl_sm_context::warn_for_state): Replace with... (impl_sm_context::warn): ...this. * sm-file.cc (fileptr_state_machine::on_stmt): Replace warn_for_state and on_transition calls with a get_state test guarding warn and set_next_state calls. * sm-malloc.cc (malloc_state_machine::on_stmt): Likewise. * sm-pattern-test.cc (pattern_test_state_machine::on_condition): Replace warn_for_state call with warn call. * sm-sensitive.cc (sensitive_state_machine::warn_for_any_exposure): Replace warn_for_state call with a get_state test guarding a warn call. * sm-signal.cc (signal_state_machine::on_stmt): Likewise. * sm-taint.cc (taint_state_machine::on_stmt): Replace warn_for_state and on_transition calls with a get_state test guarding warn and set_next_state calls. * sm.h (sm_context::warn_for_state): Replace with... (sm_context::warn): ...this.
Diffstat (limited to 'gcc/analyzer/engine.cc')
-rw-r--r--gcc/analyzer/engine.cc34
1 files changed, 11 insertions, 23 deletions
diff --git a/gcc/analyzer/engine.cc b/gcc/analyzer/engine.cc
index 07b1b15..49701b7 100644
--- a/gcc/analyzer/engine.cc
+++ b/gcc/analyzer/engine.cc
@@ -254,35 +254,23 @@ public:
to, origin_new_sval, m_eg.get_ext_state ());
}
- void warn_for_state (const supernode *snode, const gimple *stmt,
- tree var, state_machine::state_t state,
- pending_diagnostic *d) FINAL OVERRIDE
+ void warn (const supernode *snode, const gimple *stmt,
+ tree var, pending_diagnostic *d) FINAL OVERRIDE
{
LOG_FUNC (get_logger ());
gcc_assert (d); // take ownership
-
impl_region_model_context old_ctxt
(m_eg, m_enode_for_diag, m_old_state, m_new_state, NULL);
- state_machine::state_t current;
- if (var)
- {
- const svalue *var_old_sval
- = m_old_state->m_region_model->get_rvalue (var, &old_ctxt);
- current = m_old_smap->get_state (var_old_sval, m_eg.get_ext_state ());
- }
- else
- current = m_old_smap->get_global_state ();
- if (state == current)
- {
- const svalue *var_old_sval
- = m_old_state->m_region_model->get_rvalue (var, &old_ctxt);
- m_eg.get_diagnostic_manager ().add_diagnostic
- (&m_sm, m_enode_for_diag, snode, stmt, m_stmt_finder,
- var, var_old_sval, state, d);
- }
- else
- delete d;
+ const svalue *var_old_sval
+ = m_old_state->m_region_model->get_rvalue (var, &old_ctxt);
+ state_machine::state_t current
+ = (var
+ ? m_old_smap->get_state (var_old_sval, m_eg.get_ext_state ())
+ : m_old_smap->get_global_state ());
+ m_eg.get_diagnostic_manager ().add_diagnostic
+ (&m_sm, m_enode_for_diag, snode, stmt, m_stmt_finder,
+ var, var_old_sval, current, d);
}
/* Hook for picking more readable trees for SSA names of temporaries,