[clang] 2e49067 - [analyzer] Extract InterestingLValueHandler

Valeriy Savchenko via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 15 01:37:58 PDT 2021


Author: Valeriy Savchenko
Date: 2021-06-15T11:37:36+03:00
New Revision: 2e490676ea2eb419e7b2f54e1e2e537d5244ebbc

URL: https://github.com/llvm/llvm-project/commit/2e490676ea2eb419e7b2f54e1e2e537d5244ebbc
DIFF: https://github.com/llvm/llvm-project/commit/2e490676ea2eb419e7b2f54e1e2e537d5244ebbc.diff

LOG: [analyzer] Extract InterestingLValueHandler

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

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 23f925e49b15..835c54ef5f68 100644
--- a/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ b/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -2151,7 +2151,8 @@ class ArrayIndexHandler final : public ExpressionHandler {
   }
 };
 
-class DefaultExpressionHandler final : public ExpressionHandler {
+// TODO: extract it into more handlers
+class InterestingLValueHandler final : public ExpressionHandler {
 public:
   using ExpressionHandler::ExpressionHandler;
 
@@ -2219,13 +2220,26 @@ class DefaultExpressionHandler final : public ExpressionHandler {
             // previously.
             Report.addVisitor<SuppressInlineDefensiveChecksVisitor>(*DV,
                                                                     InputNode);
-
         getParentTracker().track(V, R, Opts, SFC);
-
-        return Result;
       }
     }
 
+    return Result;
+  }
+};
+
+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;
+
     // If the expression is not an "lvalue expression", we can still
     // track the constraints on its contents.
     SVal V = LVState->getSValAsScalarOrLoc(Inner, LVNode->getLocationContext());
@@ -2332,6 +2346,7 @@ Tracker::Tracker(PathSensitiveBugReport &Report) : Report(Report) {
   addLowPriorityHandler<ControlDependencyHandler>();
   addLowPriorityHandler<NilReceiverHandler>();
   addLowPriorityHandler<ArrayIndexHandler>();
+  addLowPriorityHandler<InterestingLValueHandler>();
   addLowPriorityHandler<DefaultExpressionHandler>();
   addLowPriorityHandler<PRValueHandler>();
   // Default store handlers.


        


More information about the cfe-commits mailing list