From 25dbdfa0ac846b13eb2ab5ac1a026b3e5752b04f Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Sat, 3 Dec 2016 01:57:47 +0000 Subject: [PATCH] Sema: delay the DLL exported member referencing An explicit template specialization can cause the implicit template specialization of a type which inherits the attributes. In such a case, we would end up with a delayed template specialization for a dll exported type which we would fail to reference. This would trigger an assertion. We now propagate the dll storage attributes through the inheritance chain. Only after having done so do we reference the delayed template specializations. This allows any implicit specializations which inherit dll storage to also be referenced. llvm-svn: 288570 --- clang/lib/Sema/SemaTemplate.cpp | 3 ++- ...dows-implicit-dllexport-template-specialization.cpp | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 clang/test/CodeGenCXX/windows-implicit-dllexport-template-specialization.cpp diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp index 9a64345..3438b5f 100644 --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -7687,7 +7687,6 @@ Sema::ActOnExplicitInstantiation(Scope *S, assert(DelayedDllExportClasses.empty() && "delayed exports present at explicit instantiation"); checkClassLevelDLLAttribute(Def); - referenceDLLExportedClassMethods(); // Propagate attribute to base class templates. for (auto &B : Def->bases()) { @@ -7695,6 +7694,8 @@ Sema::ActOnExplicitInstantiation(Scope *S, B.getType()->getAsCXXRecordDecl())) propagateDLLAttrToBaseClassTemplate(Def, A, BT, B.getLocStart()); } + + referenceDLLExportedClassMethods(); } } diff --git a/clang/test/CodeGenCXX/windows-implicit-dllexport-template-specialization.cpp b/clang/test/CodeGenCXX/windows-implicit-dllexport-template-specialization.cpp new file mode 100644 index 0000000..c2f2a07 --- /dev/null +++ b/clang/test/CodeGenCXX/windows-implicit-dllexport-template-specialization.cpp @@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -std=c++11 -triple i686-windows -fdeclspec -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-MS +// RUN: %clang_cc1 -std=c++11 -triple i686-windows-itanium -fdeclspec -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-IA + +template +struct s {}; + +template +class t : s {}; + +extern template class t; +template class __declspec(dllexport) t; + +// CHECK-MS: dllexport {{.*}} @"\01??4?$t@D@@QAEAAV0@ABV0@@Z" +// CHECK-MS: dllexport {{.*}} @"\01??4?$s@D@@QAEAAU0@ABU0@@Z" + +// CHECK-IA: dllexport {{.*}} @_ZN1tIcEaSERKS0_ +// CHECK-IA: dllexport {{.*}} @_ZN1sIcEaSERKS0_ + -- 2.7.4