aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2008-09-11 08:21:54 +0000
committerAnders Carlsson <andersca@mac.com>2008-09-11 08:21:54 +0000
commit1452f5599d4de1d97a71ad61786126b91da9da69 (patch)
treed21acf0c6e7bafe8dc716844a2ac00398735dc28
parent4b7ff6ebd7879ebf86cf6d0108d35d817135d513 (diff)
Make sure to emit the catch parameter as well as the catch body.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56101 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/CodeGen/CGObjC.cpp8
-rw-r--r--lib/CodeGen/CGObjCMac.cpp7
-rw-r--r--lib/CodeGen/CGStmt.cpp4
-rw-r--r--lib/CodeGen/CodeGenFunction.h1
4 files changed, 15 insertions, 5 deletions
diff --git a/lib/CodeGen/CGObjC.cpp b/lib/CodeGen/CGObjC.cpp
index a3da59410d..73f948984a 100644
--- a/lib/CodeGen/CGObjC.cpp
+++ b/lib/CodeGen/CGObjC.cpp
@@ -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() {}
diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp
index 0134c70983..d1875ac40b 100644
--- a/lib/CodeGen/CGObjCMac.cpp
+++ b/lib/CodeGen/CGObjCMac.cpp
@@ -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);
diff --git a/lib/CodeGen/CGStmt.cpp b/lib/CodeGen/CGStmt.cpp
index bf3469e538..5b88a19cf0 100644
--- a/lib/CodeGen/CGStmt.cpp
+++ b/lib/CodeGen/CGStmt.cpp
@@ -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;
diff --git a/lib/CodeGen/CodeGenFunction.h b/lib/CodeGen/CodeGenFunction.h
index 263a0f2f53..e2b0a2b5eb 100644
--- a/lib/CodeGen/CodeGenFunction.h
+++ b/lib/CodeGen/CodeGenFunction.h
@@ -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);
//===--------------------------------------------------------------------===//