From: David Majnemer Date: Wed, 1 Apr 2015 04:45:52 +0000 (+0000) Subject: [MS ABI] Disregard restrictive exception specifications X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=16467648ec1c4dc5cd0a18c487f455eda5a7abf1;p=clang [MS ABI] Disregard restrictive exception specifications MSVC treats all non-empty exception specifications the same way: all exceptions are permitted. The .xdata tables provide a way to efficiently lower exception specifications *but* this probably has to be implemented as a catch-all/rethrow mechanism instead of the Itanium way. This fixes PR23092. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@233787 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGException.cpp b/lib/CodeGen/CGException.cpp index 1925c57d1b..f10d2e1ecc 100644 --- a/lib/CodeGen/CGException.cpp +++ b/lib/CodeGen/CGException.cpp @@ -458,6 +458,10 @@ void CodeGenFunction::EmitStartEHSpec(const Decl *D) { EHStack.pushTerminate(); } } else if (EST == EST_Dynamic || EST == EST_DynamicNone) { + // TODO: Revisit exception specifications for the MS ABI. There is a way to + // encode these in an object file but MSVC doesn't do anything with it. + if (getTarget().getCXXABI().isMicrosoft()) + return; unsigned NumExceptions = Proto->getNumExceptions(); EHFilterScope *Filter = EHStack.pushFilter(NumExceptions); @@ -532,6 +536,10 @@ void CodeGenFunction::EmitEndEHSpec(const Decl *D) { EHStack.popTerminate(); } } else if (EST == EST_Dynamic || EST == EST_DynamicNone) { + // TODO: Revisit exception specifications for the MS ABI. There is a way to + // encode these in an object file but MSVC doesn't do anything with it. + if (getTarget().getCXXABI().isMicrosoft()) + return; EHFilterScope &filterScope = cast(*EHStack.begin()); emitFilterDispatchBlock(*this, filterScope); EHStack.popFilter(); diff --git a/test/CodeGenCXX/microsoft-abi-eh-catch.cpp b/test/CodeGenCXX/microsoft-abi-eh-catch.cpp index f0e2033451..15edef3d13 100644 --- a/test/CodeGenCXX/microsoft-abi-eh-catch.cpp +++ b/test/CodeGenCXX/microsoft-abi-eh-catch.cpp @@ -96,3 +96,11 @@ extern "C" void catch_a_ref() { // WIN64: %[[eptr_i8:[^ ]*]] = bitcast %struct.A* %[[eptr]] to i8* // WIN64: call void @handle_exception(i8* %[[eptr_i8]]) // WIN64: call void @llvm.eh.endcatch() + +extern "C" void fn_with_exc_spec() throw(int) { + might_throw(); +} + +// WIN64-LABEL: define void @fn_with_exc_spec() +// WIN64: call void @might_throw() +// WIN64-NEXT: ret void