From: Jordan Rose Date: Thu, 6 Dec 2012 18:58:15 +0000 (+0000) Subject: [analyzer] Use a smarter algorithm to find the last block in an inlined call. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4ecca28e20410f5e2816c5ddff5cdeaf45fb74b5;p=clang [analyzer] Use a smarter algorithm to find the last block in an inlined call. Previously we would search for the last statement, then back up to the entrance of the block that contained that statement. Now, while we're scanning for the statement, we just keep track of which blocks are being exited (in reverse order). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169526 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp b/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp index 7528b7fbf2..3ce4612160 100644 --- a/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp +++ b/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp @@ -64,6 +64,7 @@ void ExprEngine::processCallEnter(CallEnter CE, ExplodedNode *Pred) { static std::pair getLastStmt(const ExplodedNode *Node) { const Stmt *S = 0; + const CFGBlock *Blk = 0; const StackFrameContext *SF = Node->getLocation().getLocationContext()->getCurrentStackFrame(); @@ -91,6 +92,8 @@ static std::pairgetCalleeContext() != CEE->getCalleeContext()); // Continue searching the graph. + } else if (const BlockEdge *BE = dyn_cast(&PP)) { + Blk = BE->getSrc(); } } else if (const CallEnter *CE = dyn_cast(&PP)) { // If we reached the CallEnter for this function, it has no statements. @@ -104,24 +107,6 @@ static std::pairpred_begin(); } - const CFGBlock *Blk = 0; - if (S) { - // Now, get the enclosing basic block. - while (Node) { - const ProgramPoint &PP = Node->getLocation(); - if (isa(PP) && - (PP.getLocationContext()->getCurrentStackFrame() == SF)) { - BlockEdge &EPP = cast(PP); - Blk = EPP.getDst(); - break; - } - if (Node->pred_empty()) - return std::pair(S, (CFGBlock*)0); - - Node = *Node->pred_begin(); - } - } - return std::pair(S, Blk); }