]> granicus.if.org Git - clang/commitdiff
unique_ptrify PathDiagnosticConsumer::HandlePathDiagnostic
authorDavid Blaikie <dblaikie@gmail.com>
Fri, 29 Aug 2014 20:06:10 +0000 (20:06 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Fri, 29 Aug 2014 20:06:10 +0000 (20:06 +0000)
FoldingSet, another intrusive data structure that could use some
unique_ptr love on its interfaces. Eventually.

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

include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
lib/StaticAnalyzer/Core/BugReporter.cpp
lib/StaticAnalyzer/Core/PathDiagnostic.cpp

index f92077f3096081b500eb338feea912f8b8482938..b4ab1ea7854514ba35f6fb97b9cb069f50c8dc95 100644 (file)
@@ -94,8 +94,8 @@ public:
                                     FilesMade *filesMade) = 0;
 
   virtual StringRef getName() const = 0;
-  
-  void HandlePathDiagnostic(PathDiagnostic *D);
+
+  void HandlePathDiagnostic(std::unique_ptr<PathDiagnostic> D);
 
   enum PathGenerationScheme { None, Minimal, Extensive, AlternateExtensive };
   virtual PathGenerationScheme getGenerationScheme() const { return Minimal; }
index f01fc7967716b72d3e79d5b401a2031ceb6a4884..143149bc124dde968cb78639143d7e46fa94ae8e 100644 (file)
@@ -3465,7 +3465,7 @@ void BugReporter::FlushReport(BugReport *exampleReport,
     D->addMeta(*i);
   }
 
-  PD.HandlePathDiagnostic(D.release());
+  PD.HandlePathDiagnostic(std::move(D));
 }
 
 void BugReporter::EmitBasicReport(const Decl *DeclWithIssue,
index fd25bd8e3af3a2e949c0a852fe8a96b9e4b6dbbe..b971fff642d41966c1c4b117c44b3f8fe9360549 100644 (file)
@@ -197,9 +197,8 @@ PathDiagnosticConsumer::~PathDiagnosticConsumer() {
   }
 }
 
-void PathDiagnosticConsumer::HandlePathDiagnostic(PathDiagnostic *D) {
-  std::unique_ptr<PathDiagnostic> OwningD(D);
-
+void PathDiagnosticConsumer::HandlePathDiagnostic(
+    std::unique_ptr<PathDiagnostic> D) {
   if (!D || D->path.empty())
     return;
   
@@ -213,7 +212,7 @@ void PathDiagnosticConsumer::HandlePathDiagnostic(PathDiagnostic *D) {
   if (!supportsCrossFileDiagnostics()) {
     // Verify that the entire path is from the same FileID.
     FileID FID;
-    const SourceManager &SMgr = (*D->path.begin())->getLocation().getManager();
+    const SourceManager &SMgr = D->path.front()->getLocation().getManager();
     SmallVector<const PathPieces *, 5> WorkList;
     WorkList.push_back(&D->path);
 
@@ -272,12 +271,12 @@ void PathDiagnosticConsumer::HandlePathDiagnostic(PathDiagnostic *D) {
     if (orig_size <= new_size)
       return;
 
-    assert(orig != D);
+    assert(orig != D.get());
     Diags.RemoveNode(orig);
     delete orig;
   }
 
-  Diags.InsertNode(OwningD.release());
+  Diags.InsertNode(D.release());
 }
 
 static Optional<bool> comparePath(const PathPieces &X, const PathPieces &Y);