[llvm-branch-commits] [cfe-branch] r287815 - Merge r275905 into 3.9 branch: Allow iOS and tvOS version numbers with 2-digit major version numbers.

Mehdi Amini via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Nov 23 13:25:50 PST 2016


Author: mehdi_amini
Date: Wed Nov 23 15:25:50 2016
New Revision: 287815

URL: http://llvm.org/viewvc/llvm-project?rev=287815&view=rev
Log:
Merge r275905 into 3.9 branch: Allow iOS and tvOS version numbers with 2-digit major version numbers.

See: http://llvm.org/PR30555


Modified:
    cfe/branches/release_39/lib/Basic/Targets.cpp
    cfe/branches/release_39/lib/Driver/ToolChains.cpp
    cfe/branches/release_39/test/Frontend/darwin-version.c

Modified: cfe/branches/release_39/lib/Basic/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_39/lib/Basic/Targets.cpp?rev=287815&r1=287814&r2=287815&view=diff
==============================================================================
--- cfe/branches/release_39/lib/Basic/Targets.cpp (original)
+++ cfe/branches/release_39/lib/Basic/Targets.cpp Wed Nov 23 15:25:50 2016
@@ -158,14 +158,25 @@ static void getDarwinDefines(MacroBuilde
 
   // Set the appropriate OS version define.
   if (Triple.isiOS()) {
-    assert(Maj < 10 && Min < 100 && Rev < 100 && "Invalid version!");
-    char Str[6];
-    Str[0] = '0' + Maj;
-    Str[1] = '0' + (Min / 10);
-    Str[2] = '0' + (Min % 10);
-    Str[3] = '0' + (Rev / 10);
-    Str[4] = '0' + (Rev % 10);
-    Str[5] = '\0';
+    assert(Maj < 100 && Min < 100 && Rev < 100 && "Invalid version!");
+    char Str[7];
+    if (Maj < 10) {
+      Str[0] = '0' + Maj;
+      Str[1] = '0' + (Min / 10);
+      Str[2] = '0' + (Min % 10);
+      Str[3] = '0' + (Rev / 10);
+      Str[4] = '0' + (Rev % 10);
+      Str[5] = '\0';
+    } else {
+      // Handle versions >= 10.
+      Str[0] = '0' + (Maj / 10);
+      Str[1] = '0' + (Maj % 10);
+      Str[2] = '0' + (Min / 10);
+      Str[3] = '0' + (Min % 10);
+      Str[4] = '0' + (Rev / 10);
+      Str[5] = '0' + (Rev % 10);
+      Str[6] = '\0';
+    }
     if (Triple.isTvOS())
       Builder.defineMacro("__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__", Str);
     else

Modified: cfe/branches/release_39/lib/Driver/ToolChains.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_39/lib/Driver/ToolChains.cpp?rev=287815&r1=287814&r2=287815&view=diff
==============================================================================
--- cfe/branches/release_39/lib/Driver/ToolChains.cpp (original)
+++ cfe/branches/release_39/lib/Driver/ToolChains.cpp Wed Nov 23 15:25:50 2016
@@ -688,13 +688,13 @@ void Darwin::AddDeploymentTarget(Derived
     assert(iOSVersion && "Unknown target platform!");
     if (!Driver::GetReleaseVersion(iOSVersion->getValue(), Major, Minor, Micro,
                                    HadExtra) ||
-        HadExtra || Major >= 10 || Minor >= 100 || Micro >= 100)
+        HadExtra || Major >= 100 || Minor >= 100 || Micro >= 100)
       getDriver().Diag(diag::err_drv_invalid_version_number)
           << iOSVersion->getAsString(Args);
   } else if (Platform == TvOS) {
     if (!Driver::GetReleaseVersion(TvOSVersion->getValue(), Major, Minor,
                                    Micro, HadExtra) || HadExtra ||
-        Major >= 10 || Minor >= 100 || Micro >= 100)
+        Major >= 100 || Minor >= 100 || Micro >= 100)
       getDriver().Diag(diag::err_drv_invalid_version_number)
           << TvOSVersion->getAsString(Args);
   } else if (Platform == WatchOS) {

Modified: cfe/branches/release_39/test/Frontend/darwin-version.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_39/test/Frontend/darwin-version.c?rev=287815&r1=287814&r2=287815&view=diff
==============================================================================
--- cfe/branches/release_39/test/Frontend/darwin-version.c (original)
+++ cfe/branches/release_39/test/Frontend/darwin-version.c Wed Nov 23 15:25:50 2016
@@ -10,6 +10,8 @@
 // RUN: %clang_cc1 -triple armv6-apple-ios2.3.1 -dM -E -o %t %s
 // RUN: grep '__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__' %t | grep '20301' | count 1
 // RUN: not grep '__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__' %t
+// RUN: %clang_cc1 -triple armv7-apple-ios10.1.2 -dM -E -o %t %s
+// RUN: grep '__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__' %t | grep '100102' | count 1
 // RUN: %clang_cc1 -triple i386-apple-macosx10.4.0 -dM -E -o %t %s
 // RUN: grep '__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__' %t | grep '1040' | count 1
 // RUN: not grep '__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__' %t
@@ -32,6 +34,8 @@
 // RUN: grep '__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__' %t | grep '80300' | count 1
 // RUN: not grep '__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__' %t
 // RUN: not grep '__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__' %t
+// RUN: %clang_cc1 -triple arm64-apple-tvos10.2.3 -dM -E -o %t %s
+// RUN: grep '__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__' %t | grep '100203' | count 1
 
 // RUN: %clang_cc1 -triple x86_64-apple-tvos8.3 -dM -E -o %t %s
 // RUN: grep '__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__' %t | grep '80300' | count 1




More information about the llvm-branch-commits mailing list