[analyzer] Make checker silencing work for non-pathsensitive bug reports
authorKirstóf Umann <dkszelethus@gmail.com>
Fri, 21 May 2021 12:02:03 +0000 (14:02 +0200)
committerKristóf Umann <dkszelethus@gmail.com>
Thu, 17 Jun 2021 08:27:34 +0000 (10:27 +0200)
commit9cca5c1391d637b5500ada646cf136ddb38254a3
tree536cf42e199c731a55cab2125deb2ff81960150b
parenta4f81b2054c30954c6739532b923f2b223bc7d77
[analyzer] Make checker silencing work for non-pathsensitive bug reports

D66572 separated BugReport and BugReporter into basic and path sensitive
versions. As a result, checker silencing, which worked deep in the path
sensitive report generation facilities became specific to it. DeadStoresChecker,
for instance, despite being in the static analyzer, emits non-pathsensitive
reports, and was impossible to silence.

This patch moves the corresponding code before the call to the virtual function
generateDiagnosticForConsumerMap (which is overriden by the specific kinds of
bug reporters). Although we see bug reporting as relatively lightweight compared
to the analysis, this will get rid of several steps we used to throw away.

Quoting from D65379:

At a very high level, this consists of 3 steps:

For all BugReports in the same BugReportEquivClass, collect all their error
nodes in a set. With that set, create a new, trimmed ExplodedGraph whose leafs
are all error nodes.
Until a valid report is found, construct a bug path, which is yet another
ExplodedGraph, that is linear from a given error node to the root of the graph.
Run all visitors on the constructed bug path. If in this process the report got
invalidated, start over from step 2.
Checker silencing used to kick in after all of these. Now it does before any of
them :^)

Differential Revision: https://reviews.llvm.org/D102914

Change-Id: Ice42939304516f2bebd05a1ea19878b89c96a25d
clang/lib/StaticAnalyzer/Core/BugReporter.cpp
clang/test/Analysis/silence-checkers.cpp [moved from clang/test/Analysis/silence-checkers-malloc.cpp with 81% similarity]