Skip to content

Commit 1094422

Browse files
committed
[Cygwin] Template instantiations should be exported by default
Behaves as same as both of Clang and GCC targetting MinGW. Required for compatibility for Cygwin-GCC.
1 parent 76dba2e commit 1094422

File tree

6 files changed

+81
-8
lines changed

6 files changed

+81
-8
lines changed

clang/lib/Sema/SemaDeclCXX.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6576,7 +6576,7 @@ void Sema::checkClassLevelDLLAttribute(CXXRecordDecl *Class) {
65766576
// declarations, except in MinGW mode.
65776577
if (ClassExported && !ClassAttr->isInherited() &&
65786578
TSK == TSK_ExplicitInstantiationDeclaration &&
6579-
!Context.getTargetInfo().getTriple().isWindowsGNUEnvironment()) {
6579+
!Context.getTargetInfo().getTriple().isOSCygMing()) {
65806580
Class->dropAttr<DLLExportAttr>();
65816581
return;
65826582
}

clang/lib/Sema/SemaTemplate.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8987,8 +8987,7 @@ Sema::CheckSpecializationInstantiationRedecl(SourceLocation NewLoc,
89878987
// The declaration itself has not actually been instantiated, so it is
89888988
// still okay to specialize it.
89898989
StripImplicitInstantiation(
8990-
PrevDecl,
8991-
Context.getTargetInfo().getTriple().isWindowsGNUEnvironment());
8990+
PrevDecl, Context.getTargetInfo().getTriple().isOSCygMing());
89928991
return false;
89938992
}
89948993
// Fall through
@@ -9855,7 +9854,7 @@ DeclResult Sema::ActOnExplicitInstantiation(
98559854
: TSK_ExplicitInstantiationDeclaration;
98569855

98579856
if (TSK == TSK_ExplicitInstantiationDeclaration &&
9858-
!Context.getTargetInfo().getTriple().isWindowsGNUEnvironment()) {
9857+
!Context.getTargetInfo().getTriple().isOSCygMing()) {
98599858
// Check for dllexport class template instantiation declarations,
98609859
// except for MinGW mode.
98619860
for (const ParsedAttr &AL : Attr) {
@@ -9920,7 +9919,7 @@ DeclResult Sema::ActOnExplicitInstantiation(
99209919
= PrevDecl ? PrevDecl->getTemplateSpecializationKind() : TSK_Undeclared;
99219920

99229921
if (TSK == TSK_ExplicitInstantiationDefinition && PrevDecl != nullptr &&
9923-
Context.getTargetInfo().getTriple().isWindowsGNUEnvironment()) {
9922+
Context.getTargetInfo().getTriple().isOSCygMing()) {
99249923
// Check for dllexport class template instantiation definitions in MinGW
99259924
// mode, if a previous declaration of the instantiation was seen.
99269925
for (const ParsedAttr &AL : Attr) {
@@ -10088,7 +10087,7 @@ DeclResult Sema::ActOnExplicitInstantiation(
1008810087
// In MinGW mode, export the template instantiation if the declaration
1008910088
// was marked dllexport.
1009010089
if (PrevDecl_TSK == TSK_ExplicitInstantiationDeclaration &&
10091-
Context.getTargetInfo().getTriple().isWindowsGNUEnvironment() &&
10090+
Context.getTargetInfo().getTriple().isOSCygMing() &&
1009210091
PrevDecl->hasAttr<DLLExportAttr>()) {
1009310092
dllExportImportClassTemplateSpecialization(*this, Def);
1009410093
}

0 commit comments

Comments
 (0)