[PATCH] D13571: Add Triple::isAndroid().

Evgeniy Stepanov via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 8 13:35:41 PDT 2015


eugenis created this revision.
eugenis added a reviewer: echristo.
eugenis added a subscriber: llvm-commits.
eugenis set the repository for this revision to rL LLVM.
Herald added subscribers: srhines, danalbert, tberghammer.

This is a simple refactoring that replaces Triple.getEnvironment()
checks for Android with Triple.isAndroid().


Repository:
  rL LLVM

http://reviews.llvm.org/D13571

Files:
  include/llvm/ADT/Triple.h
  lib/Target/AArch64/AArch64Subtarget.h
  lib/Target/ARM/ARMSubtarget.h
  lib/Target/X86/X86Subtarget.h
  lib/Transforms/Instrumentation/AddressSanitizer.cpp
  lib/Transforms/Instrumentation/SafeStack.cpp

Index: lib/Transforms/Instrumentation/SafeStack.cpp
===================================================================
--- lib/Transforms/Instrumentation/SafeStack.cpp
+++ lib/Transforms/Instrumentation/SafeStack.cpp
@@ -262,7 +262,7 @@
   }
 
   // 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);
Index: lib/Transforms/Instrumentation/AddressSanitizer.cpp
===================================================================
--- lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -338,7 +338,7 @@
 
 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();
Index: lib/Target/X86/X86Subtarget.h
===================================================================
--- lib/Target/X86/X86Subtarget.h
+++ lib/Target/X86/X86Subtarget.h
@@ -397,9 +397,7 @@
   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(); }
Index: lib/Target/ARM/ARMSubtarget.h
===================================================================
--- lib/Target/ARM/ARMSubtarget.h
+++ lib/Target/ARM/ARMSubtarget.h
@@ -383,7 +383,7 @@
             TargetTriple.getEnvironment() == Triple::GNUEABI ||
             TargetTriple.getEnvironment() == Triple::EABIHF ||
             TargetTriple.getEnvironment() == Triple::GNUEABIHF ||
-            TargetTriple.getEnvironment() == Triple::Android) &&
+            isTargetAndroid()) &&
            !isTargetDarwin() && !isTargetWindows();
   }
 
@@ -393,9 +393,7 @@
            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;
Index: lib/Target/AArch64/AArch64Subtarget.h
===================================================================
--- lib/Target/AArch64/AArch64Subtarget.h
+++ lib/Target/AArch64/AArch64Subtarget.h
@@ -123,6 +123,7 @@
   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(); }
Index: include/llvm/ADT/Triple.h
===================================================================
--- include/llvm/ADT/Triple.h
+++ include/llvm/ADT/Triple.h
@@ -510,6 +510,9 @@
            getOS() == Triple::PS4;
   }
 
+  /// \brief Tests whether the target is Android
+  bool isAndroid() const { return getEnvironment() == Triple::Android; }
+
   /// @}
   /// @name Mutators
   /// @{


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D13571.36892.patch
Type: text/x-patch
Size: 3878 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151008/187038d2/attachment.bin>


More information about the llvm-commits mailing list