From 57b1da1588a3f5785ad8bd5d9f2d795d685e1058 Mon Sep 17 00:00:00 2001 From: Cameron Esfahani Date: Sat, 14 Sep 2013 01:09:11 +0000 Subject: [PATCH] Clean up some Triple usage in clang. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190737 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/ARCMigrate/ARCMT.cpp | 2 +- lib/ARCMigrate/Transforms.cpp | 2 +- lib/Basic/Targets.cpp | 4 ++-- lib/CodeGen/CGObjCMac.cpp | 2 +- lib/CodeGen/TargetInfo.cpp | 4 ++-- lib/Driver/Tools.cpp | 17 ++++++++--------- .../Checkers/CallAndMessageChecker.cpp | 3 +-- 7 files changed, 16 insertions(+), 18 deletions(-) diff --git a/lib/ARCMigrate/ARCMT.cpp b/lib/ARCMigrate/ARCMT.cpp index 8cd6e4bb61..477e327071 100644 --- a/lib/ARCMigrate/ARCMT.cpp +++ b/lib/ARCMigrate/ARCMT.cpp @@ -150,7 +150,7 @@ static bool HasARCRuntime(CompilerInvocation &origCI) { // and avoid unrelated complications. llvm::Triple triple(origCI.getTargetOpts().Triple); - if (triple.getOS() == llvm::Triple::IOS) + if (triple.isiOS()) return triple.getOSMajorVersion() >= 5; if (triple.getOS() == llvm::Triple::Darwin) diff --git a/lib/ARCMigrate/Transforms.cpp b/lib/ARCMigrate/Transforms.cpp index 6c724af53a..38f30a56f4 100644 --- a/lib/ARCMigrate/Transforms.cpp +++ b/lib/ARCMigrate/Transforms.cpp @@ -49,7 +49,7 @@ bool trans::canApplyWeak(ASTContext &Ctx, QualType type, return false; // iOS is always safe to use 'weak'. - if (Ctx.getTargetInfo().getTriple().getOS() == llvm::Triple::IOS) + if (Ctx.getTargetInfo().getTriple().isiOS()) AllowOnUnknownClass = true; while (const PointerType *ptr = T->getAs()) diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp index 99fc5698bf..c2ba84b225 100644 --- a/lib/Basic/Targets.cpp +++ b/lib/Basic/Targets.cpp @@ -139,7 +139,7 @@ static void getDarwinDefines(MacroBuilder &Builder, const LangOptions &Opts, } // Set the appropriate OS version define. - if (Triple.getOS() == llvm::Triple::IOS) { + if (Triple.isiOS()) { assert(Maj < 10 && Min < 100 && Rev < 100 && "Invalid version!"); char Str[6]; Str[0] = '0' + Maj; @@ -3528,7 +3528,7 @@ class ARMTargetInfo : public TargetInfo { // the kernel which on armv6 and newer uses ldrex and strex. The net result // is that if we assume the kernel is at least as recent as the hardware, // it is safe to use atomic instructions on armv6 and newer. - if (T.getOS() != llvm::Triple::Linux && + if (!T.isOSLinux() && T.getOS() != llvm::Triple::FreeBSD && T.getOS() != llvm::Triple::Bitrig) return false; diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp index e8498b06ad..f76182213a 100644 --- a/lib/CodeGen/CGObjCMac.cpp +++ b/lib/CodeGen/CGObjCMac.cpp @@ -4348,7 +4348,7 @@ void CGObjCCommonMac::EmitImageInfo() { // Indicate whether we're compiling this to run on a simulator. const llvm::Triple &Triple = CGM.getTarget().getTriple(); - if (Triple.getOS() == llvm::Triple::IOS && + if (Triple.isiOS() && (Triple.getArch() == llvm::Triple::x86 || Triple.getArch() == llvm::Triple::x86_64)) Mod.addModuleFlag(llvm::Module::Error, "Objective-C Is Simulated", diff --git a/lib/CodeGen/TargetInfo.cpp b/lib/CodeGen/TargetInfo.cpp index b56684ba5c..0706a28917 100644 --- a/lib/CodeGen/TargetInfo.cpp +++ b/lib/CodeGen/TargetInfo.cpp @@ -1445,7 +1445,7 @@ void X86_64ABIInfo::classify(QualType Ty, uint64_t OffsetBase, Current = Integer; } else if ((k == BuiltinType::Float || k == BuiltinType::Double) || (k == BuiltinType::LongDouble && - getTarget().getTriple().getOS() == llvm::Triple::NaCl)) { + getTarget().getTriple().isOSNaCl())) { Current = SSE; } else if (k == BuiltinType::LongDouble) { Lo = X87; @@ -1537,7 +1537,7 @@ void X86_64ABIInfo::classify(QualType Ty, uint64_t OffsetBase, Current = SSE; else if (ET == getContext().DoubleTy || (ET == getContext().LongDoubleTy && - getTarget().getTriple().getOS() == llvm::Triple::NaCl)) + getTarget().getTriple().isOSNaCl())) Lo = Hi = SSE; else if (ET == getContext().LongDoubleTy) Current = ComplexX87; diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index 30ecdc05d3..305cfb48d2 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -770,7 +770,7 @@ void Clang::AddARMTargetArgs(const ArgList &Args, // Kernel code has more strict alignment requirements. if (KernelOrKext) { - if (Triple.getOS() != llvm::Triple::IOS || Triple.isOSVersionLT(6)) { + if (!Triple.isiOS() || Triple.isOSVersionLT(6)) { CmdArgs.push_back("-backend-option"); CmdArgs.push_back("-arm-long-calls"); } @@ -1768,7 +1768,7 @@ static bool shouldUseFramePointer(const ArgList &Args, if ((Triple.getArch() == llvm::Triple::x86_64 || Triple.getArch() == llvm::Triple::x86 || Triple.getArch() == llvm::Triple::systemz) && - Triple.getOS() == llvm::Triple::Linux) { + Triple.isOSLinux()) { if (Arg *A = Args.getLastArg(options::OPT_O_Group)) if (!A->getOption().matches(options::OPT_O0)) return false; @@ -1790,7 +1790,7 @@ static bool shouldUseLeafFramePointer(const ArgList &Args, if ((Triple.getArch() == llvm::Triple::x86_64 || Triple.getArch() == llvm::Triple::x86 || Triple.getArch() == llvm::Triple::systemz) && - Triple.getOS() == llvm::Triple::Linux) { + Triple.isOSLinux()) { if (Arg *A = Args.getLastArg(options::OPT_O_Group)) if (!A->getOption().matches(options::OPT_O0)) return false; @@ -2091,8 +2091,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, // PIC or PIE options above, if these show up, PIC is disabled. llvm::Triple Triple(TripleStr); if (KernelOrKext && - (Triple.getOS() != llvm::Triple::IOS || - Triple.isOSVersionLT(6))) + (!Triple.isiOS() || Triple.isOSVersionLT(6))) PIC = PIE = false; if (Args.hasArg(options::OPT_static)) PIC = PIE = false; @@ -2503,7 +2502,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, // -gsplit-dwarf should turn on -g and enable the backend dwarf // splitting and extraction. // FIXME: Currently only works on Linux. - if (getToolChain().getTriple().getOS() == llvm::Triple::Linux && + if (getToolChain().getTriple().isOSLinux() && Args.hasArg(options::OPT_gsplit_dwarf)) { CmdArgs.push_back("-g"); CmdArgs.push_back("-backend-option"); @@ -3553,7 +3552,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, // Add the split debug info name to the command lines here so we // can propagate it to the backend. bool SplitDwarf = Args.hasArg(options::OPT_gsplit_dwarf) && - (getToolChain().getTriple().getOS() == llvm::Triple::Linux) && + getToolChain().getTriple().isOSLinux() && (isa(JA) || isa(JA)); const char *SplitDwarfOut; if (SplitDwarf) { @@ -3906,7 +3905,7 @@ void ClangAs::ConstructJob(Compilation &C, const JobAction &JA, // creating an object. // TODO: Currently only works on linux with newer objcopy. if (Args.hasArg(options::OPT_gsplit_dwarf) && - (getToolChain().getTriple().getOS() == llvm::Triple::Linux)) + getToolChain().getTriple().isOSLinux()) SplitDebugInfo(getToolChain(), C, *this, JA, Args, Output, SplitDebugName(Args, Inputs)); } @@ -6001,7 +6000,7 @@ void gnutools::Assemble::ConstructJob(Compilation &C, const JobAction &JA, // creating an object. // TODO: Currently only works on linux with newer objcopy. if (Args.hasArg(options::OPT_gsplit_dwarf) && - (getToolChain().getTriple().getOS() == llvm::Triple::Linux)) + getToolChain().getTriple().isOSLinux()) SplitDebugInfo(getToolChain(), C, *this, JA, Args, Output, SplitDebugName(Args, Inputs)); } diff --git a/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp b/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp index 976dcaabf6..d5ab479ec3 100644 --- a/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp @@ -446,8 +446,7 @@ void CallAndMessageChecker::emitNilReceiverBug(CheckerContext &C, static bool supportsNilWithFloatRet(const llvm::Triple &triple) { return (triple.getVendor() == llvm::Triple::Apple && - (triple.getOS() == llvm::Triple::IOS || - !triple.isMacOSXVersionLT(10,5))); + (triple.isiOS() || !triple.isMacOSXVersionLT(10,5))); } void CallAndMessageChecker::HandleNilReceiver(CheckerContext &C, -- 2.40.0