[Analysis] Use unique_ptr in AnalyaisDeclContextManager's ContextMap.

Reviewers: timshen

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D25426

llvm-svn: 283774
This commit is contained in:
Justin Lebar 2016-10-10 16:26:44 +00:00
parent 82380d8eb4
commit 5cb35e1676
2 changed files with 7 additions and 10 deletions

View File

@ -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;

View File

@ -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() {}