]> granicus.if.org Git - clang/commitdiff
[MS ABI] Disregard restrictive exception specifications
authorDavid Majnemer <david.majnemer@gmail.com>
Wed, 1 Apr 2015 04:45:52 +0000 (04:45 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Wed, 1 Apr 2015 04:45:52 +0000 (04:45 +0000)
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

lib/CodeGen/CGException.cpp
test/CodeGenCXX/microsoft-abi-eh-catch.cpp

index 1925c57d1bdbad3fe70b251b4328adcccc5b2cc9..f10d2e1ecc6196729999404b5495c50ef5ee6c7a 100644 (file)
@@ -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<EHFilterScope>(*EHStack.begin());
     emitFilterDispatchBlock(*this, filterScope);
     EHStack.popFilter();
index f0e203345192c0a60dea4af1e053e2f849df1f27..15edef3d1319f2239dbe4ff20909aeabc9f87bf9 100644 (file)
@@ -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