ARM: add watchOS default version support function.
authorTim Northover <tnorthover@apple.com>
Wed, 28 Oct 2015 22:57:14 +0000 (22:57 +0000)
committerTim Northover <tnorthover@apple.com>
Wed, 28 Oct 2015 22:57:14 +0000 (22:57 +0000)
It's useful for Clang's Driver faff.

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

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

index 4ed694cfa99ce17d124f7d560727398dee3259de..ad9fe06036472647128b87195c46db4740a33573 100644 (file)
@@ -303,10 +303,15 @@ public:
                         unsigned &Micro) const;
 
   /// getiOSVersion - Parse the version number as with getOSVersion.  This should
-  /// only be called with IOS triples.
+  /// only be called with IOS or generic triples.
   void getiOSVersion(unsigned &Major, unsigned &Minor,
                      unsigned &Micro) const;
 
+  /// getWatchOSVersion - Parse the version number as with getOSVersion.  This
+  /// should only be called with WatchOS or generic triples.
+  void getWatchOSVersion(unsigned &Major, unsigned &Minor,
+                         unsigned &Micro) const;
+
   /// @}
   /// @name Direct Component Access
   /// @{
index 8964fc09985d3a783da544fd8ea8e3d2530a920f..9d5f1455330566043c0acf621282047044e1be06 100644 (file)
@@ -958,7 +958,6 @@ void Triple::getiOSVersion(unsigned &Major, unsigned &Minor,
   default: llvm_unreachable("unexpected OS for Darwin triple");
   case Darwin:
   case MacOSX:
-  case WatchOS:
     // 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
@@ -974,6 +973,32 @@ void Triple::getiOSVersion(unsigned &Major, unsigned &Minor,
     if (Major == 0)
       Major = (getArch() == aarch64) ? 7 : 5;
     break;
+  case WatchOS:
+    llvm_unreachable("conflicting triple info");
+  }
+}
+
+void Triple::getWatchOSVersion(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 = 2;
+    Minor = 0;
+    Micro = 0;
+    break;
+  case WatchOS:
+    getOSVersion(Major, Minor, Micro);
+    if (Major == 0)
+      Major = 2;
+    break;
+  case IOS:
+    llvm_unreachable("conflicting triple info");
   }
 }