[Sema] Use MS ABI behavior for dllexport in Itanium

Similar to r284288, make the Itanium ABI follow MS ABI dllexport
semantics in the case of an explicit instantiation declaration followed
by a dllexport explicit instantiation definition.

Differential Revision: https://reviews.llvm.org/D26471

llvm-svn: 286419
This commit is contained in:
Shoaib Meenai 2016-11-09 23:52:20 +00:00
parent 0d4778f841
commit ab3f96cb21
2 changed files with 18 additions and 1 deletions

View File

@ -7674,7 +7674,8 @@ Sema::ActOnExplicitInstantiation(Scope *S,
Def->setTemplateSpecializationKind(TSK);
if (!getDLLAttr(Def) && getDLLAttr(Specialization) &&
Context.getTargetInfo().getCXXABI().isMicrosoft()) {
(Context.getTargetInfo().getCXXABI().isMicrosoft() ||
Context.getTargetInfo().getTriple().isWindowsItaniumEnvironment())) {
// In the MS ABI, an explicit instantiation definition can add a dll
// attribute to a template with a previous instantiation declaration.
// MinGW doesn't allow this.

View File

@ -7,3 +7,19 @@ struct __declspec(dllexport) s {
// CHECK: define {{.*}} dllexport {{.*}} @_ZN1saSERKS_
// CHECK: define {{.*}} dllexport {{.*}} @_ZN1s1fEv
template <class T>
class c {
void f() {}
};
template class __declspec(dllexport) c<int>;
// CHECK: define {{.*}} dllexport {{.*}} @_ZN1cIiEaSERKS0_
// CHECK: define {{.*}} dllexport {{.*}} @_ZN1cIiE1fEv
extern template class c<char>;
template class __declspec(dllexport) c<char>;
// CHECK: define {{.*}} dllexport {{.*}} @_ZN1cIcEaSERKS0_
// CHECK: define {{.*}} dllexport {{.*}} @_ZN1cIcE1fEv