CFG:
- Add 'LoopTarget' pointer field to CFGBlock. This records if the block is used
  as the 'loop back' path back to the head of a loop.
- For ForStmt, encode the loop back target as the increment code.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70274 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/CFG.cpp b/lib/AST/CFG.cpp
index 14c93f3..00f5960 100644
--- a/lib/AST/CFG.cpp
+++ b/lib/AST/CFG.cpp
@@ -752,21 +752,27 @@
       // Generate increment code in its own basic block.  This is the target
       // of continue statements.
       Succ = Visit(I);
-      
-      // Finish up the increment block if it hasn't been already.
-      if (Block) {
-        assert (Block == Succ);
-        FinishBlock(Block);
-        Block = 0;
-      }
-      
-      ContinueTargetBlock = Succ;    
     }
     else {
-      // No increment code.  Continues should go the the entry condition block.
-      ContinueTargetBlock = EntryConditionBlock;
+      // No increment code.  Create a special, empty, block that is used as
+      // the target block for "looping back" to the start of the loop.
+      assert(Succ == EntryConditionBlock);
+      Succ = createBlock();
     }
     
+    // Finish up the increment (or empty) block if it hasn't been already.
+    if (Block) {
+      assert(Block == Succ);
+      FinishBlock(Block);
+      Block = 0;
+    }
+    
+    ContinueTargetBlock = Succ;
+    
+    // The starting block for the loop increment is the block that should
+    // represent the 'loop target' for looping back to the start of the loop.
+    ContinueTargetBlock->setLoopTarget(F);
+
     // All breaks should go to the code following the loop.
     BreakTargetBlock = LoopSuccessor;