[PATCH] D51130: [analyzer] [NFC] Minor refactoring of BugReporterVisitors

George Karpenkov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 22 16:17:43 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rC340473: [analyzer] [NFC] Minor refactoring of BugReporterVisitors (authored by george.karpenkov, committed by ).
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D51130?vs=162066&id=162096#toc

Repository:
  rC Clang

https://reviews.llvm.org/D51130

Files:
  lib/StaticAnalyzer/Core/BugReporterVisitors.cpp


Index: lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
===================================================================
--- lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -759,10 +759,14 @@
 
   bool EnableNullFPSuppression;
   bool ShouldInvalidate = true;
+  AnalyzerOptions& Options;
 
 public:
-  ReturnVisitor(const StackFrameContext *Frame, bool Suppressed)
-      : StackFrame(Frame), EnableNullFPSuppression(Suppressed) {}
+  ReturnVisitor(const StackFrameContext *Frame,
+                bool Suppressed,
+                AnalyzerOptions &Options)
+      : StackFrame(Frame), EnableNullFPSuppression(Suppressed),
+        Options(Options) {}
 
   static void *getTag() {
     static int Tag = 0;
@@ -790,10 +794,10 @@
 
     // First, find when we processed the statement.
     do {
-      if (Optional<CallExitEnd> CEE = Node->getLocationAs<CallExitEnd>())
+      if (auto CEE = Node->getLocationAs<CallExitEnd>())
         if (CEE->getCalleeContext()->getCallSite() == S)
           break;
-      if (Optional<StmtPoint> SP = Node->getLocationAs<StmtPoint>())
+      if (auto SP = Node->getLocationAs<StmtPoint>())
         if (SP->getStmt() == S)
           break;
 
@@ -834,13 +838,8 @@
 
     BR.markInteresting(CalleeContext);
     BR.addVisitor(llvm::make_unique<ReturnVisitor>(CalleeContext,
-                                                   EnableNullFPSuppression));
-  }
-
-  /// Returns true if any counter-suppression heuristics are enabled for
-  /// ReturnVisitor.
-  static bool hasCounterSuppression(AnalyzerOptions &Options) {
-    return Options.shouldAvoidSuppressingNullArgumentPaths();
+                                                   EnableNullFPSuppression,
+                                                   Options));
   }
 
   std::shared_ptr<PathDiagnosticPiece>
@@ -909,8 +908,8 @@
       // If we have counter-suppression enabled, make sure we keep visiting
       // future nodes. We want to emit a path note as well, in case
       // the report is resurrected as valid later on.
-      AnalyzerOptions &Options = BRC.getAnalyzerOptions();
-      if (EnableNullFPSuppression && hasCounterSuppression(Options))
+      if (EnableNullFPSuppression &&
+          Options.shouldAvoidSuppressingNullArgumentPaths())
         Mode = MaybeUnsuppress;
 
       if (RetE->getType()->isObjCObjectPointerType())
@@ -947,8 +946,7 @@
   visitNodeMaybeUnsuppress(const ExplodedNode *N, const ExplodedNode *PrevN,
                            BugReporterContext &BRC, BugReport &BR) {
 #ifndef NDEBUG
-    AnalyzerOptions &Options = BRC.getAnalyzerOptions();
-    assert(hasCounterSuppression(Options));
+    assert(Options.shouldAvoidSuppressingNullArgumentPaths());
 #endif
 
     // Are we at the entry node for this call?


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51130.162096.patch
Type: text/x-patch
Size: 2815 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180822/1191ca39/attachment.bin>


More information about the cfe-commits mailing list