Support watchOS and tvOS driver options

This patch should add support for almost all command-line options and
driver tinkering necessary to produce a correct "clang -cc1"
invocation for watchOS and tvOS.

llvm-svn: 251706
diff --git a/clang/test/Driver/apple-kext-mkernel.c b/clang/test/Driver/apple-kext-mkernel.c
index 9c60c24..db3fbb3 100644
--- a/clang/test/Driver/apple-kext-mkernel.c
+++ b/clang/test/Driver/apple-kext-mkernel.c
@@ -26,3 +26,7 @@
 // RUN: %clang -target x86_64-apple-darwin10 \
 // RUN:   -Werror -fno-builtin -fno-exceptions -fno-common -fno-rtti \
 // RUN:   -mkernel -fsyntax-only %s
+
+// RUN: %clang -c %s -target armv7k-apple-watchos -fapple-kext -mwatchos-version-min=1.0.0 -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-WATCH
+// CHECK-WATCH-NOT: "-backend-option" "-arm-long-calls"
diff --git a/clang/test/Driver/arch-armv7k.c b/clang/test/Driver/arch-armv7k.c
new file mode 100644
index 0000000..7f5923e
--- /dev/null
+++ b/clang/test/Driver/arch-armv7k.c
@@ -0,0 +1,4 @@
+// Tests that make sure armv7k is mapped to the correct CPU
+
+// RUN: %clang -target x86_64-apple-macosx10.9 -arch armv7k -c %s -### 2>&1 | FileCheck %s
+// CHECK: "-cc1"{{.*}} "-target-cpu" "cortex-a7"
diff --git a/clang/test/Driver/darwin-ld.c b/clang/test/Driver/darwin-ld.c
index a5f9608..ffef3b1 100644
--- a/clang/test/Driver/darwin-ld.c
+++ b/clang/test/Driver/darwin-ld.c
@@ -152,6 +152,70 @@
 // RUN: FileCheck -check-prefix=LINK_NO_IOS_ARM64_CRT1 %s < %t.log
 // LINK_NO_IOS_ARM64_CRT1-NOT: crt
 
