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 | 2376002038c8b904acd20be754aedd1a7471be71 (patch) | |
tree | 5e32e46ec2a013889d309654a9c6821e425134df /lib | |
parent | 54c809b19444a01444f36e93d1d28c9a5668484c (diff) |
Remove 'AnalysisContext::setDecl()', as we the Decl associated with an
AnalysisContext should never change. Along the way, propagate some constness
around.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79701 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Analysis/AnalysisContext.cpp | 23 | ||||
-rw-r--r-- | lib/Analysis/AnalysisManager.cpp | 2 | ||||
-rw-r--r-- | lib/Analysis/CheckObjCDealloc.cpp | 4 | ||||
-rw-r--r-- | lib/Analysis/CheckObjCInstMethSignature.cpp | 14 | ||||
-rw-r--r-- | lib/Analysis/CheckObjCUnusedIVars.cpp | 3 | ||||
-rw-r--r-- | lib/Analysis/CheckSecuritySyntaxOnly.cpp | 2 | ||||
-rw-r--r-- | lib/Analysis/GRExprEngine.cpp | 4 |
7 files changed, 28 insertions, 24 deletions
diff --git a/lib/Analysis/AnalysisContext.cpp b/lib/Analysis/AnalysisContext.cpp index ef47ece70e..da671d62f1 100644 --- a/lib/Analysis/AnalysisContext.cpp +++ b/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, diff --git a/lib/Analysis/AnalysisManager.cpp b/lib/Analysis/AnalysisManager.cpp index 125c00bfee..f29cd78575 100644 --- a/lib/Analysis/AnalysisManager.cpp +++ b/lib/Analysis/AnalysisManager.cpp @@ -27,7 +27,7 @@ void AnalysisManager::DisplayFunction() { // FIXME: Is getCodeDecl() always a named decl? if (isa<FunctionDecl>(getCodeDecl()) || isa<ObjCMethodDecl>(getCodeDecl())) { - NamedDecl *ND = cast<NamedDecl>(getCodeDecl()); + const NamedDecl *ND = cast<NamedDecl>(getCodeDecl()); SourceManager &SM = getContext().getSourceManager(); llvm::cerr << "ANALYZE: " << SM.getPresumedLoc(ND->getLocation()).getFilename() diff --git a/lib/Analysis/CheckObjCDealloc.cpp b/lib/Analysis/CheckObjCDealloc.cpp index 7e6023a1f5..3392fcfdc3 100644 --- a/lib/Analysis/CheckObjCDealloc.cpp +++ b/lib/Analysis/CheckObjCDealloc.cpp @@ -87,13 +87,13 @@ static bool scan_ivar_release(Stmt* S, ObjCIvarDecl* ID, return false; } -void clang::CheckObjCDealloc(ObjCImplementationDecl* D, +void clang::CheckObjCDealloc(const ObjCImplementationDecl* D, const LangOptions& LOpts, BugReporter& BR) { assert (LOpts.getGCMode() != LangOptions::GCOnly); ASTContext& Ctx = BR.getContext(); - ObjCInterfaceDecl* ID = D->getClassInterface(); + const ObjCInterfaceDecl* ID = D->getClassInterface(); // Does the class contain any ivars that are pointers (or id<...>)? // If not, skip the check entirely. diff --git a/lib/Analysis/CheckObjCInstMethSignature.cpp b/lib/Analysis/CheckObjCInstMethSignature.cpp index c208a7c323..aae1e1da3b 100644 --- a/lib/Analysis/CheckObjCInstMethSignature.cpp +++ b/lib/Analysis/CheckObjCInstMethSignature.cpp @@ -36,10 +36,10 @@ static bool AreTypesCompatible(QualType Derived, QualType Ancestor, return C.typesAreCompatible(Derived, Ancestor); } -static void CompareReturnTypes(ObjCMethodDecl* MethDerived, - ObjCMethodDecl* MethAncestor, - BugReporter& BR, ASTContext& Ctx, - ObjCImplementationDecl* ID) { +static void CompareReturnTypes(const ObjCMethodDecl *MethDerived, + const ObjCMethodDecl *MethAncestor, + BugReporter &BR, ASTContext &Ctx, + const ObjCImplementationDecl *ID) { QualType ResDerived = MethDerived->getResultType(); QualType ResAncestor = MethAncestor->getResultType(); @@ -69,11 +69,11 @@ static void CompareReturnTypes(ObjCMethodDecl* MethDerived, } } -void clang::CheckObjCInstMethSignature(ObjCImplementationDecl* ID, +void clang::CheckObjCInstMethSignature(const ObjCImplementationDecl* ID, BugReporter& BR) { - ObjCInterfaceDecl* D = ID->getClassInterface(); - ObjCInterfaceDecl* C = D->getSuperClass(); + const ObjCInterfaceDecl* D = ID->getClassInterface(); + const ObjCInterfaceDecl* C = D->getSuperClass(); if (!C) return; diff --git a/lib/Analysis/CheckObjCUnusedIVars.cpp b/lib/Analysis/CheckObjCUnusedIVars.cpp index 3a69e00499..75470972f3 100644 --- a/lib/Analysis/CheckObjCUnusedIVars.cpp +++ b/lib/Analysis/CheckObjCUnusedIVars.cpp @@ -62,7 +62,8 @@ static void Scan(IvarUsageMap& M, const ObjCPropertyImplDecl* D) { I->second = Used; } -void clang::CheckObjCUnusedIvar(ObjCImplementationDecl* D, BugReporter& BR) { +void clang::CheckObjCUnusedIvar(const ObjCImplementationDecl *D, + BugReporter &BR) { const ObjCInterfaceDecl* ID = D->getClassInterface(); IvarUsageMap M; diff --git a/lib/Analysis/CheckSecuritySyntaxOnly.cpp b/lib/Analysis/CheckSecuritySyntaxOnly.cpp index 17fc6d7c32..96c42f8ba0 100644 --- a/lib/Analysis/CheckSecuritySyntaxOnly.cpp +++ b/lib/Analysis/CheckSecuritySyntaxOnly.cpp @@ -229,7 +229,7 @@ void WalkAST::CheckCall_gets(const CallExpr *CE, const FunctionDecl *FD) { // Entry point for check. //===----------------------------------------------------------------------===// -void clang::CheckSecuritySyntaxOnly(Decl *D, BugReporter &BR) { +void clang::CheckSecuritySyntaxOnly(const Decl *D, BugReporter &BR) { WalkAST walker(BR); walker.Visit(D->getBody()); } diff --git a/lib/Analysis/GRExprEngine.cpp b/lib/Analysis/GRExprEngine.cpp index a8d34071e6..f4711a1520 100644 --- a/lib/Analysis/GRExprEngine.cpp +++ b/lib/Analysis/GRExprEngine.cpp @@ -148,8 +148,8 @@ static inline Selector GetNullarySelector(const char* name, ASTContext& Ctx) { } -GRExprEngine::GRExprEngine(CFG& cfg, Decl& CD, ASTContext& Ctx, - LiveVariables& L, AnalysisManager &mgr, +GRExprEngine::GRExprEngine(CFG &cfg, const Decl &CD, ASTContext &Ctx, + LiveVariables &L, AnalysisManager &mgr, bool purgeDead, bool eagerlyAssume, StoreManagerCreator SMC, ConstraintManagerCreator CMC) |