]> granicus.if.org Git - clang/commitdiff
Ensure that we don't miscodegen if vlas creap into the top of the for.
authorMike Stump <mrs@apple.com>
Sat, 7 Feb 2009 20:09:00 +0000 (20:09 +0000)
committerMike Stump <mrs@apple.com>
Sat, 7 Feb 2009 20:09:00 +0000 (20:09 +0000)
This will allow us to generate break and continue even if vlas are
involved without worry that we'll silently generate bad code.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64028 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGObjC.cpp

index d62cfdc3063288ab984309eb5e78e68262963a17..a116316641f547aea80eb6c0c13b24fe95348916 100644 (file)
@@ -446,6 +446,10 @@ void CodeGenFunction::EmitObjCForCollectionStmt(const ObjCForCollectionStmt &S)
   llvm::BasicBlock *LoopStart = createBasicBlock("loopstart");
   EmitBlock(LoopStart);
 
+  // We want to ensure there are no vlas between here and when we
+  // push the break and continue context below.
+  llvm::Value *saveStackDepth = StackDepth;
+
   llvm::Value *CounterPtr = CreateTempAlloca(UnsignedLongLTy, "counter.ptr");
   Builder.CreateStore(Zero, CounterPtr);
   
@@ -515,6 +519,8 @@ void CodeGenFunction::EmitObjCForCollectionStmt(const ObjCForCollectionStmt &S)
   llvm::BasicBlock *LoopEnd = createBasicBlock("loopend");
   llvm::BasicBlock *AfterBody = createBasicBlock("afterbody");
   
+  assert (StackDepth == saveStackDepth && "vla unhandled in for");
+
   BreakContinuePush(LoopEnd, AfterBody);
 
   EmitStmt(S.getBody());