+// RUN: %clang -target arm64-apple-tvos8.3 -mtvos-version-min=8.3 -### %t.o 2> %t.log
+// RUN: FileCheck -check-prefix=LINK_TVOS_ARM64 %s < %t.log
+// LINK_TVOS_ARM64: {{ld(.exe)?"}}
+// LINK_TVOS_ARM64: -tvos_version_min
+// LINK_TVOS_ARM64-NOT: crt
+// LINK_TVOS_ARM64-NOT: lgcc_s.1
+// FIXME: This library does not get built unless the tvOS SDK is
+// installed, and the driver will not try to link it if it does not exist.
+// This should be reenabled when the tvOS SDK becomes a standard part
+// of Xcode.
+// FIXME_LINK_TVOS_ARM64: libclang_rt.tvos.a
+
+// RUN: %clang -target arm64-apple-tvos8.3 -mtvos-version-min=8.3 -fprofile-instr-generate -### %t.o 2> %t.log
+// RUN: FileCheck -check-prefix=LINK_TVOS_PROFILE %s < %t.log
+// LINK_TVOS_PROFILE: {{ld(.exe)?"}}
+// FIXME: These libraries do not get built unless the tvOS SDK is
+// installed, and the driver will not try to link them if they do not exist.
+// This should be reenabled when the tvOS SDK becomes a standard part
+// of Xcode.
+// FIXME_LINK_TVOS_PROFILE: libclang_rt.profile_tvos.a
+// FIXME_LINK_TVOS_PROFILE: libclang_rt.tvos.a
+
+// RUN: %clang -target arm64-apple-tvos8.3 -mtvos-version-min=8.3 -### %t.o -lcc_kext 2> %t.log
+// RUN: FileCheck -check-prefix=LINK_TVOS_KEXT %s < %t.log
+// LINK_TVOS_KEXT: {{ld(.exe)?"}}
+// FIXME: These libraries do not get built unless the tvOS SDK is
+// installed, and the driver will not try to link them if they do not exist.
+// This should be reenabled when the tvOS SDK becomes a standard part
+// of Xcode.
+// FIXME_LINK_TVOS_KEXT: libclang_rt.cc_kext_tvos.a
+// FIXME_LINK_TVOS_KEXT: libclang_rt.tvos.a
+
+// RUN: %clang -target armv7k-apple-watchos2.0 -mwatchos-version-min=2.0 -### %t.o 2> %t.log
+// RUN: FileCheck -check-prefix=LINK_WATCHOS_ARM %s < %t.log
+// LINK_WATCHOS_ARM: {{ld(.exe)?"}}
+// LINK_WATCHOS_ARM: -watchos_version_min
+// LINK_WATCHOS_ARM-NOT: crt
+// LINK_WATCHOS_ARM-NOT: lgcc_s.1
+// FIXME: This library does not get built unless the watchOS SDK is
+// installed, and the driver will not try to link it if it does not exist.
+// This should be reenabled when the watchOS SDK becomes a standard part
+// of Xcode.
+// FIXME_LINK_WATCHOS_ARM: libclang_rt.watchos.a
+
+// RUN: %clang -target armv7k-apple-watchos2.0 -mwatchos-version-min=2.0 -fprofile-instr-generate -### %t.o 2> %t.log
+// RUN: FileCheck -check-prefix=LINK_WATCHOS_PROFILE %s < %t.log
+// LINK_WATCHOS_PROFILE: {{ld(.exe)?"}}
+// FIXME: These libraries do not get built unless the watchOS SDK is
+// installed, and the driver will not try to link them if they do not exist.
+// This should be reenabled when the watchOS SDK becomes a standard part
+// of Xcode.
+// FIXME_LINK_WATCHOS_PROFILE: libclang_rt.profile_watchos.a
+// FIXME_LINK_WATCHOS_PROFILE: libclang_rt.watchos.a
+
+// RUN: %clang -target armv7k-apple-watchos2.0 -mwatchos-version-min=2.0 -### %t.o -lcc_kext 2> %t.log
+// RUN: FileCheck -check-prefix=LINK_WATCHOS_KEXT %s < %t.log
+// LINK_WATCHOS_KEXT: {{ld(.exe)?"}}
+// FIXME: These libraries do not get built unless the watchOS SDK is
+// installed, and the driver will not try to link them if they do not exist.
+// This should be reenabled when the watchOS SDK becomes a standard part
+// of Xcode.
+// FIXME_LINK_WATCHOS_KEXT: libclang_rt.cc_kext_watchos.a
+// FIXME_LINK_WATCHOS_KEXT: libclang_rt.watchos.a
+
 // RUN: %clang -target i386-apple-darwin12 -pg -### %t.o 2> %t.log
 // RUN: FileCheck -check-prefix=LINK_PG %s < %t.log
 // LINK_PG: -lgcrt1.o
@@ -205,6 +269,26 @@
 // LINK_IPHONEOS_VERSION_MIN: -iphoneos_version_min
 // LINK_IOS_SIMULATOR_VERSION_MIN: -ios_simulator_version_min
 
+// Ditto for tvOS....
+// RUN: env TVOS_DEPLOYMENT_TARGET=7.0 \
+// RUN:   %clang -target armv7-apple-darwin -### %t.o 2> %t.log
+// RUN: FileCheck -check-prefix=LINK_TVOS_VERSION_MIN %s < %t.log
+// RUN: env TVOS_DEPLOYMENT_TARGET=7.0 \
+// RUN:   %clang -target x86_64-apple-darwin -### %t.o 2> %t.log
+// RUN: FileCheck -check-prefix=LINK_TVOS_SIMULATOR_VERSION_MIN %s < %t.log
+// LINK_TVOS_VERSION_MIN: -tvos_version_min
+// LINK_TVOS_SIMULATOR_VERSION_MIN: -tvos_simulator_version_min
+
+// ...and for watchOS.
+// RUN: env WATCHOS_DEPLOYMENT_TARGET=2.0 \
+// RUN:   %clang -target armv7k-apple-darwin -### %t.o 2> %t.log
+// RUN: FileCheck -check-prefix=LINK_WATCHOS_VERSION_MIN %s < %t.log
+// RUN: env WATCHOS_DEPLOYMENT_TARGET=2.0 \
+// RUN:   %clang -target i386-apple-darwin -### %t.o 2> %t.log
+// RUN: FileCheck -check-prefix=LINK_WATCHOS_SIMULATOR_VERSION_MIN %s < %t.log
+// LINK_WATCHOS_VERSION_MIN: -watchos_version_min
+// LINK_WATCHOS_SIMULATOR_VERSION_MIN: -watchos_simulator_version_min
+
 // Check -iframework gets forward to ld as -F
 // RUN: %clang -target x86_64-apple-darwin %s -iframework Bar -framework Foo -### 2>&1 | \
 // RUN:   FileCheck --check-prefix=LINK-IFRAMEWORK %s
