diff options
Diffstat (limited to 'clang/lib/StaticAnalyzer/Core')
-rw-r--r-- | clang/lib/StaticAnalyzer/Core/CallEvent.cpp | 56 | ||||
-rw-r--r-- | clang/lib/StaticAnalyzer/Core/CheckerManager.cpp | 4 | ||||
-rw-r--r-- | clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp | 4 |
3 files changed, 18 insertions, 46 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/CallEvent.cpp b/clang/lib/StaticAnalyzer/Core/CallEvent.cpp index cacd3474424..e3f4c61e905 100644 --- a/clang/lib/StaticAnalyzer/Core/CallEvent.cpp +++ b/clang/lib/StaticAnalyzer/Core/CallEvent.cpp @@ -355,6 +355,18 @@ const FunctionDecl *SimpleCall::getDecl() const { } +const FunctionDecl *CXXInstanceCall::getDecl() const { + const CallExpr *CE = cast_or_null<CallExpr>(getOriginExpr()); + if (!CE) + return AnyFunctionCall::getDecl(); + + const FunctionDecl *D = CE->getDirectCallee(); + if (D) + return D; + + return getSVal(CE->getCallee()).getAsFunctionDecl(); +} + void CXXInstanceCall::getExtraInvalidatedRegions(RegionList &Regions) const { if (const MemRegion *R = getCXXThisVal().getAsRegion()) Regions.push_back(R); @@ -389,7 +401,7 @@ RuntimeDefinition CXXInstanceCall::getRuntimeDefinition() const { const CXXMethodDecl *MD = cast<CXXMethodDecl>(D); if (!MD->isVirtual()) - return SimpleCall::getRuntimeDefinition(); + return AnyFunctionCall::getRuntimeDefinition(); // If the method is virtual, see if we can find the actual implementation // based on context-sensitivity. @@ -527,46 +539,6 @@ SVal CXXDestructorCall::getCXXThisVal() const { return UnknownVal(); } -void CXXDestructorCall::getExtraInvalidatedRegions(RegionList &Regions) const { - if (Data) - Regions.push_back(static_cast<const MemRegion *>(Data)); -} - -RuntimeDefinition CXXDestructorCall::getRuntimeDefinition() const { - const Decl *D = AnyFunctionCall::getRuntimeDefinition().getDecl(); - if (!D) - return RuntimeDefinition(); - - const CXXMethodDecl *MD = cast<CXXMethodDecl>(D); - if (!MD->isVirtual()) - return RuntimeDefinition(MD); - - // If the method is virtual, see if we can find the actual implementation - // based on context-sensitivity. - // FIXME: Virtual method calls behave differently when an object is being - // constructed or destructed. It's not as simple as "no devirtualization" - // because a /partially/ constructed object can be referred to through a - // base pointer. We'll eventually want to use DynamicTypeInfo here. - if (const CXXMethodDecl *Devirtualized = devirtualize(MD, getCXXThisVal())) - return RuntimeDefinition(Devirtualized); - - return RuntimeDefinition(); -} - -void CXXDestructorCall::getInitialStackFrameContents( - const StackFrameContext *CalleeCtx, - BindingsTy &Bindings) const { - AnyFunctionCall::getInitialStackFrameContents(CalleeCtx, Bindings); - - SVal ThisVal = getCXXThisVal(); - if (!ThisVal.isUnknown()) { - SValBuilder &SVB = getState()->getStateManager().getSValBuilder(); - const CXXMethodDecl *MD = cast<CXXMethodDecl>(CalleeCtx->getDecl()); - Loc ThisLoc = SVB.getCXXThis(MD, CalleeCtx); - Bindings.push_back(std::make_pair(ThisLoc, ThisVal)); - } -} - CallEvent::param_iterator ObjCMethodCall::param_begin() const { const ObjCMethodDecl *D = getDecl(); @@ -805,7 +777,7 @@ void ObjCMethodCall::getInitialStackFrameContents( } } -CallEventRef<SimpleCall> +CallEventRef<> CallEventManager::getSimpleCall(const CallExpr *CE, ProgramStateRef State, const LocationContext *LCtx) { if (const CXXMemberCallExpr *MCE = dyn_cast<CXXMemberCallExpr>(CE)) diff --git a/clang/lib/StaticAnalyzer/Core/CheckerManager.cpp b/clang/lib/StaticAnalyzer/Core/CheckerManager.cpp index 564404e5653..c7866559c6d 100644 --- a/clang/lib/StaticAnalyzer/Core/CheckerManager.cpp +++ b/clang/lib/StaticAnalyzer/Core/CheckerManager.cpp @@ -504,9 +504,9 @@ CheckerManager::runCheckersForEvalAssume(ProgramStateRef state, /// Only one checker will evaluate the call. void CheckerManager::runCheckersForEvalCall(ExplodedNodeSet &Dst, const ExplodedNodeSet &Src, - const SimpleCall &Call, + const CallEvent &Call, ExprEngine &Eng) { - const CallExpr *CE = Call.getOriginExpr(); + const CallExpr *CE = cast<CallExpr>(Call.getOriginExpr()); for (ExplodedNodeSet::iterator NI = Src.begin(), NE = Src.end(); NI != NE; ++NI) { diff --git a/clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp b/clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp index 37c48d406ef..8ee6723057a 100644 --- a/clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp +++ b/clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp @@ -445,7 +445,7 @@ void ExprEngine::VisitCallExpr(const CallExpr *CE, ExplodedNode *Pred, // Get the call in its initial state. We use this as a template to perform // all the checks. CallEventManager &CEMgr = getStateManager().getCallEventManager(); - CallEventRef<SimpleCall> CallTemplate + CallEventRef<> CallTemplate = CEMgr.getSimpleCall(CE, Pred->getState(), Pred->getLocationContext()); // Evaluate the function call. We try each of the checkers @@ -465,7 +465,7 @@ void ExprEngine::VisitCallExpr(const CallExpr *CE, ExplodedNode *Pred, } void ExprEngine::evalCall(ExplodedNodeSet &Dst, ExplodedNode *Pred, - const SimpleCall &Call) { + const CallEvent &Call) { // WARNING: At this time, the state attached to 'Call' may be older than the // state in 'Pred'. This is a minor optimization since CheckerManager will // use an updated CallEvent instance when calling checkers, but if 'Call' is |