From: David Blaikie Date: Fri, 29 Aug 2014 19:57:52 +0000 (+0000) Subject: unique_ptrify thep passing of BugReports to BugReportEquivClass X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bacd21635973ff487d0b871567c77c42904c65cd;p=clang unique_ptrify thep passing of BugReports to BugReportEquivClass I suspect llvm::ilist should take elements by unique_ptr, since it does take ownership of the element (by stitching it into the linked list) - one day. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@216761 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h b/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h index 3e1745e840..54a0fb4541 100644 --- a/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h +++ b/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h @@ -345,9 +345,12 @@ class BugReportEquivClass : public llvm::FoldingSetNode { llvm::ilist Reports; friend class BugReporter; - void AddReport(BugReport* R) { Reports.push_back(R); } + void AddReport(std::unique_ptr R) { + Reports.push_back(R.release()); + } + public: - BugReportEquivClass(BugReport* R) { Reports.push_back(R); } + BugReportEquivClass(std::unique_ptr R) { AddReport(std::move(R)); } ~BugReportEquivClass(); void Profile(llvm::FoldingSetNodeID& ID) const { diff --git a/lib/StaticAnalyzer/Core/BugReporter.cpp b/lib/StaticAnalyzer/Core/BugReporter.cpp index 89fd8d3e1b..f01fc79677 100644 --- a/lib/StaticAnalyzer/Core/BugReporter.cpp +++ b/lib/StaticAnalyzer/Core/BugReporter.cpp @@ -3278,12 +3278,11 @@ void BugReporter::emitReport(BugReport* R) { BugReportEquivClass* EQ = EQClasses.FindNodeOrInsertPos(ID, InsertPos); if (!EQ) { - EQ = new BugReportEquivClass(UniqueR.release()); + EQ = new BugReportEquivClass(std::move(UniqueR)); EQClasses.InsertNode(EQ, InsertPos); EQClassesVector.push_back(EQ); - } - else - EQ->AddReport(UniqueR.release()); + } else + EQ->AddReport(std::move(UniqueR)); }