diff options
author | Jordan Rose <jordan_rose@apple.com> | 2012-07-09 16:54:49 +0000 |
---|---|---|
committer | Jordan Rose <jordan_rose@apple.com> | 2012-07-09 16:54:49 +0000 |
commit | ee158bc29bc12ce544996f7cdfde14aba63acf4d (patch) | |
tree | a0f52607ceb2dcbee9a4bac68815f3894ee7d99b /lib | |
parent | 6deae7cc8de2fb7578ed244d064cd34af744aac5 (diff) |
[analyzer] When inlining, make sure we use the definition decl.
This was a regression introduced during the CallEvent changes; a call to
FunctionDecl::hasBody was also being used to replace the decl found by
lookup with the actual definition. To keep from making this mistake again
(particularly if/when we start inlining Objective-C methods), this commit
adds a "getDefinition()" method to CallEvent, which should do the right
thing under any circumstances.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159940 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp b/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp index b2b1ab561b..6fb41930d3 100644 --- a/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp +++ b/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp @@ -274,7 +274,10 @@ bool ExprEngine::inlineCall(ExplodedNodeSet &Dst, const StackFrameContext *CallerSFC = Pred->getLocationContext()->getCurrentStackFrame(); - const Decl *D = Call.getDecl(); + const Decl *D = Call.getDefinition(); + if (!D) + return false; + const LocationContext *ParentOfCallee = 0; switch (Call.getKind()) { @@ -298,9 +301,7 @@ bool ExprEngine::inlineCall(ExplodedNodeSet &Dst, return false; case CE_Block: { const BlockDataRegion *BR = cast<BlockCall>(Call).getBlockRegion(); - if (!BR) - return false; - D = BR->getDecl(); + assert(BR && "If we have the block definition we should have its region"); AnalysisDeclContext *BlockCtx = AMgr.getAnalysisDeclContext(D); ParentOfCallee = BlockCtx->getBlockInvocationContext(CallerSFC, cast<BlockDecl>(D), @@ -313,8 +314,8 @@ bool ExprEngine::inlineCall(ExplodedNodeSet &Dst, // that a particular method will be called at runtime. return false; } - - if (!D || !shouldInlineDecl(D, Pred)) + + if (!shouldInlineDecl(D, Pred)) return false; if (!ParentOfCallee) |