OSDN Git Service

Add Triple::getiOSVersion.
authorChad Rosier <mcrosier@apple.com>
Wed, 9 May 2012 17:23:48 +0000 (17:23 +0000)
committerChad Rosier <mcrosier@apple.com>
Wed, 9 May 2012 17:23:48 +0000 (17:23 +0000)
This new function provides a way to get the iOS version number from ios triples.
Part of rdar://11409204

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@156483 91177308-0d34-0410-b5e6-96231b3b80d8

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

index edbbdc5..957c581 100644 (file)
@@ -196,6 +196,11 @@ public:
   bool getMacOSXVersion(unsigned &Major, unsigned &Minor,
                         unsigned &Micro) const;
 
+  /// getiOSVersion - Parse the version number as with getOSVersion.  This should
+  /// only be called with IOS triples.
+  void getiOSVersion(unsigned &Major, unsigned &Minor,
+                     unsigned &Micro) const;
+
   /// @}
   /// @name Direct Component Access
   /// @{
index 4ee4716..2a22f75 100644 (file)
@@ -596,6 +596,27 @@ bool Triple::getMacOSXVersion(unsigned &Major, unsigned &Minor,
   return true;
 }
 
+void Triple::getiOSVersion(unsigned &Major, unsigned &Minor,
+                           unsigned &Micro) const {
+  switch (getOS()) {
+  default: llvm_unreachable("unexpected OS for Darwin triple");
+  case Darwin:
+  case MacOSX:
+    // Ignore the version from the triple.  This is only handled because the
+    // the clang driver combines OS X and IOS support into a common Darwin
+    // toolchain that wants to know the iOS version number even when targeting
+    // OS X.
+    Major = 0;
+    Minor = 0;
+    Micro = 0;
+    return true;
+  case IOS:
+    getOSVersion(Major, Minor, Micro);
+    // Default to 0.0.
+    break;
+  }
+}
+
 void Triple::setTriple(const Twine &Str) {
   *this = Triple(Str);
 }