From: Evgeniy Stepanov Date: Thu, 8 Oct 2015 21:21:24 +0000 (+0000) Subject: Add Triple::isAndroid(). X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=5771ec4c40a45e46db349fbb17ef017386c9a419;p=oota-llvm.git Add Triple::isAndroid(). This is a simple refactoring that replaces Triple.getEnvironment() checks for Android with Triple.isAndroid(). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@249750 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/ADT/Triple.h b/include/llvm/ADT/Triple.h index dfb5694dc8c..99822b0764e 100644 --- a/include/llvm/ADT/Triple.h +++ b/include/llvm/ADT/Triple.h @@ -510,6 +510,9 @@ public: getOS() == Triple::PS4; } + /// \brief Tests whether the target is Android + bool isAndroid() const { return getEnvironment() == Triple::Android; } + /// @} /// @name Mutators /// @{ diff --git a/lib/Target/AArch64/AArch64Subtarget.h b/lib/Target/AArch64/AArch64Subtarget.h index 62320218207..78af28829e8 100644 --- a/lib/Target/AArch64/AArch64Subtarget.h +++ b/lib/Target/AArch64/AArch64Subtarget.h @@ -123,6 +123,7 @@ public: bool isTargetIOS() const { return TargetTriple.isiOS(); } bool isTargetLinux() const { return TargetTriple.isOSLinux(); } bool isTargetWindows() const { return TargetTriple.isOSWindows(); } + bool isTargetAndroid() const { return TargetTriple.isAndroid(); } bool isTargetCOFF() const { return TargetTriple.isOSBinFormatCOFF(); } bool isTargetELF() const { return TargetTriple.isOSBinFormatELF(); } diff --git a/lib/Target/ARM/ARMSubtarget.h b/lib/Target/ARM/ARMSubtarget.h index 554c7899496..ad546c1b14c 100644 --- a/lib/Target/ARM/ARMSubtarget.h +++ b/lib/Target/ARM/ARMSubtarget.h @@ -383,7 +383,7 @@ public: TargetTriple.getEnvironment() == Triple::GNUEABI || TargetTriple.getEnvironment() == Triple::EABIHF || TargetTriple.getEnvironment() == Triple::GNUEABIHF || - TargetTriple.getEnvironment() == Triple::Android) && + isTargetAndroid()) && !isTargetDarwin() && !isTargetWindows(); } @@ -393,9 +393,7 @@ public: TargetTriple.getEnvironment() == Triple::EABIHF || isTargetWindows(); } - bool isTargetAndroid() const { - return TargetTriple.getEnvironment() == Triple::Android; - } + bool isTargetAndroid() const { return TargetTriple.isAndroid(); } bool isAPCS_ABI() const; bool isAAPCS_ABI() const; diff --git a/lib/Target/X86/X86Subtarget.h b/lib/Target/X86/X86Subtarget.h index 198e7fbf135..382f7375f6f 100644 --- a/lib/Target/X86/X86Subtarget.h +++ b/lib/Target/X86/X86Subtarget.h @@ -397,9 +397,7 @@ public: bool isTargetMachO() const { return TargetTriple.isOSBinFormatMachO(); } bool isTargetLinux() const { return TargetTriple.isOSLinux(); } - bool isTargetAndroid() const { - return TargetTriple.getEnvironment() == Triple::Android; - } + bool isTargetAndroid() const { return TargetTriple.isAndroid(); } bool isTargetNaCl() const { return TargetTriple.isOSNaCl(); } bool isTargetNaCl32() const { return isTargetNaCl() && !is64Bit(); } bool isTargetNaCl64() const { return isTargetNaCl() && is64Bit(); } diff --git a/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/lib/Transforms/Instrumentation/AddressSanitizer.cpp index f4f58ac7ce7..9ba564e5dc8 100644 --- a/lib/Transforms/Instrumentation/AddressSanitizer.cpp +++ b/lib/Transforms/Instrumentation/AddressSanitizer.cpp @@ -338,7 +338,7 @@ struct ShadowMapping { static ShadowMapping getShadowMapping(Triple &TargetTriple, int LongSize, bool IsKasan) { - bool IsAndroid = TargetTriple.getEnvironment() == llvm::Triple::Android; + bool IsAndroid = TargetTriple.isAndroid(); bool IsIOS = TargetTriple.isiOS(); bool IsFreeBSD = TargetTriple.isOSFreeBSD(); bool IsLinux = TargetTriple.isOSLinux(); diff --git a/lib/Transforms/Instrumentation/SafeStack.cpp b/lib/Transforms/Instrumentation/SafeStack.cpp index 1b28caffd4a..c2b596c42b7 100644 --- a/lib/Transforms/Instrumentation/SafeStack.cpp +++ b/lib/Transforms/Instrumentation/SafeStack.cpp @@ -262,7 +262,7 @@ Value *SafeStack::getOrCreateUnsafeStackPtr(IRBuilder<> &IRB, Function &F) { } // Android provides a libc function that returns the stack pointer address. - if (TargetTriple.getEnvironment() == llvm::Triple::Android) { + if (TargetTriple.isAndroid()) { Value *Fn = M.getOrInsertFunction(kUnsafeStackPtrAddrFn, StackPtrTy->getPointerTo(0), nullptr); return IRB.CreateCall(Fn);