r335175 - [MS] Make sure __GetExceptionInfo works on types with no linkage

Reid Kleckner via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 20 14:12:20 PDT 2018


Author: rnk
Date: Wed Jun 20 14:12:20 2018
New Revision: 335175

URL: http://llvm.org/viewvc/llvm-project?rev=335175&view=rev
Log:
[MS] Make sure __GetExceptionInfo works on types with no linkage

Fixes PR36327

Modified:
    cfe/trunk/lib/Sema/Sema.cpp
    cfe/trunk/test/CodeGenCXX/microsoft-abi-throw.cpp

Modified: cfe/trunk/lib/Sema/Sema.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=335175&r1=335174&r2=335175&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/Sema.cpp (original)
+++ cfe/trunk/lib/Sema/Sema.cpp Wed Jun 20 14:12:20 2018
@@ -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)

Modified: cfe/trunk/test/CodeGenCXX/microsoft-abi-throw.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/microsoft-abi-throw.cpp?rev=335175&r1=335174&r2=335175&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/microsoft-abi-throw.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/microsoft-abi-throw.cpp Wed Jun 20 14:12:20 2018
@@ -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 at 84", %eh.CatchableType* @"_CT??_R0PAX at 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);
+}




More information about the cfe-commits mailing list