aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGException.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2010-07-13 22:24:23 +0000
committerJohn McCall <rjmccall@apple.com>2010-07-13 22:24:23 +0000
commitfcd5c0c62ef3d86ecd991753bb43c88c861470e7 (patch)
treea7adc51e791362c5857567e9b915ec113562ae06 /lib/CodeGen/CGException.cpp
parent8e3f86193995c47ee0d229e4336c3382410f09f5 (diff)
Switch the __cxa_rethrow cleanup to be lazy.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108288 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGException.cpp')
-rw-r--r--lib/CodeGen/CGException.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/lib/CodeGen/CGException.cpp b/lib/CodeGen/CGException.cpp
index 5e91adc669..bfe00ea158 100644
--- a/lib/CodeGen/CGException.cpp
+++ b/lib/CodeGen/CGException.cpp
@@ -1202,6 +1202,14 @@ static void BeginCatch(CodeGenFunction &CGF,
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 @@ void CodeGenFunction::ExitCXXTryStmt(const CXXTryStmt &S, bool IsFnTryBlock) {
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());