Skip to content

Commit adbcc7f

Browse files
committed
[Clang][Cygwin] Enable few conditions that are shared with MinGW
1 parent 0f696c2 commit adbcc7f

File tree

9 files changed

+14
-21
lines changed

9 files changed

+14
-21
lines changed

clang/lib/AST/ItaniumCXXABI.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,7 @@ class ItaniumCXXABI : public CXXABI {
236236

237237
CallingConv getDefaultMethodCallConv(bool isVariadic) const override {
238238
const llvm::Triple &T = Context.getTargetInfo().getTriple();
239-
if (!isVariadic && T.isWindowsGNUEnvironment() &&
240-
T.getArch() == llvm::Triple::x86)
239+
if (!isVariadic && T.isOSCygMing() && T.getArch() == llvm::Triple::x86)
241240
return CC_X86ThisCall;
242241
return Context.getTargetInfo().getDefaultCallingConv();
243242
}

clang/lib/AST/RecordLayoutBuilder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1950,7 +1950,7 @@ void ItaniumRecordLayoutBuilder::LayoutField(const FieldDecl *D,
19501950
// silently there. For other targets that have ms_struct enabled
19511951
// (most probably via a pragma or attribute), trigger a diagnostic
19521952
// that defaults to an error.
1953-
if (!Context.getTargetInfo().getTriple().isWindowsGNUEnvironment())
1953+
if (!Context.getTargetInfo().getTriple().isOSCygMing())
19541954
Diag(D->getLocation(), diag::warn_npot_ms_struct);
19551955
}
19561956
if (TypeSize > FieldAlign &&

clang/lib/CodeGen/CodeGenModule.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1680,7 +1680,7 @@ static bool shouldAssumeDSOLocal(const CodeGenModule &CGM,
16801680

16811681
const llvm::Triple &TT = CGM.getTriple();
16821682
const auto &CGOpts = CGM.getCodeGenOpts();
1683-
if (TT.isWindowsGNUEnvironment()) {
1683+
if (TT.isOSCygMing()) {
16841684
// In MinGW, variables without DLLImport can still be automatically
16851685
// imported from a DLL by the linker; don't mark variables that
16861686
// potentially could come from another DLL as DSO local.

clang/lib/CodeGen/ItaniumCXXABI.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3757,7 +3757,7 @@ static bool ShouldUseExternalRTTIDescriptor(CodeGenModule &CGM,
37573757
bool IsDLLImport = RD->hasAttr<DLLImportAttr>();
37583758

37593759
// Don't import the RTTI but emit it locally.
3760-
if (CGM.getTriple().isWindowsGNUEnvironment())
3760+
if (CGM.getTriple().isOSCygMing())
37613761
return false;
37623762

37633763
if (CGM.getVTables().isVTableExternal(RD)) {
@@ -4044,10 +4044,7 @@ static llvm::GlobalVariable::LinkageTypes getTypeInfoLinkage(CodeGenModule &CGM,
40444044
return llvm::GlobalValue::ExternalLinkage;
40454045
// MinGW always uses LinkOnceODRLinkage for type info.
40464046
if (RD->isDynamicClass() &&
4047-
!CGM.getContext()
4048-
.getTargetInfo()
4049-
.getTriple()
4050-
.isWindowsGNUEnvironment())
4047+
!CGM.getContext().getTargetInfo().getTriple().isOSCygMing())
40514048
return CGM.getVTableLinkage(RD);
40524049
}
40534050

clang/lib/CodeGen/Targets/X86.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1391,7 +1391,7 @@ class WinX86_64ABIInfo : public ABIInfo {
13911391
public:
13921392
WinX86_64ABIInfo(CodeGen::CodeGenTypes &CGT, X86AVXABILevel AVXLevel)
13931393
: ABIInfo(CGT), AVXLevel(AVXLevel),
1394-
IsMingw64(getTarget().getTriple().isWindowsGNUEnvironment()) {}
1394+
IsMingw64(getTarget().getTriple().isOSCygMing()) {}
13951395

13961396
void computeInfo(CGFunctionInfo &FI) const override;
13971397

clang/lib/Driver/ToolChain.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -744,9 +744,7 @@ std::string ToolChain::buildCompilerRTBasename(const llvm::opt::ArgList &Args,
744744
Suffix = IsITANMSVCWindows ? ".lib" : ".a";
745745
break;
746746
case ToolChain::FT_Shared:
747-
Suffix = TT.isOSWindows()
748-
? (TT.isWindowsGNUEnvironment() ? ".dll.a" : ".lib")
749-
: ".so";
747+
Suffix = TT.isOSWindows() ? (TT.isOSCygMing() ? ".dll.a" : ".lib") : ".so";
750748
break;
751749
}
752750

clang/lib/Sema/SemaDecl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12536,7 +12536,7 @@ static bool isDefaultStdCall(FunctionDecl *FD, Sema &S) {
1253612536

1253712537
// Default calling convention for MinGW is __cdecl
1253812538
const llvm::Triple &T = S.Context.getTargetInfo().getTriple();
12539-
if (T.isWindowsGNUEnvironment())
12539+
if (T.isOSCygMing())
1254012540
return false;
1254112541

1254212542
// Default calling convention for WinMain, wWinMain and DllMain

clang/lib/Sema/SemaDeclCXX.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6272,7 +6272,7 @@ static void ReferenceDllExportedMembers(Sema &S, CXXRecordDecl *Class) {
62726272
}
62736273
} MarkingDllexportedContext(S, Class, ClassAttr->getLocation());
62746274

6275-
if (S.Context.getTargetInfo().getTriple().isWindowsGNUEnvironment())
6275+
if (S.Context.getTargetInfo().getTriple().isOSCygMing())
62766276
S.MarkVTableUsed(Class->getLocation(), Class, true);
62776277

62786278
for (Decl *Member : Class->decls()) {
@@ -6574,7 +6574,7 @@ void Sema::checkClassLevelDLLAttribute(CXXRecordDecl *Class) {
65746574
// declarations, except in MinGW mode.
65756575
if (ClassExported && !ClassAttr->isInherited() &&
65766576
TSK == TSK_ExplicitInstantiationDeclaration &&
6577-
!Context.getTargetInfo().getTriple().isWindowsGNUEnvironment()) {
6577+
!Context.getTargetInfo().getTriple().isOSCygMing()) {
65786578
Class->dropAttr<DLLExportAttr>();
65796579
return;
65806580
}

clang/lib/Sema/SemaTemplate.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8889,8 +8889,7 @@ Sema::CheckSpecializationInstantiationRedecl(SourceLocation NewLoc,
88898889
// The declaration itself has not actually been instantiated, so it is
88908890
// still okay to specialize it.
88918891
StripImplicitInstantiation(
8892-
PrevDecl,
8893-
Context.getTargetInfo().getTriple().isWindowsGNUEnvironment());
8892+
PrevDecl, Context.getTargetInfo().getTriple().isOSCygMing());
88948893
return false;
88958894
}
88968895
// Fall through
@@ -9758,7 +9757,7 @@ DeclResult Sema::ActOnExplicitInstantiation(
97589757
: TSK_ExplicitInstantiationDeclaration;
97599758

97609759
if (TSK == TSK_ExplicitInstantiationDeclaration &&
9761-
!Context.getTargetInfo().getTriple().isWindowsGNUEnvironment()) {
9760+
!Context.getTargetInfo().getTriple().isOSCygMing()) {
97629761
// Check for dllexport class template instantiation declarations,
97639762
// except for MinGW mode.
97649763
for (const ParsedAttr &AL : Attr) {
@@ -9823,7 +9822,7 @@ DeclResult Sema::ActOnExplicitInstantiation(
98239822
= PrevDecl ? PrevDecl->getTemplateSpecializationKind() : TSK_Undeclared;
98249823

98259824
if (TSK == TSK_ExplicitInstantiationDefinition && PrevDecl != nullptr &&
9826-
Context.getTargetInfo().getTriple().isWindowsGNUEnvironment()) {
9825+
Context.getTargetInfo().getTriple().isOSCygMing()) {
98279826
// Check for dllexport class template instantiation definitions in MinGW
98289827
// mode, if a previous declaration of the instantiation was seen.
98299828
for (const ParsedAttr &AL : Attr) {
@@ -9991,7 +9990,7 @@ DeclResult Sema::ActOnExplicitInstantiation(
99919990
// In MinGW mode, export the template instantiation if the declaration
99929991
// was marked dllexport.
99939992
if (PrevDecl_TSK == TSK_ExplicitInstantiationDeclaration &&
9994-
Context.getTargetInfo().getTriple().isWindowsGNUEnvironment() &&
9993+
Context.getTargetInfo().getTriple().isOSCygMing() &&
99959994
PrevDecl->hasAttr<DLLExportAttr>()) {
99969995
dllExportImportClassTemplateSpecialization(*this, Def);
99979996
}

0 commit comments

Comments
 (0)