r216752 - unique_ptrify PathDiagnostic::setEndOfPath's argument
David Blaikie
dblaikie at gmail.com
Fri Aug 29 11:18:47 PDT 2014
Author: dblaikie
Date: Fri Aug 29 13:18:47 2014
New Revision: 216752
URL: http://llvm.org/viewvc/llvm-project?rev=216752&view=rev
Log:
unique_ptrify PathDiagnostic::setEndOfPath's argument
Again, if shared ownership is the right model here (I assume it is,
given graph algorithms & such) this could be tidied up (the 'release'
call removed in favor of something safer) by having
IntrunsiveRefCntPointer constructible from a unique_ptr.
(& honestly I'd probably favor taking a page out of shared_ptr's book,
allowing implicit construction from a unique_ptr rvalue, and only allow
explicit from a raw pointer - currently IntrusiveRefCntPointer can
implicitly own from a raw pointer, which seems unsafe)
Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.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=216752&r1=216751&r2=216752&view=diff
==============================================================================
--- cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h Fri Aug 29 13:18:47 2014
@@ -762,11 +762,11 @@ public:
bool isWithinCall() const { return !pathStack.empty(); }
- void setEndOfPath(PathDiagnosticPiece *EndPiece) {
+ void setEndOfPath(std::unique_ptr<PathDiagnosticPiece> EndPiece) {
assert(!Loc.isValid() && "End location already set!");
Loc = EndPiece->getLocation();
assert(Loc.isValid() && "Invalid location for end-of-path piece");
- getActivePath().push_back(EndPiece);
+ getActivePath().push_back(EndPiece.release());
}
void appendToDesc(StringRef S) {
Modified: cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp?rev=216752&r1=216751&r2=216752&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp Fri Aug 29 13:18:47 2014
@@ -3165,7 +3165,7 @@ bool GRBugReporter::generatePathDiagnost
if (!LastPiece)
LastPiece = BugReporterVisitor::getDefaultEndPath(PDB, N, *R);
assert(LastPiece);
- PD.setEndOfPath(LastPiece.release());
+ PD.setEndOfPath(std::move(LastPiece));
}
// Make sure we get a clean location context map so we don't
@@ -3450,13 +3450,13 @@ void BugReporter::FlushReport(BugReport
// of the issue.
if (D->path.empty()) {
PathDiagnosticLocation L = exampleReport->getLocation(getSourceManager());
- PathDiagnosticPiece *piece =
- new PathDiagnosticEventPiece(L, exampleReport->getDescription());
+ auto piece = llvm::make_unique<PathDiagnosticEventPiece>(
+ L, exampleReport->getDescription());
BugReport::ranges_iterator Beg, End;
std::tie(Beg, End) = exampleReport->getRanges();
for ( ; Beg != End; ++Beg)
piece->addRange(*Beg);
- D->setEndOfPath(piece);
+ D->setEndOfPath(std::move(piece));
}
// Get the meta data.
More information about the cfe-commits
mailing list