r349752 - Replace getOS() == llvm::Triple::*BSD with isOS*BSD() [NFCI]
Michal Gorny via cfe-commits
cfe-commits at lists.llvm.org
Thu Dec 20 05:09:30 PST 2018
Author: mgorny
Date: Thu Dec 20 05:09:30 2018
New Revision: 349752
URL: http://llvm.org/viewvc/llvm-project?rev=349752&view=rev
Log:
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
Modified:
cfe/trunk/lib/Basic/Targets/AArch64.cpp
cfe/trunk/lib/Basic/Targets/ARM.cpp
cfe/trunk/lib/Basic/Targets/Mips.h
cfe/trunk/lib/Basic/Targets/PPC.cpp
cfe/trunk/lib/Basic/Targets/PPC.h
cfe/trunk/lib/Basic/Targets/Sparc.h
cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
cfe/trunk/lib/Driver/XRayArgs.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp
Modified: cfe/trunk/lib/Basic/Targets/AArch64.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/AArch64.cpp?rev=349752&r1=349751&r2=349752&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets/AArch64.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/AArch64.cpp Thu Dec 20 05:09:30 2018
@@ -37,11 +37,11 @@ const Builtin::Info AArch64TargetInfo::B
AArch64TargetInfo::AArch64TargetInfo(const llvm::Triple &Triple,
const TargetOptions &Opts)
: TargetInfo(Triple), ABI("aapcs") {
- if (getTriple().getOS() == llvm::Triple::OpenBSD) {
+ if (getTriple().isOSOpenBSD()) {
Int64Type = SignedLongLong;
IntMaxType = SignedLongLong;
} else {
- if (!getTriple().isOSDarwin() && getTriple().getOS() != llvm::Triple::NetBSD)
+ if (!getTriple().isOSDarwin() && !getTriple().isOSNetBSD())
WCharType = UnsignedInt;
Int64Type = SignedLong;
Modified: cfe/trunk/lib/Basic/Targets/ARM.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/ARM.cpp?rev=349752&r1=349751&r2=349752&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets/ARM.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/ARM.cpp Thu Dec 20 05:09:30 2018
@@ -28,8 +28,8 @@ void ARMTargetInfo::setABIAAPCS() {
DoubleAlign = LongLongAlign = LongDoubleAlign = SuitableAlign = 64;
const llvm::Triple &T = getTriple();
- bool IsNetBSD = T.getOS() == llvm::Triple::NetBSD;
- bool IsOpenBSD = T.getOS() == llvm::Triple::OpenBSD;
+ bool IsNetBSD = T.isOSNetBSD();
+ bool IsOpenBSD = T.isOSOpenBSD();
if (!T.isOSWindows() && !IsNetBSD && !IsOpenBSD)
WCharType = UnsignedInt;
@@ -217,8 +217,8 @@ ARMTargetInfo::ARMTargetInfo(const llvm:
const TargetOptions &Opts)
: TargetInfo(Triple), FPMath(FP_Default), IsAAPCS(true), LDREX(0),
HW_FP(0) {
- bool IsOpenBSD = Triple.getOS() == llvm::Triple::OpenBSD;
- bool IsNetBSD = Triple.getOS() == llvm::Triple::NetBSD;
+ bool IsOpenBSD = Triple.isOSOpenBSD();
+ bool IsNetBSD = Triple.isOSNetBSD();
// FIXME: the isOSBinFormatMachO is a workaround for identifying a Darwin-like
// environment where size_t is `unsigned long` rather than `unsigned int`
@@ -282,9 +282,9 @@ ARMTargetInfo::ARMTargetInfo(const llvm:
setABI("apcs-gnu");
break;
default:
- if (Triple.getOS() == llvm::Triple::NetBSD)
+ if (IsNetBSD)
setABI("apcs-gnu");
- else if (Triple.getOS() == llvm::Triple::OpenBSD)
+ else if (IsOpenBSD)
setABI("aapcs-linux");
else
setABI("aapcs");
Modified: cfe/trunk/lib/Basic/Targets/Mips.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/Mips.h?rev=349752&r1=349751&r2=349752&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets/Mips.h (original)
+++ cfe/trunk/lib/Basic/Targets/Mips.h Thu Dec 20 05:09:30 2018
@@ -78,8 +78,8 @@ public:
CPU = ABI == "o32" ? "mips32r2" : "mips64r2";
- CanUseBSDABICalls = Triple.getOS() == llvm::Triple::FreeBSD ||
- Triple.getOS() == llvm::Triple::OpenBSD;
+ CanUseBSDABICalls = Triple.isOSFreeBSD() ||
+ Triple.isOSOpenBSD();
}
bool isIEEE754_2008Default() const {
@@ -132,7 +132,7 @@ public:
void setN32N64ABITypes() {
LongDoubleWidth = LongDoubleAlign = 128;
LongDoubleFormat = &llvm::APFloat::IEEEquad();
- if (getTriple().getOS() == llvm::Triple::FreeBSD) {
+ if (getTriple().isOSFreeBSD()) {
LongDoubleWidth = LongDoubleAlign = 64;
LongDoubleFormat = &llvm::APFloat::IEEEdouble();
}
@@ -142,7 +142,7 @@ public:
void setN64ABITypes() {
setN32N64ABITypes();
- if (getTriple().getOS() == llvm::Triple::OpenBSD) {
+ if (getTriple().isOSOpenBSD()) {
Int64Type = SignedLongLong;
} else {
Int64Type = SignedLong;
Modified: cfe/trunk/lib/Basic/Targets/PPC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/PPC.cpp?rev=349752&r1=349751&r2=349752&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets/PPC.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/PPC.cpp Thu Dec 20 05:09:30 2018
@@ -83,8 +83,8 @@ void PPCTargetInfo::getTargetDefines(con
if (getTriple().getArch() == llvm::Triple::ppc64le) {
Builder.defineMacro("_LITTLE_ENDIAN");
} else {
- if (getTriple().getOS() != llvm::Triple::NetBSD &&
- getTriple().getOS() != llvm::Triple::OpenBSD)
+ if (!getTriple().isOSNetBSD() &&
+ !getTriple().isOSOpenBSD())
Builder.defineMacro("_BIG_ENDIAN");
}
Modified: cfe/trunk/lib/Basic/Targets/PPC.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/PPC.h?rev=349752&r1=349751&r2=349752&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets/PPC.h (original)
+++ cfe/trunk/lib/Basic/Targets/PPC.h Thu Dec 20 05:09:30 2018
@@ -331,7 +331,7 @@ public:
break;
}
- if (getTriple().getOS() == llvm::Triple::FreeBSD) {
+ if (getTriple().isOSFreeBSD()) {
LongDoubleWidth = LongDoubleAlign = 64;
LongDoubleFormat = &llvm::APFloat::IEEEdouble();
}
Modified: cfe/trunk/lib/Basic/Targets/Sparc.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/Sparc.h?rev=349752&r1=349751&r2=349752&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets/Sparc.h (original)
+++ cfe/trunk/lib/Basic/Targets/Sparc.h Thu Dec 20 05:09:30 2018
@@ -199,7 +199,7 @@ public:
LongWidth = LongAlign = PointerWidth = PointerAlign = 64;
// OpenBSD uses long long for int64_t and intmax_t.
- if (getTriple().getOS() == llvm::Triple::OpenBSD)
+ if (getTriple().isOSOpenBSD())
IntMaxType = SignedLongLong;
else
IntMaxType = SignedLong;
Modified: cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp?rev=349752&r1=349751&r2=349752&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp Thu Dec 20 05:09:30 2018
@@ -47,12 +47,12 @@ void mips::getMipsCPUAndABI(const ArgLis
}
// MIPS3 is the default for mips64*-unknown-openbsd.
- if (Triple.getOS() == llvm::Triple::OpenBSD)
+ if (Triple.isOSOpenBSD())
DefMips64CPU = "mips3";
// MIPS2 is the default for mips(el)?-unknown-freebsd.
// MIPS3 is the default for mips64(el)?-unknown-freebsd.
- if (Triple.getOS() == llvm::Triple::FreeBSD) {
+ if (Triple.isOSFreeBSD()) {
DefMips32CPU = "mips2";
DefMips64CPU = "mips3";
}
Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=349752&r1=349751&r2=349752&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Thu Dec 20 05:09:30 2018
@@ -526,7 +526,7 @@ static bool useFramePointerForTargetByDe
break;
}
- if (Triple.getOS() == llvm::Triple::NetBSD) {
+ if (Triple.isOSNetBSD()) {
return !areOptimizationsEnabled(Args);
}
@@ -2848,8 +2848,8 @@ static void RenderCharacterOptions(const
} else {
bool IsARM = T.isARM() || T.isThumb() || T.isAArch64();
CmdArgs.push_back("-fwchar-type=int");
- if (IsARM && !(T.isOSWindows() || T.getOS() == llvm::Triple::NetBSD ||
- T.getOS() == llvm::Triple::OpenBSD))
+ if (IsARM && !(T.isOSWindows() || T.isOSNetBSD() ||
+ T.isOSOpenBSD()))
CmdArgs.push_back("-fno-signed-wchar");
else
CmdArgs.push_back("-fsigned-wchar");
@@ -5274,8 +5274,8 @@ void Clang::ConstructJob(Compilation &C,
(TC.getTriple().isOSBinFormatELF() ||
TC.getTriple().isOSBinFormatCOFF()) &&
!TC.getTriple().isPS4() &&
- TC.useIntegratedAs() &&
- RawTriple.getOS() != llvm::Triple::NetBSD))
+ !TC.getTriple().isOSNetBSD() &&
+ TC.useIntegratedAs()))
CmdArgs.push_back("-faddrsig");
// Finally add the compile command to the compilation.
Modified: cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp?rev=349752&r1=349751&r2=349752&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp Thu Dec 20 05:09:30 2018
@@ -603,19 +603,19 @@ void tools::linkSanitizerRuntimeDeps(con
if (TC.getTriple().getOS() != llvm::Triple::RTEMS &&
!TC.getTriple().isAndroid()) {
CmdArgs.push_back("-lpthread");
- if (TC.getTriple().getOS() != llvm::Triple::OpenBSD)
+ if (TC.getTriple().isOSOpenBSD())
CmdArgs.push_back("-lrt");
}
CmdArgs.push_back("-lm");
// There's no libdl on all OSes.
- if (TC.getTriple().getOS() != llvm::Triple::FreeBSD &&
- TC.getTriple().getOS() != llvm::Triple::NetBSD &&
- TC.getTriple().getOS() != llvm::Triple::OpenBSD &&
- TC.getTriple().getOS() != llvm::Triple::RTEMS)
+ if (!TC.getTriple().isOSFreeBSD() &&
+ !TC.getTriple().isOSNetBSD() &&
+ !TC.getTriple().isOSOpenBSD() &&
+ TC.getTriple().getOS() != llvm::Triple::RTEMS)
CmdArgs.push_back("-ldl");
// Required for backtrace on some OSes
- if (TC.getTriple().getOS() == llvm::Triple::NetBSD ||
- TC.getTriple().getOS() == llvm::Triple::FreeBSD)
+ if (TC.getTriple().isOSFreeBSD() ||
+ TC.getTriple().isOSNetBSD())
CmdArgs.push_back("-lexecinfo");
}
@@ -790,13 +790,13 @@ bool tools::addXRayRuntime(const ToolCha
void tools::linkXRayRuntimeDeps(const ToolChain &TC, ArgStringList &CmdArgs) {
CmdArgs.push_back("--no-as-needed");
CmdArgs.push_back("-lpthread");
- if (TC.getTriple().getOS() != llvm::Triple::OpenBSD)
+ if (!TC.getTriple().isOSOpenBSD())
CmdArgs.push_back("-lrt");
CmdArgs.push_back("-lm");
- if (TC.getTriple().getOS() != llvm::Triple::FreeBSD &&
- TC.getTriple().getOS() != llvm::Triple::NetBSD &&
- TC.getTriple().getOS() != llvm::Triple::OpenBSD)
+ if (!TC.getTriple().isOSFreeBSD() &&
+ !TC.getTriple().isOSNetBSD() &&
+ !TC.getTriple().isOSOpenBSD())
CmdArgs.push_back("-ldl");
}
@@ -933,7 +933,7 @@ tools::ParsePICArgs(const ToolChain &Too
}
// OpenBSD-specific defaults for PIE
- if (Triple.getOS() == llvm::Triple::OpenBSD) {
+ if (Triple.isOSOpenBSD()) {
switch (ToolChain.getArch()) {
case llvm::Triple::arm:
case llvm::Triple::aarch64:
Modified: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Gnu.cpp?rev=349752&r1=349751&r2=349752&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp Thu Dec 20 05:09:30 2018
@@ -2597,7 +2597,7 @@ void Generic_ELF::addClangTargetOptions(
bool UseInitArrayDefault =
getTriple().getArch() == llvm::Triple::aarch64 ||
getTriple().getArch() == llvm::Triple::aarch64_be ||
- (getTriple().getOS() == llvm::Triple::FreeBSD &&
+ (getTriple().isOSFreeBSD() &&
getTriple().getOSMajorVersion() >= 12) ||
(getTriple().getOS() == llvm::Triple::Linux &&
((!GCCInstallation.isValid() || !V.isOlderThan(4, 7, 0)) ||
Modified: cfe/trunk/lib/Driver/XRayArgs.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/XRayArgs.cpp?rev=349752&r1=349751&r2=349752&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/XRayArgs.cpp (original)
+++ cfe/trunk/lib/Driver/XRayArgs.cpp Thu Dec 20 05:09:30 2018
@@ -50,9 +50,9 @@ XRayArgs::XRayArgs(const ToolChain &TC,
D.Diag(diag::err_drv_clang_unsupported)
<< (std::string(XRayInstrumentOption) + " on " + Triple.str());
}
- } else if (Triple.getOS() == llvm::Triple::FreeBSD ||
- Triple.getOS() == llvm::Triple::OpenBSD ||
- Triple.getOS() == llvm::Triple::NetBSD ||
+ } else if (Triple.isOSFreeBSD() ||
+ Triple.isOSOpenBSD() ||
+ Triple.isOSNetBSD() ||
Triple.getOS() == llvm::Triple::Darwin) {
if (Triple.getArch() != llvm::Triple::x86_64) {
D.Diag(diag::err_drv_clang_unsupported)
Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp?rev=349752&r1=349751&r2=349752&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp Thu Dec 20 05:09:30 2018
@@ -29,10 +29,10 @@ static bool isArc4RandomAvailable(const
const llvm::Triple &T = Ctx.getTargetInfo().getTriple();
return T.getVendor() == llvm::Triple::Apple ||
T.getOS() == llvm::Triple::CloudABI ||
- T.getOS() == llvm::Triple::FreeBSD ||
- T.getOS() == llvm::Triple::NetBSD ||
- T.getOS() == llvm::Triple::OpenBSD ||
- T.getOS() == llvm::Triple::DragonFly;
+ T.isOSFreeBSD() ||
+ T.isOSNetBSD() ||
+ T.isOSOpenBSD() ||
+ T.isOSDragonFly();
}
namespace {
More information about the cfe-commits
mailing list