Author: compnerd Date: Fri Dec 2 19:57:47 2016 New Revision: 288570 URL: http://llvm.org/viewvc/llvm-project?rev=288570&view=rev Log: 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. Added: cfe/trunk/test/CodeGenCXX/windows-implicit-dllexport-template-specialization.cpp Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=288570&r1=288569&r2=288570&view=diff ============================================================================== --- cfe/trunk/lib/Sema/SemaTemplate.cpp (original) +++ cfe/trunk/lib/Sema/SemaTemplate.cpp Fri Dec 2 19:57:47 2016 @@ -7687,7 +7687,6 @@ Sema::ActOnExplicitInstantiation(Scope * 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 * B.getType()->getAsCXXRecordDecl())) propagateDLLAttrToBaseClassTemplate(Def, A, BT, B.getLocStart()); } + + referenceDLLExportedClassMethods(); } } Added: cfe/trunk/test/CodeGenCXX/windows-implicit-dllexport-template-specialization.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/windows-implicit-dllexport-template-specialization.cpp?rev=288570&view=auto ============================================================================== --- cfe/trunk/test/CodeGenCXX/windows-implicit-dllexport-template-specialization.cpp (added) +++ cfe/trunk/test/CodeGenCXX/windows-implicit-dllexport-template-specialization.cpp Fri Dec 2 19:57:47 2016 @@ -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 <typename> +struct s {}; + +template <typename T_> +class t : s<T_> {}; + +extern template class t<char>; +template class __declspec(dllexport) t<char>; + +// 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_ + _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits