r216764 - unique_ptrify PathDiagnosticConsumer::HandlePathDiagnostic
David Blaikie
dblaikie at gmail.com
Fri Aug 29 13:06:10 PDT 2014
Author: dblaikie
Date: Fri Aug 29 15:06:10 2014
New Revision: 216764
URL: http://llvm.org/viewvc/llvm-project?rev=216764&view=rev
Log:
unique_ptrify PathDiagnosticConsumer::HandlePathDiagnostic
FoldingSet, another intrusive data structure that could use some
unique_ptr love on its interfaces. Eventually.
Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h?rev=216764&r1=216763&r2=216764&view=diff
==============================================================================
--- cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h Fri Aug 29 15:06:10 2014
@@ -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; }
Modified: cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp?rev=216764&r1=216763&r2=216764&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp Fri Aug 29 15:06:10 2014
@@ -3465,7 +3465,7 @@ void BugReporter::FlushReport(BugReport
D->addMeta(*i);
}
- PD.HandlePathDiagnostic(D.release());
+ PD.HandlePathDiagnostic(std::move(D));
}
void BugReporter::EmitBasicReport(const Decl *DeclWithIssue,
Modified: cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp?rev=216764&r1=216763&r2=216764&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp Fri Aug 29 15:06:10 2014
@@ -197,9 +197,8 @@ PathDiagnosticConsumer::~PathDiagnosticC
}
}
-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::HandlePathD
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::HandlePathD
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);
More information about the cfe-commits
mailing list