diff --git a/include/clang/Analysis/AnalysisContext.h b/include/clang/Analysis/AnalysisContext.h index 4324a0352e3a1b6f79aae687e2e89bddfd2884d3..f6a47d646d1dd7dad95d7d35a8269a1dbcfe67c7 100644 --- a/include/clang/Analysis/AnalysisContext.h +++ b/include/clang/Analysis/AnalysisContext.h @@ -406,7 +406,8 @@ private: }; class AnalysisDeclContextManager { - typedef llvm::DenseMap<const Decl*, AnalysisDeclContext*> ContextMap; + typedef llvm::DenseMap<const Decl *, std::unique_ptr<AnalysisDeclContext>> + ContextMap; ContextMap Contexts; LocationContextManager LocContexts; diff --git a/lib/Analysis/AnalysisDeclContext.cpp b/lib/Analysis/AnalysisDeclContext.cpp index 6bbe8f86d48eaaa7670e39533c96b49792cf8bbb..6b58916162f630f262d65db3fbde367847428d69 100644 --- a/lib/Analysis/AnalysisDeclContext.cpp +++ b/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<AnalysisDeclContext> &AC = Contexts[D]; if (!AC) - AC = new AnalysisDeclContext(this, D, cfgBuildOptions); - return AC; + AC = llvm::make_unique<AnalysisDeclContext>(this, D, cfgBuildOptions); + return AC.get(); } const StackFrameContext * @@ -606,9 +604,7 @@ AnalysisDeclContext::~AnalysisDeclContext() { } } -AnalysisDeclContextManager::~AnalysisDeclContextManager() { - llvm::DeleteContainerSeconds(Contexts); -} +AnalysisDeclContextManager::~AnalysisDeclContextManager() {} LocationContext::~LocationContext() {}