[cfe-commits] r60998 - in /cfe/trunk/lib/CodeGen: CGObjC.cpp CGStmt.cpp CodeGenFunction.h

Anders Carlsson andersca at mac.com
Sat Dec 13 14:52:24 PST 2008


Author: andersca
Date: Sat Dec 13 16:52:24 2008
New Revision: 60998

URL: http://llvm.org/viewvc/llvm-project?rev=60998&view=rev
Log:
Store the size of the EH stack inside each BreakContinue struct so we know when a break/continue won't cross a try block.

Modified:
    cfe/trunk/lib/CodeGen/CGObjC.cpp
    cfe/trunk/lib/CodeGen/CGStmt.cpp
    cfe/trunk/lib/CodeGen/CodeGenFunction.h

Modified: cfe/trunk/lib/CodeGen/CGObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjC.cpp?rev=60998&r1=60997&r2=60998&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjC.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjC.cpp Sat Dec 13 16:52:24 2008
@@ -492,7 +492,8 @@
   llvm::BasicBlock *LoopEnd = createBasicBlock("loopend");
   llvm::BasicBlock *AfterBody = createBasicBlock("afterbody");
   
-  BreakContinueStack.push_back(BreakContinue(LoopEnd, AfterBody));
+  BreakContinueStack.push_back(BreakContinue(LoopEnd, AfterBody, 
+                                             ObjCEHStack.size()));
 
   EmitStmt(S.getBody());
   

Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=60998&r1=60997&r2=60998&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGStmt.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmt.cpp Sat Dec 13 16:52:24 2008
@@ -322,7 +322,8 @@
     Builder.CreateCondBr(BoolCondVal, LoopBody, ExitBlock);
   
   // Store the blocks to use for break and continue.
-  BreakContinueStack.push_back(BreakContinue(ExitBlock, LoopHeader));
+  BreakContinueStack.push_back(BreakContinue(ExitBlock, LoopHeader, 
+                                             ObjCEHStack.size()));
   
   // Emit the loop body.
   EmitBlock(LoopBody);
@@ -355,7 +356,8 @@
   llvm::BasicBlock *DoCond = createBasicBlock("do.cond");
   
   // Store the blocks to use for break and continue.
-  BreakContinueStack.push_back(BreakContinue(AfterDo, DoCond));
+  BreakContinueStack.push_back(BreakContinue(AfterDo, DoCond, 
+                                             ObjCEHStack.size()));
   
   // Emit the body of the loop into the block.
   EmitStmt(S.getBody());
@@ -433,7 +435,8 @@
     ContinueBlock = CondBlock;  
   
   // Store the blocks to use for break and continue.
-  BreakContinueStack.push_back(BreakContinue(AfterFor, ContinueBlock));
+  BreakContinueStack.push_back(BreakContinue(AfterFor, ContinueBlock,
+                                             ObjCEHStack.size()));
   
   // If the condition is true, execute the body of the for stmt.
   EmitStmt(S.getBody());
@@ -510,7 +513,7 @@
   assert(!BreakContinueStack.empty() && "break stmt not in a loop or switch!");
 
   // FIXME: Implement break in @try or @catch blocks.
-  if (!ObjCEHStack.empty()) {
+  if (ObjCEHStack.size() != BreakContinueStack.back().EHStackSize) {
     CGM.ErrorUnsupported(&S, "continue inside an Obj-C exception block");
     return;
   }
@@ -528,7 +531,7 @@
   assert(!BreakContinueStack.empty() && "continue stmt not in a loop!");
 
   // FIXME: Implement continue in @try or @catch blocks.
-  if (!ObjCEHStack.empty()) {
+  if (ObjCEHStack.size() != BreakContinueStack.back().EHStackSize) {
     CGM.ErrorUnsupported(&S, "continue inside an Obj-C exception block");
     return;
   }
@@ -646,7 +649,8 @@
   llvm::BasicBlock *ContinueBlock = NULL;
   if (!BreakContinueStack.empty())
     ContinueBlock = BreakContinueStack.back().ContinueBlock;
-  BreakContinueStack.push_back(BreakContinue(NextBlock, ContinueBlock));
+  BreakContinueStack.push_back(BreakContinue(NextBlock, ContinueBlock,
+                                             ObjCEHStack.size()));
 
   // Emit switch body.
   EmitStmt(S.getBody());

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=60998&r1=60997&r2=60998&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Sat Dec 13 16:52:24 2008
@@ -148,13 +148,14 @@
   llvm::DenseMap<const LabelStmt*, llvm::BasicBlock*> LabelMap;
   
   // BreakContinueStack - This keeps track of where break and continue 
-  // statements should jump to.
+  // statements should jump to, as well as the size of the eh stack.
   struct BreakContinue {
-    BreakContinue(llvm::BasicBlock *bb, llvm::BasicBlock *cb)
-      : BreakBlock(bb), ContinueBlock(cb) {}
+    BreakContinue(llvm::BasicBlock *bb, llvm::BasicBlock *cb, size_t ehss)
+      : BreakBlock(bb), ContinueBlock(cb), EHStackSize(ehss) {}
       
     llvm::BasicBlock *BreakBlock;
     llvm::BasicBlock *ContinueBlock;
+    size_t EHStackSize;
   }; 
   llvm::SmallVector<BreakContinue, 8> BreakContinueStack;
 





More information about the cfe-commits mailing list