aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGObjC.cpp
diff options
context:
space:
mode:
authorMike Stump <mrs@apple.com>2009-02-07 20:09:00 +0000
committerMike Stump <mrs@apple.com>2009-02-07 20:09:00 +0000
commit501af1f721d837a565b947bf194a3476db32d926 (patch)
tree2909856f4bfa48ef373247011f06c203fde3f318 /lib/CodeGen/CGObjC.cpp
parentbfee9b2d909b80ef56b49980665016b9eecacf12 (diff)
Ensure that we don't miscodegen if vlas creap into the top of the for.
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
Diffstat (limited to 'lib/CodeGen/CGObjC.cpp')
-rw-r--r--lib/CodeGen/CGObjC.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/CodeGen/CGObjC.cpp b/lib/CodeGen/CGObjC.cpp
index d62cfdc306..a116316641 100644
--- a/lib/CodeGen/CGObjC.cpp
+++ b/lib/CodeGen/CGObjC.cpp
@@ -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());