]> granicus.if.org Git - clang/commitdiff
Make sure to emit the catch parameter as well as the catch body.
authorAnders Carlsson <andersca@mac.com>
Thu, 11 Sep 2008 08:21:54 +0000 (08:21 +0000)
committerAnders Carlsson <andersca@mac.com>
Thu, 11 Sep 2008 08:21:54 +0000 (08:21 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56101 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGObjC.cpp
lib/CodeGen/CGObjCMac.cpp
lib/CodeGen/CGStmt.cpp
lib/CodeGen/CodeGenFunction.h

index a3da59410d96982a9f793d51869e3bb7080170e7..73f948984a131630cc40c791c771e5cef9bda745 100644 (file)
@@ -456,4 +456,12 @@ void CodeGenFunction::EmitObjCAtThrowStmt(const ObjCAtThrowStmt &S)
   CGM.getObjCRuntime().EmitThrowStmt(*this, S);
 }
 
+void CodeGenFunction::EmitObjCAtCatchStmt(const ObjCAtCatchStmt &S)
+{
+  if (const Stmt *CatchParam = S.getCatchParamStmt())
+    EmitStmt(CatchParam);
+  
+  EmitStmt(S.getCatchBody());
+}
+
 CGObjCRuntime::~CGObjCRuntime() {}
index 0134c70983876786ee4c122fe3d6fc6747b05240..d1875ac40b61a0cab01d5520ed4e25aafb9da50b 100644 (file)
@@ -1459,8 +1459,9 @@ void CGObjCMac::EmitTryStmt(CodeGen::CodeGenFunction &CGF,
           MatchesAll = true;
       }
       
-      if (MatchesAll) {        
-        CGF.EmitStmt(CatchStmt->getCatchBody());
+      if (MatchesAll) {   
+        CGF.EmitStmt(CatchStmt);
+        
         CGF.Builder.CreateBr(FinallyBlock);
         
         CGF.EmitBlock(NextCatchBlock);        
@@ -1485,7 +1486,7 @@ void CGObjCMac::EmitTryStmt(CodeGen::CodeGenFunction &CGF,
       
       // Emit the @catch block.
       CGF.EmitBlock(MatchedBlock);
-      CGF.EmitStmt(CatchStmt->getCatchBody());
+      CGF.EmitStmt(CatchStmt);
       CGF.Builder.CreateBr(FinallyBlock);
       
       CGF.EmitBlock(NextCatchBlock);
index bf3469e53873c2befbcd0c10cff241ee3e909bc4..5b88a19cf0e8275b78d2c60bfe088f9a346f67a3 100644 (file)
@@ -81,8 +81,8 @@ void CodeGenFunction::EmitStmt(const Stmt *S) {
     EmitObjCAtTryStmt(cast<ObjCAtTryStmt>(*S));
     break;    
   case Stmt::ObjCAtCatchStmtClass:
-    assert(0 && "@catch statements should be handled by EmitObjCAtTryStmt");
-    break;
+    EmitObjCAtCatchStmt(cast<ObjCAtCatchStmt>(*S));
+    break;    
   case Stmt::ObjCAtFinallyStmtClass:
     assert(0 && "@finally statements should be handled by EmitObjCAtTryStmt");
     break;
index 263a0f2f53167b92e1db55283929c695c178e20b..e2b0a2b5eb00cfa5d9c13acf26d60877d05c2f36 100644 (file)
@@ -269,6 +269,7 @@ public:
   
   void EmitObjCForCollectionStmt(const ObjCForCollectionStmt &S);
   void EmitObjCAtTryStmt(const ObjCAtTryStmt &S);
+  void EmitObjCAtCatchStmt(const ObjCAtCatchStmt &S);
   void EmitObjCAtThrowStmt(const ObjCAtThrowStmt &S);
   
   //===--------------------------------------------------------------------===//