From 25ef215abb1aa701db7ab173b9f2ac653cecf634 Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Fri, 28 Aug 2020 10:10:38 -0400 Subject: 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. --- gcc/analyzer/sm-sensitive.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'gcc/analyzer/sm-sensitive.cc') diff --git a/gcc/analyzer/sm-sensitive.cc b/gcc/analyzer/sm-sensitive.cc index f100083..49f9eb3 100644 --- a/gcc/analyzer/sm-sensitive.cc +++ b/gcc/analyzer/sm-sensitive.cc @@ -174,8 +174,9 @@ sensitive_state_machine::warn_for_any_exposure (sm_context *sm_ctxt, tree arg) const { tree diag_arg = sm_ctxt->get_diagnostic_tree (arg); - sm_ctxt->warn_for_state (node, stmt, arg, m_sensitive, - new exposure_through_output_file (*this, diag_arg)); + if (sm_ctxt->get_state (stmt, arg) == m_sensitive) + sm_ctxt->warn (node, stmt, arg, + new exposure_through_output_file (*this, diag_arg)); } /* Implementation of state_machine::on_stmt vfunc for -- cgit v1.1