From 1452f5599d4de1d97a71ad61786126b91da9da69 Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Thu, 11 Sep 2008 08:21:54 +0000 Subject: [PATCH] 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 --- lib/CodeGen/CGObjC.cpp | 8 ++++++++ lib/CodeGen/CGObjCMac.cpp | 7 ++++--- lib/CodeGen/CGStmt.cpp | 4 ++-- lib/CodeGen/CodeGenFunction.h | 1 + 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(*S)); break; case Stmt::ObjCAtCatchStmtClass: - assert(0 && "@catch statements should be handled by EmitObjCAtTryStmt"); - break; + EmitObjCAtCatchStmt(cast(*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); //===--------------------------------------------------------------------===// -- 2.40.0