ADT/Triple: Add isOSDarwin() and isOSWindows() helper functions.
authorDaniel Dunbar <daniel@zuster.org>
Tue, 19 Apr 2011 21:12:05 +0000 (21:12 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Tue, 19 Apr 2011 21:12:05 +0000 (21:12 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129815 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ADT/Triple.h
lib/Support/Triple.cpp

index 480c9316bd044cf38a27ed59836dc90574d90af3..f8e0ec887866a20cbb0bad3ac0003046c76a482f 100644 (file)
@@ -249,6 +249,8 @@ public:
     return getOSMajorVersion();
   }
 
+  /// isOSVersionLT - Helper function for doing comparisons against version
+  /// numbers included in the target triple.
   bool isOSVersionLT(unsigned Major, unsigned Minor = 0,
                      unsigned Micro = 0) const {
     unsigned LHS[3];
@@ -270,6 +272,17 @@ public:
     return getOS() == Triple::Darwin || getOS() == Triple::OSX;
   }
 
+  /// isOSDarwin - Is this a "Darwin" OS (OS X or iOS).
+  bool isOSDarwin() const {
+    return isOSX() ||getOS() == Triple::IOS;
+  }
+
+  /// isOSWindows - Is this a "Windows" OS.
+  bool isOSWindows() const {
+    return getOS() == Triple::Win32 || getOS() == Triple::Cygwin ||
+      getOS() == Triple::MinGW32;
+  }
+
   /// isOSXVersionLT - Comparison function for checking OS X version
   /// compatibility, which handles supporting skewed version numbering schemes
   /// used by the "darwin" triples.
index 51f6c0787f23dbde7582e47fe64ea01df26561fc..8281b483c95d563d81a2fbf42b16e85bc2c61b61 100644 (file)
@@ -213,8 +213,7 @@ Triple::ArchType Triple::getArchTypeForDarwinArchName(StringRef Str) {
 
 // Returns architecture name that is understood by the target assembler.
 const char *Triple::getArchNameForAssembler() {
-  if (getOS() != Triple::Darwin && getOS() != Triple::OSX &&
-      getOS() != Triple::IOS && getVendor() != Triple::Apple)
+  if (!isOSDarwin() && getVendor() != Triple::Apple)
     return NULL;
 
   StringRef Str = getArchName();