Skip to content

Commit 5a409d0

Browse files
committedDec 20, 2018
Replace getOS() == llvm::Triple::*BSD with isOS*BSD() [NFCI]
Replace multiple comparisons of getOS() value with FreeBSD, NetBSD, OpenBSD and DragonFly with matching isOS*BSD() methods. This should improve the consistency of coding style without changing the behavior. Direct getOS() comparisons were left whenever used in switch or switch- like context. Differential Revision: https://reviews.llvm.org/D55916 llvm-svn: 349752
1 parent 22ca9c6 commit 5a409d0

File tree

12 files changed

+43
-43
lines changed

12 files changed

+43
-43
lines changed
 

‎clang/lib/Basic/Targets/AArch64.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ const Builtin::Info AArch64TargetInfo::BuiltinInfo[] = {
3737
AArch64TargetInfo::AArch64TargetInfo(const llvm::Triple &Triple,
3838
const TargetOptions &Opts)
3939
: TargetInfo(Triple), ABI("aapcs") {
40-
if (getTriple().getOS() == llvm::Triple::OpenBSD) {
40+
if (getTriple().isOSOpenBSD()) {
4141
Int64Type = SignedLongLong;
4242
IntMaxType = SignedLongLong;
4343
} else {
44-
if (!getTriple().isOSDarwin() && getTriple().getOS() != llvm::Triple::NetBSD)
44+
if (!getTriple().isOSDarwin() && !getTriple().isOSNetBSD())
4545
WCharType = UnsignedInt;
4646

4747
Int64Type = SignedLong;

‎clang/lib/Basic/Targets/ARM.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ void ARMTargetInfo::setABIAAPCS() {
2828
DoubleAlign = LongLongAlign = LongDoubleAlign = SuitableAlign = 64;
2929
const llvm::Triple &T = getTriple();
3030

31-
bool IsNetBSD = T.getOS() == llvm::Triple::NetBSD;
32-
bool IsOpenBSD = T.getOS() == llvm::Triple::OpenBSD;
31+
bool IsNetBSD = T.isOSNetBSD();
32+
bool IsOpenBSD = T.isOSOpenBSD();
3333
if (!T.isOSWindows() && !IsNetBSD && !IsOpenBSD)
3434
WCharType = UnsignedInt;
3535

@@ -217,8 +217,8 @@ ARMTargetInfo::ARMTargetInfo(const llvm::Triple &Triple,
217217
const TargetOptions &Opts)
218218
: TargetInfo(Triple), FPMath(FP_Default), IsAAPCS(true), LDREX(0),
219219
HW_FP(0) {
220-
bool IsOpenBSD = Triple.getOS() == llvm::Triple::OpenBSD;
221-
bool IsNetBSD = Triple.getOS() == llvm::Triple::NetBSD;
220+
bool IsOpenBSD = Triple.isOSOpenBSD();
221+
bool IsNetBSD = Triple.isOSNetBSD();
222222

223223
// FIXME: the isOSBinFormatMachO is a workaround for identifying a Darwin-like
224224
// environment where size_t is `unsigned long` rather than `unsigned int`
@@ -282,9 +282,9 @@ ARMTargetInfo::ARMTargetInfo(const llvm::Triple &Triple,
282282
setABI("apcs-gnu");
283283
break;
284284
default:
285-
if (Triple.getOS() == llvm::Triple::NetBSD)
285+
if (IsNetBSD)
286286
setABI("apcs-gnu");
287-
else if (Triple.getOS() == llvm::Triple::OpenBSD)
287+
else if (IsOpenBSD)
288288
setABI("aapcs-linux");
289289
else
290290
setABI("aapcs");

‎clang/lib/Basic/Targets/Mips.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ class LLVM_LIBRARY_VISIBILITY MipsTargetInfo : public TargetInfo {
7878

7979
CPU = ABI == "o32" ? "mips32r2" : "mips64r2";
8080

81-
CanUseBSDABICalls = Triple.getOS() == llvm::Triple::FreeBSD ||
82-
Triple.getOS() == llvm::Triple::OpenBSD;
81+
CanUseBSDABICalls = Triple.isOSFreeBSD() ||
82+
Triple.isOSOpenBSD();
8383
}
8484

8585
bool isIEEE754_2008Default() const {
@@ -132,7 +132,7 @@ class LLVM_LIBRARY_VISIBILITY MipsTargetInfo : public TargetInfo {
132132
void setN32N64ABITypes() {
133133
LongDoubleWidth = LongDoubleAlign = 128;
134134
LongDoubleFormat = &llvm::APFloat::IEEEquad();
135-
if (getTriple().getOS() == llvm::Triple::FreeBSD) {
135+
if (getTriple().isOSFreeBSD()) {
136136
LongDoubleWidth = LongDoubleAlign = 64;
137137
LongDoubleFormat = &llvm::APFloat::IEEEdouble();
138138
}
@@ -142,7 +142,7 @@ class LLVM_LIBRARY_VISIBILITY MipsTargetInfo : public TargetInfo {
142142

143143
void setN64ABITypes() {
144144
setN32N64ABITypes();
145-
if (getTriple().getOS() == llvm::Triple::OpenBSD) {
145+
if (getTriple().isOSOpenBSD()) {
146146
Int64Type = SignedLongLong;
147147
} else {
148148
Int64Type = SignedLong;

‎clang/lib/Basic/Targets/PPC.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ void PPCTargetInfo::getTargetDefines(const LangOptions &Opts,
8383
if (getTriple().getArch() == llvm::Triple::ppc64le) {
8484
Builder.defineMacro("_LITTLE_ENDIAN");
8585
} else {
86-
if (getTriple().getOS() != llvm::Triple::NetBSD &&
87-
getTriple().getOS() != llvm::Triple::OpenBSD)
86+
if (!getTriple().isOSNetBSD() &&
87+
!getTriple().isOSOpenBSD())
8888
Builder.defineMacro("_BIG_ENDIAN");
8989
}
9090

‎clang/lib/Basic/Targets/PPC.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ class LLVM_LIBRARY_VISIBILITY PPC32TargetInfo : public PPCTargetInfo {
331331
break;
332332
}
333333

334-
if (getTriple().getOS() == llvm::Triple::FreeBSD) {
334+
if (getTriple().isOSFreeBSD()) {
335335
LongDoubleWidth = LongDoubleAlign = 64;
336336
LongDoubleFormat = &llvm::APFloat::IEEEdouble();
337337
}

‎clang/lib/Basic/Targets/Sparc.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ class LLVM_LIBRARY_VISIBILITY SparcV9TargetInfo : public SparcTargetInfo {
199199
LongWidth = LongAlign = PointerWidth = PointerAlign = 64;
200200

201201
// OpenBSD uses long long for int64_t and intmax_t.
202-
if (getTriple().getOS() == llvm::Triple::OpenBSD)
202+
if (getTriple().isOSOpenBSD())
203203
IntMaxType = SignedLongLong;
204204
else
205205
IntMaxType = SignedLong;

‎clang/lib/Driver/ToolChains/Arch/Mips.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ void mips::getMipsCPUAndABI(const ArgList &Args, const llvm::Triple &Triple,
4747
}
4848

4949
// MIPS3 is the default for mips64*-unknown-openbsd.
50-
if (Triple.getOS() == llvm::Triple::OpenBSD)
50+
if (Triple.isOSOpenBSD())
5151
DefMips64CPU = "mips3";
5252

5353
// MIPS2 is the default for mips(el)?-unknown-freebsd.
5454
// MIPS3 is the default for mips64(el)?-unknown-freebsd.
55-
if (Triple.getOS() == llvm::Triple::FreeBSD) {
55+
if (Triple.isOSFreeBSD()) {
5656
DefMips32CPU = "mips2";
5757
DefMips64CPU = "mips3";
5858
}

‎clang/lib/Driver/ToolChains/Clang.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ static bool useFramePointerForTargetByDefault(const ArgList &Args,
526526
break;
527527
}
528528

529-
if (Triple.getOS() == llvm::Triple::NetBSD) {
529+
if (Triple.isOSNetBSD()) {
530530
return !areOptimizationsEnabled(Args);
531531
}
532532

@@ -2848,8 +2848,8 @@ static void RenderCharacterOptions(const ArgList &Args, const llvm::Triple &T,
28482848
} else {
28492849
bool IsARM = T.isARM() || T.isThumb() || T.isAArch64();
28502850
CmdArgs.push_back("-fwchar-type=int");
2851-
if (IsARM && !(T.isOSWindows() || T.getOS() == llvm::Triple::NetBSD ||
2852-
T.getOS() == llvm::Triple::OpenBSD))
2851+
if (IsARM && !(T.isOSWindows() || T.isOSNetBSD() ||
2852+
T.isOSOpenBSD()))
28532853
CmdArgs.push_back("-fno-signed-wchar");
28542854
else
28552855
CmdArgs.push_back("-fsigned-wchar");
@@ -5274,8 +5274,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
52745274
(TC.getTriple().isOSBinFormatELF() ||
52755275
TC.getTriple().isOSBinFormatCOFF()) &&
52765276
!TC.getTriple().isPS4() &&
5277-
TC.useIntegratedAs() &&
5278-
RawTriple.getOS() != llvm::Triple::NetBSD))
5277+
!TC.getTriple().isOSNetBSD() &&
5278+
TC.useIntegratedAs()))
52795279
CmdArgs.push_back("-faddrsig");
52805280

52815281
// Finally add the compile command to the compilation.

‎clang/lib/Driver/ToolChains/CommonArgs.cpp

+12-12
Original file line numberDiff line numberDiff line change
@@ -603,19 +603,19 @@ void tools::linkSanitizerRuntimeDeps(const ToolChain &TC,
603603
if (TC.getTriple().getOS() != llvm::Triple::RTEMS &&
604604
!TC.getTriple().isAndroid()) {
605605
CmdArgs.push_back("-lpthread");
606-
if (TC.getTriple().getOS() != llvm::Triple::OpenBSD)
606+
if (TC.getTriple().isOSOpenBSD())
607607
CmdArgs.push_back("-lrt");
608608
}
609609
CmdArgs.push_back("-lm");
610610
// There's no libdl on all OSes.
611-
if (TC.getTriple().getOS() != llvm::Triple::FreeBSD &&
612-
TC.getTriple().getOS() != llvm::Triple::NetBSD &&
613-
TC.getTriple().getOS() != llvm::Triple::OpenBSD &&
614-
TC.getTriple().getOS() != llvm::Triple::RTEMS)
611+
if (!TC.getTriple().isOSFreeBSD() &&
612+
!TC.getTriple().isOSNetBSD() &&
613+
!TC.getTriple().isOSOpenBSD() &&
614+
TC.getTriple().getOS() != llvm::Triple::RTEMS)
615615
CmdArgs.push_back("-ldl");
616616
// Required for backtrace on some OSes
617-
if (TC.getTriple().getOS() == llvm::Triple::NetBSD ||
618-
TC.getTriple().getOS() == llvm::Triple::FreeBSD)
617+
if (TC.getTriple().isOSFreeBSD() ||
618+
TC.getTriple().isOSNetBSD())
619619
CmdArgs.push_back("-lexecinfo");
620620
}
621621

@@ -790,13 +790,13 @@ bool tools::addXRayRuntime(const ToolChain&TC, const ArgList &Args, ArgStringLis
790790
void tools::linkXRayRuntimeDeps(const ToolChain &TC, ArgStringList &CmdArgs) {
791791
CmdArgs.push_back("--no-as-needed");
792792
CmdArgs.push_back("-lpthread");
793-
if (TC.getTriple().getOS() != llvm::Triple::OpenBSD)
793+
if (!TC.getTriple().isOSOpenBSD())
794794
CmdArgs.push_back("-lrt");
795795
CmdArgs.push_back("-lm");
796796

797-
if (TC.getTriple().getOS() != llvm::Triple::FreeBSD &&
798-
TC.getTriple().getOS() != llvm::Triple::NetBSD &&
799-
TC.getTriple().getOS() != llvm::Triple::OpenBSD)
797+
if (!TC.getTriple().isOSFreeBSD() &&
798+
!TC.getTriple().isOSNetBSD() &&
799+
!TC.getTriple().isOSOpenBSD())
800800
CmdArgs.push_back("-ldl");
801801
}
802802

@@ -933,7 +933,7 @@ tools::ParsePICArgs(const ToolChain &ToolChain, const ArgList &Args) {
933933
}
934934

935935
// OpenBSD-specific defaults for PIE
936-
if (Triple.getOS() == llvm::Triple::OpenBSD) {
936+
if (Triple.isOSOpenBSD()) {
937937
switch (ToolChain.getArch()) {
938938
case llvm::Triple::arm:
939939
case llvm::Triple::aarch64:

‎clang/lib/Driver/ToolChains/Gnu.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -2597,7 +2597,7 @@ void Generic_ELF::addClangTargetOptions(const ArgList &DriverArgs,
25972597
bool UseInitArrayDefault =
25982598
getTriple().getArch() == llvm::Triple::aarch64 ||
25992599
getTriple().getArch() == llvm::Triple::aarch64_be ||
2600-
(getTriple().getOS() == llvm::Triple::FreeBSD &&
2600+
(getTriple().isOSFreeBSD() &&
26012601
getTriple().getOSMajorVersion() >= 12) ||
26022602
(getTriple().getOS() == llvm::Triple::Linux &&
26032603
((!GCCInstallation.isValid() || !V.isOlderThan(4, 7, 0)) ||

‎clang/lib/Driver/XRayArgs.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ XRayArgs::XRayArgs(const ToolChain &TC, const ArgList &Args) {
5050
D.Diag(diag::err_drv_clang_unsupported)
5151
<< (std::string(XRayInstrumentOption) + " on " + Triple.str());
5252
}
53-
} else if (Triple.getOS() == llvm::Triple::FreeBSD ||
54-
Triple.getOS() == llvm::Triple::OpenBSD ||
55-
Triple.getOS() == llvm::Triple::NetBSD ||
53+
} else if (Triple.isOSFreeBSD() ||
54+
Triple.isOSOpenBSD() ||
55+
Triple.isOSNetBSD() ||
5656
Triple.getOS() == llvm::Triple::Darwin) {
5757
if (Triple.getArch() != llvm::Triple::x86_64) {
5858
D.Diag(diag::err_drv_clang_unsupported)

‎clang/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ static bool isArc4RandomAvailable(const ASTContext &Ctx) {
2929
const llvm::Triple &T = Ctx.getTargetInfo().getTriple();
3030
return T.getVendor() == llvm::Triple::Apple ||
3131
T.getOS() == llvm::Triple::CloudABI ||
32-
T.getOS() == llvm::Triple::FreeBSD ||
33-
T.getOS() == llvm::Triple::NetBSD ||
34-
T.getOS() == llvm::Triple::OpenBSD ||
35-
T.getOS() == llvm::Triple::DragonFly;
32+
T.isOSFreeBSD() ||
33+
T.isOSNetBSD() ||
34+
T.isOSOpenBSD() ||
35+
T.isOSDragonFly();
3636
}
3737

3838
namespace {

0 commit comments

Comments
 (0)
Please sign in to comment.