aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Lebar <jlebar@google.com>2016-10-10 16:26:44 +0000
committerJustin Lebar <jlebar@google.com>2016-10-10 16:26:44 +0000
commit5cb35e16766848ab29b2b00d74c222119b0edfbc (patch)
tree21ca81bc3b31c78c4bb1ed4d48aadcb3132f68c3
parent82380d8eb489289ce296d6889673aec08c1b83bb (diff)
downloadllvm-5cb35e16766848ab29b2b00d74c222119b0edfbc.zip
llvm-5cb35e16766848ab29b2b00d74c222119b0edfbc.tar.gz
llvm-5cb35e16766848ab29b2b00d74c222119b0edfbc.tar.bz2
[Analysis] Use unique_ptr in AnalyaisDeclContextManager's ContextMap.
Reviewers: timshen Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D25426 llvm-svn: 283774
-rw-r--r--clang/include/clang/Analysis/AnalysisContext.h3
-rw-r--r--clang/lib/Analysis/AnalysisDeclContext.cpp14
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<const Decl*, AnalysisDeclContext*> ContextMap;
+ typedef llvm::DenseMap<const Decl *, std::unique_ptr<AnalysisDeclContext>>
+ 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<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() {}