]> granicus.if.org Git - clang/commit
[analyzer] De-duplicate path diagnostics for each exploded graph node.
authorArtem Dergachev <artem.dergachev@gmail.com>
Wed, 20 Dec 2017 01:17:53 +0000 (01:17 +0000)
committerArtem Dergachev <artem.dergachev@gmail.com>
Wed, 20 Dec 2017 01:17:53 +0000 (01:17 +0000)
commit3ad7a89220f4dd3d8433659d0d31bb6b49762612
treea790b2dabc498944c49e246a44a0de1f1e9a2bb5
parente955b4474aa27bd68bc1d3e90b7bef394afc9c85
[analyzer] De-duplicate path diagnostics for each exploded graph node.

The bugreporter::trackNullOrUndefValue() mechanism contains a system of bug
reporter visitors that recursively call each other in order to track where a
null or undefined value came from, where each visitor represents a particular
tracking mechanism (track how the value was stored, track how the value was
returned from a function, track how the value was constrained to null, etc.).

Each visitor is only added once per value it needs to track. Almost. One
exception from this rule would be FindLastStoreBRVisitor that has two operation
modes: it contains a flag that indicates whether null stored values should be
suppressed. Two instances of FindLastStoreBRVisitor with different values of
this flag are considered to be different visitors, so they can be added twice
and produce the same diagnostic twice. This was indeed the case in the affected
test.

With the current logic of this whole machinery, such duplication seems
unavoidable. We should be able to safely add visitors with different flag
values without constructing duplicate diagnostic pieces. Hence the effort
in this commit to de-duplicate diagnostics regardless of what visitors
have produced them.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321135 91177308-0d34-0410-b5e6-96231b3b80d8
include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
lib/StaticAnalyzer/Core/BugReporter.cpp
test/Analysis/inlining/path-notes.cpp