From 089c5510b81360ec63ecc5954ffae67b36f15b0d Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Fri, 21 Sep 2012 06:13:13 +0000 Subject: [PATCH] Simplify getRuntimeDefinition() back to taking no arguments. llvm-svn: 164363 --- clang/include/clang/Analysis/AnalysisContext.h | 6 ++++++ .../StaticAnalyzer/Core/PathSensitive/CallEvent.h | 25 +++++++++------------- clang/lib/StaticAnalyzer/Core/CallEvent.cpp | 18 ++++++++-------- .../Core/ExprEngineCallAndReturn.cpp | 2 +- 4 files changed, 26 insertions(+), 25 deletions(-) diff --git a/clang/include/clang/Analysis/AnalysisContext.h b/clang/include/clang/Analysis/AnalysisContext.h index 0185e8b..02b8530 100644 --- a/clang/include/clang/Analysis/AnalysisContext.h +++ b/clang/include/clang/Analysis/AnalysisContext.h @@ -104,6 +104,12 @@ public: ASTContext &getASTContext() const { return D->getASTContext(); } const Decl *getDecl() const { return D; } + /// Return the AnalysisDeclContextManager (if any) that created + /// this AnalysisDeclContext. + AnalysisDeclContextManager *getManager() const { + return Manager; + } + /// Return the build options used to construct the CFG. CFG::BuildOptions &getCFGBuildOptions() { return cfgBuildOptions; diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h index 1b9a33e..bd05116 100644 --- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h +++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h @@ -192,8 +192,7 @@ public: /// \brief Returns the definition of the function or method that will be /// called. - virtual RuntimeDefinition - getRuntimeDefinition(AnalysisDeclContextManager &M) const = 0; + virtual RuntimeDefinition getRuntimeDefinition() const = 0; /// \brief Returns the expression whose value will be the result of this call. /// May be null. @@ -366,13 +365,14 @@ public: return cast(CallEvent::getDecl()); } - virtual RuntimeDefinition - getRuntimeDefinition(AnalysisDeclContextManager &M) const { + virtual RuntimeDefinition getRuntimeDefinition() const { const FunctionDecl *FD = getDecl(); // Note that the AnalysisDeclContext will have the FunctionDecl with // the definition (if one exists). if (FD) { - AnalysisDeclContext *AD = M.getContext(FD); + AnalysisDeclContext *AD = + getLocationContext()->getAnalysisDeclContext()-> + getManager()->getContext(FD); if (AD->getBody()) return RuntimeDefinition(AD->getDecl()); } @@ -476,8 +476,7 @@ public: return BR->getDecl(); } - virtual RuntimeDefinition - getRuntimeDefinition(AnalysisDeclContextManager &M) const { + virtual RuntimeDefinition getRuntimeDefinition() const { return RuntimeDefinition(getBlockDecl()); } @@ -519,8 +518,7 @@ public: virtual const FunctionDecl *getDecl() const; - virtual RuntimeDefinition - getRuntimeDefinition(AnalysisDeclContextManager &M) const; + virtual RuntimeDefinition getRuntimeDefinition() const; virtual void getInitialStackFrameContents(const StackFrameContext *CalleeCtx, BindingsTy &Bindings) const; @@ -562,8 +560,7 @@ public: virtual const Expr *getCXXThisExpr() const; - virtual RuntimeDefinition - getRuntimeDefinition(AnalysisDeclContextManager &M) const; + virtual RuntimeDefinition getRuntimeDefinition() const; virtual Kind getKind() const { return CE_CXXMember; } @@ -643,8 +640,7 @@ public: virtual SourceRange getSourceRange() const { return Location; } virtual unsigned getNumArgs() const { return 0; } - virtual RuntimeDefinition - getRuntimeDefinition(AnalysisDeclContextManager &M) const; + virtual RuntimeDefinition getRuntimeDefinition() const; /// \brief Returns the value of the implicit 'this' object. virtual SVal getCXXThisVal() const; @@ -850,8 +846,7 @@ public: llvm_unreachable("Unknown message kind"); } - virtual RuntimeDefinition - getRuntimeDefinition(AnalysisDeclContextManager &M) const; + virtual RuntimeDefinition getRuntimeDefinition() const; virtual void getInitialStackFrameContents(const StackFrameContext *CalleeCtx, BindingsTy &Bindings) const; diff --git a/clang/lib/StaticAnalyzer/Core/CallEvent.cpp b/clang/lib/StaticAnalyzer/Core/CallEvent.cpp index 3743871..3b4c134 100644 --- a/clang/lib/StaticAnalyzer/Core/CallEvent.cpp +++ b/clang/lib/StaticAnalyzer/Core/CallEvent.cpp @@ -414,7 +414,7 @@ SVal CXXInstanceCall::getCXXThisVal() const { } -RuntimeDefinition CXXInstanceCall::getRuntimeDefinition(AnalysisDeclContextManager &M) const { +RuntimeDefinition CXXInstanceCall::getRuntimeDefinition() const { // Do we have a decl at all? const Decl *D = getDecl(); if (!D) @@ -423,7 +423,7 @@ RuntimeDefinition CXXInstanceCall::getRuntimeDefinition(AnalysisDeclContextManag // If the method is non-virtual, we know we can inline it. const CXXMethodDecl *MD = cast(D); if (!MD->isVirtual()) - return AnyFunctionCall::getRuntimeDefinition(M); + return AnyFunctionCall::getRuntimeDefinition(); // Do we know the implicit 'this' object being called? const MemRegion *R = getCXXThisVal().getAsRegion(); @@ -513,16 +513,16 @@ const Expr *CXXMemberCall::getCXXThisExpr() const { return getOriginExpr()->getImplicitObjectArgument(); } -RuntimeDefinition CXXMemberCall::getRuntimeDefinition(AnalysisDeclContextManager &M) const { +RuntimeDefinition CXXMemberCall::getRuntimeDefinition() const { // C++11 [expr.call]p1: ...If the selected function is non-virtual, or if the // id-expression in the class member access expression is a qualified-id, // that function is called. Otherwise, its final overrider in the dynamic type // of the object expression is called. if (const MemberExpr *ME = dyn_cast(getOriginExpr()->getCallee())) if (ME->hasQualifier()) - return AnyFunctionCall::getRuntimeDefinition(M); + return AnyFunctionCall::getRuntimeDefinition(); - return CXXInstanceCall::getRuntimeDefinition(M); + return CXXInstanceCall::getRuntimeDefinition(); } @@ -600,13 +600,13 @@ SVal CXXDestructorCall::getCXXThisVal() const { return UnknownVal(); } -RuntimeDefinition CXXDestructorCall::getRuntimeDefinition(AnalysisDeclContextManager &M) const { +RuntimeDefinition CXXDestructorCall::getRuntimeDefinition() const { // Base destructors are always called non-virtually. // Skip CXXInstanceCall's devirtualization logic in this case. if (isBaseDestructor()) - return AnyFunctionCall::getRuntimeDefinition(M); + return AnyFunctionCall::getRuntimeDefinition(); - return CXXInstanceCall::getRuntimeDefinition(M); + return CXXInstanceCall::getRuntimeDefinition(); } @@ -790,7 +790,7 @@ bool ObjCMethodCall::canBeOverridenInSubclass(ObjCInterfaceDecl *IDecl, llvm_unreachable("The while loop should always terminate."); } -RuntimeDefinition ObjCMethodCall::getRuntimeDefinition(AnalysisDeclContextManager &M) const { +RuntimeDefinition ObjCMethodCall::getRuntimeDefinition() const { const ObjCMessageExpr *E = getOriginExpr(); assert(E); Selector Sel = E->getSelector(); diff --git a/clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp b/clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp index 9d4d16c..eb5395e 100644 --- a/clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp +++ b/clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp @@ -640,7 +640,7 @@ void ExprEngine::defaultEvalCall(NodeBuilder &Bldr, ExplodedNode *Pred, // If we already tried once and failed, make sure we don't retry later. State = InlinedFailedState; } else { - RuntimeDefinition RD = Call->getRuntimeDefinition(AnalysisDeclContexts); + RuntimeDefinition RD = Call->getRuntimeDefinition(); const Decl *D = RD.getDecl(); if (D) { if (RD.mayHaveOtherDefinitions()) { -- 2.7.4