From: John McCall Date: Tue, 10 Aug 2010 18:51:44 +0000 (+0000) Subject: When initializing a static local, pop the guard-abort EH cleanup after X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=224124c7b85596157201a67a7ba12d2b0f5c153c;p=clang When initializing a static local, pop the guard-abort EH cleanup after the variable is fully initialized. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110704 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGDeclCXX.cpp b/lib/CodeGen/CGDeclCXX.cpp index ddb1abc70a..38345e4741 100644 --- a/lib/CodeGen/CGDeclCXX.cpp +++ b/lib/CodeGen/CGDeclCXX.cpp @@ -398,6 +398,10 @@ CodeGenFunction::EmitStaticCXXBlockVarDeclInit(const VarDecl &D, EmitDeclInit(*this, D, GV); if (ThreadsafeStatics) { + // Pop the guard-abort cleanup if we pushed one. + if (Exceptions) + PopCleanupBlock(); + // Call __cxa_guard_release. This cannot throw. Builder.CreateCall(getGuardReleaseFn(*this), GuardVariable); } else { diff --git a/test/CodeGenCXX/threadsafe-statics-exceptions.cpp b/test/CodeGenCXX/threadsafe-statics-exceptions.cpp index 17c10301d4..c91590fd58 100644 --- a/test/CodeGenCXX/threadsafe-statics-exceptions.cpp +++ b/test/CodeGenCXX/threadsafe-statics-exceptions.cpp @@ -17,7 +17,7 @@ void f() { static X x; // CHECK: call i8* @__cxa_allocate_exception - // CHECK: invoke void @__cxa_throw + // CHECK: call void @__cxa_throw throw Y(); // Finally, the landing pad.