[clang] 85f475c - [analyzer] Extract ControlDependencyHandler
Valeriy Savchenko via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 15 01:37:52 PDT 2021
Author: Valeriy Savchenko
Date: 2021-06-15T11:37:36+03:00
New Revision: 85f475c979aa49b1b833c9e66af9cb35eafd02c7
URL: https://github.com/llvm/llvm-project/commit/85f475c979aa49b1b833c9e66af9cb35eafd02c7
DIFF: https://github.com/llvm/llvm-project/commit/85f475c979aa49b1b833c9e66af9cb35eafd02c7.diff
LOG: [analyzer] Extract ControlDependencyHandler
Differential Revision: https://reviews.llvm.org/D103677
Added:
Modified:
clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
Removed:
################################################################################
diff --git a/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp b/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
index 0d0b34d7782a..10b674be4972 100644
--- a/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ b/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -2088,17 +2088,14 @@ class DefaultStoreHandler final : public StoreHandler {
}
};
-class DefaultExpressionHandler final : public ExpressionHandler {
+class ControlDependencyHandler final : public ExpressionHandler {
public:
using ExpressionHandler::ExpressionHandler;
Tracker::Result handle(const Expr *Inner, const ExplodedNode *InputNode,
const ExplodedNode *LVNode,
TrackingOptions Opts) override {
- ProgramStateRef LVState = LVNode->getState();
- const StackFrameContext *SFC = LVNode->getStackFrame();
PathSensitiveBugReport &Report = getParentTracker().getReport();
- Tracker::Result Result;
// We only track expressions if we believe that they are important. Chances
// are good that control dependencies to the tracking point are also
@@ -2106,14 +2103,31 @@ class DefaultExpressionHandler final : public ExpressionHandler {
// this point.
// TODO: Shouldn't we track control dependencies of every bug location,
// rather than only tracked expressions?
- if (LVState->getAnalysisManager()
+ if (LVNode->getState()
+ ->getAnalysisManager()
.getAnalyzerOptions()
.ShouldTrackConditions) {
Report.addVisitor<TrackControlDependencyCondBRVisitor>(
&getParentTracker(), InputNode);
- Result.FoundSomethingToTrack = true;
+ return {/*FoundSomethingToTrack=*/true};
}
+ return {};
+ }
+};
+
+class DefaultExpressionHandler final : public ExpressionHandler {
+public:
+ using ExpressionHandler::ExpressionHandler;
+
+ Tracker::Result handle(const Expr *Inner, const ExplodedNode *InputNode,
+ const ExplodedNode *LVNode,
+ TrackingOptions Opts) override {
+ ProgramStateRef LVState = LVNode->getState();
+ const StackFrameContext *SFC = LVNode->getStackFrame();
+ PathSensitiveBugReport &Report = getParentTracker().getReport();
+ Tracker::Result Result;
+
// The message send could be nil due to the receiver being nil.
// At this point in the path, the receiver should be live since we are at
// the message send expr. If it is nil, start tracking it.
@@ -2293,7 +2307,8 @@ class PRValueHandler final : public ExpressionHandler {
Tracker::Tracker(PathSensitiveBugReport &Report) : Report(Report) {
// Default expression handlers.
- addHighPriorityHandler<DefaultExpressionHandler>();
+ addLowPriorityHandler<ControlDependencyHandler>();
+ addLowPriorityHandler<DefaultExpressionHandler>();
addLowPriorityHandler<PRValueHandler>();
// Default store handlers.
addHighPriorityHandler<DefaultStoreHandler>();
More information about the cfe-commits
mailing list