diff options
author | Ted Kremenek <kremenek@apple.com> | 2009-08-21 23:58:43 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2009-08-21 23:58:43 +0000 |
commit | cdf5f4aa7ba5c776bdd50a04603783c0d331e2dc (patch) | |
tree | 8ea841bf0354a2b86cb35e239882ad5fe6ac6f0f /clang/lib/Analysis/AnalysisContext.cpp | |
parent | 00aeae98b5da228d335da1b8b6340ec1dba0ddf2 (diff) | |
download | bcm5719-llvm-cdf5f4aa7ba5c776bdd50a04603783c0d331e2dc.tar.gz bcm5719-llvm-cdf5f4aa7ba5c776bdd50a04603783c0d331e2dc.zip |
Remove 'AnalysisContext::setDecl()', as we the Decl associated with an
AnalysisContext should never change. Along the way, propagate some constness
around.
llvm-svn: 79701
Diffstat (limited to 'clang/lib/Analysis/AnalysisContext.cpp')
-rw-r--r-- | clang/lib/Analysis/AnalysisContext.cpp | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/clang/lib/Analysis/AnalysisContext.cpp b/clang/lib/Analysis/AnalysisContext.cpp index ef47ece70ed..da671d62f13 100644 --- a/clang/lib/Analysis/AnalysisContext.cpp +++ b/clang/lib/Analysis/AnalysisContext.cpp @@ -28,10 +28,15 @@ AnalysisContext::~AnalysisContext() { delete PM; } +AnalysisContextManager::~AnalysisContextManager() { + for (ContextMap::iterator I = Contexts.begin(), E = Contexts.end(); I!=E; ++I) + delete I->second; +} + Stmt *AnalysisContext::getBody() { - if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) + if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) return FD->getBody(); - else if (ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(D)) + else if (const ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(D)) return MD->getBody(); llvm::llvm_unreachable("unknown code decl"); @@ -70,14 +75,12 @@ LiveVariables *AnalysisContext::getLiveVariables() { return liveness; } -AnalysisContext *AnalysisContextManager::getContext(Decl *D) { - iterator I = Contexts.find(D); - if (I != Contexts.end()) - return &(I->second); - - AnalysisContext &Ctx = Contexts[D]; - Ctx.setDecl(D); - return &Ctx; +AnalysisContext *AnalysisContextManager::getContext(const Decl *D) { + AnalysisContext *&AC = Contexts[D]; + if (!AC) + AC = new AnalysisContext(D); + + return AC; } void LocationContext::Profile(llvm::FoldingSetNodeID &ID, ContextKind k, |