]> granicus.if.org Git - clang/commitdiff
CFGBuilder: don't create the empty "loop back" block for DoStmts if the loop edge...
authorTed Kremenek <kremenek@apple.com>
Tue, 17 Aug 2010 20:59:56 +0000 (20:59 +0000)
committerTed Kremenek <kremenek@apple.com>
Tue, 17 Aug 2010 20:59:56 +0000 (20:59 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111282 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/CFG.cpp

index f8f26f61075c7d19d83dd2d5d42bacd3b993eae5..1d5d8521ad5f5a01d09f9977d78071d8890a26d9 100644 (file)
@@ -1476,18 +1476,22 @@ CFGBlock *CFGBuilder::VisitDoStmt(DoStmt* D) {
         return 0;
     }
 
-    // Add an intermediate block between the BodyBlock and the
-    // ExitConditionBlock to represent the "loop back" transition.  Create an
-    // empty block to represent the transition block for looping back to the
-    // head of the loop.
-    // FIXME: Can we do this more efficiently without adding another block?
-    Block = NULL;
-    Succ = BodyBlock;
-    CFGBlock *LoopBackBlock = createBlock();
-    LoopBackBlock->setLoopTarget(D);
-
-    // Add the loop body entry as a successor to the condition.
-    AddSuccessor(ExitConditionBlock, KnownVal.isFalse() ? NULL : LoopBackBlock);
+    if (!KnownVal.isFalse()) {
+      // Add an intermediate block between the BodyBlock and the
+      // ExitConditionBlock to represent the "loop back" transition.  Create an
+      // empty block to represent the transition block for looping back to the
+      // head of the loop.
+      // FIXME: Can we do this more efficiently without adding another block?
+      Block = NULL;
+      Succ = BodyBlock;
+      CFGBlock *LoopBackBlock = createBlock();
+      LoopBackBlock->setLoopTarget(D);
+
+      // Add the loop body entry as a successor to the condition.
+      AddSuccessor(ExitConditionBlock, LoopBackBlock);
+    }
+    else
+      AddSuccessor(ExitConditionBlock, NULL);
   }
 
   // Link up the condition block with the code that follows the loop.