From 5cb35e16766848ab29b2b00d74c222119b0edfbc Mon Sep 17 00:00:00 2001 From: Justin Lebar Date: Mon, 10 Oct 2016 16:26:44 +0000 Subject: [PATCH] [Analysis] Use unique_ptr in AnalyaisDeclContextManager's ContextMap. Reviewers: timshen Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D25426 llvm-svn: 283774 --- clang/include/clang/Analysis/AnalysisContext.h | 3 ++- clang/lib/Analysis/AnalysisDeclContext.cpp | 14 +++++--------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/clang/include/clang/Analysis/AnalysisContext.h b/clang/include/clang/Analysis/AnalysisContext.h index 4324a03..f6a47d6 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 6bbe8f8..6b58916 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() {} -- 2.7.4