diff --git a/clang/test/Driver/darwin-version.c b/clang/test/Driver/darwin-version.c
index 3e7496b..96b4a6c 100644
--- a/clang/test/Driver/darwin-version.c
+++ b/clang/test/Driver/darwin-version.c
@@ -33,12 +33,24 @@
 // RUN: %clang -target x86_64-apple-macosx -mmacosx-version-min= -c %s -### 2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-MISSING %s
 // CHECK-VERSION-MISSING: invalid version number
+// RUN: %clang -target armv7k-apple-darwin -mwatchos-version-min=2.0 -c %s -### 2>&1 | \
+// RUN:   FileCheck --check-prefix=CHECK-VERSION-WATCHOS20 %s
+// RUN: %clang -target armv7-apple-darwin -mtvos-version-min=8.3 -c %s -### 2>&1 | \
+// RUN:   FileCheck --check-prefix=CHECK-VERSION-TVOS83 %s
+// CHECK-VERSION-TVOS83: "thumbv7-apple-tvos8.3.0"
+// RUN: %clang -target i386-apple-darwin -mtvos-simulator-version-min=8.3 -c %s -### 2>&1 | \
+// RUN:   FileCheck --check-prefix=CHECK-VERSION-TVSIM83 %s
+// CHECK-VERSION-TVSIM83: "i386-apple-tvos8.3.0"
+// CHECK-VERSION-WATCHOS20: "thumbv7k-apple-watchos2.0.0"
+// RUN: %clang -target i386-apple-darwin -mwatchos-simulator-version-min=2.0 -c %s -### 2>&1 | \
+// RUN:   FileCheck --check-prefix=CHECK-VERSION-WATCHSIM20 %s
+// CHECK-VERSION-WATCHSIM20: "i386-apple-watchos2.0.0"
 
 // Check environment variable gets interpreted correctly
-// RUN: env MACOSX_DEPLOYMENT_TARGET=10.5 \
+// RUN: env MACOSX_DEPLOYMENT_TARGET=10.5 IPHONEOS_DEPLOYMENT_TARGET=2.0 \
 // RUN:   %clang -target i386-apple-darwin9 -c %s -### 2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-OSX5 %s
-// RUN: env IPHONEOS_DEPLOYMENT_TARGET=2.0 \
+// RUN: env MACOSX_DEPLOYMENT_TARGET=10.5 IPHONEOS_DEPLOYMENT_TARGET=2.0 \
 // RUN:   %clang -target armv6-apple-darwin9 -c %s -### 2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-IOS2 %s
 
@@ -50,3 +62,21 @@
 // RUN:   %clang -target armv6-apple-darwin9 -c %s -### 2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-IOS231 %s
 // CHECK-VERSION-IOS231: "armv6k-apple-ios2.3.1"
+
+// RUN: env MACOSX_DEPLOYMENT_TARGET=10.5 TVOS_DEPLOYMENT_TARGET=8.3.1 \
+// RUN:   %clang -target armv7-apple-darwin9 -c %s -### 2>&1 | \
+// RUN:   FileCheck --check-prefix=CHECK-VERSION-TVOS %s
+// CHECK-VERSION-TVOS: "thumbv7-apple-tvos8.3.1"
+// RUN: env TVOS_DEPLOYMENT_TARGET=8.3.1 \
+// RUN:   %clang -target i386-apple-darwin9 -c %s -### 2>&1 | \
+// RUN:   FileCheck --check-prefix=CHECK-VERSION-TVOSSIM %s
+// CHECK-VERSION-TVOSSIM: "i386-apple-tvos8.3.1"
+
+// RUN: env MACOSX_DEPLOYMENT_TARGET=10.5 WATCHOS_DEPLOYMENT_TARGET=2.0 \
+// RUN:   %clang -target armv7-apple-darwin9 -c %s -### 2>&1 | \
+// RUN:   FileCheck --check-prefix=CHECK-VERSION-WATCHOS %s
+// CHECK-VERSION-WATCHOS: "thumbv7-apple-watchos2.0.0"
+// RUN: env WATCHOS_DEPLOYMENT_TARGET=2.0 \
+// RUN:   %clang -target i386-apple-darwin9 -c %s -### 2>&1 | \
+// RUN:   FileCheck --check-prefix=CHECK-VERSION-WATCHOSSIM %s
+// CHECK-VERSION-WATCHOSSIM: "i386-apple-watchos2.0.0"
diff --git a/clang/test/Driver/pic.c b/clang/test/Driver/pic.c
index 53b001e..ca4b892 100644
--- a/clang/test/Driver/pic.c
+++ b/clang/test/Driver/pic.c
@@ -212,6 +212,8 @@
 // RUN:   | FileCheck %s --check-prefix=CHECK-PIC2
 // RUN: %clang -x assembler -c %s -target arm64-apple-ios -mkernel -miphoneos-version-min=7.0.0 -no-integrated-as -### 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-NO-STATIC
