Jelajahi Sumber

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
David Blaikie 11 tahun lalu
induk
melakukan
bacd216359

+ 5 - 2
include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h

@@ -345,9 +345,12 @@ class BugReportEquivClass : public llvm::FoldingSetNode {
   llvm::ilist<BugReport> Reports;
 
   friend class BugReporter;
-  void AddReport(BugReport* R) { Reports.push_back(R); }
+  void AddReport(std::unique_ptr<BugReport> R) {
+    Reports.push_back(R.release());
+  }
+
 public:
-  BugReportEquivClass(BugReport* R) { Reports.push_back(R); }
+  BugReportEquivClass(std::unique_ptr<BugReport> R) { AddReport(std::move(R)); }
   ~BugReportEquivClass();
 
   void Profile(llvm::FoldingSetNodeID& ID) const {

+ 3 - 4
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));
 }