diff --git a/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h b/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h index d45c4b71e780a1..51565524db1e68 100644 --- a/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h +++ b/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h @@ -589,7 +589,7 @@ class BugReporter { std::vector EQClassesVector; public: - BugReporter(BugReporterData &d) : D(d) {} + BugReporter(BugReporterData &d); virtual ~BugReporter(); /// Generate and flush diagnostics for all bug reports. @@ -632,7 +632,7 @@ class BugReporter { ArrayRef Fixits = None); private: - llvm::StringMap StrBugTypes; + llvm::StringMap> StrBugTypes; /// Returns a BugType that is associated with the given name and /// category. diff --git a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp index 0848d6a6ec61fb..efae511da83b45 100644 --- a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp +++ b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp @@ -2390,6 +2390,7 @@ ProgramStateManager &PathSensitiveBugReporter::getStateManager() const { return Eng.getStateManager(); } +BugReporter::BugReporter(BugReporterData &d) : D(d) {} BugReporter::~BugReporter() { // Make sure reports are flushed. assert(StrBugTypes.empty() && @@ -2410,7 +2411,7 @@ void BugReporter::FlushReports() { // EmitBasicReport. // FIXME: There are leaks from checkers that assume that the BugTypes they // create will be destroyed by the BugReporter. - llvm::DeleteContainerSeconds(StrBugTypes); + StrBugTypes.clear(); } //===----------------------------------------------------------------------===// @@ -3263,8 +3264,8 @@ BugType *BugReporter::getBugTypeForName(CheckerNameRef CheckName, SmallString<136> fullDesc; llvm::raw_svector_ostream(fullDesc) << CheckName.getName() << ":" << name << ":" << category; - BugType *&BT = StrBugTypes[fullDesc]; + std::unique_ptr &BT = StrBugTypes[fullDesc]; if (!BT) - BT = new BugType(CheckName, name, category); - return BT; + BT = std::make_unique(CheckName, name, category); + return BT.get(); }