+// RUN: %clang -c %s -target armv7k-apple-watchos -fapple-kext -mwatchos-version-min=1.0.0 -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIC2
 // RUN: %clang -c %s -target armv7-apple-ios -fapple-kext -miphoneos-version-min=5.0.0 -### 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-NO-PIC
 // RUN: %clang -c %s -target armv7-apple-ios -fapple-kext -miphoneos-version-min=6.0.0 -static -### 2>&1 \
diff --git a/clang/test/Modules/modules.idx b/clang/test/Modules/modules.idx
new file mode 100644
index 0000000..58010c0
--- /dev/null
+++ b/clang/test/Modules/modules.idx
Binary files differ
diff --git a/clang/test/Preprocessor/arm-target-features.c b/clang/test/Preprocessor/arm-target-features.c
index 1f2f103..640cf9e 100644
--- a/clang/test/Preprocessor/arm-target-features.c
+++ b/clang/test/Preprocessor/arm-target-features.c
@@ -210,10 +210,9 @@
 // A5:#define __ARM_FP 0xE
 
 // Test whether predefines are as expected when targeting cortex-a7.
-// RUN: %clang -target armv7 -mcpu=cortex-a7 -x c -E -dM %s -o - | FileCheck --check-prefix=A7 %s
-// RUN: %clang -target armv7 -mthumb -mcpu=cortex-a7 -x c -E -dM %s -o - | FileCheck --check-prefix=A7 %s
+// RUN: %clang -target armv7k -mcpu=cortex-a7 -x c -E -dM %s -o - | FileCheck --check-prefix=A7 %s
+// RUN: %clang -target armv7k -mthumb -mcpu=cortex-a7 -x c -E -dM %s -o - | FileCheck --check-prefix=A7 %s
 // A7:#define __ARM_ARCH 7
-// A7:#define __ARM_ARCH_7A__ 1
 // A7:#define __ARM_ARCH_EXT_IDIV__ 1
 // A7:#define __ARM_ARCH_PROFILE 'A'
 // A7:#define __ARM_FEATURE_DSP
diff --git a/clang/test/SemaObjC/opaque-is-access-warn.m b/clang/test/SemaObjC/opaque-is-access-warn.m
index ac0f724..4f86866 100644
--- a/clang/test/SemaObjC/opaque-is-access-warn.m
+++ b/clang/test/SemaObjC/opaque-is-access-warn.m
@@ -1,7 +1,9 @@
 // RUN: %clang -target x86_64-apple-darwin -arch arm64 -mios-version-min=7 -fsyntax-only -Wdeprecated-objc-isa-usage %s -Xclang -verify
 // RUN: %clang -target x86_64-apple-darwin -arch arm64 -mios-version-min=7 -fsyntax-only %s -Xclang -verify
 // RUN: %clang -target x86_64-apple-darwin -mios-simulator-version-min=7 -fsyntax-only -Wdeprecated-objc-isa-usage %s -Xclang -verify
+// RUN: %clang -target x86_64-apple-darwin -arch armv7k -mwatchos-version-min=2 -fsyntax-only -Wdeprecated-objc-isa-usage %s -Xclang -verify
 // rdar://10709102
+// RUN: %clang -target x86_64-apple-darwin -arch x86_64 -fsyntax-only -Wdeprecated-objc-isa-usage %s -Xclang -verify
 
 typedef struct objc_object {
   struct objc_class *isa;