]> granicus.if.org Git - clang/commitdiff
[MS] Make sure __GetExceptionInfo works on types with no linkage
authorReid Kleckner <rnk@google.com>
Wed, 20 Jun 2018 21:12:20 +0000 (21:12 +0000)
committerReid Kleckner <rnk@google.com>
Wed, 20 Jun 2018 21:12:20 +0000 (21:12 +0000)
Fixes PR36327

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@335175 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/Sema.cpp
test/CodeGenCXX/microsoft-abi-throw.cpp

index aa4f6461b65e60e1bb0244cfd6ce61b938f6530d..7a8cd1ca4e6ec6b67503de4fc5d0940b8b2195a9 100644 (file)
@@ -645,6 +645,8 @@ void Sema::getUndefinedButUsed(
           !isExternalWithNoLinkageType(FD) &&
           !FD->getMostRecentDecl()->isInlined())
         continue;
+      if (FD->getBuiltinID())
+        continue;
     } else {
       auto *VD = cast<VarDecl>(ND);
       if (VD->hasDefinition() != VarDecl::DeclarationOnly)
index 8800e97a03f7523d01f78a97baf01c579e57510f..cbbce2daaad860f09d1bc4af05bb58d86ef9ee88 100644 (file)
@@ -22,6 +22,7 @@
 // CHECK-DAG: @_TI1P6AXXZ = linkonce_odr unnamed_addr constant %eh.ThrowInfo { i32 0, i8* null, i8* null, i8* bitcast (%eh.CatchableTypeArray.1* @_CTA1P6AXXZ to i8*) }, section ".xdata", comdat
 // CHECK-DAG: @_TIU2PAPFAH = linkonce_odr unnamed_addr constant %eh.ThrowInfo { i32 4, i8* null, i8* null, i8* bitcast (%eh.CatchableTypeArray.2* @_CTA2PAPFAH to i8*) }, section ".xdata", comdat
 // CHECK-DAG: @_CTA2PAPFAH = linkonce_odr unnamed_addr constant %eh.CatchableTypeArray.2 { i32 2, [2 x %eh.CatchableType*] [%eh.CatchableType* @"_CT??_R0PAPFAH@84", %eh.CatchableType* @"_CT??_R0PAX@84"] }, section ".xdata", comdat
+// CHECK-DAG: @"_TI1?AUFoo@?A@@" = internal unnamed_addr constant %eh.ThrowInfo { i32 0, i8* null, i8* null, i8* bitcast (%eh.CatchableTypeArray.1* @"_CTA1?AUFoo@?A@@" to i8*) }, section ".xdata"
 
 
 struct N { ~N(); };
@@ -128,3 +129,12 @@ void *GetExceptionInfo_test1() {
 // CHECK:  ret i8* bitcast (%eh.ThrowInfo* @_TI1P6AXXZ to i8*)
   return __GetExceptionInfo<void (*)()>(&h);
 }
+
+// PR36327: Try an exception type with no linkage.
+namespace { struct Foo { } foo_exc; }
+
+void *GetExceptionInfo_test2() {
+// CHECK-LABEL: @"?GetExceptionInfo_test2@@YAPAXXZ"
+// CHECK:  ret i8* bitcast (%eh.ThrowInfo* @"_TI1?AUFoo@?A@@" to i8*)
+  return __GetExceptionInfo(foo_exc);
+}