[cfe-commits] r56958 - /cfe/trunk/lib/CodeGen/CGStmt.cpp

Daniel Dunbar daniel at zuster.org
Thu Oct 2 11:02:09 PDT 2008


Author: ddunbar
Date: Thu Oct  2 13:02:06 2008
New Revision: 56958

URL: http://llvm.org/viewvc/llvm-project?rev=56958&view=rev
Log:
Emit error unsupported for break/continue/goto inside Obj-C exception
handling blocks.
 - This has false positives, but at least prevents miscompiles.

Modified:
    cfe/trunk/lib/CodeGen/CGStmt.cpp

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

==============================================================================
--- cfe/trunk/lib/CodeGen/CGStmt.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmt.cpp Thu Oct  2 13:02:06 2008
@@ -70,8 +70,24 @@
   case Stmt::ReturnStmtClass:   EmitReturnStmt(cast<ReturnStmt>(*S));     break;
   case Stmt::DeclStmtClass:     EmitDeclStmt(cast<DeclStmt>(*S));         break;
       
-  case Stmt::BreakStmtClass:    EmitBreakStmt();                          break;
-  case Stmt::ContinueStmtClass: EmitContinueStmt();                       break;
+  case Stmt::BreakStmtClass:    
+    // FIXME: Implement break in @try or @catch blocks.
+    if (!ObjCEHStack.empty()) {
+      CGM.ErrorUnsupported(S, "continue inside an Obj-C exception block");
+      return;
+    }
+    EmitBreakStmt();                          
+    break;
+
+  case Stmt::ContinueStmtClass: 
+    // FIXME: Implement continue in @try or @catch blocks.
+    if (!ObjCEHStack.empty()) {
+      CGM.ErrorUnsupported(S, "continue inside an Obj-C exception block");
+      return;
+    }
+    EmitContinueStmt();                       
+    break;
+
   case Stmt::SwitchStmtClass:   EmitSwitchStmt(cast<SwitchStmt>(*S));     break;
   case Stmt::DefaultStmtClass:  EmitDefaultStmt(cast<DefaultStmt>(*S));   break;
   case Stmt::CaseStmtClass:     EmitCaseStmt(cast<CaseStmt>(*S));         break;
@@ -168,6 +184,12 @@
 }
 
 void CodeGenFunction::EmitGotoStmt(const GotoStmt &S) {
+  // FIXME: Implement goto out in @try or @catch blocks.
+  if (!ObjCEHStack.empty()) {
+    CGM.ErrorUnsupported(&S, "goto inside an Obj-C exception block");
+    return;
+  }
+
   Builder.CreateBr(getBasicBlockForLabel(S.getLabel()));
   
   // Emit a block after the branch so that dead code after a goto has some place
@@ -176,6 +198,12 @@
 }
 
 void CodeGenFunction::EmitIndirectGotoStmt(const IndirectGotoStmt &S) {
+  // FIXME: Implement indirect goto in @try or @catch blocks.
+  if (!ObjCEHStack.empty()) {
+    CGM.ErrorUnsupported(&S, "goto inside an Obj-C exception block");
+    return;
+  }
+
   // Emit initial switch which will be patched up later by
   // EmitIndirectSwitches(). We need a default dest, so we use the
   // current BB, but this is overwritten.





More information about the cfe-commits mailing list