vsavchenko updated this revision to Diff 351111.
vsavchenko added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D103902/new/

https://reviews.llvm.org/D103902

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
@@ -2118,24 +2118,35 @@
   }
 };
 
-class DefaultExpressionHandler final : public ExpressionHandler {
+class NilReceiverHandler 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.
     if (const Expr *Receiver =
             NilReceiverBRVisitor::getNilReceiver(Inner, LVNode))
-      Result.combineWith(getParentTracker().track(Receiver, LVNode, Opts));
+      return getParentTracker().track(Receiver, LVNode, Opts);
+
+    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;
 
     // Track the index if this is an array subscript.
     if (const auto *Arr = dyn_cast<ArraySubscriptExpr>(Inner))
@@ -2310,6 +2321,7 @@
 Tracker::Tracker(PathSensitiveBugReport &Report) : Report(Report) {
   // Default expression handlers.
   addLowPriorityHandler<ControlDependencyHandler>();
+  addLowPriorityHandler<NilReceiverHandler>();
   addLowPriorityHandler<DefaultExpressionHandler>();
   addLowPriorityHandler<RValueHandler>();
   // Default store handlers.


Index: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
===================================================================
--- clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -2118,24 +2118,35 @@
   }
 };
 
-class DefaultExpressionHandler final : public ExpressionHandler {
+class NilReceiverHandler 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.
     if (const Expr *Receiver =
             NilReceiverBRVisitor::getNilReceiver(Inner, LVNode))
-      Result.combineWith(getParentTracker().track(Receiver, LVNode, Opts));
+      return getParentTracker().track(Receiver, LVNode, Opts);
+
+    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;
 
     // Track the index if this is an array subscript.
     if (const auto *Arr = dyn_cast<ArraySubscriptExpr>(Inner))
@@ -2310,6 +2321,7 @@
 Tracker::Tracker(PathSensitiveBugReport &Report) : Report(Report) {
   // Default expression handlers.
   addLowPriorityHandler<ControlDependencyHandler>();
+  addLowPriorityHandler<NilReceiverHandler>();
   addLowPriorityHandler<DefaultExpressionHandler>();
   addLowPriorityHandler<RValueHandler>();
   // Default store handlers.
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to