]> granicus.if.org Git - clang/commitdiff
[analyzer][NFC] Refactoring BugReporter.cpp P3.: std::shared_pointer<PathDiagnosticPi...
authorKristof Umann <dkszelethus@gmail.com>
Tue, 13 Aug 2019 16:45:48 +0000 (16:45 +0000)
committerKristof Umann <dkszelethus@gmail.com>
Tue, 13 Aug 2019 16:45:48 +0000 (16:45 +0000)
find clang/ -type f -exec sed -i 's/std::shared_ptr<PathDiagnosticPiece>/PathDiagnosticPieceRef/g' {} \;
git diff -U3 --no-color HEAD^ | clang-format-diff-6.0 -p1 -i

Just as C++ is meant to be refactored, right?

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368717 91177308-0d34-0410-b5e6-96231b3b80d8

24 files changed:
include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
lib/StaticAnalyzer/Checkers/DeleteWithNonVirtualDtorChecker.cpp
lib/StaticAnalyzer/Checkers/DynamicTypeChecker.cpp
lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
lib/StaticAnalyzer/Checkers/InnerPointerChecker.cpp
lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
lib/StaticAnalyzer/Checkers/MPI-Checker/MPIBugReporter.cpp
lib/StaticAnalyzer/Checkers/MPI-Checker/MPIBugReporter.h
lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp
lib/StaticAnalyzer/Checkers/MallocChecker.cpp
lib/StaticAnalyzer/Checkers/MoveChecker.cpp
lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
lib/StaticAnalyzer/Checkers/ObjCSuperDeallocChecker.cpp
lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
lib/StaticAnalyzer/Checkers/Taint.cpp
lib/StaticAnalyzer/Checkers/Taint.h
lib/StaticAnalyzer/Checkers/TestAfterDivZeroChecker.cpp
lib/StaticAnalyzer/Checkers/ValistChecker.cpp
lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
lib/StaticAnalyzer/Core/BugReporter.cpp
lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
lib/StaticAnalyzer/Core/PlistDiagnostics.cpp

index ef5d327d39da5932ea3fb6531f7b9c0bf467223d..ecd5ed0ca392788c4d61c8c4875701b847f43393 100644 (file)
@@ -38,6 +38,7 @@ class BugReporterContext;
 class ExplodedNode;
 class MemRegion;
 class PathDiagnosticPiece;
+using PathDiagnosticPieceRef = std::shared_ptr<PathDiagnosticPiece>;
 
 /// BugReporterVisitors are used to add custom diagnostics along a path.
 class BugReporterVisitor : public llvm::FoldingSetNode {
@@ -57,9 +58,9 @@ public:
   ///
   /// The last parameter can be used to register a new visitor with the given
   /// BugReport while processing a node.
-  virtual std::shared_ptr<PathDiagnosticPiece>
-  VisitNode(const ExplodedNode *Succ, 
-            BugReporterContext &BRC, BugReport &BR) = 0;
+  virtual PathDiagnosticPieceRef VisitNode(const ExplodedNode *Succ,
+                                           BugReporterContext &BRC,
+                                           BugReport &BR) = 0;
 
   /// Last function called on the visitor, no further calls to VisitNode
   /// would follow.
@@ -72,15 +73,15 @@ public:
   ///
   /// NOTE that this function can be implemented on at most one used visitor,
   /// and otherwise it crahes at runtime.
-  virtual std::shared_ptr<PathDiagnosticPiece>
+  virtual PathDiagnosticPieceRef
   getEndPath(BugReporterContext &BRC, const ExplodedNode *N, BugReport &BR);
 
   virtual void Profile(llvm::FoldingSetNodeID &ID) const = 0;
 
   /// Generates the default final diagnostic piece.
-  static std::shared_ptr<PathDiagnosticPiece>
-  getDefaultEndPath(BugReporterContext &BRC, const ExplodedNode *N,
-                    BugReport &BR);
+  static PathDiagnosticPieceRef getDefaultEndPath(BugReporterContext &BRC,
+                                                  const ExplodedNode *N,
+                                                  BugReport &BR);
 };
 
 /// Finds last store into the given region,
@@ -106,9 +107,9 @@ public:
 
   void Profile(llvm::FoldingSetNodeID &ID) const override;
 
-  std::shared_ptr<PathDiagnosticPiece> VisitNode(const ExplodedNode *N,
-                                                 BugReporterContext &BRC,
-                                                 BugReport &BR) override;
+  PathDiagnosticPieceRef VisitNode(const ExplodedNode *N,
+                                   BugReporterContext &BRC,
+                                   BugReport &BR) override;
 };
 
 class TrackConstraintBRVisitor final : public BugReporterVisitor {
@@ -132,9 +133,9 @@ public:
   /// to make all PathDiagnosticPieces created by this visitor.
   static const char *getTag();
 
-  std::shared_ptr<PathDiagnosticPiece> VisitNode(const ExplodedNode *N,
-                                                 BugReporterContext &BRC,
-                                                 BugReport &BR) override;
+  PathDiagnosticPieceRef VisitNode(const ExplodedNode *N,
+                                   BugReporterContext &BRC,
+                                   BugReport &BR) override;
 
 private:
   /// Checks if the constraint is valid in the current state.
@@ -150,9 +151,9 @@ public:
     ID.AddPointer(&x);
   }
 
-  std::shared_ptr<PathDiagnosticPiece> VisitNode(const ExplodedNode *N,
-                                                 BugReporterContext &BRC,
-                                                 BugReport &BR) override;
+  PathDiagnosticPieceRef VisitNode(const ExplodedNode *N,
+                                   BugReporterContext &BRC,
+                                   BugReport &BR) override;
 
   /// If the statement is a message send expression with nil receiver, returns
   /// the receiver expression. Returns NULL otherwise.
@@ -175,39 +176,40 @@ public:
   /// to make all PathDiagnosticPieces created by this visitor.
   static const char *getTag();
 
-  std::shared_ptr<PathDiagnosticPiece> VisitNode(const ExplodedNode *N,
-                                                 BugReporterContext &BRC,
-                                                 BugReport &BR) override;
+  PathDiagnosticPieceRef VisitNode(const ExplodedNode *N,
+                                   BugReporterContext &BRC,
+                                   BugReport &BR) override;
 
-  std::shared_ptr<PathDiagnosticPiece> VisitNodeImpl(const ExplodedNode *N,
-                                                     BugReporterContext &BRC,
-                                                     BugReport &BR);
+  PathDiagnosticPieceRef VisitNodeImpl(const ExplodedNode *N,
+                                       BugReporterContext &BRC, BugReport &BR);
 
-  std::shared_ptr<PathDiagnosticPiece>
-  VisitTerminator(const Stmt *Term, const ExplodedNode *N,
-                  const CFGBlock *srcBlk, const CFGBlock *dstBlk, BugReport &R,
-                  BugReporterContext &BRC);
+  PathDiagnosticPieceRef VisitTerminator(const Stmt *Term,
+                                         const ExplodedNode *N,
+                                         const CFGBlock *SrcBlk,
+                                         const CFGBlock *DstBlk, BugReport &R,
+                                         BugReporterContext &BRC);
 
-  std::shared_ptr<PathDiagnosticPiece>
-  VisitTrueTest(const Expr *Cond, BugReporterContext &BRC, BugReport &R,
-                const ExplodedNode *N, bool TookTrue);
+  PathDiagnosticPieceRef VisitTrueTest(const Expr *Cond,
+                                       BugReporterContext &BRC, BugReport &R,
+                                       const ExplodedNode *N, bool TookTrue);
 
-  std::shared_ptr<PathDiagnosticPiece>
-  VisitTrueTest(const Expr *Cond, const DeclRefExpr *DR,
-                BugReporterContext &BRC, BugReport &R, const ExplodedNode *N,
-                bool TookTrue, bool IsAssuming);
+  PathDiagnosticPieceRef VisitTrueTest(const Expr *Cond, const DeclRefExpr *DR,
+                                       BugReporterContext &BRC, BugReport &R,
+                                       const ExplodedNode *N, bool TookTrue,
+                                       bool IsAssuming);
 
