aboutsummaryrefslogtreecommitdiff
path: root/gcc/analyzer/sm-sensitive.cc
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2021-03-26 13:26:15 -0400
committerDavid Malcolm <dmalcolm@redhat.com>2021-03-30 17:51:21 -0400
commit0f9aa35c79a0fe195d5076375b5794246cf44819 (patch)
treeb6811f24977b7776b2a2077116ab64242e1ffd85 /gcc/analyzer/sm-sensitive.cc
parenta01f5fd71031bb34fd9d2792e6ec42d982c68a8e (diff)
downloadgcc-0f9aa35c79a0fe195d5076375b5794246cf44819.zip
gcc-0f9aa35c79a0fe195d5076375b5794246cf44819.tar.gz
gcc-0f9aa35c79a0fe195d5076375b5794246cf44819.tar.bz2
analyzer: only call get_diagnostic_tree when it's needed
impl_sm_context::get_diagnostic_tree could be expensive, and I find myself needing to put a breakpoint on it to debug PR analyzer/99771, so only call it if we're about to use the result. gcc/analyzer/ChangeLog: * sm-file.cc (fileptr_state_machine::on_stmt): Only call get_diagnostic_tree if the result will be used. * sm-malloc.cc (malloc_state_machine::on_stmt): Likewise. (malloc_state_machine::on_deallocator_call): Likewise. (malloc_state_machine::on_realloc_call): Likewise. (malloc_state_machine::on_realloc_call): Likewise. * sm-sensitive.cc (sensitive_state_machine::warn_for_any_exposure): Likewise. * sm-taint.cc (taint_state_machine::on_stmt): Likewise.
Diffstat (limited to 'gcc/analyzer/sm-sensitive.cc')
-rw-r--r--gcc/analyzer/sm-sensitive.cc8
1 files changed, 5 insertions, 3 deletions
diff --git a/gcc/analyzer/sm-sensitive.cc b/gcc/analyzer/sm-sensitive.cc
index 95172f0..9703f7e 100644
--- a/gcc/analyzer/sm-sensitive.cc
+++ b/gcc/analyzer/sm-sensitive.cc
@@ -174,10 +174,12 @@ sensitive_state_machine::warn_for_any_exposure (sm_context *sm_ctxt,
const gimple *stmt,
tree arg) const
{
- tree diag_arg = sm_ctxt->get_diagnostic_tree (arg);
if (sm_ctxt->get_state (stmt, arg) == m_sensitive)
- sm_ctxt->warn (node, stmt, arg,
- new exposure_through_output_file (*this, diag_arg));
+ {
+ tree diag_arg = sm_ctxt->get_diagnostic_tree (arg);
+ sm_ctxt->warn (node, stmt, arg,
+ new exposure_through_output_file (*this, diag_arg));
+ }
}
/* Implementation of state_machine::on_stmt vfunc for