diff options
author | David Malcolm <dmalcolm@redhat.com> | 2021-03-26 13:26:15 -0400 |
---|---|---|
committer | David Malcolm <dmalcolm@redhat.com> | 2021-03-30 17:51:21 -0400 |
commit | 0f9aa35c79a0fe195d5076375b5794246cf44819 (patch) | |
tree | b6811f24977b7776b2a2077116ab64242e1ffd85 /gcc/analyzer/sm-file.cc | |
parent | a01f5fd71031bb34fd9d2792e6ec42d982c68a8e (diff) | |
download | gcc-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-file.cc')
-rw-r--r-- | gcc/analyzer/sm-file.cc | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/gcc/analyzer/sm-file.cc b/gcc/analyzer/sm-file.cc index 7a81c8f..d64c313 100644 --- a/gcc/analyzer/sm-file.cc +++ b/gcc/analyzer/sm-file.cc @@ -344,7 +344,6 @@ fileptr_state_machine::on_stmt (sm_context *sm_ctxt, if (is_named_call_p (callee_fndecl, "fclose", call, 1)) { tree arg = gimple_call_arg (call, 0); - tree diag_arg = sm_ctxt->get_diagnostic_tree (arg); sm_ctxt->on_transition (node, stmt, arg, m_start, m_closed); @@ -356,6 +355,7 @@ fileptr_state_machine::on_stmt (sm_context *sm_ctxt, if (sm_ctxt->get_state (stmt, arg) == m_closed) { + tree diag_arg = sm_ctxt->get_diagnostic_tree (arg); sm_ctxt->warn (node, stmt, arg, new double_fclose (*this, diag_arg)); sm_ctxt->set_next_state (stmt, arg, m_stop); |