-  std::shared_ptr<PathDiagnosticPiece>
-  VisitTrueTest(const Expr *Cond, const BinaryOperator *BExpr,
-                BugReporterContext &BRC, BugReport &R, const ExplodedNode *N,
-                bool TookTrue, bool IsAssuming);
+  PathDiagnosticPieceRef VisitTrueTest(const Expr *Cond,
+                                       const BinaryOperator *BExpr,
+                                       BugReporterContext &BRC, BugReport &R,
+                                       const ExplodedNode *N, bool TookTrue,
+                                       bool IsAssuming);
 
-  std::shared_ptr<PathDiagnosticPiece>
-  VisitTrueTest(const Expr *Cond, const MemberExpr *ME, BugReporterContext &BRC,
-                BugReport &R, const ExplodedNode *N, bool TookTrue,
-                bool IsAssuming);
+  PathDiagnosticPieceRef VisitTrueTest(const Expr *Cond, const MemberExpr *ME,
+                                       BugReporterContext &BRC, BugReport &R,
+                                       const ExplodedNode *N, bool TookTrue,
+                                       bool IsAssuming);
 
-  std::shared_ptr<PathDiagnosticPiece>
+  PathDiagnosticPieceRef
   VisitConditionVariable(StringRef LhsString, const Expr *CondVarExpr,
                          BugReporterContext &BRC, BugReport &R,
                          const ExplodedNode *N, bool TookTrue);
@@ -251,9 +253,8 @@ public:
     ID.AddPointer(getTag());
   }
 
-  std::shared_ptr<PathDiagnosticPiece> VisitNode(const ExplodedNode *,
-                                                 BugReporterContext &,
-                                                 BugReport &) override {
+  PathDiagnosticPieceRef VisitNode(const ExplodedNode *, BugReporterContext &,
+                                   BugReport &) override {
     return nullptr;
   }
 
@@ -279,9 +280,9 @@ public:
     ID.AddPointer(R);
   }
 
-  std::shared_ptr<PathDiagnosticPiece> VisitNode(const ExplodedNode *N,
-                                                 BugReporterContext &BRC,
-                                                 BugReport &BR) override;
+  PathDiagnosticPieceRef VisitNode(const ExplodedNode *N,
+                                   BugReporterContext &BRC,
+                                   BugReport &BR) override;
 };
 
 class SuppressInlineDefensiveChecksVisitor final : public BugReporterVisitor {
@@ -308,9 +309,9 @@ public:
   /// to make all PathDiagnosticPieces created by this visitor.
   static const char *getTag();
 
-  std::shared_ptr<PathDiagnosticPiece> VisitNode(const ExplodedNode *Succ,
-                                                 BugReporterContext &BRC,
-                                                 BugReport &BR) override;
+  PathDiagnosticPieceRef VisitNode(const ExplodedNode *Succ,
+                                   BugReporterContext &BRC,
+                                   BugReport &BR) override;
 };
 
 /// The bug visitor will walk all the nodes in a path and collect all the
@@ -326,9 +327,9 @@ public:
 
   void Profile(llvm::FoldingSetNodeID &ID) const override;
 
-  std::shared_ptr<PathDiagnosticPiece> VisitNode(const ExplodedNode *N,
-                                                 BugReporterContext &BRC,
-                                                 BugReport &BR) override;
+  PathDiagnosticPieceRef VisitNode(const ExplodedNode *N,
+                                   BugReporterContext &BRC,
+                                   BugReport &BR) override;
 
   void finalizeVisitor(BugReporterContext &BRC, const ExplodedNode *EndPathNode,
                        BugReport &BR) override;
@@ -340,9 +341,9 @@ class TagVisitor : public BugReporterVisitor {
 public:
   void Profile(llvm::FoldingSetNodeID &ID) const override;
 
-  std::shared_ptr<PathDiagnosticPiece> VisitNode(const ExplodedNode *N,
-                                                 BugReporterContext &BRC,
-                                                 BugReport &R) override;
+  PathDiagnosticPieceRef VisitNode(const ExplodedNode *N,
+                                   BugReporterContext &BRC,
+                                   BugReport &R) override;
 };
 
 namespace bugreporter {
index 5230742a4aa43280dfee1fa70ece659b586d782e..f98259560030bd9ad3d01289c9ddaaf6e1fe137a 100644 (file)
@@ -446,7 +446,9 @@ public:
   virtual void dump() const = 0;
 };
 
