diff --git a/clang/include/clang/Analysis/AnalysisContext.h b/clang/include/clang/Analysis/AnalysisContext.h index 4324a0352e3a..f6a47d646d1d 100644 --- a/clang/include/clang/Analysis/AnalysisContext.h +++ b/clang/include/clang/Analysis/AnalysisContext.h @@ -406,7 +406,8 @@ private: }; class AnalysisDeclContextManager { - typedef llvm::DenseMap ContextMap; + typedef llvm::DenseMap> + ContextMap; ContextMap Contexts; LocationContextManager LocContexts; diff --git a/clang/lib/Analysis/AnalysisDeclContext.cpp b/clang/lib/Analysis/AnalysisDeclContext.cpp index 6bbe8f86d48e..6b58916162f6 100644 --- a/clang/lib/Analysis/AnalysisDeclContext.cpp +++ b/clang/lib/Analysis/AnalysisDeclContext.cpp @@ -81,9 +81,7 @@ AnalysisDeclContextManager::AnalysisDeclContextManager(bool useUnoptimizedCFG, cfgBuildOptions.AddCXXNewAllocator = addCXXNewAllocator; } -void AnalysisDeclContextManager::clear() { - llvm::DeleteContainerSeconds(Contexts); -} +void AnalysisDeclContextManager::clear() { Contexts.clear(); } static BodyFarm &getBodyFarm(ASTContext &C, CodeInjector *injector = nullptr) { static BodyFarm *BF = new BodyFarm(C, injector); @@ -307,10 +305,10 @@ AnalysisDeclContext *AnalysisDeclContextManager::getContext(const Decl *D) { D = FD; } - AnalysisDeclContext *&AC = Contexts[D]; + std::unique_ptr &AC = Contexts[D]; if (!AC) - AC = new AnalysisDeclContext(this, D, cfgBuildOptions); - return AC; + AC = llvm::make_unique(this, D, cfgBuildOptions); + return AC.get(); } const StackFrameContext * @@ -606,9 +604,7 @@ AnalysisDeclContext::~AnalysisDeclContext() { } } -AnalysisDeclContextManager::~AnalysisDeclContextManager() { - llvm::DeleteContainerSeconds(Contexts); -} +AnalysisDeclContextManager::~AnalysisDeclContextManager() {} LocationContext::~LocationContext() {}