[clang] 87a5c4d - [analyzer] Hide and rename FindLastStoreBRVisitor

Valeriy Savchenko via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 11 02:51:56 PDT 2021


Author: Valeriy Savchenko
Date: 2021-06-11T12:49:03+03:00
New Revision: 87a5c4d3745a06ec0594fa3f7aaf7f58a53315ec

URL: https://github.com/llvm/llvm-project/commit/87a5c4d3745a06ec0594fa3f7aaf7f58a53315ec
DIFF: https://github.com/llvm/llvm-project/commit/87a5c4d3745a06ec0594fa3f7aaf7f58a53315ec.diff

LOG: [analyzer] Hide and rename FindLastStoreBRVisitor

This component should not be used directly at this point and it is
simply an implementation detail, that's why StoreSiteFinder is
out of the header file.

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

Added: 
    

Modified: 
    clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
    clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h b/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
index 4b0d5378e0c13..ba652be33fb52 100644
--- a/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
+++ b/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
@@ -378,50 +378,6 @@ const Expr *getDerefExpr(const Stmt *S);
 
 } // namespace bugreporter
 
-/// Finds last store into the given region,
-/// which is 
diff erent from a given symbolic value.
-class FindLastStoreBRVisitor final
-    : public bugreporter::TrackingBugReporterVisitor {
-  const MemRegion *R;
-  SVal V;
-  bool Satisfied = false;
-
-  /// If the visitor is tracking the value directly responsible for the
-  /// bug, we are going to employ false positive suppression.
-  bool EnableNullFPSuppression;
-
-  using TrackingKind = bugreporter::TrackingKind;
-  TrackingKind TKind;
-  const StackFrameContext *OriginSFC;
-
-public:
-  /// \param V We're searching for the store where \c R received this value.
-  /// \param R The region we're tracking.
-  /// \param TKind May limit the amount of notes added to the bug report.
-  /// \param OriginSFC Only adds notes when the last store happened in a
-  ///        
diff erent stackframe to this one. Disregarded if the tracking kind
-  ///        is thorough.
-  ///        This is useful, because for non-tracked regions, notes about
-  ///        changes to its value in a nested stackframe could be pruned, and
-  ///        this visitor can prevent that without polluting the bugpath too
-  ///        much.
-  FindLastStoreBRVisitor(bugreporter::TrackerRef ParentTracker, KnownSVal V,
-                         const MemRegion *R, bool InEnableNullFPSuppression,
-                         TrackingKind TKind,
-                         const StackFrameContext *OriginSFC = nullptr)
-      : TrackingBugReporterVisitor(ParentTracker), R(R), V(V),
-        EnableNullFPSuppression(InEnableNullFPSuppression), TKind(TKind),
-        OriginSFC(OriginSFC) {
-    assert(R);
-  }
-
-  void Profile(llvm::FoldingSetNodeID &ID) const override;
-
-  PathDiagnosticPieceRef VisitNode(const ExplodedNode *N,
-                                   BugReporterContext &BRC,
-                                   PathSensitiveBugReport &BR) override;
-};
-
 class TrackConstraintBRVisitor final : public BugReporterVisitor {
   DefinedSVal Constraint;
   bool Assumption;

diff  --git a/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp b/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
index ec16a4deae029..af553a2b5903e 100644
--- a/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ b/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -1219,10 +1219,53 @@ class ReturnVisitor : public BugReporterVisitor {
 } // end of anonymous namespace
 
 //===----------------------------------------------------------------------===//
-// Implementation of FindLastStoreBRVisitor.
+//                               StoreSiteFinder
 //===----------------------------------------------------------------------===//
 
-void FindLastStoreBRVisitor::Profile(llvm::FoldingSetNodeID &ID) const {
+/// Finds last store into the given region,
+/// which is 
diff erent from a given symbolic value.
+class StoreSiteFinder final : public TrackingBugReporterVisitor {
+  const MemRegion *R;
+  SVal V;
+  bool Satisfied = false;
+
+  /// If the visitor is tracking the value directly responsible for the
+  /// bug, we are going to employ false positive suppression.
+  bool EnableNullFPSuppression;
+
+  using TrackingKind = bugreporter::TrackingKind;
+  TrackingKind TKind;
+  const StackFrameContext *OriginSFC;
+
+public:
+  /// \param V We're searching for the store where \c R received this value.
+  /// \param R The region we're tracking.
+  /// \param TKind May limit the amount of notes added to the bug report.
+  /// \param OriginSFC Only adds notes when the last store happened in a
+  ///        
diff erent stackframe to this one. Disregarded if the tracking kind
+  ///        is thorough.
+  ///        This is useful, because for non-tracked regions, notes about
+  ///        changes to its value in a nested stackframe could be pruned, and
+  ///        this visitor can prevent that without polluting the bugpath too
+  ///        much.
+  StoreSiteFinder(bugreporter::TrackerRef ParentTracker, KnownSVal V,
+                  const MemRegion *R, bool InEnableNullFPSuppression,
+                  TrackingKind TKind,
+                  const StackFrameContext *OriginSFC = nullptr)
+      : TrackingBugReporterVisitor(ParentTracker), R(R), V(V),
+        EnableNullFPSuppression(InEnableNullFPSuppression), TKind(TKind),
+        OriginSFC(OriginSFC) {
+    assert(R);
+  }
+
+  void Profile(llvm::FoldingSetNodeID &ID) const override;
+
+  PathDiagnosticPieceRef VisitNode(const ExplodedNode *N,
+                                   BugReporterContext &BRC,
+                                   PathSensitiveBugReport &BR) override;
+};
+
+void StoreSiteFinder::Profile(llvm::FoldingSetNodeID &ID) const {
   static int tag = 0;
   ID.AddPointer(&tag);
   ID.AddPointer(R);
@@ -1393,10 +1436,9 @@ static void showBRDefaultDiagnostics(llvm::raw_svector_ostream &os,
   }
 }
 
-PathDiagnosticPieceRef
-FindLastStoreBRVisitor::VisitNode(const ExplodedNode *Succ,
-                                  BugReporterContext &BRC,
-                                  PathSensitiveBugReport &BR) {
+PathDiagnosticPieceRef StoreSiteFinder::VisitNode(const ExplodedNode *Succ,
+                                                  BugReporterContext &BRC,
+                                                  PathSensitiveBugReport &BR) {
   if (Satisfied)
     return nullptr;
 
@@ -2238,7 +2280,7 @@ Tracker::Result Tracker::track(const Expr *E, const ExplodedNode *N,
 Tracker::Result Tracker::track(SVal V, const MemRegion *R, TrackingOptions Opts,
                                const StackFrameContext *Origin) {
   if (auto KV = V.getAs<KnownSVal>()) {
-    Report.addVisitor<FindLastStoreBRVisitor>(
+    Report.addVisitor<StoreSiteFinder>(
         this, *KV, R, Opts.EnableNullFPSuppression, Opts.Kind, Origin);
     return {true};
   }


        


More information about the cfe-commits mailing list