Make this code more resilient against catch variables which need cleanups.

llvm-svn: 131215
This commit is contained in:
John McCall 2011-05-12 01:00:15 +00:00
parent cfdf33904b
commit 3f6e745292
1 changed files with 4 additions and 3 deletions

View File

@ -233,6 +233,8 @@ void CGObjCRuntime::EmitTryCatchStmt(CodeGenFunction &CGF,
cast<llvm::CallInst>(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);
}