vsavchenko updated this revision to Diff 351110. vsavchenko added a comment.
Rebase Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D103677/new/ https://reviews.llvm.org/D103677 Files: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp Index: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp =================================================================== --- clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp +++ clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp @@ -2090,17 +2090,14 @@ } }; -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 @@ -2108,14 +2105,31 @@ // 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 {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. @@ -2295,7 +2309,8 @@ Tracker::Tracker(PathSensitiveBugReport &Report) : Report(Report) { // Default expression handlers. - addHighPriorityHandler<DefaultExpressionHandler>(); + addLowPriorityHandler<ControlDependencyHandler>(); + addLowPriorityHandler<DefaultExpressionHandler>(); addLowPriorityHandler<RValueHandler>(); // Default store handlers. addHighPriorityHandler<DefaultStoreHandler>();
Index: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp =================================================================== --- clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp +++ clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp @@ -2090,17 +2090,14 @@ } }; -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 @@ -2108,14 +2105,31 @@ // 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 {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. @@ -2295,7 +2309,8 @@ Tracker::Tracker(PathSensitiveBugReport &Report) : Report(Report) { // Default expression handlers. - addHighPriorityHandler<DefaultExpressionHandler>(); + addLowPriorityHandler<ControlDependencyHandler>(); + addLowPriorityHandler<DefaultExpressionHandler>(); addLowPriorityHandler<RValueHandler>(); // Default store handlers. addHighPriorityHandler<DefaultStoreHandler>();
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits