From: David Blaikie Date: Fri, 29 Aug 2014 18:18:47 +0000 (+0000) Subject: unique_ptrify PathDiagnostic::setEndOfPath's argument X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f990758c7bf88340ef832db834510f5388506171;p=clang 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) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@216752 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h b/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h index cbd0b6192a..f92077f309 100644 --- a/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h +++ b/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h @@ -762,11 +762,11 @@ public: bool isWithinCall() const { return !pathStack.empty(); } - void setEndOfPath(PathDiagnosticPiece *EndPiece) { + void setEndOfPath(std::unique_ptr 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) { diff --git a/lib/StaticAnalyzer/Core/BugReporter.cpp b/lib/StaticAnalyzer/Core/BugReporter.cpp index 5589e329b6..89fd8d3e1b 100644 --- a/lib/StaticAnalyzer/Core/BugReporter.cpp +++ b/lib/StaticAnalyzer/Core/BugReporter.cpp @@ -3165,7 +3165,7 @@ bool GRBugReporter::generatePathDiagnostic(PathDiagnostic& PD, 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 *exampleReport, // of the issue. if (D->path.empty()) { PathDiagnosticLocation L = exampleReport->getLocation(getSourceManager()); - PathDiagnosticPiece *piece = - new PathDiagnosticEventPiece(L, exampleReport->getDescription()); + auto piece = llvm::make_unique( + 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.