analyzer: only call get_diagnostic_tree when it's needed
authorDavid Malcolm <dmalcolm@redhat.com>
Fri, 26 Mar 2021 17:26:15 +0000 (13:26 -0400)
committerDavid Malcolm <dmalcolm@redhat.com>
Tue, 30 Mar 2021 21:51:21 +0000 (17:51 -0400)
commit0f9aa35c79a0fe195d5076375b5794246cf44819
treeb6811f24977b7776b2a2077116ab64242e1ffd85
parenta01f5fd71031bb34fd9d2792e6ec42d982c68a8e
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.
gcc/analyzer/sm-file.cc
gcc/analyzer/sm-malloc.cc
gcc/analyzer/sm-sensitive.cc
gcc/analyzer/sm-taint.cc