-class PathPieces : public std::list<std::shared_ptr<PathDiagnosticPiece>> {
+using PathDiagnosticPieceRef = std::shared_ptr<PathDiagnosticPiece>;
+
+class PathPieces : public std::list<PathDiagnosticPieceRef> {
   void flattenTo(PathPieces &Primary, PathPieces &Current,
                  bool ShouldFlattenMacros) const;
 
@@ -836,7 +838,7 @@ public:
 
   bool isWithinCall() const { return !pathStack.empty(); }
 
-  void setEndOfPath(std::shared_ptr<PathDiagnosticPiece> EndPiece) {
+  void setEndOfPath(PathDiagnosticPieceRef EndPiece) {
     assert(!Loc.isValid() && "End location already set!");
     Loc = EndPiece->getLocation();
     assert(Loc.isValid() && "Invalid location for end-of-path piece");
index 8bf77c109f8a68d805bc35c080c86ba1ca1d37a4..2059ff6c0e42b7fbead6d6ad05f5ecea28c6120b 100644 (file)
@@ -45,9 +45,9 @@ class DeleteWithNonVirtualDtorChecker
       static int X = 0;
       ID.AddPointer(&X);
     }
-    std::shared_ptr<PathDiagnosticPiece> VisitNode(const ExplodedNode *N,
-                                                   BugReporterContext &BRC,
-                                                   BugReport &BR) override;
+    PathDiagnosticPieceRef VisitNode(const ExplodedNode *N,
+                                     BugReporterContext &BRC,
+                                     BugReport &BR) override;
 
   private:
     bool Satisfied;
@@ -100,10 +100,9 @@ void DeleteWithNonVirtualDtorChecker::checkPreStmt(const CXXDeleteExpr *DE,
   C.emitReport(std::move(R));
 }
 
-std::shared_ptr<PathDiagnosticPiece>
+PathDiagnosticPieceRef
 DeleteWithNonVirtualDtorChecker::DeleteBugVisitor::VisitNode(
-    const ExplodedNode *N, BugReporterContext &BRC,
-    BugReport &BR) {
+    const ExplodedNode *N, BugReporterContext &BRC, BugReport &BR) {
   // Stop traversal after the first conversion was found on a path.
   if (Satisfied)
     return nullptr;
index 4d979dc9f2400a63e04432f9bc4735b82ae5ee4e..7dc4b93d2f88b94a47620d3f60c69506585b3e68 100644 (file)
@@ -47,9 +47,9 @@ class DynamicTypeChecker : public Checker<check::PostStmt<ImplicitCastExpr>> {
       ID.AddPointer(Reg);
     }
 
-    std::shared_ptr<PathDiagnosticPiece> VisitNode(const ExplodedNode *N,
-                                                   BugReporterContext &BRC,
-                                                   BugReport &BR) override;
+    PathDiagnosticPieceRef VisitNode(const ExplodedNode *N,
+                                     BugReporterContext &BRC,
+                                     BugReport &BR) override;
 
   private:
     // The tracked region.
@@ -88,10 +88,8 @@ void DynamicTypeChecker::reportTypeError(QualType DynamicType,
   C.emitReport(std::move(R));
 }
 
-std::shared_ptr<PathDiagnosticPiece>
-DynamicTypeChecker::DynamicTypeBugVisitor::VisitNode(const ExplodedNode *N,
-                                                     BugReporterContext &BRC,
-                                                     BugReport &) {
+PathDiagnosticPieceRef DynamicTypeChecker::DynamicTypeBugVisitor::VisitNode(
+    const ExplodedNode *N, BugReporterContext &BRC, BugReport &) {
   ProgramStateRef State = N->getState();
   ProgramStateRef StatePrev = N->getFirstPred()->getState();
 
index 3cfe4dc82a10063073ac3966d2f63bf6167edbd7..3beeddbf6e0ad8610685fa344360cb4f9813af3b 100644 (file)
@@ -83,9 +83,9 @@ class DynamicTypePropagation:
       ID.AddPointer(Sym);
     }
 
-    std::shared_ptr<PathDiagnosticPiece> VisitNode(const ExplodedNode *N,
-                                                   BugReporterContext &BRC,
-                                                   BugReport &BR) override;
+    PathDiagnosticPieceRef VisitNode(const ExplodedNode *N,
+                                     BugReporterContext &BRC,
+                                     BugReport &BR) override;
 
   private:
     // The tracked symbol.
@@ -928,10 +928,8 @@ void DynamicTypePropagation::reportGenericsBug(
   C.emitReport(std::move(R));
 }
 
-std::shared_ptr<PathDiagnosticPiece>
-DynamicTypePropagation::GenericsBugVisitor::VisitNode(const ExplodedNode *N,
-                                                      BugReporterContext &BRC,
-                                                      BugReport &BR) {
+PathDiagnosticPieceRef DynamicTypePropagation::GenericsBugVisitor::VisitNode(
+    const ExplodedNode *N, BugReporterContext &BRC, BugReport &BR) {
   ProgramStateRef state = N->getState();
   ProgramStateRef statePrev = N->getFirstPred()->getState();
 
index e3270f1f7be27c1458c09da05b95759a3b882997..3644fd87bd31fcb3cab337d2a3e1a5e432f5b526 100644 (file)
@@ -54,9 +54,9 @@ public:
       ID.AddPointer(getTag());
     }
 
-    virtual std::shared_ptr<PathDiagnosticPiece> VisitNode(const ExplodedNode *N,
-                                                   BugReporterContext &BRC,
-                                                   BugReport &BR) override;
+    virtual PathDiagnosticPieceRef VisitNode(const ExplodedNode *N,
+                                             BugReporterContext &BRC,
+                                             BugReport &BR) override;
 
     // FIXME: Scan the map once in the visitor's constructor and do a direct
     // lookup by region.
@@ -278,10 +278,8 @@ const MemRegion *getContainerObjRegion(ProgramStateRef State, SymbolRef Sym) {
 } // end namespace ento
 } // end namespace clang
 
-std::shared_ptr<PathDiagnosticPiece>
-InnerPointerChecker::InnerPointerBRVisitor::VisitNode(const ExplodedNode *N,
-                                                      BugReporterContext &BRC,
-                                                      BugReport &) {
+PathDiagnosticPieceRef InnerPointerChecker::InnerPointerBRVisitor::VisitNode(
+    const ExplodedNode *N, BugReporterContext &BRC, BugReport &) {
   if (!isSymbolTracked(N->getState(), PtrToBuf) ||
       isSymbolTracked(N->getFirstPred()->getState(), PtrToBuf))
     return nullptr;
index 46067ecbca99189342b31716ad7f7f981fe75648..ee4e27b95225b63e56915a63f23228ebc43da988 100644 (file)
@@ -120,12 +120,12 @@ class NonLocalizedStringBRVisitor final : public BugReporterVisitor {
 public:
   NonLocalizedStringBRVisitor(const MemRegion *NonLocalizedString)
       : NonLocalizedString(NonLocalizedString), Satisfied(false) {
-        assert(NonLocalizedString);
+    assert(NonLocalizedString);
   }
 
-  std::shared_ptr<PathDiagnosticPiece> VisitNode(const ExplodedNode *Succ,
-                                                 BugReporterContext &BRC,
-                                                 BugReport &BR) override;
+  PathDiagnosticPieceRef VisitNode(const ExplodedNode *Succ,
+                                   BugReporterContext &BRC,
+                                   BugReport &BR) override;
 
   void Profile(llvm::FoldingSetNodeID &ID) const override {
     ID.Add(NonLocalizedString);
@@ -998,7 +998,7 @@ void NonLocalizedStringChecker::checkPostStmt(const ObjCStringLiteral *SL,
   setNonLocalizedState(sv, C);
 }
 
-std::shared_ptr<PathDiagnosticPiece>
+PathDiagnosticPieceRef
 NonLocalizedStringBRVisitor::VisitNode(const ExplodedNode *Succ,
                                        BugReporterContext &BRC, BugReport &BR) {
   if (Satisfied)
index b250d3f8795e7e96860f6a02d55936969d18efc8..b40ddacca59247f5a2face499d84d5294d3ddace 100644 (file)
@@ -84,10 +84,8 @@ void MPIBugReporter::reportUnmatchedWait(
   BReporter.emitReport(std::move(Report));
 }
 
-std::shared_ptr<PathDiagnosticPiece>
-MPIBugReporter::RequestNodeVisitor::VisitNode(const ExplodedNode *N,
-                                              BugReporterContext &BRC,
-                                              BugReport &BR) {
+PathDiagnosticPieceRef MPIBugReporter::RequestNodeVisitor::VisitNode(
+    const ExplodedNode *N, BugReporterContext &BRC, BugReport &BR) {
 
   if (IsNodeFound)
     return nullptr;
index 6fbc30288655ccc4a0d6f60d89ab8eb9fac76667..66da02f76156eaf5e51317e69641a5512baa5b68 100644 (file)
@@ -89,9 +89,9 @@ private:
       ID.AddPointer(RequestRegion);
     }
 
-    std::shared_ptr<PathDiagnosticPiece> VisitNode(const ExplodedNode *N,
-                                                   BugReporterContext &BRC,
-                                                   BugReport &BR) override;
+    PathDiagnosticPieceRef VisitNode(const ExplodedNode *N,
+                                     BugReporterContext &BRC,
+                                     BugReport &BR) override;
 
   private:
     const MemRegion *const RequestRegion;
index 32ba9bc8e2ef59569238466edb43bfce9780860b..c3c5701328fccdc8c67817fe8c9165175231241f 100644 (file)
@@ -139,9 +139,9 @@ private:
       ID.AddPointer(Sym);
     }
 
-    std::shared_ptr<PathDiagnosticPiece> VisitNode(const ExplodedNode *N,
-                                                   BugReporterContext &BRC,
-                                                   BugReport &BR) override;
+    PathDiagnosticPieceRef VisitNode(const ExplodedNode *N,
+                                     BugReporterContext &BRC,
+                                     BugReport &BR) override;
   };
 };
 }
@@ -613,7 +613,7 @@ ProgramStateRef MacOSKeychainAPIChecker::checkPointerEscape(
   return State;
 }
 
-std::shared_ptr<PathDiagnosticPiece>
+PathDiagnosticPieceRef
 MacOSKeychainAPIChecker::SecKeychainBugVisitor::VisitNode(
     const ExplodedNode *N, BugReporterContext &BRC, BugReport &BR) {
   const AllocationState *AS = N->getState()->get<AllocatedData>(Sym);
index a79b3418906556b48fbfc63f1da5642677eb1614..9cfb98ef88fd7dda465531848884f675465708b8 100644 (file)
@@ -516,19 +516,19 @@ private:
       // released -> allocated, it must be the realloc return value
       // check. If we have to handle more cases here, it might be cleaner just
       // to track this extra bit in the state itself.
-      return ((!Stmt || !isa<CallExpr>(Stmt)) &&
-              (S && (S->isAllocated() || S->isAllocatedOfSizeZero())) &&
-              (SPrev && !(SPrev->isAllocated() ||
-                          SPrev->isAllocatedOfSizeZero())));
+      return (
+          (!Stmt || !isa<CallExpr>(Stmt)) &&
+          (S && (S->isAllocated() || S->isAllocatedOfSizeZero())) &&
+          (SPrev && !(SPrev->isAllocated() || SPrev->isAllocatedOfSizeZero())));
     }
 
-    std::shared_ptr<PathDiagnosticPiece> VisitNode(const ExplodedNode *N,
-                                                   BugReporterContext &BRC,
-                                                   BugReport &BR) override;
+    PathDiagnosticPieceRef VisitNode(const ExplodedNode *N,
+                                     BugReporterContext &BRC,
+                                     BugReport &BR) override;
 
-    std::shared_ptr<PathDiagnosticPiece>
-    getEndPath(BugReporterContext &BRC, const ExplodedNode *EndPathNode,
-               BugReport &BR) override {
+    PathDiagnosticPieceRef getEndPath(BugReporterContext &BRC,
+                                      const ExplodedNode *EndPathNode,
+                                      BugReport &BR) override {
       if (!IsLeak)
         return nullptr;
 
@@ -2906,7 +2906,7 @@ static bool isReferenceCountingPointerDestructor(const CXXDestructorDecl *DD) {
   return false;
 }
 
-std::shared_ptr<PathDiagnosticPiece> MallocChecker::MallocBugVisitor::VisitNode(
+PathDiagnosticPieceRef MallocChecker::MallocBugVisitor::VisitNode(
     const ExplodedNode *N, BugReporterContext &BRC, BugReport &BR) {
 
   ProgramStateRef state = N->getState();
index d8a9af78536a0fb4bb279ddfe3270e7d25a2b9b6..47fea7dcf5c42965b9fc43326ccdb5f05ec9fc7a 100644 (file)
@@ -169,9 +169,9 @@ private:
       // in the first place.
     }
 
-    std::shared_ptr<PathDiagnosticPiece> VisitNode(const ExplodedNode *N,
-                                                   BugReporterContext &BRC,
-                                                   BugReport &BR) override;
+    PathDiagnosticPieceRef VisitNode(const ExplodedNode *N,
+                                     BugReporterContext &BRC,
+                                     BugReport &BR) override;
 
   private:
     const MoveChecker &Chk;
@@ -270,9 +270,8 @@ static const MemRegion *unwrapRValueReferenceIndirection(const MemRegion *MR) {
   return MR;
 }
 
-std::shared_ptr<PathDiagnosticPiece>
-MoveChecker::MovedBugVisitor::VisitNode(const ExplodedNode *N,
-                                        BugReporterContext &BRC, BugReport &BR) {
+PathDiagnosticPieceRef MoveChecker::MovedBugVisitor::VisitNode(
+    const ExplodedNode *N, BugReporterContext &BRC, BugReport &BR) {
   // We need only the last move of the reported object's region.
   // The visitor walks the ExplodedGraph backwards.
   if (Found)
index af21c84b995b4c2e3ad8c55fc62499bc5a49af71..a0182ed2e51c24bf59868b519ac00f1c16b59de1 100644 (file)
@@ -137,9 +137,9 @@ private:
       ID.AddPointer(Region);
     }
 
-    std::shared_ptr<PathDiagnosticPiece> VisitNode(const ExplodedNode *N,
-                                                   BugReporterContext &BRC,
-                                                   BugReport &BR) override;
+    PathDiagnosticPieceRef VisitNode(const ExplodedNode *N,
+                                     BugReporterContext &BRC,
+                                     BugReport &BR) override;
 
   private:
     // The tracked region.
@@ -290,10 +290,8 @@ NullabilityChecker::getTrackRegion(SVal Val, bool CheckSuperRegion) const {
   return dyn_cast<SymbolicRegion>(Region);
 }
 
-std::shared_ptr<PathDiagnosticPiece>
-NullabilityChecker::NullabilityBugVisitor::VisitNode(const ExplodedNode *N,
-                                                     BugReporterContext &BRC,
-                                                     BugReport &BR) {
+PathDiagnosticPieceRef NullabilityChecker::NullabilityBugVisitor::VisitNode(
+    const ExplodedNode *N, BugReporterContext &BRC, BugReport &BR) {
   ProgramStateRef State = N->getState();
   ProgramStateRef StatePrev = N->getFirstPred()->getState();
 
index f435f00c08e79b4163d923822307659c95231c29..dc2cb2ba9d556fd0e418fd13cf3f6388ca8e42ca 100644 (file)
@@ -67,12 +67,11 @@ class SuperDeallocBRVisitor final : public BugReporterVisitor {
 
 public:
   SuperDeallocBRVisitor(SymbolRef ReceiverSymbol)
-      : ReceiverSymbol(ReceiverSymbol),
-        Satisfied(false) {}
+      : ReceiverSymbol(ReceiverSymbol), Satisfied(false) {}
 
-  std::shared_ptr<PathDiagnosticPiece> VisitNode(const ExplodedNode *Succ,
-                                                 BugReporterContext &BRC,
-                                                 BugReport &BR) override;
+  PathDiagnosticPieceRef VisitNode(const ExplodedNode *Succ,
+                                   BugReporterContext &BRC,
+                                   BugReport &BR) override;
 
   void Profile(llvm::FoldingSetNodeID &ID) const override {
     ID.Add(ReceiverSymbol);
@@ -243,7 +242,7 @@ ObjCSuperDeallocChecker::isSuperDeallocMessage(const ObjCMethodCall &M) const {
   return M.getSelector() == SELdealloc;
 }
 
-std::shared_ptr<PathDiagnosticPiece>
+PathDiagnosticPieceRef
 SuperDeallocBRVisitor::VisitNode(const ExplodedNode *Succ,
                                  BugReporterContext &BRC, BugReport &) {
   if (Satisfied)
index 796fd882ffd5e7800c869d2cfb51ee4cdeb06e4b..28670bf38ca31442b803d0e94054f8d43a22b81c 100644 (file)
@@ -325,22 +325,22 @@ public:
     ID.AddPointer(Sym);
   }
 
-  std::shared_ptr<PathDiagnosticPiece> VisitNode(const ExplodedNode *N,
-                                                 BugReporterContext &BRC,
-                                                 BugReport &BR) override;
+  PathDiagnosticPieceRef VisitNode(const ExplodedNode *N,
+                                   BugReporterContext &BRC,
+                                   BugReport &BR) override;
 
-  std::shared_ptr<PathDiagnosticPiece> getEndPath(BugReporterContext &BRC,
-                                                  const ExplodedNode *N,
-                                                  BugReport &BR) override;
+  PathDiagnosticPieceRef getEndPath(BugReporterContext &BRC,
+                                    const ExplodedNode *N,
+                                    BugReport &BR) override;
 };
 
 class RefLeakReportVisitor : public RefCountReportVisitor {
 public:
   RefLeakReportVisitor(SymbolRef sym) : RefCountReportVisitor(sym) {}
 
-  std::shared_ptr<PathDiagnosticPiece> getEndPath(BugReporterContext &BRC,
-                                                  const ExplodedNode *N,
-                                                  BugReport &BR) override;
+  PathDiagnosticPieceRef getEndPath(BugReporterContext &BRC,
+                                    const ExplodedNode *N,
+                                    BugReport &BR) override;
 };
 
 } // end namespace retaincountchecker
@@ -448,9 +448,9 @@ annotateStartParameter(const ExplodedNode *N, SymbolRef Sym,
   return std::make_shared<PathDiagnosticEventPiece>(L, os.str());
 }
 
-std::shared_ptr<PathDiagnosticPiece>
-RefCountReportVisitor::VisitNode(const ExplodedNode *N,
-                              BugReporterContext &BRC, BugReport &BR) {
+PathDiagnosticPieceRef RefCountReportVisitor::VisitNode(const ExplodedNode *N,
+                                                        BugReporterContext &BRC,
+                                                        BugReport &BR) {
 
   const auto &BT = static_cast<const RefCountBug&>(BR.getBugType());
   const auto *Checker =
@@ -709,21 +709,20 @@ static AllocationInfo GetAllocationSite(ProgramStateManager &StateMgr,
       LeakContext)
     FirstBinding = nullptr;
 
-  return AllocationInfo(AllocationNodeInCurrentOrParentContext,
-                        FirstBinding,
+  return AllocationInfo(AllocationNodeInCurrentOrParentContext, FirstBinding,
                         InterestingMethodContext);
 }
 
-std::shared_ptr<PathDiagnosticPiece>
+PathDiagnosticPieceRef
 RefCountReportVisitor::getEndPath(BugReporterContext &BRC,
-                               const ExplodedNode *EndN, BugReport &BR) {
+                                  const ExplodedNode *EndN, BugReport &BR) {
   BR.markInteresting(Sym);
   return BugReporterVisitor::getDefaultEndPath(BRC, EndN, BR);
 }
 
-std::shared_ptr<PathDiagnosticPiece>
+PathDiagnosticPieceRef
 RefLeakReportVisitor::getEndPath(BugReporterContext &BRC,
-                                   const ExplodedNode *EndN, BugReport &BR) {
+                                 const ExplodedNode *EndN, BugReport &BR) {
 
   // Tell the BugReporterContext to report cases when the tracked symbol is
   // assigned to different variables, etc.
index bc120949ee4f1b32932355b82b4faf4dfae8fe5d..cd8cab8f52e40ca682530fddb9c91791132b568d 100644 (file)
@@ -204,9 +204,9 @@ bool taint::isTainted(ProgramStateRef State, SymbolRef Sym, TaintTagType Kind) {
   return false;
 }
 
-std::shared_ptr<PathDiagnosticPiece>
-TaintBugVisitor::VisitNode(const ExplodedNode *N, BugReporterContext &BRC,
-                           BugReport &BR) {
+PathDiagnosticPieceRef TaintBugVisitor::VisitNode(const ExplodedNode *N,
+                                                  BugReporterContext &BRC,
+                                                  BugReport &BR) {
 
   // Find the ExplodedNode where the taint was first introduced
   if (!isTainted(N->getState(), V) ||
index 72cf6a79d52c4cc22c14ae70ac788fdb0bcc7122..2c3b001b5f0a069b0dab173726353161b793a24b 100644 (file)
@@ -89,9 +89,9 @@ public:
   TaintBugVisitor(const SVal V) : V(V) {}
   void Profile(llvm::FoldingSetNodeID &ID) const override { ID.Add(V); }
 
-  std::shared_ptr<PathDiagnosticPiece> VisitNode(const ExplodedNode *N,
-                                                 BugReporterContext &BRC,
-                                                 BugReport &BR) override;
+  PathDiagnosticPieceRef VisitNode(const ExplodedNode *N,
+                                   BugReporterContext &BRC,
+                                   BugReport &BR) override;
 };
 
 } // namespace taint
index 7a33845a6a266a13c196773fb8610e04fdc0a110..e95c86e23e021c951a242f5ddf0d2a96d0512740 100644 (file)
@@ -69,9 +69,9 @@ public:
     ID.Add(SFC);
   }
 
-  std::shared_ptr<PathDiagnosticPiece> VisitNode(const ExplodedNode *Succ,
-                                                 BugReporterContext &BRC,
-                                                 BugReport &BR) override;
+  PathDiagnosticPieceRef VisitNode(const ExplodedNode *Succ,
+                                   BugReporterContext &BRC,
+                                   BugReport &BR) override;
 };
 
 class TestAfterDivZeroChecker
@@ -92,9 +92,9 @@ public:
 
 REGISTER_SET_WITH_PROGRAMSTATE(DivZeroMap, ZeroState)
 
-std::shared_ptr<PathDiagnosticPiece>
-DivisionBRVisitor::VisitNode(const ExplodedNode *Succ, 
-                             BugReporterContext &BRC, BugReport &BR) {
+PathDiagnosticPieceRef DivisionBRVisitor::VisitNode(const ExplodedNode *Succ,
+                                                    BugReporterContext &BRC,
+                                                    BugReport &BR) {
   if (Satisfied)
     return nullptr;
 
index 13ad3d98e8ebb243313885ba0eef5d2bad9f5b47..0ae556c3669f3006b8508c3a4a99a2686447e3f4 100644 (file)
@@ -77,20 +77,21 @@ private:
       ID.AddPointer(&X);
       ID.AddPointer(Reg);
     }
-    std::shared_ptr<PathDiagnosticPiece>
-    getEndPath(BugReporterContext &BRC, const ExplodedNode *EndPathNode,
-               BugReport &BR) override {
+    PathDiagnosticPieceRef getEndPath(BugReporterContext &BRC,
+                                      const ExplodedNode *EndPathNode,
+                                      BugReport &BR) override {
       if (!IsLeak)
         return nullptr;
 
       PathDiagnosticLocation L = PathDiagnosticLocation::createEndOfPath(
           EndPathNode, BRC.getSourceManager());
       // Do not add the statement itself as a range in case of leak.
-      return std::make_shared<PathDiagnosticEventPiece>(L, BR.getDescription(), false);
+      return std::make_shared<PathDiagnosticEventPiece>(L, BR.getDescription(),
+                                                        false);
     }
-    std::shared_ptr<PathDiagnosticPiece> VisitNode(const ExplodedNode *N,
-                                                   BugReporterContext &BRC,
-                                                   BugReport &BR) override;
+    PathDiagnosticPieceRef VisitNode(const ExplodedNode *N,
+                                     BugReporterContext &BRC,
+                                     BugReport &BR) override;
 
   private:
     const MemRegion *Reg;
@@ -373,9 +374,8 @@ void ValistChecker::checkVAListEndCall(const CallEvent &Call,
   C.addTransition(State);
 }
 
-std::shared_ptr<PathDiagnosticPiece> ValistChecker::ValistBugVisitor::VisitNode(
-    const ExplodedNode *N, BugReporterContext &BRC,
-    BugReport &) {
+PathDiagnosticPieceRef ValistChecker::ValistBugVisitor::VisitNode(
+    const ExplodedNode *N, BugReporterContext &BRC, BugReport &) {
   ProgramStateRef State = N->getState();
   ProgramStateRef StatePrev = N->getFirstPred()->getState();
 
index 762c9c1c8d7aa3db5b556660346c6d896ea8fb6c..0d76a098d4088f87dde50134e7b69e3e2c6816e9 100644 (file)
@@ -70,9 +70,9 @@ private:
       ID.AddPointer(ObjectRegion);
     }
 
-    std::shared_ptr<PathDiagnosticPiece> VisitNode(const ExplodedNode *N,
-                                                   BugReporterContext &BRC,
-                                                   BugReport &BR) override;
+    PathDiagnosticPieceRef VisitNode(const ExplodedNode *N,
+                                     BugReporterContext &BRC,
+                                     BugReport &BR) override;
   };
 };
 } // end namespace
@@ -80,10 +80,8 @@ private:
 // GDM (generic data map) to the memregion of this for the ctor and dtor.
 REGISTER_MAP_WITH_PROGRAMSTATE(CtorDtorMap, const MemRegion *, ObjectState)
 
-std::shared_ptr<PathDiagnosticPiece>
-VirtualCallChecker::VirtualBugVisitor::VisitNode(const ExplodedNode *N,
-                                                 BugReporterContext &BRC,
-                                                 BugReport &) {
+PathDiagnosticPieceRef VirtualCallChecker::VirtualBugVisitor::VisitNode(
+    const ExplodedNode *N, BugReporterContext &BRC, BugReport &) {
   // We need the last ctor/dtor which call the virtual function.
   // The visitor walks the ExplodedGraph backwards.
   if (Found)
index 0ee5f459e3b301c871f8faf15708d9bb4f4682cb..5104b00ab748d80cf5fc3317d64748247f3b8524 100644 (file)
@@ -1881,12 +1881,11 @@ static void dropFunctionEntryEdge(PathPieces &Path, LocationContextMap &LCM,
   Path.pop_front();
 }
 
-using VisitorsDiagnosticsTy = llvm::DenseMap<const ExplodedNode *,
-                   std::vector<std::shared_ptr<PathDiagnosticPiece>>>;
+using VisitorsDiagnosticsTy =
+    llvm::DenseMap<const ExplodedNode *, std::vector<PathDiagnosticPieceRef>>;
 
 /// Populate executes lines with lines containing at least one diagnostics.
-static void updateExecutedLinesWithDiagnosticPieces(
-  PathDiagnostic &PD) {
+static void updateExecutedLinesWithDiagnosticPieces(PathDiagnostic &PD) {
 
   PathPieces path = PD.path.flatten(/*ShouldFlattenMacros=*/true);
   FilesToLineNumsMap &ExecutedLines = PD.getExecutedLines();
@@ -1930,7 +1929,7 @@ static std::unique_ptr<PathDiagnostic> generatePathDiagnosticForConsumer(
 
   if (GenerateDiagnostics) {
     auto EndNotes = VisitorsDiagnostics.find(ErrorNode);
-    std::shared_ptr<PathDiagnosticPiece> LastPiece;
+    PathDiagnosticPieceRef LastPiece;
     if (EndNotes != VisitorsDiagnostics.end()) {
       assert(!EndNotes->second.empty());
       LastPiece = EndNotes->second[0];
@@ -1957,7 +1956,7 @@ static std::unique_ptr<PathDiagnostic> generatePathDiagnosticForConsumer(
     std::set<llvm::FoldingSetNodeID> DeduplicationSet;
 
     // Add pieces from custom visitors.
-    for (const auto &Note : VisitorNotes->second) {
+    for (const PathDiagnosticPieceRef &Note : VisitorNotes->second) {
       llvm::FoldingSetNodeID ID;
       Note->Profile(ID);
       auto P = DeduplicationSet.insert(ID);
@@ -2430,11 +2429,10 @@ BugPathInfo *BugPathGetter::getNextBugPath() {
 /// object and collapses PathDiagosticPieces that are expanded by macros.
 static void CompactMacroExpandedPieces(PathPieces &path,
                                        const SourceManager& SM) {
-  using MacroStackTy =
-      std::vector<
-          std::pair<std::shared_ptr<PathDiagnosticMacroPiece>, SourceLocation>>;
+  using MacroStackTy = std::vector<
+      std::pair<std::shared_ptr<PathDiagnosticMacroPiece>, SourceLocation>>;
 
-  using PiecesTy = std::vector<std::shared_ptr<PathDiagnosticPiece>>;
+  using PiecesTy = std::vector<PathDiagnosticPieceRef>;
 
   MacroStackTy MacroStack;
   PiecesTy Pieces;
@@ -2546,7 +2544,7 @@ generateVisitorsDiagnostics(BugReport *R, const ExplodedNode *ErrorNode,
 
     const ExplodedNode *Pred = NextNode->getFirstPred();
     if (!Pred) {
-      std::shared_ptr<PathDiagnosticPiece> LastPiece;
+      PathDiagnosticPieceRef LastPiece;
       for (auto &V : visitors) {
         V->finalizeVisitor(BRC, ErrorNode, *R);
 
index 731545022cab00cd6527f08725f85327ebb40882..a71ac21fe693af3f383f3cfe5a29a10a0c5c65a6 100644 (file)
@@ -255,20 +255,19 @@ static bool wasRegionOfInterestModifiedAt(const SubRegion *RegionOfInterest,
 // Implementation of BugReporterVisitor.
 //===----------------------------------------------------------------------===//
 
-std::shared_ptr<PathDiagnosticPiece>
-BugReporterVisitor::getEndPath(BugReporterContext &,
-                               const ExplodedNode *, BugReport &) {
+PathDiagnosticPieceRef BugReporterVisitor::getEndPath(BugReporterContext &,
+                                                      const ExplodedNode *,
+                                                      BugReport &) {
   return nullptr;
 }
 
-void
-BugReporterVisitor::finalizeVisitor(BugReporterContext &,
-                                    const ExplodedNode *, BugReport &) {}
+void BugReporterVisitor::finalizeVisitor(BugReporterContext &,
+                                         const ExplodedNode *, BugReport &) {}
 
-std::shared_ptr<PathDiagnosticPiece> BugReporterVisitor::getDefaultEndPath(
+PathDiagnosticPieceRef BugReporterVisitor::getDefaultEndPath(
     BugReporterContext &BRC, const ExplodedNode *EndPathNode, BugReport &BR) {
-  PathDiagnosticLocation L =
-    PathDiagnosticLocation::createEndOfPath(EndPathNode,BRC.getSourceManager());
+  PathDiagnosticLocation L = PathDiagnosticLocation::createEndOfPath(
+      EndPathNode, BRC.getSourceManager());
 
   const auto &Ranges = BR.getRanges();
 
@@ -333,9 +332,9 @@ public:
     return static_cast<void *>(&Tag);
   }
 
-  std::shared_ptr<PathDiagnosticPiece> VisitNode(const ExplodedNode *N,
-                                                 BugReporterContext &BR,
-                                                 BugReport &R) override;
+  PathDiagnosticPieceRef VisitNode(const ExplodedNode *N,
+                                   BugReporterContext &BR,
+                                   BugReport &R) override;
 
 private:
   /// Attempts to find the region of interest in a given record decl,
@@ -368,7 +367,7 @@ private:
   /// either emit a note or suppress the report enirely.
   /// \return Diagnostics piece for region not modified in the current function,
   /// if it decides to emit one.
-  std::shared_ptr<PathDiagnosticPiece>
+  PathDiagnosticPieceRef
   maybeEmitNote(BugReport &R, const CallEvent &Call, const ExplodedNode *N,
                 const RegionVector &FieldChain, const MemRegion *MatchedRegion,
                 StringRef FirstElement, bool FirstIsReferenceType,
@@ -501,9 +500,9 @@ NoStoreFuncVisitor::findRegionOfInterestInRecord(
   return None;
 }
 
-std::shared_ptr<PathDiagnosticPiece>
-NoStoreFuncVisitor::VisitNode(const ExplodedNode *N, BugReporterContext &BR,
-                              BugReport &R) {
+PathDiagnosticPieceRef NoStoreFuncVisitor::VisitNode(const ExplodedNode *N,
+                                                     BugReporterContext &BR,
+                                                     BugReport &R) {
 
   const LocationContext *Ctx = N->getLocationContext();
   const StackFrameContext *SCtx = Ctx->getStackFrame();
@@ -611,7 +610,7 @@ void NoStoreFuncVisitor::findModifyingFrames(const ExplodedNode *N) {
   } while (N);
 }
 
-std::shared_ptr<PathDiagnosticPiece> NoStoreFuncVisitor::maybeEmitNote(
+PathDiagnosticPieceRef NoStoreFuncVisitor::maybeEmitNote(
     BugReport &R, const CallEvent &Call, const ExplodedNode *N,
     const RegionVector &FieldChain, const MemRegion *MatchedRegion,
     StringRef FirstElement, bool FirstIsReferenceType,
@@ -752,13 +751,12 @@ class MacroNullReturnSuppressionVisitor final : public BugReporterVisitor {
   bool WasModified = false;
 
 public:
-  MacroNullReturnSuppressionVisitor(const SubRegion *R,
-                                    const SVal V) : RegionOfInterest(R),
-                                                    ValueAtDereference(V) {}
+  MacroNullReturnSuppressionVisitor(const SubRegion *R, const SVal V)
+      : RegionOfInterest(R), ValueAtDereference(V) {}
 
-  std::shared_ptr<PathDiagnosticPiece> VisitNode(const ExplodedNode *N,
-                                                 BugReporterContext &BRC,
-                                                 BugReport &BR) override {
+  PathDiagnosticPieceRef VisitNode(const ExplodedNode *N,
+                                   BugReporterContext &BRC,
+                                   BugReport &BR) override {
     if (WasModified)
       return nullptr;
 
@@ -956,9 +954,9 @@ public:
                                                    Options));
   }
 
-  std::shared_ptr<PathDiagnosticPiece>
-  visitNodeInitial(const ExplodedNode *N,
-                   BugReporterContext &BRC, BugReport &BR) {
+  PathDiagnosticPieceRef visitNodeInitial(const ExplodedNode *N,
+                                          BugReporterContext &BRC,
+                                          BugReport &BR) {
     // Only print a message at the interesting return statement.
     if (N->getLocationContext() != StackFrame)
       return nullptr;
@@ -1059,9 +1057,9 @@ public:
     return std::make_shared<PathDiagnosticEventPiece>(L, Out.str());
   }
 
-  std::shared_ptr<PathDiagnosticPiece>
-  visitNodeMaybeUnsuppress(const ExplodedNode *N,
-                           BugReporterContext &BRC, BugReport &BR) {
+  PathDiagnosticPieceRef visitNodeMaybeUnsuppress(const ExplodedNode *N,
+                                                  BugReporterContext &BRC,
+                                                  BugReport &BR) {
 #ifndef NDEBUG
     assert(Options.ShouldAvoidSuppressingNullArgumentPaths);
 #endif
@@ -1108,9 +1106,9 @@ public:
     return nullptr;
   }
 
-  std::shared_ptr<PathDiagnosticPiece> VisitNode(const ExplodedNode *N,
-                                                 BugReporterContext &BRC,
-                                                 BugReport &BR) override {
+  PathDiagnosticPieceRef VisitNode(const ExplodedNode *N,
+                                   BugReporterContext &BRC,
+                                   BugReport &BR) override {
     switch (Mode) {
     case Initial:
       return visitNodeInitial(N, BRC, BR);
@@ -1291,7 +1289,7 @@ static void showBRDefaultDiagnostics(llvm::raw_svector_ostream& os,
   }
 }
 
-std::shared_ptr<PathDiagnosticPiece>
+PathDiagnosticPieceRef
 FindLastStoreBRVisitor::VisitNode(const ExplodedNode *Succ,
                                   BugReporterContext &BRC, BugReport &BR) {
   if (Satisfied)
@@ -1467,7 +1465,7 @@ bool TrackConstraintBRVisitor::isUnderconstrained(const ExplodedNode *N) const {
   return (bool)N->getState()->assume(Constraint, !Assumption);
 }
 
-std::shared_ptr<PathDiagnosticPiece>
+PathDiagnosticPieceRef
 TrackConstraintBRVisitor::VisitNode(const ExplodedNode *N,
                                     BugReporterContext &BRC, BugReport &) {
   const ExplodedNode *PrevN = N->getFirstPred();
@@ -1547,10 +1545,8 @@ const char *SuppressInlineDefensiveChecksVisitor::getTag() {
   return "IDCVisitor";
 }
 
-std::shared_ptr<PathDiagnosticPiece>
-SuppressInlineDefensiveChecksVisitor::VisitNode(const ExplodedNode *Succ,
-                                                BugReporterContext &BRC,
-                                                BugReport &BR) {
+PathDiagnosticPieceRef SuppressInlineDefensiveChecksVisitor::VisitNode(
+    const ExplodedNode *Succ, BugReporterContext &BRC, BugReport &BR) {
   const ExplodedNode *Pred = Succ->getFirstPred();
   if (IsSatisfied)
     return nullptr;
@@ -1649,9 +1645,9 @@ public:
     ID.AddPointer(&x);
   }
 
-  std::shared_ptr<PathDiagnosticPiece> VisitNode(const ExplodedNode *N,
-                                                 BugReporterContext &BRC,
-                                                 BugReport &BR) override;
+  PathDiagnosticPieceRef VisitNode(const ExplodedNode *N,
+                                   BugReporterContext &BRC,
+                                   BugReport &BR) override;
 };
 } // end of anonymous namespace
 
@@ -1687,10 +1683,8 @@ constructDebugPieceForTrackedCondition(const Expr *Cond,
           (Twine() + "Tracking condition '" + ConditionText + "'").str());
 }
 
-std::shared_ptr<PathDiagnosticPiece>
-TrackControlDependencyCondBRVisitor::VisitNode(const ExplodedNode *N,
-                                               BugReporterContext &BRC,
-                                               BugReport &BR) {
+PathDiagnosticPieceRef TrackControlDependencyCondBRVisitor::VisitNode(
+    const ExplodedNode *N, BugReporterContext &BRC, BugReport &BR) {
   // We can only reason about control dependencies within the same stack frame.
   if (Origin->getStackFrame() != N->getStackFrame())
     return nullptr;
@@ -1978,9 +1972,9 @@ const Expr *NilReceiverBRVisitor::getNilReceiver(const Stmt *S,
   return nullptr;
 }
 
-std::shared_ptr<PathDiagnosticPiece>
-NilReceiverBRVisitor::VisitNode(const ExplodedNode *N,
-                                BugReporterContext &BRC, BugReport &BR) {
+PathDiagnosticPieceRef NilReceiverBRVisitor::VisitNode(const ExplodedNode *N,
+                                                       BugReporterContext &BRC,
+                                                       BugReport &BR) {
   Optional<PreStmt> P = N->getLocationAs<PreStmt>();
   if (!P)
     return nullptr;
@@ -2059,13 +2053,11 @@ void FindLastStoreBRVisitor::registerStatementVarDecls(BugReport &BR,
 
 /// Return the tag associated with this visitor.  This tag will be used
 /// to make all PathDiagnosticPieces created by this visitor.
-const char *ConditionBRVisitor::getTag() {
-  return "ConditionBRVisitor";
-}
+const char *ConditionBRVisitor::getTag() { return "ConditionBRVisitor"; }
 
-std::shared_ptr<PathDiagnosticPiece>
-ConditionBRVisitor::VisitNode(const ExplodedNode *N,
-                              BugReporterContext &BRC, BugReport &BR) {
+PathDiagnosticPieceRef ConditionBRVisitor::VisitNode(const ExplodedNode *N,
+                                                     BugReporterContext &BRC,
+                                                     BugReport &BR) {
   auto piece = VisitNodeImpl(N, BRC, BR);
   if (piece) {
     piece->setTag(getTag());
@@ -2075,7 +2067,7 @@ ConditionBRVisitor::VisitNode(const ExplodedNode *N,
   return piece;
 }
 
-std::shared_ptr<PathDiagnosticPiece>
+PathDiagnosticPieceRef
 ConditionBRVisitor::VisitNodeImpl(const ExplodedNode *N,
                                   BugReporterContext &BRC, BugReport &BR) {
   ProgramPoint ProgPoint = N->getLocation();
@@ -2113,7 +2105,7 @@ ConditionBRVisitor::VisitNodeImpl(const ExplodedNode *N,
   return nullptr;
 }
 
-std::shared_ptr<PathDiagnosticPiece> ConditionBRVisitor::VisitTerminator(
+PathDiagnosticPieceRef ConditionBRVisitor::VisitTerminator(
     const Stmt *Term, const ExplodedNode *N, const CFGBlock *srcBlk,
     const CFGBlock *dstBlk, BugReport &R, BugReporterContext &BRC) {
   const Expr *Cond = nullptr;
@@ -2170,7 +2162,7 @@ std::shared_ptr<PathDiagnosticPiece> ConditionBRVisitor::VisitTerminator(
   return VisitTrueTest(Cond, BRC, R, N, TookTrue);
 }
 
-std::shared_ptr<PathDiagnosticPiece>
+PathDiagnosticPieceRef
 ConditionBRVisitor::VisitTrueTest(const Expr *Cond, BugReporterContext &BRC,
                                   BugReport &R, const ExplodedNode *N,
                                   bool TookTrue) {
@@ -2326,7 +2318,7 @@ bool ConditionBRVisitor::patternMatch(const Expr *Ex,
   return false;
 }
 
-std::shared_ptr<PathDiagnosticPiece> ConditionBRVisitor::VisitTrueTest(
+PathDiagnosticPieceRef ConditionBRVisitor::VisitTrueTest(
     const Expr *Cond, const BinaryOperator *BExpr, BugReporterContext &BRC,
     BugReport &R, const ExplodedNode *N, bool TookTrue, bool IsAssuming) {
   bool shouldInvert = false;
@@ -2441,7 +2433,7 @@ std::shared_ptr<PathDiagnosticPiece> ConditionBRVisitor::VisitTrueTest(
   return event;
 }
 
-std::shared_ptr<PathDiagnosticPiece> ConditionBRVisitor::VisitConditionVariable(
+PathDiagnosticPieceRef ConditionBRVisitor::VisitConditionVariable(
     StringRef LhsString, const Expr *CondVarExpr, BugReporterContext &BRC,
     BugReport &report, const ExplodedNode *N, bool TookTrue) {
   // FIXME: If there's already a constraint tracker for this variable,
@@ -2471,7 +2463,7 @@ std::shared_ptr<PathDiagnosticPiece> ConditionBRVisitor::VisitConditionVariable(
   return event;
 }
 
-std::shared_ptr<PathDiagnosticPiece> ConditionBRVisitor::VisitTrueTest(
+PathDiagnosticPieceRef ConditionBRVisitor::VisitTrueTest(
     const Expr *Cond, const DeclRefExpr *DRE, BugReporterContext &BRC,
     BugReport &report, const ExplodedNode *N, bool TookTrue, bool IsAssuming) {
   const auto *VD = dyn_cast<VarDecl>(DRE->getDecl());
@@ -2509,7 +2501,7 @@ std::shared_ptr<PathDiagnosticPiece> ConditionBRVisitor::VisitTrueTest(
   return std::move(event);
 }
 
-std::shared_ptr<PathDiagnosticPiece> ConditionBRVisitor::VisitTrueTest(
+PathDiagnosticPieceRef ConditionBRVisitor::VisitTrueTest(
     const Expr *Cond, const MemberExpr *ME, BugReporterContext &BRC,
     BugReport &report, const ExplodedNode *N, bool TookTrue, bool IsAssuming) {
   SmallString<256> Buf;
@@ -2677,9 +2669,9 @@ void LikelyFalsePositiveSuppressionBRVisitor::finalizeVisitor(
 // Implementation of UndefOrNullArgVisitor.
 //===----------------------------------------------------------------------===//
 
-std::shared_ptr<PathDiagnosticPiece>
-UndefOrNullArgVisitor::VisitNode(const ExplodedNode *N,
-                                 BugReporterContext &BRC, BugReport &BR) {
+PathDiagnosticPieceRef UndefOrNullArgVisitor::VisitNode(const ExplodedNode *N,
+                                                        BugReporterContext &BRC,
+                                                        BugReport &BR) {
   ProgramStateRef State = N->getState();
   ProgramPoint ProgLoc = N->getLocation();
 
@@ -2770,10 +2762,9 @@ void FalsePositiveRefutationBRVisitor::finalizeVisitor(
     BR.markInvalid("Infeasible constraints", EndPathNode->getLocationContext());
 }
 
-std::shared_ptr<PathDiagnosticPiece>
+PathDiagnosticPieceRef
 FalsePositiveRefutationBRVisitor::VisitNode(const ExplodedNode *N,
-                                            BugReporterContext &,
-                                            BugReport &) {
+                                            BugReporterContext &, BugReport &) {
   // Collect new constraints
   const ConstraintRangeTy &NewCs = N->getState()->get<ConstraintRange>();
   ConstraintRangeTy::Factory &CF =
@@ -2807,9 +2798,9 @@ void TagVisitor::Profile(llvm::FoldingSetNodeID &ID) const {
   ID.AddPointer(&Tag);
 }
 
-std::shared_ptr<PathDiagnosticPiece>
-TagVisitor::VisitNode(const ExplodedNode *N, BugReporterContext &BRC,
-                      BugReport &R) {
+PathDiagnosticPieceRef TagVisitor::VisitNode(const ExplodedNode *N,
+                                             BugReporterContext &BRC,
+                                             BugReport &R) {
   ProgramPoint PP = N->getLocation();
   const NoteTag *T = dyn_cast_or_null<NoteTag>(PP.getTag());
   if (!T)
index a6416957225003db1406013cd21ce81313bbfd6f..39500a20fde3c6864f74c7b83a7fc9f8c6f65a28 100644 (file)
@@ -657,16 +657,14 @@ void HTMLDiagnostics::RewriteFile(Rewriter &R,
   // Process the path.
   // Maintain the counts of extra note pieces separately.
   unsigned TotalPieces = path.size();
-  unsigned TotalNotePieces =
-      std::count_if(path.begin(), path.end(),
-                    [](const std::shared_ptr<PathDiagnosticPiece> &p) {
-                      return isa<PathDiagnosticNotePiece>(*p);
-                    });
-  unsigned PopUpPieceCount =
-      std::count_if(path.begin(), path.end(),
-                    [](const std::shared_ptr<PathDiagnosticPiece> &p) {
-                      return isa<PathDiagnosticPopUpPiece>(*p);
-                    });
+  unsigned TotalNotePieces = std::count_if(
+      path.begin(), path.end(), [](const PathDiagnosticPieceRef &p) {
+        return isa<PathDiagnosticNotePiece>(*p);
+      });
+  unsigned PopUpPieceCount = std::count_if(
+      path.begin(), path.end(), [](const PathDiagnosticPieceRef &p) {
+        return isa<PathDiagnosticPopUpPiece>(*p);
+      });
 
   unsigned TotalRegularPieces = TotalPieces - TotalNotePieces - PopUpPieceCount;
   unsigned NumRegularPieces = TotalRegularPieces;
index d79d91679ad599b4a31f7d1f340b00ab7a924752..04640eb5709e2512c98651953e9571ba4a4c478c 100644 (file)
@@ -479,16 +479,16 @@ static void printBugPath(llvm::raw_ostream &o, const FIDMap& FM,
                          const cross_tu::CrossTranslationUnitContext &CTU,
                          const PathPieces &Path) {
   PlistPrinter Printer(FM, AnOpts, PP, CTU);
-  assert(std::is_partitioned(
-           Path.begin(), Path.end(),
-           [](const std::shared_ptr<PathDiagnosticPiece> &E)
-             { return E->getKind() == PathDiagnosticPiece::Note; }) &&
+  assert(std::is_partitioned(Path.begin(), Path.end(),
+                             [](const PathDiagnosticPieceRef &E) {
+                               return E->getKind() == PathDiagnosticPiece::Note;
+                             }) &&
          "PathDiagnostic is not partitioned so that notes precede the rest");
 
   PathPieces::const_iterator FirstNonNote = std::partition_point(
-      Path.begin(), Path.end(),
-      [](const std::shared_ptr<PathDiagnosticPiece> &E)
-        { return E->getKind() == PathDiagnosticPiece::Note; });
+      Path.begin(), Path.end(), [](const PathDiagnosticPieceRef &E) {
+        return E->getKind() == PathDiagnosticPiece::Note;
+      });
 
   PathPieces::const_iterator I = Path.begin();