]> gcc.gnu.org Git - gcc.git/commit
analyzer: fix further overzealous state purging [PR108733]
authorDavid Malcolm <dmalcolm@redhat.com>
Thu, 9 Feb 2023 22:09:51 +0000 (17:09 -0500)
committerDavid Malcolm <dmalcolm@redhat.com>
Thu, 9 Feb 2023 22:09:51 +0000 (17:09 -0500)
commit125b57aa67400388a496c2c0c40d9c8c55e0c94a
treedfc35cfe81c72d775fcc456d2f37bf9495627eb0
parent10827a92f1a8c3207b327515f77845b34c1d9512
analyzer: fix further overzealous state purging [PR108733]

PR analyzer/108733 reports various false positives in qemu from
-Wanalyzer-use-of-uninitialized-value with __attribute__((cleanup))
at -O1 and above.

Root cause is that the state-purging code was failing to treat:
   _25 = MEM[(void * *)&val];
as a usage of "val", leading to it erroneously purging the
initialization of "val" along an execution path that didn't otherwise
use "val", apart from the  __attribute__((cleanup)).

Fixed thusly.

Integration testing on the patch show this change in the number of
diagnostics:
  -Wanalyzer-use-of-uninitialized-value
       coreutils-9.1: 18 -> 16 (-2)
          qemu-7.2.0: 87 -> 80 (-7)
where all that I investigated appear to have been false positives, hence
an improvement.

gcc/analyzer/ChangeLog:
PR analyzer/108733
* state-purge.cc (get_candidate_for_purging): Add ADDR_EXPR
and MEM_REF.

gcc/testsuite/ChangeLog:
PR analyzer/108733
* gcc.dg/analyzer/torture/uninit-pr108733.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
gcc/analyzer/state-purge.cc
gcc/testsuite/gcc.dg/analyzer/torture/uninit-pr108733.c [new file with mode: 0644]
This page took 0.064864 seconds and 5 git commands to generate.