Skip to content
Snippets Groups Projects
Commit aa601e30 authored by David Malcolm's avatar David Malcolm
Browse files

analyzer: don't warn for deref-before-check for checks in macros [PR108745]


Integration testing shows this patch fixes all 9 known false positives
from -Wanalyzer-deref-before-check within ImageMagick-7.1.0-57, and
eliminates 34 further as-yet unassessed such diagnostics, without
eliminating the 1 known true positive.

This improves the rate of true positives for the warning from
1.56% to 4.76% of the total:

-Wanalyzer-deref-before-check: 1.56% -> 4.76% (GOOD: 1 BAD: 63->20)
    TRUE:  1
   FALSE: 15 ->  6 (-9)
             ImageMagick-7.1.0-57:  9 ->  0 (-9)
    TODO: 48 -> 14 (-34)
             ImageMagick-7.1.0-57: 21 ->  1 (-20)
                       qemu-7.2.0: 25 -> 11 (-14)

gcc/analyzer/ChangeLog:
	PR analyzer/108745
	* sm-malloc.cc (deref_before_check::emit): Reject the warning if
	the check occurs within a macro defintion.

gcc/testsuite/ChangeLog:
	PR analyzer/108745
	* gcc.dg/analyzer/deref-before-check-macro-pr108745.c: New test.
	* gcc.dg/analyzer/deref-before-check-macro.c: New test.

Signed-off-by: default avatarDavid Malcolm <dmalcolm@redhat.com>
parent 305037ee
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment