[cfe-commits] r108288 - /cfe/trunk/lib/CodeGen/CGException.cpp

John McCall rjmccall at apple.com
Tue Jul 13 15:24:23 PDT 2010


Author: rjmccall
Date: Tue Jul 13 17:24:23 2010
New Revision: 108288

URL: http://llvm.org/viewvc/llvm-project?rev=108288&view=rev
Log:
Switch the __cxa_rethrow cleanup to be lazy.


Modified:
    cfe/trunk/lib/CodeGen/CGException.cpp

Modified: cfe/trunk/lib/CodeGen/CGException.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGException.cpp?rev=108288&r1=108287&r2=108288&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGException.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGException.cpp Tue Jul 13 17:24:23 2010
@@ -1202,6 +1202,14 @@
   CGF.EmitLocalBlockVarDecl(*CatchParam, &InitCatchParam);
 }
 
+namespace {
+  struct CallRethrow : EHScopeStack::LazyCleanup {
+    void Emit(CodeGenFunction &CGF, bool IsForEH) {
+      CGF.EmitCallOrInvoke(getReThrowFn(CGF), 0, 0);
+    }
+  };
+}
+
 void CodeGenFunction::ExitCXXTryStmt(const CXXTryStmt &S, bool IsFnTryBlock) {
   unsigned NumHandlers = S.getNumHandlers();
   EHCatchScope &CatchScope = cast<EHCatchScope>(*EHStack.begin());
@@ -1242,12 +1250,10 @@
     BeginCatch(*this, C);
 
     // If there's an implicit rethrow, push a normal "cleanup" to call
-    // _cxa_rethrow.  This needs to happen before _cxa_end_catch is
-    // called.
-    if (ImplicitRethrow) {
-      CleanupBlock Rethrow(*this, NormalCleanup);
-      EmitCallOrInvoke(getReThrowFn(*this), 0, 0);
-    }
+    // _cxa_rethrow.  This needs to happen before __cxa_end_catch is
+    // called, and so it is pushed after BeginCatch.
+    if (ImplicitRethrow)
+      EHStack.pushLazyCleanup<CallRethrow>(NormalCleanup);
 
     // Perform the body of the catch.
     EmitStmt(C->getHandlerBlock());





More information about the cfe-commits mailing list