]> granicus.if.org Git - clang/commitdiff
Make this code more resilient against catch variables which need cleanups.
authorJohn McCall <rjmccall@apple.com>
Thu, 12 May 2011 01:00:15 +0000 (01:00 +0000)
committerJohn McCall <rjmccall@apple.com>
Thu, 12 May 2011 01:00:15 +0000 (01:00 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131215 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGObjCRuntime.cpp

index 3d854d41acbe89e21f13ba781cf5806f750863cb..43fceceae2d4f5768abcc2e82f2df2ea4ec30daf 100644 (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);
   }