aboutsummaryrefslogtreecommitdiff
path: root/gcc/coverage.h
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2023-03-10 08:20:10 -0500
committerDavid Malcolm <dmalcolm@redhat.com>2023-03-10 08:20:10 -0500
commitc4fd232f9843bb800548a906653aeb0723cdb411 (patch)
treedb0e039b56a6a1ad65bae0d864e068ead3e8f186 /gcc/coverage.h
parent44f80a370b76fd1564e280f08d6640d0f641d487 (diff)
downloadgcc-c4fd232f9843bb800548a906653aeb0723cdb411.zip
gcc-c4fd232f9843bb800548a906653aeb0723cdb411.tar.gz
gcc-c4fd232f9843bb800548a906653aeb0723cdb411.tar.bz2
analyzer: fix deref-before-check false +ves seen in haproxy [PR108475,PR109060]
Integration testing showed various false positives from -Wanalyzer-deref-before-check where the expression that's dereferenced is different from the one that's checked, but the diagnostic is emitted because they both evaluate to the same symbolic value. This patch rejects such warnings, unless we have tree expressions for both and that both tree expressions are "spelled the same way" i.e. would be printed to the same user-facing string. gcc/analyzer/ChangeLog: PR analyzer/108475 PR analyzer/109060 * sm-malloc.cc (deref_before_check::deref_before_check): Initialize new field m_deref_expr. Assert that arg is non-NULL. (deref_before_check::emit): Reject cases where the spelling of the thing that was dereferenced differs from that of what is checked, or if the dereference expression was not found. Remove code to handle NULL m_arg. (deref_before_check::describe_state_change): Remove code to handle NULL m_arg. (deref_before_check::describe_final_event): Likewise. (deref_before_check::sufficiently_similar_p): New. (deref_before_check::m_deref_expr): New field. (malloc_state_machine::maybe_complain_about_deref_before_check): Don't warn if the diag_ptr is NULL. gcc/testsuite/ChangeLog: PR analyzer/108475 PR analyzer/109060 * gcc.dg/analyzer/deref-before-check-pr108475-1.c: New test. * gcc.dg/analyzer/deref-before-check-pr108475-haproxy-tcpcheck.c: New test. * gcc.dg/analyzer/deref-before-check-pr109060-haproxy-cfgparse.c: New test. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
Diffstat (limited to 'gcc/coverage.h')
0 files changed, 0 insertions, 0 deletions