From: John McCall Date: Thu, 12 May 2011 01:00:15 +0000 (+0000) Subject: Make this code more resilient against catch variables which need cleanups. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fe3e3bd63d73c1a370b0b0447b8744d495fa6626;p=clang Make this code more resilient against catch variables which need cleanups. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131215 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGObjCRuntime.cpp b/lib/CodeGen/CGObjCRuntime.cpp index 3d854d41ac..43fceceae2 100644 --- a/lib/CodeGen/CGObjCRuntime.cpp +++ b/lib/CodeGen/CGObjCRuntime.cpp @@ -233,6 +233,8 @@ void CGObjCRuntime::EmitTryCatchStmt(CodeGenFunction &CGF, cast(Exn)->setDoesNotThrow(); } + CodeGenFunction::RunCleanupsScope cleanups(CGF); + if (endCatchFn) { // Add a cleanup to leave the catch. bool EndCatchMightThrow = (Handler.Variable == 0); @@ -255,9 +257,8 @@ void CGObjCRuntime::EmitTryCatchStmt(CodeGenFunction &CGF, CGF.EmitStmt(Handler.Body); CGF.ObjCEHValueStack.pop_back(); - // Leave the earlier cleanup. - if (endCatchFn) - CGF.PopCleanupBlock(); + // Leave any cleanups associated with the catch. + cleanups.ForceCleanup(); CGF.EmitBranchThroughCleanup(Cont); }