]> granicus.if.org Git - clang/commitdiff
[analyzer] Use a smarter algorithm to find the last block in an inlined call.
authorJordan Rose <jordan_rose@apple.com>
Thu, 6 Dec 2012 18:58:15 +0000 (18:58 +0000)
committerJordan Rose <jordan_rose@apple.com>
Thu, 6 Dec 2012 18:58:15 +0000 (18:58 +0000)
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

lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp

index 7528b7fbf2e56f5eef99cae1fdd16d1cb3943d27..3ce46121607ebb177ad069ac2f3c2f6ddb77fafe 100644 (file)
@@ -64,6 +64,7 @@ void ExprEngine::processCallEnter(CallEnter CE, ExplodedNode *Pred) {
 static std::pair<const Stmt*,
                  const CFGBlock*> 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::pair<const Stmt*,
         } while (!CE || CE->getCalleeContext() != CEE->getCalleeContext());
 
         // Continue searching the graph.
+      } else if (const BlockEdge *BE = dyn_cast<BlockEdge>(&PP)) {
+        Blk = BE->getSrc();
       }
     } else if (const CallEnter *CE = dyn_cast<CallEnter>(&PP)) {
       // If we reached the CallEnter for this function, it has no statements.
@@ -104,24 +107,6 @@ static std::pair<const Stmt*,
     Node = *Node->pred_begin();
   }
 
-  const CFGBlock *Blk = 0;
-  if (S) {
-    // Now, get the enclosing basic block.
-    while (Node) {
-      const ProgramPoint &PP = Node->getLocation();
-      if (isa<BlockEdge>(PP) &&
-          (PP.getLocationContext()->getCurrentStackFrame() == SF)) {
-        BlockEdge &EPP = cast<BlockEdge>(PP);
-        Blk = EPP.getDst();
-        break;
-      }
-      if (Node->pred_empty())
-        return std::pair<const Stmt*, const CFGBlock*>(S, (CFGBlock*)0);
-
-      Node = *Node->pred_begin();
-    }
-  }
-
   return std::pair<const Stmt*, const CFGBlock*>(S, Blk);
 }