diff options
author | Kristof Umann <dkszelethus@gmail.com> | 2019-08-21 21:33:25 +0000 |
---|---|---|
committer | Kristof Umann <dkszelethus@gmail.com> | 2019-08-21 21:33:25 +0000 |
commit | a5f916ab4dba511a6d37159cf9184fae6257bc1d (patch) | |
tree | ea77e3ba65e6080e57cc6c2334373f44155ae797 /include/clang/StaticAnalyzer | |
parent | 3b7bea967efe82ca4adee696a9c18eee18b7e6eb (diff) | |
download | clang-a5f916ab4dba511a6d37159cf9184fae6257bc1d.tar.gz |
[analyzer][NFC] Add different interestingness kinds
We defined (on the mailing list and here on phabricator) 2 different cases where
retrieving information about a control dependency condition is very important:
* When the condition's last write happened in a different stack frame
* When the collapse point of the condition (when we can constrain it to be
true/false) didn't happen in the actual condition.
It seems like we solved this problem with the help of expression value tracking,
and have started working on better diagnostics notes about this process.
Expression value tracking is nothing more than registering a variety of visitors
to construct reports about it. Each of the registered visitors (ReturnVisitor,
FindLastStoreVisitor, NoStoreFuncVisitor, etc) have something to go by: a
MemRegion, an SVal, an ExplodedNode, etc. For this reason, better explaining a
last write is super simple, we can always just pass on some more information to
the visitor in question (as seen in D65575).
ConditionBRVisitor is a different beast, as it was built for a different
purpose. It is responsible for constructing events at, well, conditions, and is
registered only once, and isn't a part of the "expression value tracking
family". Unfortunately, it is also the visitor to tinker with for constructing
better diagnostics about the collapse point problem.
This creates a need for alternative way to communicate with ConditionBRVisitor
that a specific condition is being tracked for for the reason of being a control
dependency. Since at almost all PathDiagnosticEventPiece construction the
visitor checks interestingness, it makes sense to pair interestingness with a
reason as to why we marked an entity as such.
Differential Revision: https://reviews.llvm.org/D65723
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@369583 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/StaticAnalyzer')
-rw-r--r-- | include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h b/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h index c786ab3adf..76c282aae4 100644 --- a/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h +++ b/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h @@ -102,14 +102,15 @@ protected: /// diagnostics to include when constructing the final path diagnostic. /// The stack is largely used by BugReporter when generating PathDiagnostics /// for multiple PathDiagnosticConsumers. - llvm::DenseSet<SymbolRef> InterestingSymbols; + llvm::DenseMap<SymbolRef, bugreporter::TrackingKind> InterestingSymbols; /// A (stack of) set of regions that are registered with this report as being /// "interesting", and thus used to help decide which diagnostics /// to include when constructing the final path diagnostic. /// The stack is largely used by BugReporter when generating PathDiagnostics /// for multiple PathDiagnosticConsumers. - llvm::DenseSet<const MemRegion *> InterestingRegions; + llvm::DenseMap<const MemRegion *, bugreporter::TrackingKind> + InterestingRegions; /// A set of location contexts that correspoind to call sites which should be /// considered "interesting". @@ -209,9 +210,24 @@ public: /// Disable all path pruning when generating a PathDiagnostic. void disablePathPruning() { DoNotPrunePath = true; } - void markInteresting(SymbolRef sym); - void markInteresting(const MemRegion *R); - void markInteresting(SVal V); + /// Marks a symbol as interesting. Different kinds of interestingness will + /// be processed differently by visitors (e.g. if the tracking kind is + /// condition, will append "will be used as a condition" to the message). + void markInteresting(SymbolRef sym, bugreporter::TrackingKind TKind = + bugreporter::TrackingKind::Thorough); + + /// Marks a region as interesting. Different kinds of interestingness will + /// be processed differently by visitors (e.g. if the tracking kind is + /// condition, will append "will be used as a condition" to the message). + void markInteresting( + const MemRegion *R, + bugreporter::TrackingKind TKind = bugreporter::TrackingKind::Thorough); + + /// Marks a symbolic value as interesting. Different kinds of interestingness + /// will be processed differently by visitors (e.g. if the tracking kind is + /// condition, will append "will be used as a condition" to the message). + void markInteresting(SVal V, bugreporter::TrackingKind TKind = + bugreporter::TrackingKind::Thorough); void markInteresting(const LocationContext *LC); bool isInteresting(SymbolRef sym) const; @@ -219,6 +235,14 @@ public: bool isInteresting(SVal V) const; bool isInteresting(const LocationContext *LC) const; + Optional<bugreporter::TrackingKind> + getInterestingnessKind(SymbolRef sym) const; + + Optional<bugreporter::TrackingKind> + getInterestingnessKind(const MemRegion *R) const; + + Optional<bugreporter::TrackingKind> getInterestingnessKind(SVal V) const; + /// Returns whether or not this report should be considered valid. /// /// Invalid reports are those that have been classified as likely false |