diff options
| author | Tim Northover <tnorthover@apple.com> | 2015-10-30 16:30:30 +0000 |
|---|---|---|
| committer | Tim Northover <tnorthover@apple.com> | 2015-10-30 16:30:30 +0000 |
| commit | 67465f80eca80beb18f1602095fe03c76b74d52e (patch) | |
| tree | f19db1a3dfaf8d2c006f145140a9de72a0aea9e0 | |
| parent | 6f3ff22e739441cfdcd8ad1de92dba6f48fa3da7 (diff) | |
| download | bcm5719-llvm-67465f80eca80beb18f1602095fe03c76b74d52e.tar.gz bcm5719-llvm-67465f80eca80beb18f1602095fe03c76b74d52e.zip | |
Preprocessor: define correct tvOS and watchOS version macros
llvm-svn: 251707
| -rw-r--r-- | clang/lib/Basic/Targets.cpp | 17 | ||||
| -rw-r--r-- | clang/test/Frontend/darwin-version.c | 22 |
2 files changed, 38 insertions, 1 deletions
diff --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp index a0c379aeb7f..2a220360088 100644 --- a/clang/lib/Basic/Targets.cpp +++ b/clang/lib/Basic/Targets.cpp @@ -162,7 +162,22 @@ static void getDarwinDefines(MacroBuilder &Builder, const LangOptions &Opts, Str[3] = '0' + (Rev / 10); Str[4] = '0' + (Rev % 10); Str[5] = '\0'; - Builder.defineMacro("__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__", Str); + if (Triple.isTvOS()) + Builder.defineMacro("__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__", Str); + else + Builder.defineMacro("__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__", + Str); + + } else if (Triple.isWatchOS()) { + 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'; + Builder.defineMacro("__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__", Str); } else if (Triple.isMacOSX()) { // Note that the Driver allows versions which aren't representable in the // define (because we only get a single digit for the minor and micro diff --git a/clang/test/Frontend/darwin-version.c b/clang/test/Frontend/darwin-version.c index 2da0c4c7a57..e7bc41117e3 100644 --- a/clang/test/Frontend/darwin-version.c +++ b/clang/test/Frontend/darwin-version.c @@ -13,6 +13,8 @@ // 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 +// RUN: not grep '__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__' %t +// RUN: not grep '__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__' %t // RUN: %clang_cc1 -triple i386-apple-macosx10.4.10 -dM -E -o %t %s // RUN: grep '__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__' %t | grep '1049' | count 1 // RUN: not grep '__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__' %t @@ -25,3 +27,23 @@ // RUN: %clang_cc1 -triple x86_64-apple-macosx10.10.0 -dM -E -o %t %s // RUN: grep '__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__' %t | grep '101000' | count 1 // RUN: not grep '__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__' %t + +// RUN: %clang_cc1 -triple arm64-apple-tvos8.3 -dM -E -o %t %s +// 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 x86_64-apple-tvos8.3 -dM -E -o %t %s +// 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 armv7k-apple-watchos2.1 -dM -E -o %t %s +// RUN: grep '__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__' %t | grep '20100' | 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 i386-apple-watchos2.1 -dM -E -o %t %s +// RUN: grep '__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__' %t | grep '20100' | count 1 +// RUN: not grep '__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__' %t +// RUN: not grep '__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__' %t |

