aboutsummaryrefslogtreecommitdiff
path: root/test/Driver
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2013-04-08 18:45:10 +0000
committerDimitry Andric <dim@FreeBSD.org>2013-04-08 18:45:10 +0000
commit809500fc2c13c8173a16b052304d983864e4a1e1 (patch)
tree4fc2f184c499d106f29a386c452b49e5197bf63d /test/Driver
parentbe7c9ec198dcdb5bf73a35bfbb00b3333cb87909 (diff)
downloadsrc-809500fc2c13c8173a16b052304d983864e4a1e1.tar.gz
src-809500fc2c13c8173a16b052304d983864e4a1e1.zip
Vendor import of clang trunk r178860:vendor/clang/clang-trunk-r178860
Notes
Notes: svn path=/vendor/clang/dist/; revision=249261 svn path=/vendor/clang/clang-trunk-r178860/; revision=249262; tag=vendor/clang/clang-trunk-r178860
Diffstat (limited to 'test/Driver')
-rw-r--r--test/Driver/Inputs/basic_linux_tree/usr/lib/gcc/x86_64-unknown-linux/4.6.0/crtbeginT.o0
-rwxr-xr-xtest/Driver/Inputs/hexagon_tree/gnu/bin/hexagon-as1
-rwxr-xr-xtest/Driver/Inputs/hexagon_tree/gnu/bin/hexagon-gcc1
-rwxr-xr-xtest/Driver/Inputs/hexagon_tree/gnu/bin/hexagon-ld1
-rw-r--r--test/Driver/Inputs/hexagon_tree/gnu/hexagon/include/c++/4.4.0/ios1
-rw-r--r--test/Driver/Inputs/hexagon_tree/gnu/hexagon/include/stdio.h1
-rw-r--r--test/Driver/Inputs/hexagon_tree/gnu/lib/gcc/hexagon/4.4.0/include-fixed/limits.h1
-rw-r--r--test/Driver/Inputs/hexagon_tree/gnu/lib/gcc/hexagon/4.4.0/include/stddef.h1
-rw-r--r--test/Driver/Inputs/hexagon_tree/qc/bin/placeholder1
-rw-r--r--test/Driver/Inputs/lit.local.cfg1
-rw-r--r--test/Driver/Inputs/resource_dir/lib/linux/libclang_rt.asan-i386.a.syms0
-rw-r--r--test/Driver/Inputs/resource_dir/lib/linux/libclang_rt.asan-x86_64.a.syms0
-rw-r--r--test/Driver/Inputs/resource_dir/lib/linux/libclang_rt.msan-x86_64.a.syms0
-rw-r--r--test/Driver/Inputs/resource_dir/lib/linux/libclang_rt.tsan-x86_64.a.syms0
-rw-r--r--test/Driver/Inputs/resource_dir/lib/linux/libclang_rt.ubsan-i386.a.syms0
-rw-r--r--test/Driver/Inputs/resource_dir/lib/linux/libclang_rt.ubsan-x86_64.a.syms0
-rw-r--r--test/Driver/Inputs/resource_dir/lib/linux/libclang_rt.ubsan_cxx-i386.a.syms0
-rw-r--r--test/Driver/Inputs/resource_dir/lib/linux/libclang_rt.ubsan_cxx-x86_64.a.syms0
-rw-r--r--test/Driver/Inputs/ubuntu_13.04_multiarch_tree/lib/x86_64-linux-gnu/.keep0
-rw-r--r--test/Driver/Inputs/ubuntu_13.04_multiarch_tree/usr/include/c++/4.7/backward/.keep0
-rw-r--r--test/Driver/Inputs/ubuntu_13.04_multiarch_tree/usr/include/x86_64-linux-gnu/c++/4.7/.keep0
-rw-r--r--test/Driver/Inputs/ubuntu_13.04_multiarch_tree/usr/include/x86_64-linux-gnu/c++/4.7/32/.keep0
-rw-r--r--test/Driver/Inputs/ubuntu_13.04_multiarch_tree/usr/lib/gcc/x86_64-linux-gnu/4.7/32/.keep0
-rw-r--r--test/Driver/Inputs/ubuntu_13.04_multiarch_tree/usr/lib/gcc/x86_64-linux-gnu/4.7/32/crtbegin.o0
-rw-r--r--test/Driver/Inputs/ubuntu_13.04_multiarch_tree/usr/lib/gcc/x86_64-linux-gnu/4.7/crtbegin.o0
-rw-r--r--test/Driver/aarch64-features.c5
-rw-r--r--test/Driver/altivec.cpp15
-rw-r--r--test/Driver/apple-kext-mkernel.c3
-rw-r--r--test/Driver/arm-cortex-cpus.c8
-rw-r--r--test/Driver/asan-ld.c50
-rw-r--r--test/Driver/bounds-checking.c16
-rw-r--r--test/Driver/claim-unused.c3
-rw-r--r--test/Driver/clang-g-opts.c14
-rw-r--r--test/Driver/clang-translation.c102
-rw-r--r--test/Driver/clang_f_opts.c32
-rw-r--r--test/Driver/constructors.c50
-rw-r--r--test/Driver/crash-report.c2
-rw-r--r--test/Driver/darwin-debug-flags.c4
-rw-r--r--test/Driver/darwin-iphone-defaults.m3
-rw-r--r--test/Driver/darwin-sanitizer-ld.c52
-rw-r--r--test/Driver/darwin-sdkroot.c15
-rw-r--r--test/Driver/debug-comp-dir.S11
-rw-r--r--test/Driver/debug-main-file.S12
-rw-r--r--test/Driver/debug-options-as.c17
-rw-r--r--test/Driver/fast-math.c2
-rw-r--r--test/Driver/fcomment-block-commands.c8
-rw-r--r--test/Driver/flags.c11
-rw-r--r--test/Driver/frame-pointer-elim.c30
-rw-r--r--test/Driver/freebsd-mips-as.c18
-rw-r--r--test/Driver/freebsd.c11
-rw-r--r--test/Driver/fsanitize-blacklist.c18
-rw-r--r--test/Driver/fsanitize.c115
-rw-r--r--test/Driver/gold-lto.c25
-rw-r--r--test/Driver/hexagon-toolchain-elf.c564
-rw-r--r--test/Driver/hexagon-toolchain.c564
-rw-r--r--test/Driver/inhibit-downstream-commands.c6
-rw-r--r--test/Driver/integrated-as.c7
-rw-r--r--test/Driver/integrated-as.s6
-rw-r--r--test/Driver/linker-opts.c3
-rw-r--r--test/Driver/linux-header-search.cpp28
-rw-r--r--test/Driver/linux-ld.c57
-rw-r--r--test/Driver/lit.local.cfg1
-rw-r--r--test/Driver/mips-as.c18
-rw-r--r--test/Driver/mips-eleb.c31
-rw-r--r--test/Driver/mips-features.c12
-rw-r--r--test/Driver/mips-float.c41
-rw-r--r--test/Driver/mips-long-double.c19
-rw-r--r--test/Driver/modules.m6
-rw-r--r--test/Driver/modules_integrated_as.c6
-rw-r--r--test/Driver/ms-inline-asm.c15
-rw-r--r--test/Driver/no-integrated-as-win.c3
-rw-r--r--test/Driver/nodefaultlib.c4
-rw-r--r--test/Driver/objc++-cpp-output.mm6
-rw-r--r--test/Driver/objc_default_synth.m6
-rw-r--r--test/Driver/openbsd.c20
-rw-r--r--test/Driver/output-file-cleanup.c43
-rw-r--r--test/Driver/output-file-is-dir.c7
-rw-r--r--test/Driver/pic.c6
-rw-r--r--test/Driver/ppc-features.cpp88
-rw-r--r--test/Driver/qa_override.c10
-rw-r--r--test/Driver/r600-mcpu.cl50
-rw-r--r--test/Driver/sanitizer-ld.c151
-rw-r--r--test/Driver/split-debug.c25
-rw-r--r--test/Driver/target-as.s8
-rw-r--r--test/Driver/ubsan-ld.c10
-rw-r--r--test/Driver/unknown-arg.c4
-rw-r--r--test/Driver/unknown-gcc-arch.c40
-rw-r--r--test/Driver/visibility.cpp34
-rw-r--r--test/Driver/warning-options.cpp10
-rw-r--r--test/Driver/warning-options_pedantic.cpp2
-rw-r--r--test/Driver/x86_64-nacl-defines.cpp2
91 files changed, 2415 insertions, 159 deletions
diff --git a/test/Driver/Inputs/basic_linux_tree/usr/lib/gcc/x86_64-unknown-linux/4.6.0/crtbeginT.o b/test/Driver/Inputs/basic_linux_tree/usr/lib/gcc/x86_64-unknown-linux/4.6.0/crtbeginT.o
new file mode 100644
index 000000000000..e69de29bb2d1
--- /dev/null
+++ b/test/Driver/Inputs/basic_linux_tree/usr/lib/gcc/x86_64-unknown-linux/4.6.0/crtbeginT.o
diff --git a/test/Driver/Inputs/hexagon_tree/gnu/bin/hexagon-as b/test/Driver/Inputs/hexagon_tree/gnu/bin/hexagon-as
new file mode 100755
index 000000000000..331ef4a6bc06
--- /dev/null
+++ b/test/Driver/Inputs/hexagon_tree/gnu/bin/hexagon-as
@@ -0,0 +1 @@
+# placeholder for testing purposes \ No newline at end of file
diff --git a/test/Driver/Inputs/hexagon_tree/gnu/bin/hexagon-gcc b/test/Driver/Inputs/hexagon_tree/gnu/bin/hexagon-gcc
new file mode 100755
index 000000000000..331ef4a6bc06
--- /dev/null
+++ b/test/Driver/Inputs/hexagon_tree/gnu/bin/hexagon-gcc
@@ -0,0 +1 @@
+# placeholder for testing purposes \ No newline at end of file
diff --git a/test/Driver/Inputs/hexagon_tree/gnu/bin/hexagon-ld b/test/Driver/Inputs/hexagon_tree/gnu/bin/hexagon-ld
new file mode 100755
index 000000000000..331ef4a6bc06
--- /dev/null
+++ b/test/Driver/Inputs/hexagon_tree/gnu/bin/hexagon-ld
@@ -0,0 +1 @@
+# placeholder for testing purposes \ No newline at end of file
diff --git a/test/Driver/Inputs/hexagon_tree/gnu/hexagon/include/c++/4.4.0/ios b/test/Driver/Inputs/hexagon_tree/gnu/hexagon/include/c++/4.4.0/ios
new file mode 100644
index 000000000000..777a4ec06213
--- /dev/null
+++ b/test/Driver/Inputs/hexagon_tree/gnu/hexagon/include/c++/4.4.0/ios
@@ -0,0 +1 @@
+// placeholder for testing purposes
diff --git a/test/Driver/Inputs/hexagon_tree/gnu/hexagon/include/stdio.h b/test/Driver/Inputs/hexagon_tree/gnu/hexagon/include/stdio.h
new file mode 100644
index 000000000000..777a4ec06213
--- /dev/null
+++ b/test/Driver/Inputs/hexagon_tree/gnu/hexagon/include/stdio.h
@@ -0,0 +1 @@
+// placeholder for testing purposes
diff --git a/test/Driver/Inputs/hexagon_tree/gnu/lib/gcc/hexagon/4.4.0/include-fixed/limits.h b/test/Driver/Inputs/hexagon_tree/gnu/lib/gcc/hexagon/4.4.0/include-fixed/limits.h
new file mode 100644
index 000000000000..777a4ec06213
--- /dev/null
+++ b/test/Driver/Inputs/hexagon_tree/gnu/lib/gcc/hexagon/4.4.0/include-fixed/limits.h
@@ -0,0 +1 @@
+// placeholder for testing purposes
diff --git a/test/Driver/Inputs/hexagon_tree/gnu/lib/gcc/hexagon/4.4.0/include/stddef.h b/test/Driver/Inputs/hexagon_tree/gnu/lib/gcc/hexagon/4.4.0/include/stddef.h
new file mode 100644
index 000000000000..777a4ec06213
--- /dev/null
+++ b/test/Driver/Inputs/hexagon_tree/gnu/lib/gcc/hexagon/4.4.0/include/stddef.h
@@ -0,0 +1 @@
+// placeholder for testing purposes
diff --git a/test/Driver/Inputs/hexagon_tree/qc/bin/placeholder b/test/Driver/Inputs/hexagon_tree/qc/bin/placeholder
new file mode 100644
index 000000000000..777a4ec06213
--- /dev/null
+++ b/test/Driver/Inputs/hexagon_tree/qc/bin/placeholder
@@ -0,0 +1 @@
+// placeholder for testing purposes
diff --git a/test/Driver/Inputs/lit.local.cfg b/test/Driver/Inputs/lit.local.cfg
new file mode 100644
index 000000000000..e6f55eef7af5
--- /dev/null
+++ b/test/Driver/Inputs/lit.local.cfg
@@ -0,0 +1 @@
+config.suffixes = []
diff --git a/test/Driver/Inputs/resource_dir/lib/linux/libclang_rt.asan-i386.a.syms b/test/Driver/Inputs/resource_dir/lib/linux/libclang_rt.asan-i386.a.syms
new file mode 100644
index 000000000000..e69de29bb2d1
--- /dev/null
+++ b/test/Driver/Inputs/resource_dir/lib/linux/libclang_rt.asan-i386.a.syms
diff --git a/test/Driver/Inputs/resource_dir/lib/linux/libclang_rt.asan-x86_64.a.syms b/test/Driver/Inputs/resource_dir/lib/linux/libclang_rt.asan-x86_64.a.syms
new file mode 100644
index 000000000000..e69de29bb2d1
--- /dev/null
+++ b/test/Driver/Inputs/resource_dir/lib/linux/libclang_rt.asan-x86_64.a.syms
diff --git a/test/Driver/Inputs/resource_dir/lib/linux/libclang_rt.msan-x86_64.a.syms b/test/Driver/Inputs/resource_dir/lib/linux/libclang_rt.msan-x86_64.a.syms
new file mode 100644
index 000000000000..e69de29bb2d1
--- /dev/null
+++ b/test/Driver/Inputs/resource_dir/lib/linux/libclang_rt.msan-x86_64.a.syms
diff --git a/test/Driver/Inputs/resource_dir/lib/linux/libclang_rt.tsan-x86_64.a.syms b/test/Driver/Inputs/resource_dir/lib/linux/libclang_rt.tsan-x86_64.a.syms
new file mode 100644
index 000000000000..e69de29bb2d1
--- /dev/null
+++ b/test/Driver/Inputs/resource_dir/lib/linux/libclang_rt.tsan-x86_64.a.syms
diff --git a/test/Driver/Inputs/resource_dir/lib/linux/libclang_rt.ubsan-i386.a.syms b/test/Driver/Inputs/resource_dir/lib/linux/libclang_rt.ubsan-i386.a.syms
new file mode 100644
index 000000000000..e69de29bb2d1
--- /dev/null
+++ b/test/Driver/Inputs/resource_dir/lib/linux/libclang_rt.ubsan-i386.a.syms
diff --git a/test/Driver/Inputs/resource_dir/lib/linux/libclang_rt.ubsan-x86_64.a.syms b/test/Driver/Inputs/resource_dir/lib/linux/libclang_rt.ubsan-x86_64.a.syms
new file mode 100644
index 000000000000..e69de29bb2d1
--- /dev/null
+++ b/test/Driver/Inputs/resource_dir/lib/linux/libclang_rt.ubsan-x86_64.a.syms
diff --git a/test/Driver/Inputs/resource_dir/lib/linux/libclang_rt.ubsan_cxx-i386.a.syms b/test/Driver/Inputs/resource_dir/lib/linux/libclang_rt.ubsan_cxx-i386.a.syms
new file mode 100644
index 000000000000..e69de29bb2d1
--- /dev/null
+++ b/test/Driver/Inputs/resource_dir/lib/linux/libclang_rt.ubsan_cxx-i386.a.syms
diff --git a/test/Driver/Inputs/resource_dir/lib/linux/libclang_rt.ubsan_cxx-x86_64.a.syms b/test/Driver/Inputs/resource_dir/lib/linux/libclang_rt.ubsan_cxx-x86_64.a.syms
new file mode 100644
index 000000000000..e69de29bb2d1
--- /dev/null
+++ b/test/Driver/Inputs/resource_dir/lib/linux/libclang_rt.ubsan_cxx-x86_64.a.syms
diff --git a/test/Driver/Inputs/ubuntu_13.04_multiarch_tree/lib/x86_64-linux-gnu/.keep b/test/Driver/Inputs/ubuntu_13.04_multiarch_tree/lib/x86_64-linux-gnu/.keep
new file mode 100644
index 000000000000..e69de29bb2d1
--- /dev/null
+++ b/test/Driver/Inputs/ubuntu_13.04_multiarch_tree/lib/x86_64-linux-gnu/.keep
diff --git a/test/Driver/Inputs/ubuntu_13.04_multiarch_tree/usr/include/c++/4.7/backward/.keep b/test/Driver/Inputs/ubuntu_13.04_multiarch_tree/usr/include/c++/4.7/backward/.keep
new file mode 100644
index 000000000000..e69de29bb2d1
--- /dev/null
+++ b/test/Driver/Inputs/ubuntu_13.04_multiarch_tree/usr/include/c++/4.7/backward/.keep
diff --git a/test/Driver/Inputs/ubuntu_13.04_multiarch_tree/usr/include/x86_64-linux-gnu/c++/4.7/.keep b/test/Driver/Inputs/ubuntu_13.04_multiarch_tree/usr/include/x86_64-linux-gnu/c++/4.7/.keep
new file mode 100644
index 000000000000..e69de29bb2d1
--- /dev/null
+++ b/test/Driver/Inputs/ubuntu_13.04_multiarch_tree/usr/include/x86_64-linux-gnu/c++/4.7/.keep
diff --git a/test/Driver/Inputs/ubuntu_13.04_multiarch_tree/usr/include/x86_64-linux-gnu/c++/4.7/32/.keep b/test/Driver/Inputs/ubuntu_13.04_multiarch_tree/usr/include/x86_64-linux-gnu/c++/4.7/32/.keep
new file mode 100644
index 000000000000..e69de29bb2d1
--- /dev/null
+++ b/test/Driver/Inputs/ubuntu_13.04_multiarch_tree/usr/include/x86_64-linux-gnu/c++/4.7/32/.keep
diff --git a/test/Driver/Inputs/ubuntu_13.04_multiarch_tree/usr/lib/gcc/x86_64-linux-gnu/4.7/32/.keep b/test/Driver/Inputs/ubuntu_13.04_multiarch_tree/usr/lib/gcc/x86_64-linux-gnu/4.7/32/.keep
new file mode 100644
index 000000000000..e69de29bb2d1
--- /dev/null
+++ b/test/Driver/Inputs/ubuntu_13.04_multiarch_tree/usr/lib/gcc/x86_64-linux-gnu/4.7/32/.keep
diff --git a/test/Driver/Inputs/ubuntu_13.04_multiarch_tree/usr/lib/gcc/x86_64-linux-gnu/4.7/32/crtbegin.o b/test/Driver/Inputs/ubuntu_13.04_multiarch_tree/usr/lib/gcc/x86_64-linux-gnu/4.7/32/crtbegin.o
new file mode 100644
index 000000000000..e69de29bb2d1
--- /dev/null
+++ b/test/Driver/Inputs/ubuntu_13.04_multiarch_tree/usr/lib/gcc/x86_64-linux-gnu/4.7/32/crtbegin.o
diff --git a/test/Driver/Inputs/ubuntu_13.04_multiarch_tree/usr/lib/gcc/x86_64-linux-gnu/4.7/crtbegin.o b/test/Driver/Inputs/ubuntu_13.04_multiarch_tree/usr/lib/gcc/x86_64-linux-gnu/4.7/crtbegin.o
new file mode 100644
index 000000000000..e69de29bb2d1
--- /dev/null
+++ b/test/Driver/Inputs/ubuntu_13.04_multiarch_tree/usr/lib/gcc/x86_64-linux-gnu/4.7/crtbegin.o
diff --git a/test/Driver/aarch64-features.c b/test/Driver/aarch64-features.c
new file mode 100644
index 000000000000..2acb7157f6c5
--- /dev/null
+++ b/test/Driver/aarch64-features.c
@@ -0,0 +1,5 @@
+// RUN: %clang -target aarch64-none-linux-gnu -### %s -fsyntax-only 2>&1 | FileCheck %s
+
+// The AArch64 PCS states that chars should be unsigned.
+// CHECK: fno-signed-char
+
diff --git a/test/Driver/altivec.cpp b/test/Driver/altivec.cpp
deleted file mode 100644
index 4e6fbe597272..000000000000
--- a/test/Driver/altivec.cpp
+++ /dev/null
@@ -1,15 +0,0 @@
-// Check that we error when -faltivec is specified on non-ppc platforms.
-
-// RUN: %clang -target powerpc-unk-unk -faltivec -fsyntax-only %s
-// RUN: %clang -target powerpc64-linux-gnu -faltivec -fsyntax-only %s
-// RUN: %clang -target powerpc64-linux-gnu -maltivec -fsyntax-only %s
-
-// RUN: %clang -target i386-pc-win32 -faltivec -fsyntax-only %s 2>&1 | FileCheck %s
-// RUN: %clang -target x86_64-unknown-freebsd -faltivec -fsyntax-only %s 2>&1 | FileCheck %s
-// RUN: %clang -target armv6-apple-darwin -faltivec -fsyntax-only %s 2>&1 | FileCheck %s
-// RUN: %clang -target armv7-apple-darwin -faltivec -fsyntax-only %s 2>&1 | FileCheck %s
-// RUN: %clang -target mips-linux-gnu -faltivec -fsyntax-only %s 2>&1 | FileCheck %s
-// RUN: %clang -target mips64-linux-gnu -faltivec -fsyntax-only %s 2>&1 | FileCheck %s
-// RUN: %clang -target sparc-unknown-solaris -faltivec -fsyntax-only %s 2>&1 | FileCheck %s
-
-// CHECK: invalid argument '-faltivec' only allowed with 'ppc/ppc64'
diff --git a/test/Driver/apple-kext-mkernel.c b/test/Driver/apple-kext-mkernel.c
index f8b7b90844a5..8282c05dd8f1 100644
--- a/test/Driver/apple-kext-mkernel.c
+++ b/test/Driver/apple-kext-mkernel.c
@@ -8,11 +8,12 @@
// CHECK-X86: "-fno-common"
// RUN: %clang -target x86_64-apple-darwin10 \
-// RUN: -arch armv7 -mkernel -### -fsyntax-only %s 2> %t
+// RUN: -arch armv7 -mkernel -mstrict-align -### -fsyntax-only %s 2> %t
// RUN: FileCheck --check-prefix=CHECK-ARM < %t %s
// CHECK-ARM: "-backend-option" "-arm-long-calls"
// CHECK-ARM: "-backend-option" "-arm-strict-align"
+// CHECK-ARM-NOT: "-backend-option" "-arm-strict-align"
// CHECK-ARM: "-fno-builtin"
// CHECK-ARM: "-fno-rtti"
// CHECK-ARM: "-fno-common"
diff --git a/test/Driver/arm-cortex-cpus.c b/test/Driver/arm-cortex-cpus.c
new file mode 100644
index 000000000000..6fa649aa392a
--- /dev/null
+++ b/test/Driver/arm-cortex-cpus.c
@@ -0,0 +1,8 @@
+// RUN: %clang -target armv6m-apple-darwin -arch armv6m -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V6M %s
+// CHECK-V6M: "-cc1"{{.*}} "-triple" "thumbv6m-{{.*}} "-target-cpu" "cortex-m0"
+
+// RUN: %clang -target armv7m-apple-darwin -arch armv7m -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V7M %s
+// CHECK-V7M: "-cc1"{{.*}} "-triple" "thumbv7m-{{.*}} "-target-cpu" "cortex-m3"
+
+// RUN: %clang -target armv7em-apple-darwin -arch armv7em -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V7EM %s
+// CHECK-V7EM: "-cc1"{{.*}} "-triple" "thumbv7em-{{.*}} "-target-cpu" "cortex-m4"
diff --git a/test/Driver/asan-ld.c b/test/Driver/asan-ld.c
deleted file mode 100644
index 59dbda15c88d..000000000000
--- a/test/Driver/asan-ld.c
+++ /dev/null
@@ -1,50 +0,0 @@
-// Test AddressSanitizer ld flags.
-
-// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: -target i386-unknown-linux -faddress-sanitizer \
-// RUN: --sysroot=%S/Inputs/basic_linux_tree \
-// RUN: | FileCheck --check-prefix=CHECK-LINUX %s
-//
-// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: -target i386-unknown-linux -fsanitize=address \
-// RUN: --sysroot=%S/Inputs/basic_linux_tree \
-// RUN: | FileCheck --check-prefix=CHECK-LINUX %s
-//
-// CHECK-LINUX: "{{.*}}ld{{(.exe)?}}"
-// CHECK-LINUX-NOT: "-lc"
-// CHECK-LINUX: libclang_rt.asan-i386.a"
-// CHECK-LINUX: "-lpthread"
-// CHECK-LINUX: "-ldl"
-// CHECK-LINUX: "-export-dynamic"
-
-// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: -target arm-linux-androideabi -faddress-sanitizer \
-// RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \
-// RUN: | FileCheck --check-prefix=CHECK-ANDROID %s
-//
-// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: -target arm-linux-androideabi -fsanitize=address \
-// RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \
-// RUN: | FileCheck --check-prefix=CHECK-ANDROID %s
-//
-// CHECK-ANDROID: "{{.*}}ld{{(.exe)?}}"
-// CHECK-ANDROID-NOT: "-lc"
-// CHECK-ANDROID: libclang_rt.asan-arm-android.so"
-// CHECK-ANDROID-NOT: "-lpthread"
-
-// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: -target arm-linux-androideabi -faddress-sanitizer \
-// RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \
-// RUN: -shared \
-// RUN: | FileCheck --check-prefix=CHECK-ANDROID-SHARED %s
-//
-// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: -target arm-linux-androideabi -fsanitize=address \
-// RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \
-// RUN: -shared \
-// RUN: | FileCheck --check-prefix=CHECK-ANDROID-SHARED %s
-//
-// CHECK-ANDROID-SHARED: "{{.*}}ld{{(.exe)?}}"
-// CHECK-ANDROID-SHARED-NOT: "-lc"
-// CHECK-ANDROID-SHARED: libclang_rt.asan-arm-android.so"
-// CHECK-ANDROID-SHARED-NOT: "-lpthread"
diff --git a/test/Driver/bounds-checking.c b/test/Driver/bounds-checking.c
index 95bb8afd0d8b..a4f97e820b4c 100644
--- a/test/Driver/bounds-checking.c
+++ b/test/Driver/bounds-checking.c
@@ -1,7 +1,11 @@
-// RUN: %clang -target x86_64-apple-darwin10 -fbounds-checking -### -fsyntax-only %s 2> %t
-// RUN: FileCheck < %t %s
-// RUN: %clang -target x86_64-apple-darwin10 -fbounds-checking=3 -### -fsyntax-only %s 2> %t
-// RUN: FileCheck -check-prefix=CHECK2 < %t %s
+// RUN: %clang -fsanitize=bounds -### -fsyntax-only %s 2> %t
+// RUN: FileCheck -check-prefix=CHECK < %t %s
+// CHECK: "-fsanitize=bounds"
-// CHECK: "-fbounds-checking=1"
-// CHECK2: "-fbounds-checking=3"
+// RUN: %clang -fbounds-checking -### -fsyntax-only %s 2> %t
+// RUN: FileCheck -check-prefix=CHECK-OLD < %t %s
+// CHECK-OLD: "-fsanitize=bounds"
+
+// RUN: %clang -fbounds-checking=3 -### -fsyntax-only %s 2> %t
+// RUN: FileCheck -check-prefix=CHECK-OLD2 < %t %s
+// CHECK-OLD2: "-fsanitize=bounds"
diff --git a/test/Driver/claim-unused.c b/test/Driver/claim-unused.c
new file mode 100644
index 000000000000..c7b798934b3c
--- /dev/null
+++ b/test/Driver/claim-unused.c
@@ -0,0 +1,3 @@
+// RUN: touch %t.o
+// RUN: %clang --param ssp-buffer-size=1 %t.o -### 2>&1 | FileCheck %s
+// CHECK-NOT: warning: argument unused during compilation: '--param ssp-buffer-size=1'
diff --git a/test/Driver/clang-g-opts.c b/test/Driver/clang-g-opts.c
index 4dbdf6167734..f5d09fda3dd8 100644
--- a/test/Driver/clang-g-opts.c
+++ b/test/Driver/clang-g-opts.c
@@ -1,5 +1,9 @@
-// RUN: %clang -S -v -o %t %s 2>&1 | not grep -w -- -g
-// RUN: %clang -S -v -o %t %s -g 2>&1 | grep -w -- -g
-// RUN: %clang -S -v -o %t %s -g0 2>&1 | not grep -w -- -g
-// RUN: %clang -S -v -o %t %s -g -g0 2>&1 | not grep -w -- -g
-// RUN: %clang -S -v -o %t %s -g0 -g 2>&1 | grep -w -- -g
+// RUN: %clang -### -S %s 2>&1 | FileCheck --check-prefix=CHECK-WITHOUT-G %s
+// RUN: %clang -### -S %s -g 2>&1 | FileCheck --check-prefix=CHECK-WITH-G %s
+// RUN: %clang -### -S %s -g0 2>&1 | FileCheck --check-prefix=CHECK-WITHOUT-G %s
+// RUN: %clang -### -S %s -g -g0 2>&1 | FileCheck --check-prefix=CHECK-WITHOUT-G %s
+// RUN: %clang -### -S %s -g0 -g 2>&1 | FileCheck --check-prefix=CHECK-WITH-G %s
+
+// CHECK-WITHOUT-G-NOT: "-g"
+// CHECK-WITH-G: "-g"
+
diff --git a/test/Driver/clang-translation.c b/test/Driver/clang-translation.c
index 3ddb189eb10d..3b2b7e81f916 100644
--- a/test/Driver/clang-translation.c
+++ b/test/Driver/clang-translation.c
@@ -67,6 +67,108 @@
// PPCPWR7: "-target-cpu" "pwr7"
// RUN: %clang -target powerpc64-unknown-linux-gnu \
+// RUN: -### -S %s -mcpu=a2q 2>&1 | FileCheck -check-prefix=PPCA2Q %s
+// PPCA2Q: clang
+// PPCA2Q: "-cc1"
+// PPCA2Q: "-target-cpu" "a2q"
+
+// RUN: %clang -target powerpc64-unknown-linux-gnu \
+// RUN: -### -S %s -mcpu=630 2>&1 | FileCheck -check-prefix=PPC630 %s
+// PPC630: clang
+// PPC630: "-cc1"
+// PPC630: "-target-cpu" "pwr3"
+
+// RUN: %clang -target powerpc64-unknown-linux-gnu \
+// RUN: -### -S %s -mcpu=power3 2>&1 | FileCheck -check-prefix=PPCPOWER3 %s
+// PPCPOWER3: clang
+// PPCPOWER3: "-cc1"
+// PPCPOWER3: "-target-cpu" "pwr3"
+
+// RUN: %clang -target powerpc64-unknown-linux-gnu \
+// RUN: -### -S %s -mcpu=pwr3 2>&1 | FileCheck -check-prefix=PPCPWR3 %s
+// PPCPWR3: clang
+// PPCPWR3: "-cc1"
+// PPCPWR3: "-target-cpu" "pwr3"
+
+// RUN: %clang -target powerpc64-unknown-linux-gnu \
+// RUN: -### -S %s -mcpu=power4 2>&1 | FileCheck -check-prefix=PPCPOWER4 %s
+// PPCPOWER4: clang
+// PPCPOWER4: "-cc1"
+// PPCPOWER4: "-target-cpu" "pwr4"
+
+// RUN: %clang -target powerpc64-unknown-linux-gnu \
+// RUN: -### -S %s -mcpu=pwr4 2>&1 | FileCheck -check-prefix=PPCPWR4 %s
+// PPCPWR4: clang
+// PPCPWR4: "-cc1"
+// PPCPWR4: "-target-cpu" "pwr4"
+
+// RUN: %clang -target powerpc64-unknown-linux-gnu \
+// RUN: -### -S %s -mcpu=power5 2>&1 | FileCheck -check-prefix=PPCPOWER5 %s
+// PPCPOWER5: clang
+// PPCPOWER5: "-cc1"
+// PPCPOWER5: "-target-cpu" "pwr5"
+
+// RUN: %clang -target powerpc64-unknown-linux-gnu \
+// RUN: -### -S %s -mcpu=pwr5 2>&1 | FileCheck -check-prefix=PPCPWR5 %s
+// PPCPWR5: clang
+// PPCPWR5: "-cc1"
+// PPCPWR5: "-target-cpu" "pwr5"
+
+// RUN: %clang -target powerpc64-unknown-linux-gnu \
+// RUN: -### -S %s -mcpu=power5x 2>&1 | FileCheck -check-prefix=PPCPOWER5X %s
+// PPCPOWER5X: clang
+// PPCPOWER5X: "-cc1"
+// PPCPOWER5X: "-target-cpu" "pwr5x"
+
+// RUN: %clang -target powerpc64-unknown-linux-gnu \
+// RUN: -### -S %s -mcpu=pwr5x 2>&1 | FileCheck -check-prefix=PPCPWR5X %s
+// PPCPWR5X: clang
+// PPCPWR5X: "-cc1"
+// PPCPWR5X: "-target-cpu" "pwr5x"
+
+// RUN: %clang -target powerpc64-unknown-linux-gnu \
+// RUN: -### -S %s -mcpu=power6 2>&1 | FileCheck -check-prefix=PPCPOWER6 %s
+// PPCPOWER6: clang
+// PPCPOWER6: "-cc1"
+// PPCPOWER6: "-target-cpu" "pwr6"
+
+// RUN: %clang -target powerpc64-unknown-linux-gnu \
+// RUN: -### -S %s -mcpu=pwr6 2>&1 | FileCheck -check-prefix=PPCPWR6 %s
+// PPCPWR6: clang
+// PPCPWR6: "-cc1"
+// PPCPWR6: "-target-cpu" "pwr6"
+
+// RUN: %clang -target powerpc64-unknown-linux-gnu \
+// RUN: -### -S %s -mcpu=power6x 2>&1 | FileCheck -check-prefix=PPCPOWER6X %s
+// PPCPOWER6X: clang
+// PPCPOWER6X: "-cc1"
+// PPCPOWER6X: "-target-cpu" "pwr6x"
+
+// RUN: %clang -target powerpc64-unknown-linux-gnu \
+// RUN: -### -S %s -mcpu=pwr6x 2>&1 | FileCheck -check-prefix=PPCPWR6X %s
+// PPCPWR6X: clang
+// PPCPWR6X: "-cc1"
+// PPCPWR6X: "-target-cpu" "pwr6x"
+
+// RUN: %clang -target powerpc64-unknown-linux-gnu \
+// RUN: -### -S %s -mcpu=power7 2>&1 | FileCheck -check-prefix=PPCPOWER7 %s
+// PPCPOWER7: clang
+// PPCPOWER7: "-cc1"
+// PPCPOWER7: "-target-cpu" "pwr7"
+
+// RUN: %clang -target powerpc64-unknown-linux-gnu \
+// RUN: -### -S %s -mcpu=powerpc 2>&1 | FileCheck -check-prefix=PPCPOWERPC %s
+// PPCPOWERPC: clang
+// PPCPOWERPC: "-cc1"
+// PPCPOWERPC: "-target-cpu" "ppc"
+
+// RUN: %clang -target powerpc64-unknown-linux-gnu \
+// RUN: -### -S %s -mcpu=powerpc64 2>&1 | FileCheck -check-prefix=PPCPOWERPC64 %s
+// PPCPOWERPC64: clang
+// PPCPOWERPC64: "-cc1"
+// PPCPOWERPC64: "-target-cpu" "ppc64"
+
+// RUN: %clang -target powerpc64-unknown-linux-gnu \
// RUN: -### -S %s 2>&1 | FileCheck -check-prefix=PPC64NS %s
// PPC64NS: clang
// PPC64NS: "-cc1"
diff --git a/test/Driver/clang_f_opts.c b/test/Driver/clang_f_opts.c
index 0ee7d2dabe70..c1431a1f9e28 100644
--- a/test/Driver/clang_f_opts.c
+++ b/test/Driver/clang_f_opts.c
@@ -1,6 +1,7 @@
-// RUN: %clang -### -S -fasm -fblocks -fbuiltin -fno-math-errno -fcommon -fpascal-strings -fno-blocks -fno-builtin -fmath-errno -fno-common -fno-pascal-strings -fblocks -fbuiltin -fmath-errno -fcommon -fpascal-strings %s 2>&1 | FileCheck -check-prefix=CHECK-OPTIONS1 %s
+// RUN: %clang -### -S -fasm -fblocks -fbuiltin -fno-math-errno -fcommon -fpascal-strings -fno-blocks -fno-builtin -fmath-errno -fno-common -fno-pascal-strings -fblocks -fbuiltin -fmath-errno -fcommon -fpascal-strings -fsplit-stack %s 2>&1 | FileCheck -check-prefix=CHECK-OPTIONS1 %s
// RUN: %clang -### -S -fasm -fblocks -fbuiltin -fno-math-errno -fcommon -fpascal-strings -fno-asm -fno-blocks -fno-builtin -fmath-errno -fno-common -fno-pascal-strings -fno-show-source-location -fshort-enums -fshort-wchar %s 2>&1 | FileCheck -check-prefix=CHECK-OPTIONS2 %s
+// CHECK-OPTIONS1: -split-stacks
// CHECK-OPTIONS1: -fgnu-keywords
// CHECK-OPTIONS1: -fblocks
// CHECK-OPTIONS1: -fpascal-strings
@@ -36,5 +37,30 @@
// FP-CONTRACT-FAST-CHECK: -ffp-contract=fast
// FP-CONTRACT-OFF-CHECK: -ffp-contract=off
-// RUN: %clang -fms-extensions -fenable-experimental-ms-inline-asm %s -### 2>&1 | FileCheck -check-prefix=CHECK-OPTIONS3 %s
-// CHECK-OPTIONS3: -fenable-experimental-ms-inline-asm
+// RUN: %clang -### -S -fvectorize %s 2>&1 | FileCheck -check-prefix=CHECK-VECTORIZE %s
+// RUN: %clang -### -S -fno-vectorize -fvectorize %s 2>&1 | FileCheck -check-prefix=CHECK-VECTORIZE %s
+// RUN: %clang -### -S -fno-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-NO-VECTORIZE %s
+// RUN: %clang -### -S -fvectorize -fno-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-NO-VECTORIZE %s
+// RUN: %clang -### -S -ftree-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-VECTORIZE %s
+// RUN: %clang -### -S -fno-tree-vectorize -fvectorize %s 2>&1 | FileCheck -check-prefix=CHECK-VECTORIZE %s
+// RUN: %clang -### -S -fno-tree-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-NO-VECTORIZE %s
+// RUN: %clang -### -S -ftree-vectorize -fno-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-NO-VECTORIZE %s
+// CHECK-VECTORIZE: "-vectorize-loops"
+// CHECK-NO-VECTORIZE-NOT: "-vectorize-loops"
+
+// RUN: %clang -### -S -fslp-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-SLP-VECTORIZE %s
+// RUN: %clang -### -S -fno-slp-vectorize -fslp-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-SLP-VECTORIZE %s
+// RUN: %clang -### -S -fno-slp-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-NO-SLP-VECTORIZE %s
+// RUN: %clang -### -S -fslp-vectorize -fno-slp-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-NO-SLP-VECTORIZE %s
+// RUN: %clang -### -S -ftree-slp-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-SLP-VECTORIZE %s
+// RUN: %clang -### -S -fno-tree-slp-vectorize -fslp-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-SLP-VECTORIZE %s
+// RUN: %clang -### -S -fno-tree-slp-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-NO-SLP-VECTORIZE %s
+// RUN: %clang -### -S -ftree-slp-vectorize -fno-slp-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-NO-SLP-VECTORIZE %s
+// CHECK-SLP-VECTORIZE: "-vectorize"
+// CHECK-NO-SLP-VECTORIZE-NOT: "-vectorize"
+
+// RUN: %clang -### -S -fextended-identifiers %s 2>&1 | FileCheck -check-prefix=CHECK-EXTENDED-IDENTIFIERS %s
+// RUN: %clang -### -S -fno-extended-identifiers %s 2>&1 | FileCheck -check-prefix=CHECK-NO-EXTENDED-IDENTIFIERS %s
+// CHECK-EXTENDED-IDENTIFIERS: "-cc1"
+// CHECK-EXTENDED-IDENTIFIERS-NOT: "-fextended-identifiers"
+// CHECK-NO-EXTENDED-IDENTIFIERS: error: unsupported option '-fno-extended-identifiers'
diff --git a/test/Driver/constructors.c b/test/Driver/constructors.c
index ca2cac22934e..9ea91d95689a 100644
--- a/test/Driver/constructors.c
+++ b/test/Driver/constructors.c
@@ -1,14 +1,48 @@
+// Test whether or not the driver instructs the backend to use .init_array
+// sections for global constructors.
+//
+// CHECK-INIT-ARRAY: -fuse-init-array
+// CHECK-NO-INIT-ARRAY-NOT: -fuse-init-array
+//
// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
// RUN: -target i386-unknown-linux \
// RUN: --sysroot=%S/Inputs/fake_install_tree \
-// RUN: | FileCheck --check-prefix=CHECK-GCC-4-7 %s
-
-// CHECK-GCC-4-7: -fuse-init-array
-
+// RUN: | FileCheck --check-prefix=CHECK-INIT-ARRAY %s
+//
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
+// RUN: -fno-use-init-array \
+// RUN: -target i386-unknown-linux \
+// RUN: --sysroot=%S/Inputs/fake_install_tree \
+// RUN: | FileCheck --check-prefix=CHECK-NO-INIT-ARRAY %s
+//
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
+// RUN: -fno-use-init-array -fuse-init-array \
+// RUN: -target i386-unknown-linux \
+// RUN: --sysroot=%S/Inputs/fake_install_tree \
+// RUN: | FileCheck --check-prefix=CHECK-INIT-ARRAY %s
+//
// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
// RUN: -target i386-unknown-linux \
// RUN: --sysroot=%S/Inputs/basic_linux_tree \
-// RUN: | FileCheck --check-prefix=CHECK-GCC-4-6 %s
-
-
-// CHECK-GCC-4-6-NOT: -fuse-init-array
+// RUN: | FileCheck --check-prefix=CHECK-NO-INIT-ARRAY %s
+//
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
+// RUN: -fuse-init-array \
+// RUN: -target i386-unknown-linux \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN: | FileCheck --check-prefix=CHECK-INIT-ARRAY %s
+//
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
+// RUN: -target arm-unknown-linux-androideabi \
+// RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \
+// RUN: | FileCheck --check-prefix=CHECK-INIT-ARRAY %s
+//
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
+// RUN: -target mipsel-unknown-linux-android \
+// RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \
+// RUN: | FileCheck --check-prefix=CHECK-INIT-ARRAY %s
+//
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
+// RUN: -target i386-unknown-linux-android \
+// RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \
+// RUN: | FileCheck --check-prefix=CHECK-INIT-ARRAY %s
diff --git a/test/Driver/crash-report.c b/test/Driver/crash-report.c
index bfcd5732b33d..975e9a8a714f 100644
--- a/test/Driver/crash-report.c
+++ b/test/Driver/crash-report.c
@@ -9,6 +9,8 @@
// RUN: cat %t/crash-report-*.sh | FileCheck --check-prefix=CHECKSH %s
// REQUIRES: crash-recovery
+// RUN: env FORCE_CLANG_DIAGNOSTICS_CRASH=1 %clang -fsyntax-only -x c /dev/null 2>&1 | FileCheck %s
+
#pragma clang __debug parser_crash
// CHECK: Preprocessed source(s) and associated run script(s) are located at:
// CHECK-NEXT: note: diagnostic msg: {{.*}}.c
diff --git a/test/Driver/darwin-debug-flags.c b/test/Driver/darwin-debug-flags.c
index baf28475f8e8..f98e9ce7bd8c 100644
--- a/test/Driver/darwin-debug-flags.c
+++ b/test/Driver/darwin-debug-flags.c
@@ -2,6 +2,8 @@
// <rdar://problem/7256886>
// RUN: touch %t.s
// RUN: env RC_DEBUG_OPTIONS=1 %clang -### -target i386-apple-darwin9 -c -g %t.s 2>&1 | FileCheck -check-prefix=S %s
+// <rdar://problem/12955296>
+// RUN: %clang -### -target i386-apple-darwin9 -c -g %t.s 2>&1 | FileCheck -check-prefix=P %s
// CHECK: !0 = metadata !{
// CHECK: -g -Os
@@ -11,3 +13,5 @@
int x;
// S: "-dwarf-debug-flags"
+
+// P: "-dwarf-debug-producer"
diff --git a/test/Driver/darwin-iphone-defaults.m b/test/Driver/darwin-iphone-defaults.m
index bba0cc0869e0..3e2a9125db5a 100644
--- a/test/Driver/darwin-iphone-defaults.m
+++ b/test/Driver/darwin-iphone-defaults.m
@@ -1,6 +1,6 @@
// RUN: %clang -target i386-apple-darwin9 -miphoneos-version-min=3.0 -arch armv7 -flto -S -o - %s | FileCheck %s
-// CHECK: @f0() ssp
+// CHECK: @f0() [[F0:#[0-9]+]]
// CHECK: @__f0_block_invoke
// CHECK: void @f1
// CHECK-NOT: msgSend_fixup_alloc
@@ -26,3 +26,4 @@ void f1() {
[I1 alloc];
}
+// CHECK: attributes [[F0]] = { ssp{{.*}} }
diff --git a/test/Driver/darwin-sanitizer-ld.c b/test/Driver/darwin-sanitizer-ld.c
new file mode 100644
index 000000000000..98b37e96fe2e
--- /dev/null
+++ b/test/Driver/darwin-sanitizer-ld.c
@@ -0,0 +1,52 @@
+// Test sanitizer link flags on Darwin.
+
+// RUN: %clang -no-canonical-prefixes -### -target x86_64-darwin \
+// RUN: -fsanitize=address %s -o %t.o 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-ASAN %s
+
+// CHECK-ASAN: "{{.*}}ld{{(.exe)?}}"
+// CHECK-ASAN: libclang_rt.asan_osx_dynamic.dylib"
+// CHECK-ASAN: stdc++
+
+// RUN: %clang -no-canonical-prefixes -### -target x86_64-darwin \
+// RUN: -fPIC -shared -fsanitize=address %s -o %t.so 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-DYN-ASAN %s
+
+// CHECK-DYN-ASAN: "{{.*}}ld{{(.exe)?}}"
+// CHECK-DYN-ASAN: "-dylib"
+// CHECK-DYN-ASAN-NOT: libclang_rt.asan_osx_dynamic.dylib
+// CHECK-DYN-ASAN: "-undefined"
+// CHECK-DYN-ASAN: "dynamic_lookup"
+// CHECK-DYN-ASAN-NOT: libclang_rt.asan_osx_dynamic.dylib
+
+// RUN: %clang -no-canonical-prefixes -### -target x86_64-darwin \
+// RUN: -fsanitize=undefined %s -o %t.o 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-UBSAN %s
+
+// CHECK-UBSAN: "{{.*}}ld{{(.exe)?}}"
+// CHECK-UBSAN: libclang_rt.ubsan_osx.a"
+// CHECK-UBSAN: stdc++
+
+// RUN: %clang -no-canonical-prefixes -### -target x86_64-darwin \
+// RUN: -fsanitize=bounds -fsanitize-undefined-trap-on-error \
+// RUN: %s -o %t.o 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-BOUNDS %s
+
+// CHECK-BOUNDS: "{{.*}}ld{{(.exe)?}}"
+// CHECK-BOUNDS-NOT: libclang_rt.ubsan_osx.a"
+
+// RUN: %clang -no-canonical-prefixes -### -target x86_64-darwin \
+// RUN: -fPIC -shared -fsanitize=undefined %s -o %t.so 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-DYN-UBSAN %s
+
+// CHECK-DYN-UBSAN: "{{.*}}ld{{(.exe)?}}"
+// CHECK-DYN-UBSAN: "-dylib"
+// CHECK-DYN-UBSAN: libclang_rt.ubsan_osx.a
+
+// RUN: %clang -no-canonical-prefixes -### -target x86_64-darwin \
+// RUN: -fsanitize=bounds -fsanitize-undefined-trap-on-error \
+// RUN: %s -o %t.so -fPIC -shared 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-DYN-BOUNDS %s
+
+// CHECK-DYN-BOUNDS: "{{.*}}ld{{(.exe)?}}"
+// CHECK-DYN-BOUNDS-NOT: libclang_rt.ubsan_osx.a
diff --git a/test/Driver/darwin-sdkroot.c b/test/Driver/darwin-sdkroot.c
index 5abf08156362..b727fa6bb0ce 100644
--- a/test/Driver/darwin-sdkroot.c
+++ b/test/Driver/darwin-sdkroot.c
@@ -11,7 +11,7 @@
// CHECK-BASIC: "-isysroot" "{{.*tmpdir}}"
// Check that we don't use SDKROOT as the default if it is not a valid path.
-
+//
// RUN: rm -rf %t.nonpath
// RUN: env SDKROOT=%t.nonpath %clang -target x86_64-apple-darwin10 \
// RUN: -c %s -### 2> %t.log
@@ -20,3 +20,16 @@
// CHECK-NONPATH: clang
// CHECK-NONPATH: "-cc1"
// CHECK-NONPATH-NOT: "-isysroot"
+
+// Check that we don't use SDKROOT as the default if it is just "/"
+//
+// RUN: env SDKROOT=/ %clang -target x86_64-apple-darwin10 \
+// RUN: -c %s -### 2> %t.log
+// RUN: FileCheck --check-prefix=CHECK-NONROOT < %t.log %s
+//
+// CHECK-NONROOT: clang
+// CHECK-NONROOT: "-cc1"
+// CHECK-NONROOT-NOT: "-isysroot"
+//
+// It doesn't make sense on msys bash.
+// REQUIRES: shell-preserves-root
diff --git a/test/Driver/debug-comp-dir.S b/test/Driver/debug-comp-dir.S
new file mode 100644
index 000000000000..ca1ca30ae6b5
--- /dev/null
+++ b/test/Driver/debug-comp-dir.S
@@ -0,0 +1,11 @@
+// RUN: cd %S && %clang -### -g %s -c 2>&1 | FileCheck -check-prefix=CHECK-PWD %s
+// CHECK-PWD: {{"-fdebug-compilation-dir" ".*Driver.*"}}
+
+// RUN: env PWD=/foo %clang -### -g %s -c 2>&1 | FileCheck -check-prefix=CHECK-FOO %s
+// CHECK-FOO: {{"-fdebug-compilation-dir" ".*foo"}}
+
+// "PWD=/foo gcc" wouldn't necessarily work. You would need to pick a different
+// path to the same directory (try a symlink).
+
+// This depends on host's behavior how $PWD would be set.
+// REQUIRES: shell
diff --git a/test/Driver/debug-main-file.S b/test/Driver/debug-main-file.S
new file mode 100644
index 000000000000..8c154a32df17
--- /dev/null
+++ b/test/Driver/debug-main-file.S
@@ -0,0 +1,12 @@
+// REQUIRES: clang-driver
+// RUN: %clang -### -c -save-temps -integrated-as -g %s 2>&1 \
+// RUN: | FileCheck %s
+
+// CHECK: main-file-name
+
+#ifdef(1)
+foo:
+ nop
+ nop
+ nop
+#endif
diff --git a/test/Driver/debug-options-as.c b/test/Driver/debug-options-as.c
index 57036e42db07..0b639b2959cb 100644
--- a/test/Driver/debug-options-as.c
+++ b/test/Driver/debug-options-as.c
@@ -1,5 +1,5 @@
// cygming have not supported integrated-as yet.
-// XFAIL: cygwin,mingw32
+// REQUIRES: clang-driver
//
// Check to make sure clang is somewhat picky about -g options.
// (Delived from debug-options.c)
@@ -14,7 +14,16 @@
// rdar://9275556
// RUN: touch %t.s
// RUN: %clang -### -c -integrated-as -g %t.s 2>&1 \
-// RUN: | FileCheck -check-prefix=S %s
+// RUN: | FileCheck %s
//
-// S: "-cc1as"
-// S: "-g"
+// CHECK: "-cc1as"
+// CHECK: "-g"
+
+// Check to make sure clang with -g on a .s file gets passed -dwarf-debug-producer.
+// rdar://12955296
+// RUN: touch %t.s
+// RUN: %clang -### -c -integrated-as -g %t.s 2>&1 \
+// RUN: | FileCheck -check-prefix=P %s
+//
+// P: "-cc1as"
+// P: "-dwarf-debug-producer"
diff --git a/test/Driver/fast-math.c b/test/Driver/fast-math.c
index 17bf6ed617dd..91af2e1dce45 100644
--- a/test/Driver/fast-math.c
+++ b/test/Driver/fast-math.c
@@ -5,7 +5,7 @@
// support.
//
// Both of them use gcc driver for as.
-// XFAIL: cygwin,mingw32
+// REQUIRES: clang-driver
//
// RUN: %clang -### -fno-honor-infinities -c %s 2>&1 \
// RUN: | FileCheck --check-prefix=CHECK-NO-INFS %s
diff --git a/test/Driver/fcomment-block-commands.c b/test/Driver/fcomment-block-commands.c
new file mode 100644
index 000000000000..d83662ae67be
--- /dev/null
+++ b/test/Driver/fcomment-block-commands.c
@@ -0,0 +1,8 @@
+// Check that we pass -fcomment-block-commands to frontend.
+//
+// RUN: %clang -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ARG
+// RUN: %clang -c %s -fcomment-block-commands=Foo -### 2>&1 | FileCheck %s --check-prefix=CHECK-ARG
+//
+// CHECK-ARG: -fcomment-block-commands=Foo
+//
+// CHECK-NO-ARG-NOT: -fcomment-block-commands=
diff --git a/test/Driver/flags.c b/test/Driver/flags.c
index 698a54ecf78b..27862316f88f 100644
--- a/test/Driver/flags.c
+++ b/test/Driver/flags.c
@@ -7,5 +7,14 @@
// RUN: %clang -target i386-apple-darwin9 -### -S -mno-soft-float %s -msoft-float 2> %t.log
// RUN: grep '"-no-implicit-float"' %t.log
+// RUN: %clang -target i386-apple-darwin9 -### -S -mno-implicit-float %s 2> %t.log
+// RUN: grep '"-no-implicit-float"' %t.log
+
+// RUN: %clang -target i386-apple-darwin9 -### -S -mkernel %s 2> %t.log
+// RUN: grep '"-no-implicit-float"' %t.log
+
+// RUN: %clang -target i386-apple-darwin9 -### -S -mkernel -mno-soft-float %s 2> %t.log
+// RUN: grep '"-no-implicit-float"' %t.log | count 0
+
// RUN: %clang -target armv7-apple-darwin10 -### -S -mno-implicit-float %s 2> %t.log
-// RUN: grep '"-no-implicit-float"' %t.log | count 1
+// RUN: grep '"-no-implicit-float"' %t.log
diff --git a/test/Driver/frame-pointer-elim.c b/test/Driver/frame-pointer-elim.c
new file mode 100644
index 000000000000..286cd6e61f83
--- /dev/null
+++ b/test/Driver/frame-pointer-elim.c
@@ -0,0 +1,30 @@
+// For these next two tests when optimized we should omit the leaf frame
+// pointer, for unoptimized we should have a leaf frame pointer.
+// RUN: %clang -### -target i386-pc-linux-gnu -S -O1 %s 2>&1 | \
+// RUN: FileCheck --check-prefix=LINUX-OPT %s
+// LINUX-OPT: "-momit-leaf-frame-pointer"
+
+// RUN: %clang -### -target i386-pc-linux-gnu -S %s 2>&1 | \
+// RUN: FileCheck --check-prefix=LINUX %s
+// LINUX-NOT: "-momit-leaf-frame-pointer"
+
+// Darwin disables omitting the leaf frame pointer even under optimization
+// unless the command lines are given.
+// RUN: %clang -### -target i386-apple-darwin -S %s 2>&1 | \
+// RUN: FileCheck --check-prefix=DARWIN %s
+// DARWIN: "-mdisable-fp-elim"
+
+// RUN: %clang -### -target i386-apple-darwin -S -O1 %s 2>&1 | \
+// RUN: FileCheck --check-prefix=DARWIN-OPT %s
+// DARWIN-OPT-NOT: "-momit-leaf-frame-pointer"
+
+// RUN: %clang -### -target i386-darwin -S -fomit-frame-pointer %s 2>&1 | \
+// RUN: FileCheck --check-prefix=OMIT_ALL %s
+// OMIT_ALL-NOT: "-mdisable-fp-elim"
+
+// RUN: %clang -### -target i386-darwin -S -momit-leaf-frame-pointer %s 2>&1 | \
+// RUN: FileCheck --check-prefix=OMIT_LEAF %s
+// OMIT_LEAF: "-momit-leaf-frame-pointer"
+
+void f0() {}
+void f1() { f0(); }
diff --git a/test/Driver/freebsd-mips-as.c b/test/Driver/freebsd-mips-as.c
index 54ff1875155b..508debae7fb8 100644
--- a/test/Driver/freebsd-mips-as.c
+++ b/test/Driver/freebsd-mips-as.c
@@ -32,8 +32,8 @@
//
// RUN: %clang -target mipsel-unknown-freebsd -### \
// RUN: -no-integrated-as -c %s 2>&1 \
-// RUN: | FileCheck -check-prefix=MIPS32-EL-AS %s
-// MIPS32-EL-AS: as{{(.exe)?}}" "-march" "mips32" "-mabi" "32" "-EL"
+// RUN: | FileCheck -check-prefix=MIPS32-DEF-EL-AS %s
+// MIPS32-DEF-EL-AS: as{{(.exe)?}}" "-march" "mips32" "-mabi" "32" "-EL"
//
// RUN: %clang -target mips64-unknown-freebsd -### \
// RUN: -no-integrated-as -c %s 2>&1 \
@@ -42,8 +42,8 @@
//
// RUN: %clang -target mips64el-unknown-freebsd -### \
// RUN: -no-integrated-as -c %s 2>&1 \
-// RUN: | FileCheck -check-prefix=MIPS64-EL-AS %s
-// MIPS64-EL-AS: as{{(.exe)?}}" "-march" "mips64" "-mabi" "64" "-EL"
+// RUN: | FileCheck -check-prefix=MIPS64-DEF-EL-AS %s
+// MIPS64-DEF-EL-AS: as{{(.exe)?}}" "-march" "mips64" "-mabi" "64" "-EL"
//
// RUN: %clang -target mips-unknown-freebsd -mabi=eabi -### \
// RUN: -no-integrated-as -c %s 2>&1 \
@@ -55,6 +55,16 @@
// RUN: | FileCheck -check-prefix=MIPS-N32 %s
// MIPS-N32: as{{(.exe)?}}" "-march" "mips64" "-mabi" "n32" "-EB"
//
+// RUN: %clang -target mipsel-unknown-freebsd -mabi=32 -### \
+// RUN: -no-integrated-as -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix=MIPS32-EL-AS %s
+// MIPS32-EL-AS: as{{(.exe)?}}" "-march" "mips32" "-mabi" "32" "-EL"
+//
+// RUN: %clang -target mips64el-unknown-freebsd -mabi=64 -### \
+// RUN: -no-integrated-as -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix=MIPS64-EL-AS %s
+// MIPS64-EL-AS: as{{(.exe)?}}" "-march" "mips64" "-mabi" "64" "-EL"
+//
// RUN: %clang -target mips-linux-freebsd -march=mips32r2 -### \
// RUN: -no-integrated-as -c %s 2>&1 \
// RUN: | FileCheck -check-prefix=MIPS-32R2 %s
diff --git a/test/Driver/freebsd.c b/test/Driver/freebsd.c
index db53d4ddd8a1..cc7244396176 100644
--- a/test/Driver/freebsd.c
+++ b/test/Driver/freebsd.c
@@ -96,3 +96,14 @@
// RUN: | FileCheck --check-prefix=CHECK-NORMAL %s
// CHECK-NORMAL: crt1.o
// CHECK-NORMAL: crtbegin.o
+
+// RUN: %clang %s -### -o %t.o -target arm-unknown-freebsd10.0 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-ARM %s
+// CHECK-ARM: clang{{.*}}" "-cc1"{{.*}}" "-fsjlj-exceptions"
+// CHECK-ARM: as{{.*}}" "-mfpu=softvfp"{{.*}}"-matpcs"
+
+// RUN: %clang %s -### -o %t.o -target arm-gnueabi-freebsd10.0 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-ARM-EABI %s
+// CHECK-ARM-EABI-NOT: clang{{.*}}" "-cc1"{{.*}}" "-fsjlj-exceptions"
+// CHECK-ARM-EABI: as{{.*}}" "-mfpu=softvfp" "-meabi=5"
+// CHECK-ARM-EABI-NOT: as{{.*}}" "-matpcs"
diff --git a/test/Driver/fsanitize-blacklist.c b/test/Driver/fsanitize-blacklist.c
new file mode 100644
index 000000000000..5327bc16a340
--- /dev/null
+++ b/test/Driver/fsanitize-blacklist.c
@@ -0,0 +1,18 @@
+// General blacklist usage.
+// RUN: %clang -fsanitize=address -fsanitize-blacklist=%s %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-BLACKLIST
+// CHECK-BLACKLIST: -fsanitize-blacklist
+
+// Ignore -fsanitize-blacklist flag if there is no -fsanitize flag.
+// RUN: %clang -fsanitize-blacklist=%s %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-SANITIZE
+// CHECK-NO-SANITIZE-NOT: -fsanitize-blacklist
+
+// Flag -fno-sanitize-blacklist wins if it is specified later.
+// RUN: %clang -fsanitize=address -fsanitize-blacklist=%s -fno-sanitize-blacklist %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-BLACKLIST
+// CHECK-NO-BLACKLIST-NOT: -fsanitize-blacklist
+
+// Driver barks on unexisting blacklist files.
+// RUN: %clang -fno-sanitize-blacklist -fsanitize-blacklist=unexisting.txt %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-SUCH-FILE
+// CHECK-NO-SUCH-FILE: error: no such file or directory: 'unexisting.txt'
+
+// PR12920
+// REQUIRES: clang-driver
diff --git a/test/Driver/fsanitize.c b/test/Driver/fsanitize.c
index 9f7cd46c6cf7..1d606b43b1eb 100644
--- a/test/Driver/fsanitize.c
+++ b/test/Driver/fsanitize.c
@@ -1,23 +1,118 @@
-// RUN: %clang -target x86_64-linux-gnu -fcatch-undefined-behavior %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-UNDEFINED
+// RUN: %clang -target x86_64-linux-gnu -fcatch-undefined-behavior %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-UNDEFINED-TRAP
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=undefined-trap -fsanitize-undefined-trap-on-error %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-UNDEFINED-TRAP
+// RUN: %clang -target x86_64-linux-gnu -fsanitize-undefined-trap-on-error -fsanitize=undefined-trap %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-UNDEFINED-TRAP
+// CHECK-UNDEFINED-TRAP: "-fsanitize={{((signed-integer-overflow|integer-divide-by-zero|float-divide-by-zero|shift|unreachable|return|vla-bound|alignment|null|object-size|float-cast-overflow|bounds|enum|bool),?){14}"}}
+// CHECK-UNDEFINED-TRAP: "-fsanitize-undefined-trap-on-error"
+
// RUN: %clang -target x86_64-linux-gnu -fsanitize=undefined %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-UNDEFINED
-// CHECK-UNDEFINED: "-fsanitize={{((signed-integer-overflow|divide-by-zero|shift|unreachable|return|vla-bound|alignment|null|vptr|object-size|float-cast-overflow),?){11}"}}
+// CHECK-UNDEFINED: "-fsanitize={{((signed-integer-overflow|integer-divide-by-zero|float-divide-by-zero|shift|unreachable|return|vla-bound|alignment|null|vptr|object-size|float-cast-overflow|bounds|enum|bool),?){15}"}}
+
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=integer %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-INTEGER
+// CHECK-INTEGER: "-fsanitize={{((signed-integer-overflow|unsigned-integer-overflow|integer-divide-by-zero|shift),?){4}"}}
+
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=thread,undefined -fno-thread-sanitizer -fno-sanitize=float-cast-overflow,vptr,bool,enum %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-PARTIAL-UNDEFINED
+// CHECK-PARTIAL-UNDEFINED: "-fsanitize={{((signed-integer-overflow|integer-divide-by-zero|float-divide-by-zero|shift|unreachable|return|vla-bound|alignment|null|object-size|bounds),?){11}"}}
+
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=address-full %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-FULL
+// CHECK-ASAN-FULL: "-fsanitize={{((address|init-order|use-after-return|use-after-scope),?){4}"}}
+
+// RUN: %clang -target x86_64-linux-gnu -fno-sanitize=init-order -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-IMPLIED-INIT-ORDER
+// CHECK-ASAN-IMPLIED-INIT-ORDER: "-fsanitize={{((address|init-order),?){2}"}}
+
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=address -fno-sanitize=init-order %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-NO-IMPLIED-INIT-ORDER
+// CHECK-ASAN-NO-IMPLIED-INIT-ORDER-NOT: init-order
+
+// RUN: %clang -target x86_64-linux-gnu -fcatch-undefined-behavior -fno-sanitize-undefined-trap-on-error %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-UNDEFINED-NO-TRAP-ERROR
+// CHECK-UNDEFINED-NO-TRAP-ERROR: '-fcatch-undefined-behavior' not allowed with '-fno-sanitize-undefined-trap-on-error'
+
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=vptr -fcatch-undefined-behavior %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-VPTR-UNDEF-ERROR
+// CHECK-VPTR-UNDEF-ERROR: '-fsanitize=vptr' not allowed with '-fcatch-undefined-behavior'
-// RUN: %clang -target x86_64-linux-gnu -fsanitize=thread,undefined -fno-thread-sanitizer -fno-sanitize=float-cast-overflow,vptr %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-PARTIAL-UNDEFINED
-// CHECK-PARTIAL-UNDEFINED: "-fsanitize={{((signed-integer-overflow|divide-by-zero|shift|unreachable|return|vla-bound|alignment|null|object-size),?){9}"}}
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=undefined -fsanitize-undefined-trap-on-error %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-UNDEFINED-TRAP-ON-ERROR-UNDEF
+// CHECK-UNDEFINED-TRAP-ON-ERROR-UNDEF: '-fsanitize=undefined' not allowed with '-fsanitize-undefined-trap-on-error'
-// RUN: %clang -target x86_64-linux-gnu -fsanitize=vptr -fno-rtti %s -c -o /dev/null 2>&1 | FileCheck %s --check-prefix=CHECK-VPTR-NO-RTTI
-// RUN: %clang -target x86_64-linux-gnu -fsanitize=undefined -fno-rtti %s -c -o /dev/null 2>&1 | FileCheck %s --check-prefix=CHECK-VPTR-NO-RTTI
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=vptr -fsanitize-undefined-trap-on-error %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-UNDEFINED-TRAP-ON-ERROR-VPTR
+// CHECK-UNDEFINED-TRAP-ON-ERROR-VPTR: '-fsanitize=vptr' not allowed with '-fsanitize-undefined-trap-on-error'
+
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=vptr -fno-rtti %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-VPTR-NO-RTTI
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=undefined -fno-rtti %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-VPTR-NO-RTTI
// CHECK-VPTR-NO-RTTI: '-fsanitize=vptr' not allowed with '-fno-rtti'
-// RUN: %clang -target x86_64-linux-gnu -fsanitize=address,thread -fno-rtti %s -c -o /dev/null 2>&1 | FileCheck %s --check-prefix=CHECK-SANA-SANT
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=address,thread -fno-rtti %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANA-SANT
// CHECK-SANA-SANT: '-fsanitize=address' not allowed with '-fsanitize=thread'
-// RUN: %clang -target x86_64-linux-gnu -faddress-sanitizer -fthread-sanitizer -fno-rtti %s -c -o /dev/null 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-TSAN
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=address,memory -pie -fno-rtti %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANA-SANM
+// CHECK-SANA-SANM: '-fsanitize=address' not allowed with '-fsanitize=memory'
+
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=thread,memory -pie -fno-rtti %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANT-SANM
+// CHECK-SANT-SANM: '-fsanitize=thread' not allowed with '-fsanitize=memory'
+
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=memory,thread -pie -fno-rtti %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANM-SANT
+// CHECK-SANM-SANT: '-fsanitize=thread' not allowed with '-fsanitize=memory'
+
+// RUN: %clang -target x86_64-linux-gnu -faddress-sanitizer -fthread-sanitizer -fno-rtti %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-TSAN
// CHECK-ASAN-TSAN: '-faddress-sanitizer' not allowed with '-fthread-sanitizer'
-// RUN: %clang -target x86_64-linux-gnu -fcatch-undefined-behavior -fthread-sanitizer -fno-thread-sanitizer -faddress-sanitizer -fno-address-sanitizer -c -o /dev/null %s 2>&1 | FileCheck %s --check-prefix=CHECK-DEPRECATED
-// CHECK-DEPRECATED: argument '-fcatch-undefined-behavior' is deprecated, use '-fsanitize=undefined' instead
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=init-order %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ONLY-EXTRA-ASAN
+// CHECK-ONLY-EXTRA-ASAN: '-fsanitize=init-order' is ignored in absence of '-fsanitize=address'
+
+// RUN: %clang -target x86_64-linux-gnu -Wno-unused-sanitize-argument -fsanitize=init-order %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-WNO-UNUSED-SANITIZE-ARGUMENT
+// CHECK-WNO-UNUSED-SANITIZE-ARGUMENT-NOT: '-fsanitize=init-order' is ignored in absence of '-fsanitize=address'
+
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=address,init-order -fno-sanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-NOWARN-ONLY-EXTRA-ASAN
+// CHECK-NOWARN-ONLY-EXTRA-ASAN-NOT: is ignored in absence of '-fsanitize=address'
+
+// RUN: %clang -target x86_64-linux-gnu -fsanitize-memory-track-origins -pie %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ONLY-TRACK-ORIGINS
+// CHECK-ONLY-TRACK-ORIGINS: warning: argument unused during compilation: '-fsanitize-memory-track-origins'
+
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-EXTRA-TRACK-ORIGINS
+// CHECK-NO-EXTRA-TRACK-ORIGINS-NOT: "-fsanitize-memory-track-origins"
+
+// RUN: %clang -target x86_64-linux-gnu -fsanitize-address-zero-base-shadow -pie %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ONLY-ASAN-ZERO-BASE-SHADOW
+// CHECK-ONLY-ASAN-ZERO-BASE-SHADOW: warning: argument unused during compilation: '-fsanitize-address-zero-base-shadow'
+
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=address -fsanitize=alignment -fsanitize=vptr -fno-sanitize=vptr %s -### 2>&1
+// OK
+
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=memory -pie %s -### 2>&1
+// OK
+
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=memory -fsanitize-memory-track-origins -pie %s -### 2>&1
+// OK
+
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=vptr -fno-sanitize=vptr -fsanitize=undefined,address %s -### 2>&1
+// OK
+
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=address -fsanitize-address-zero-base-shadow -pie %s -### 2>&1
+// OK
+
+// RUN: %clang -target x86_64-linux-gnu -fcatch-undefined-behavior -fthread-sanitizer -fno-thread-sanitizer -faddress-sanitizer -fno-address-sanitizer -fbounds-checking -### %s 2>&1 | FileCheck %s --check-prefix=CHECK-DEPRECATED
+// CHECK-DEPRECATED: argument '-fcatch-undefined-behavior' is deprecated, use '-fsanitize=undefined-trap -fsanitize-undefined-trap-on-error' instead
// CHECK-DEPRECATED: argument '-fthread-sanitizer' is deprecated, use '-fsanitize=thread' instead
// CHECK-DEPRECATED: argument '-fno-thread-sanitizer' is deprecated, use '-fno-sanitize=thread' instead
// CHECK-DEPRECATED: argument '-faddress-sanitizer' is deprecated, use '-fsanitize=address' instead
// CHECK-DEPRECATED: argument '-fno-address-sanitizer' is deprecated, use '-fno-sanitize=address' instead
+// CHECK-DEPRECATED: argument '-fbounds-checking' is deprecated, use '-fsanitize=bounds' instead
+
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=thread %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TSAN-NO-PIE
+// CHECK-TSAN-NO-PIE: invalid argument '-fsanitize=thread' only allowed with '-pie'
+
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=memory %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-MSAN-NO-PIE
+// CHECK-MSAN-NO-PIE: invalid argument '-fsanitize=memory' only allowed with '-pie'
+
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=address -fsanitize-address-zero-base-shadow %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-ZERO-BASE-SHADOW-NO-PIE
+// CHECK-ASAN-ZERO-BASE-SHADOW-NO-PIE: invalid argument '-fsanitize-address-zero-base-shadow' only allowed with '-pie'
+
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=address -fsanitize-address-zero-base-shadow -fno-sanitize-address-zero-base-shadow %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-ZERO-BASE-SHADOW-CANCEL
+// CHECK-ASAN-ZERO-BASE-SHADOW-CANCEL-NOT: '-fsanitize-address-zero-base-shadow' only allowed with '-pie'
+
+// RUN: %clang -target arm-linux-androideabi -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ANDROID-ASAN-NO-PIE
+// CHECK-ANDROID-ASAN-NO-PIE: AddressSanitizer on Android requires '-pie'
+
+// RUN: %clang -target x86_64-linux-gnu %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-RECOVER
+// RUN: %clang -target x86_64-linux-gnu %s -fsanitize-recover -### 2>&1 | FileCheck %s --check-prefix=CHECK-RECOVER
+// RUN: %clang -target x86_64-linux-gnu %s -fno-sanitize-recover -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-RECOVER
+// RUN: %clang -target x86_64-linux-gnu %s -fno-sanitize-recover -fsanitize-recover -### 2>&1 | FileCheck %s --check-prefix=CHECK-RECOVER
+// RUN: %clang -target x86_64-linux-gnu %s -fsanitize-recover -fno-sanitize-recover -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-RECOVER
+// CHECK-RECOVER-NOT: sanitize-recover
+// CHECK-NO-RECOVER: "-fno-sanitize-recover"
diff --git a/test/Driver/gold-lto.c b/test/Driver/gold-lto.c
index 05ac27aab9fb..c2e8bdfbc747 100644
--- a/test/Driver/gold-lto.c
+++ b/test/Driver/gold-lto.c
@@ -1,6 +1,21 @@
// RUN: touch %t.o
-// RUN: %clang -target x86_64-pc-linux-gnu -### %t.o -O4 -Wl,-plugin-opt=foo 2> %t.log
-// RUN: FileCheck %s < %t.log
-
-// CHECK: "-plugin" "{{.*}}/LLVMgold.so"
-// CHECK: "-plugin-opt=foo"
+//
+// RUN: %clang -target x86_64-unknown-linux -### %t.o -flto 2>&1 \
+// RUN: -Wl,-plugin-opt=foo \
+// RUN: | FileCheck %s --check-prefix=CHECK-X86-64-BASIC
+// CHECK-X86-64-BASIC: "-plugin" "{{.*}}/LLVMgold.so"
+// CHECK-X86-64-BASIC: "-plugin-opt=foo"
+//
+// RUN: %clang -target x86_64-unknown-linux -### %t.o -flto 2>&1 \
+// RUN: -march=corei7 -Wl,-plugin-opt=foo \
+// RUN: | FileCheck %s --check-prefix=CHECK-X86-64-COREI7
+// CHECK-X86-64-COREI7: "-plugin" "{{.*}}/LLVMgold.so"
+// CHECK-X86-64-COREI7: "-plugin-opt=mcpu=corei7"
+// CHECK-X86-64-COREI7: "-plugin-opt=foo"
+//
+// RUN: %clang -target arm-unknown-linux -### %t.o -flto 2>&1 \
+// RUN: -march=armv7a -Wl,-plugin-opt=foo \
+// RUN: | FileCheck %s --check-prefix=CHECK-ARM-V7A
+// CHECK-ARM-V7A: "-plugin" "{{.*}}/LLVMgold.so"
+// CHECK-ARM-V7A: "-plugin-opt=mcpu=cortex-a8"
+// CHECK-ARM-V7A: "-plugin-opt=foo"
diff --git a/test/Driver/hexagon-toolchain-elf.c b/test/Driver/hexagon-toolchain-elf.c
new file mode 100644
index 000000000000..b3ff7b6c3a7d
--- /dev/null
+++ b/test/Driver/hexagon-toolchain-elf.c
@@ -0,0 +1,564 @@
+// REQUIRES: hexagon-registered-target
+
+// -----------------------------------------------------------------------------
+// Test standard include paths
+// -----------------------------------------------------------------------------
+
+// RUN: %clang -### -target hexagon-unknown-elf \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK001 %s
+// CHECK001: "-cc1" {{.*}} "-internal-externc-isystem" "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/lib/gcc/hexagon/4.4.0/include"
+// CHECK001: "-internal-externc-isystem" "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/lib/gcc/hexagon/4.4.0/include-fixed"
+// CHECK001: "-internal-externc-isystem" "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/hexagon/include"
+// CHECK001-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin/hexagon-as"
+
+// RUN: %clang -ccc-cxx -x c++ -### -target hexagon-unknown-elf \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK002 %s
+// CHECK002: "-cc1" {{.*}} "-internal-isystem" "[[INSTALL_DIR:.*]]/Inputs/hexagon_tree/qc/bin/../../gnu/hexagon/include/c++/4.4.0"
+// CHECK002: "-internal-externc-isystem" "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/lib/gcc/hexagon/4.4.0/include"
+// CHECK002: "-internal-externc-isystem" "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/lib/gcc/hexagon/4.4.0/include-fixed"
+// CHECK002: "-internal-externc-isystem" "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/hexagon/include"
+// CHECK002-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin/hexagon-as"
+
+// -----------------------------------------------------------------------------
+// Test -nostdinc, -nostdlibinc, -nostdinc++
+// -----------------------------------------------------------------------------
+
+// RUN: %clang -### -target hexagon-unknown-elf \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: -nostdinc \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK003 %s
+// CHECK003: "-cc1"
+// CHECK003-NOT: "-internal-externc-isystem" "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/lib/gcc/hexagon/4.4.0/include"
+// CHECK003-NOT: "-internal-externc-isystem" "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/lib/gcc/hexagon/4.4.0/include-fixed"
+// CHECK003-NOT: "-internal-externc-isystem" "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/hexagon/include"
+// CHECK003-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin/hexagon-as"
+
+// RUN: %clang -### -target hexagon-unknown-elf \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: -nostdlibinc \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK004 %s
+// CHECK004: "-cc1"
+// CHECK004-NOT: "-internal-externc-isystem" "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/lib/gcc/hexagon/4.4.0/include"
+// CHECK004-NOT: "-internal-externc-isystem" "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/lib/gcc/hexagon/4.4.0/include-fixed"
+// CHECK004-NOT: "-internal-externc-isystem" "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/hexagon/include"
+// CHECK004-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin/hexagon-as"
+
+// RUN: %clang -ccc-cxx -x c++ -### -target hexagon-unknown-elf \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: -nostdlibinc \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK005 %s
+// CHECK005: "-cc1"
+// CHECK005-NOT: "-internal-isystem" "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/hexagon/include/c++/4.4.0"
+// CHECK005-NOT: "-internal-externc-isystem" "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/lib/gcc/hexagon/4.4.0/include"
+// CHECK005-NOT: "-internal-externc-isystem" "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/lib/gcc/hexagon/4.4.0/include-fixed"
+// CHECK005-NOT: "-internal-externc-isystem" "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/hexagon/include"
+// CHECK005-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin/hexagon-as"
+
+// RUN: %clang -ccc-cxx -x c++ -### -target hexagon-unknown-elf \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: -nostdinc++ \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK006 %s
+// CHECK006: "-cc1"
+// CHECK006-NOT: "-internal-isystem" "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/hexagon/include/c++/4.4.0"
+// CHECK006-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin/hexagon-as"
+
+// -----------------------------------------------------------------------------
+// Test -march=<archname> -mcpu=<archname> -mv<number>
+// -----------------------------------------------------------------------------
+// RUN: %clang -### -target hexagon-unknown-elf \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: -march=hexagonv3 \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK007 %s
+// CHECK007: "-cc1" {{.*}} "-target-cpu" "hexagonv3"
+// CHECK007-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin/hexagon-as"{{.*}} "-march=v3"
+// CHECK007-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin/hexagon-ld"{{.*}} "-mv3"
+
+// RUN: %clang -### -target hexagon-unknown-elf \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: -mcpu=hexagonv5 \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK008 %s
+// CHECK008: "-cc1" {{.*}} "-target-cpu" "hexagonv5"
+// CHECK008-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin/hexagon-as"{{.*}} "-march=v5"
+// CHECK008-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin/hexagon-ld"{{.*}} "-mv5"
+
+// RUN: %clang -### -target hexagon-unknown-elf \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: -mv2 \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK009 %s
+// CHECK009: "-cc1" {{.*}} "-target-cpu" "hexagonv2"
+// CHECK009-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin/hexagon-as"{{.*}} "-march=v2"
+// CHECK009-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin/hexagon-ld"{{.*}} "-mv2"
+
+// RUN: %clang -### -target hexagon-unknown-elf \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK010 %s
+// CHECK010: "-cc1" {{.*}} "-target-cpu" "hexagonv4"
+// CHECK010-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin/hexagon-as"{{.*}} "-march=v4"
+// CHECK010-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin/hexagon-ld"{{.*}} "-mv4"
+
+// RUN: %clang -march=hexagonv2 -target hexagon-unknown-elf \
+// RUN: %s 2>&1 | FileCheck -check-prefix=CHECK-UNKNOWN-V2 %s
+// RUN: %clang -mcpu=hexagonv2 -target hexagon-unknown-elf \
+// RUN: %s 2>&1 | FileCheck -check-prefix=CHECK-UNKNOWN-V2 %s
+// RUN: %clang -mv2 -target hexagon-unknown-elf \
+// RUN: %s 2>&1 | FileCheck -check-prefix=CHECK-UNKNOWN-V2 %s
+// CHECK-UNKNOWN-V2: error: unknown target CPU 'hexagonv2'
+
+// RUN: %clang -march=hexagonv3 -target hexagon-unknown-elf \
+// RUN: %s 2>&1 | FileCheck -check-prefix=CHECK-UNKNOWN-V3 %s
+// RUN: %clang -mcpu=hexagonv3 -target hexagon-unknown-elf \
+// RUN: %s 2>&1 | FileCheck -check-prefix=CHECK-UNKNOWN-V3 %s
+// RUN: %clang -mv3 -target hexagon-unknown-elf \
+// RUN: %s 2>&1 | FileCheck -check-prefix=CHECK-UNKNOWN-V3 %s
+// CHECK-UNKNOWN-V3: error: unknown target CPU 'hexagonv3'
+
+// -----------------------------------------------------------------------------
+// Test Linker related args
+// -----------------------------------------------------------------------------
+
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+// Defaults for C
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+// RUN: %clang -### -target hexagon-unknown-elf \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK011 %s
+// CHECK011: "{{.*}}clang{{.*}}" "-cc1"
+// CHECK011-NEXT: "{{.*}}/bin/hexagon-as"{{.*}}
+// CHECK011-NEXT: "{{.*}}/bin/hexagon-ld"
+// CHECK011-NOT: "-static"
+// CHECK011-NOT: "-shared"
+// CHECK011: "{{.*}}/hexagon/lib/v4/crt0_standalone.o"
+// CHECK011: "{{.*}}/hexagon/lib/v4/crt0.o"
+// CHECK011: "{{.*}}/hexagon/lib/v4/init.o"
+// CHECK011: "-L{{.*}}/lib/gcc/hexagon/4.4.0/v4"
+// CHECK011: "-L{{.*}}/lib/gcc/hexagon/4.4.0"
+// CHECK011: "-L{{.*}}/lib/gcc"
+// CHECK011: "-L{{.*}}/hexagon/lib/v4"
+// CHECK011: "-L{{.*}}/hexagon/lib"
+// CHECK011: "{{[^"]+}}.o"
+// CHECK011: "--start-group" "-lstandalone" "-lc" "-lgcc" "--end-group"
+// CHECK011: "{{.*}}/hexagon/lib/v4/fini.o"
+
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+// Defaults for C++
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+// RUN: %clang -ccc-cxx -x c++ -### -target hexagon-unknown-elf \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK012 %s
+// CHECK012: "{{.*}}clang{{.*}}" "-cc1"
+// CHECK012-NEXT: "{{.*}}/bin/hexagon-as"{{.*}}
+// CHECK012-NEXT: "{{.*}}/bin/hexagon-ld"
+// CHECK012-NOT: "-static"
+// CHECK012-NOT: "-shared"
+// CHECK012: "{{.*}}/hexagon/lib/v4/crt0_standalone.o"
+// CHECK012: "{{.*}}/hexagon/lib/v4/crt0.o"
+// CHECK012: "{{.*}}/hexagon/lib/v4/init.o"
+// CHECK012: "-L{{.*}}/lib/gcc/hexagon/4.4.0/v4"
+// CHECK012: "-L{{.*}}/lib/gcc/hexagon/4.4.0"
+// CHECK012: "-L{{.*}}/lib/gcc"
+// CHECK012: "-L{{.*}}/hexagon/lib/v4"
+// CHECK012: "-L{{.*}}/hexagon/lib"
+// CHECK012: "{{[^"]+}}.o"
+// CHECK012: "-lstdc++" "-lm"
+// CHECK012: "--start-group" "-lstandalone" "-lc" "-lgcc" "--end-group"
+// CHECK012: "{{.*}}/hexagon/lib/v4/fini.o"
+
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+// Additional Libraries (-L)
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+// RUN: %clang -### -target hexagon-unknown-elf \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: -Lone -L two -L three \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK013 %s
+// CHECK013: "{{.*}}clang{{.*}}" "-cc1"
+// CHECK013-NEXT: "{{.*}}/bin/hexagon-as"{{.*}}
+// CHECK013-NEXT: "{{.*}}/bin/hexagon-ld"
+// CHECK013: "{{.*}}/hexagon/lib/v4/crt0_standalone.o"
+// CHECK013: "{{.*}}/hexagon/lib/v4/crt0.o"
+// CHECK013: "{{.*}}/hexagon/lib/v4/init.o"
+// CHECK013: "-Lone" "-Ltwo" "-Lthree"
+// CHECK013: "-L{{.*}}/lib/gcc/hexagon/4.4.0/v4"
+// CHECK013: "-L{{.*}}/lib/gcc/hexagon/4.4.0"
+// CHECK013: "-L{{.*}}/lib/gcc"
+// CHECK013: "-L{{.*}}/hexagon/lib/v4"
+// CHECK013: "-L{{.*}}/hexagon/lib"
+// CHECK013: "{{[^"]+}}.o"
+// CHECK013: "--start-group" "-lstandalone" "-lc" "-lgcc" "--end-group"
+// CHECK013: "{{.*}}/hexagon/lib/v4/fini.o"
+
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+// -static, -shared
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+// RUN: %clang -### -target hexagon-unknown-elf \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: -static \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK014 %s
+// CHECK014: "{{.*}}clang{{.*}}" "-cc1"
+// CHECK014-NEXT: "{{.*}}/bin/hexagon-as"{{.*}}
+// CHECK014-NEXT: "{{.*}}/bin/hexagon-ld"
+// CHECK014: "-static"
+// CHECK014: "{{.*}}/hexagon/lib/v4/crt0_standalone.o"
+// CHECK014: "{{.*}}/hexagon/lib/v4/crt0.o"
+// CHECK014: "{{.*}}/hexagon/lib/v4/init.o"
+// CHECK014: "-L{{.*}}/lib/gcc/hexagon/4.4.0/v4"
+// CHECK014: "-L{{.*}}/lib/gcc/hexagon/4.4.0"
+// CHECK014: "-L{{.*}}/lib/gcc"
+// CHECK014: "-L{{.*}}/hexagon/lib/v4"
+// CHECK014: "-L{{.*}}/hexagon/lib"
+// CHECK014: "{{[^"]+}}.o"
+// CHECK014: "--start-group" "-lstandalone" "-lc" "-lgcc" "--end-group"
+// CHECK014: "{{.*}}/hexagon/lib/v4/fini.o"
+
+// RUN: %clang -### -target hexagon-unknown-elf \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: -shared \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK015 %s
+// CHECK015: "{{.*}}clang{{.*}}" "-cc1"
+// CHECK015-NEXT: "{{.*}}/bin/hexagon-as"{{.*}}
+// CHECK015-NEXT: "{{.*}}/bin/hexagon-ld"
+// CHECK015: "-shared" "-call_shared"
+// CHECK015-NOT: crt0_standalone.o
+// CHECK015-NOT: crt0.o
+// CHECK015: "{{.*}}/hexagon/lib/v4/G0/initS.o"
+// CHECK015: "-L{{.*}}/lib/gcc/hexagon/4.4.0/v4/G0"
+// CHECK015: "-L{{.*}}/lib/gcc/hexagon/4.4.0/G0"
+// CHECK015: "-L{{.*}}/lib/gcc/hexagon/4.4.0/v4"
+// CHECK015: "-L{{.*}}/lib/gcc/hexagon/4.4.0"
+// CHECK015: "-L{{.*}}/lib/gcc"
+// CHECK015: "-L{{.*}}/hexagon/lib/v4/G0"
+// CHECK015: "-L{{.*}}/hexagon/lib/G0"
+// CHECK015: "-L{{.*}}/hexagon/lib/v4"
+// CHECK015: "-L{{.*}}/hexagon/lib"
+// CHECK015: "{{[^"]+}}.o"
+// CHECK015: "--start-group"
+// CHECK015-NOT: "-lstandalone"
+// CHECK015-NOT: "-lc"
+// CHECK015: "-lgcc"
+// CHECK015: "--end-group"
+// CHECK015: "{{.*}}/hexagon/lib/v4/G0/finiS.o"
+
+// RUN: %clang -### -target hexagon-unknown-elf \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: -shared \
+// RUN: -static \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK016 %s
+// CHECK016: "{{.*}}clang{{.*}}" "-cc1"
+// CHECK016-NEXT: "{{.*}}/bin/hexagon-as"{{.*}}
+// CHECK016-NEXT: "{{.*}}/bin/hexagon-ld"
+// CHECK016: "-shared" "-call_shared" "-static"
+// CHECK016-NOT: crt0_standalone.o
+// CHECK016-NOT: crt0.o
+// CHECK016: "{{.*}}/hexagon/lib/v4/G0/init.o"
+// CHECK016: "-L{{.*}}/lib/gcc/hexagon/4.4.0/v4/G0"
+// CHECK016: "-L{{.*}}/lib/gcc/hexagon/4.4.0/G0"
+// CHECK016: "-L{{.*}}/lib/gcc/hexagon/4.4.0/v4"
+// CHECK016: "-L{{.*}}/lib/gcc/hexagon/4.4.0"
+// CHECK016: "-L{{.*}}/lib/gcc"
+// CHECK016: "-L{{.*}}/hexagon/lib/v4/G0"
+// CHECK016: "-L{{.*}}/hexagon/lib/G0"
+// CHECK016: "-L{{.*}}/hexagon/lib/v4"
+// CHECK016: "-L{{.*}}/hexagon/lib"
+// CHECK016: "{{[^"]+}}.o"
+// CHECK016: "--start-group"
+// CHECK016-NOT: "-lstandalone"
+// CHECK016-NOT: "-lc"
+// CHECK016: "-lgcc"
+// CHECK016: "--end-group"
+// CHECK016: "{{.*}}/hexagon/lib/v4/G0/fini.o"
+
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+// -nostdlib, -nostartfiles, -nodefaultlibs
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+// RUN: %clang -ccc-cxx -x c++ -### -target hexagon-unknown-elf \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: -nostdlib \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK017 %s
+// CHECK017: "{{.*}}clang{{.*}}" "-cc1"
+// CHECK017-NEXT: "{{.*}}/bin/hexagon-as"{{.*}}
+// CHECK017-NEXT: "{{.*}}/bin/hexagon-ld"
+// CHECK017-NOT: crt0_standalone.o
+// CHECK017-NOT: crt0.o
+// CHECK017-NOT: init.o
+// CHECK017: "-L{{.*}}/lib/gcc/hexagon/4.4.0/v4"
+// CHECK017: "-L{{.*}}/lib/gcc/hexagon/4.4.0"
+// CHECK017: "-L{{.*}}/lib/gcc"
+// CHECK017: "-L{{.*}}/hexagon/lib/v4"
+// CHECK017: "-L{{.*}}/hexagon/lib"
+// CHECK017: "{{[^"]+}}.o"
+// CHECK017-NOT: "-lstdc++"
+// CHECK017-NOT: "-lm"
+// CHECK017-NOT: "--start-group"
+// CHECK017-NOT: "-lstandalone"
+// CHECK017-NOT: "-lc"
+// CHECK017-NOT: "-lgcc"
+// CHECK017-NOT: "--end-group"
+// CHECK017-NOT: fini.o
+
+// RUN: %clang -ccc-cxx -x c++ -### -target hexagon-unknown-elf \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: -nostartfiles \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK018 %s
+// CHECK018: "{{.*}}clang{{.*}}" "-cc1"
+// CHECK018-NEXT: "{{.*}}/bin/hexagon-as"{{.*}}
+// CHECK018-NEXT: "{{.*}}/bin/hexagon-ld"
+// CHECK018-NOT: crt0_standalone.o
+// CHECK018-NOT: crt0.o
+// CHECK018-NOT: init.o
+// CHECK018: "-L{{.*}}/lib/gcc/hexagon/4.4.0/v4"
+// CHECK018: "-L{{.*}}/lib/gcc/hexagon/4.4.0"
+// CHECK018: "-L{{.*}}/lib/gcc"
+// CHECK018: "-L{{.*}}/hexagon/lib/v4"
+// CHECK018: "-L{{.*}}/hexagon/lib"
+// CHECK018: "{{[^"]+}}.o"
+// CHECK018: "-lstdc++"
+// CHECK018: "-lm"
+// CHECK018: "--start-group"
+// CHECK018: "-lstandalone"
+// CHECK018: "-lc"
+// CHECK018: "-lgcc"
+// CHECK018: "--end-group"
+// CHECK018-NOT: fini.o
+
+// RUN: %clang -ccc-cxx -x c++ -### -target hexagon-unknown-elf \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: -nodefaultlibs \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK019 %s
+// CHECK019: "{{.*}}clang{{.*}}" "-cc1"
+// CHECK019-NEXT: "{{.*}}/bin/hexagon-as"{{.*}}
+// CHECK019-NEXT: "{{.*}}/bin/hexagon-ld"
+// CHECK019: "{{.*}}/hexagon/lib/v4/crt0_standalone.o"
+// CHECK019: "{{.*}}/hexagon/lib/v4/crt0.o"
+// CHECK019: "{{.*}}/hexagon/lib/v4/init.o"
+// CHECK019: "-L{{.*}}/lib/gcc/hexagon/4.4.0/v4"
+// CHECK019: "-L{{.*}}/lib/gcc/hexagon/4.4.0"
+// CHECK019: "-L{{.*}}/lib/gcc"
+// CHECK019: "-L{{.*}}/hexagon/lib/v4"
+// CHECK019: "-L{{.*}}/hexagon/lib"
+// CHECK019: "{{[^"]+}}.o"
+// CHECK019-NOT: "-lstdc++"
+// CHECK019-NOT: "-lm"
+// CHECK019-NOT: "--start-group"
+// CHECK019-NOT: "-lstandalone"
+// CHECK019-NOT: "-lc"
+// CHECK019-NOT: "-lgcc"
+// CHECK019-NOT: "--end-group"
+// CHECK019: "{{.*}}/hexagon/lib/v4/fini.o"
+
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+// -moslib
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+// RUN: %clang -### -target hexagon-unknown-elf \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: -moslib=first -moslib=second \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK020 %s
+// CHECK020: "{{.*}}clang{{.*}}" "-cc1"
+// CHECK020-NEXT: "{{.*}}/bin/hexagon-as"{{.*}}
+// CHECK020-NEXT: "{{.*}}/bin/hexagon-ld"
+// CHECK020-NOT: "-static"
+// CHECK020-NOT: "-shared"
+// CHECK020-NOT: crt0_standalone.o
+// CHECK020: "{{.*}}/hexagon/lib/v4/crt0.o"
+// CHECK020: "{{.*}}/hexagon/lib/v4/init.o"
+// CHECK020: "-L{{.*}}/lib/gcc/hexagon/4.4.0/v4"
+// CHECK020: "-L{{.*}}/lib/gcc/hexagon/4.4.0"
+// CHECK020: "-L{{.*}}/lib/gcc"
+// CHECK020: "-L{{.*}}/hexagon/lib/v4"
+// CHECK020: "-L{{.*}}/hexagon/lib"
+// CHECK020: "{{[^"]+}}.o"
+// CHECK020: "--start-group"
+// CHECK020: "-lfirst" "-lsecond"
+// CHECK020-NOT: "-lstandalone"
+// CHECK020: "-lc" "-lgcc" "--end-group"
+// CHECK020: "{{.*}}/hexagon/lib/v4/fini.o"
+
+// RUN: %clang -### -target hexagon-unknown-elf \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: -moslib=first -moslib=second -moslib=standalone\
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK021 %s
+// CHECK021: "{{.*}}clang{{.*}}" "-cc1"
+// CHECK021-NEXT: "{{.*}}/bin/hexagon-as"{{.*}}
+// CHECK021-NEXT: "{{.*}}/bin/hexagon-ld"
+// CHECK021-NOT: "-static"
+// CHECK021-NOT: "-shared"
+// CHECK021: "{{.*}}/hexagon/lib/v4/crt0_standalone.o"
+// CHECK021: "{{.*}}/hexagon/lib/v4/crt0.o"
+// CHECK021: "{{.*}}/hexagon/lib/v4/init.o"
+// CHECK021: "-L{{.*}}/lib/gcc/hexagon/4.4.0/v4"
+// CHECK021: "-L{{.*}}/lib/gcc/hexagon/4.4.0"
+// CHECK021: "-L{{.*}}/lib/gcc"
+// CHECK021: "-L{{.*}}/hexagon/lib/v4"
+// CHECK021: "-L{{.*}}/hexagon/lib"
+// CHECK021: "{{[^"]+}}.o"
+// CHECK021: "--start-group"
+// CHECK021: "-lfirst" "-lsecond"
+// CHECK021: "-lstandalone"
+// CHECK021: "-lc" "-lgcc" "--end-group"
+// CHECK021: "{{.*}}/hexagon/lib/v4/fini.o"
+
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+// Other args to pass to linker
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+// RUN: %clang -ccc-cxx -x c++ -### -target hexagon-unknown-elf \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: -s \
+// RUN: -Tbss 0xdead -Tdata 0xbeef -Ttext 0xcafe \
+// RUN: -t \
+// RUN: -e start_here \
+// RUN: -uFoo -undefined Bar \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK022 %s
+// CHECK022: "{{.*}}clang{{.*}}" "-cc1"
+// CHECK022-NEXT: "{{.*}}/bin/hexagon-as"{{.*}}
+// CHECK022-NEXT: "{{.*}}/bin/hexagon-ld"
+// CHECK022: "{{.*}}/hexagon/lib/v4/crt0_standalone.o"
+// CHECK022: "{{.*}}/hexagon/lib/v4/crt0.o"
+// CHECK022: "{{.*}}/hexagon/lib/v4/init.o"
+// CHECK022: "-L{{.*}}/lib/gcc/hexagon/4.4.0/v4"
+// CHECK022: "-L{{.*}}/lib/gcc/hexagon/4.4.0"
+// CHECK022: "-L{{.*}}/lib/gcc"
+// CHECK022: "-L{{.*}}/hexagon/lib/v4"
+// CHECK022: "-L{{.*}}/hexagon/lib"
+// CHECK022: "-Tbss" "0xdead" "-Tdata" "0xbeef" "-Ttext" "0xcafe"
+// CHECK022: "-s"
+// CHECK022: "-t"
+// CHECK022: "-u" "Foo" "-undefined" "Bar"
+// CHECK022: "{{[^"]+}}.o"
+// CHECK022: "-lstdc++" "-lm"
+// CHECK022: "--start-group" "-lstandalone" "-lc" "-lgcc" "--end-group"
+// CHECK022: "{{.*}}/hexagon/lib/v4/fini.o"
+
+// -----------------------------------------------------------------------------
+// pic, small data threshold
+// -----------------------------------------------------------------------------
+// RUN: %clang -### -target hexagon-unknown-elf \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK023 %s
+// CHECK023: "{{.*}}clang{{.*}}" "-cc1"
+// CHECK023: "-mrelocation-model" "static"
+// CHECK023-NEXT: "{{.*}}/bin/hexagon-as"
+// CHECK023-NOT: "-G{{[0-9]+}}"
+// CHECK023-NEXT: "{{.*}}/bin/hexagon-ld"
+// CHECK023-NOT: "-G{{[0-9]+}}"
+
+// RUN: %clang -### -target hexagon-unknown-elf \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: -fpic \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK024 %s
+// RUN: %clang -### -target hexagon-unknown-elf \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: -fPIC \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK024 %s
+// RUN: %clang -### -target hexagon-unknown-elf \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: -fPIC \
+// RUN: -msmall_data_threshold=8 \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK024 %s
+// CHECK024: "{{.*}}clang{{.*}}" "-cc1"
+// CHECK024-NOT: "-mrelocation-model" "static"
+// CHECK024: "-pic-level" "{{[12]}}"
+// CHECK024: "-mllvm" "-hexagon-small-data-threshold=0"
+// CHECK024-NEXT: "{{.*}}/bin/hexagon-as"
+// CHECK024: "-G0"
+// CHECK024-NEXT: "{{.*}}/bin/hexagon-ld"
+// CHECK024: "-G0"
+
+// RUN: %clang -### -target hexagon-unknown-elf \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: -G=8 \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK025 %s
+// RUN: %clang -### -target hexagon-unknown-elf \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: -G 8 \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK025 %s
+// RUN: %clang -### -target hexagon-unknown-elf \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: -msmall-data-threshold=8 \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK025 %s
+// CHECK025: "{{.*}}clang{{.*}}" "-cc1"
+// CHECK025: "-mrelocation-model" "static"
+// CHECK025: "-mllvm" "-hexagon-small-data-threshold=8"
+// CHECK025-NEXT: "{{.*}}/bin/hexagon-as"
+// CHECK025: "-G8"
+// CHECK025-NEXT: "{{.*}}/bin/hexagon-ld"
+// CHECK025: "-G8"
+
+// -----------------------------------------------------------------------------
+// pie
+// -----------------------------------------------------------------------------
+// RUN: %clang -### -target hexagon-unknown-elf \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: -pie \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK026 %s
+// CHECK026: "{{.*}}clang{{.*}}" "-cc1"
+// CHECK026-NEXT: "{{.*}}/bin/hexagon-as"
+// CHECK026-NEXT: "{{.*}}/bin/hexagon-ld"
+// CHECK026: "-pie"
+
+// RUN: %clang -### -target hexagon-unknown-elf \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: -pie -shared \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK027 %s
+// CHECK027: "{{.*}}clang{{.*}}" "-cc1"
+// CHECK027-NEXT: "{{.*}}/bin/hexagon-as"
+// CHECK027-NEXT: "{{.*}}/bin/hexagon-ld"
+// CHECK027-NOT: "-pie"
+
+// -----------------------------------------------------------------------------
+// Misc Defaults
+// -----------------------------------------------------------------------------
+// RUN: %clang -### -target hexagon-unknown-elf \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK028 %s
+// CHECK028: "{{.*}}clang{{.*}}" "-cc1"
+// CHECK028: "-mqdsp6-compat"
+// CHECK028: "-Wreturn-type"
+// CHECK028-NEXT: "{{.*}}/bin/hexagon-as"
+// CHECK028-NEXT: "{{.*}}/bin/hexagon-ld"
+
+// -----------------------------------------------------------------------------
+// Test Assembler related args
+// -----------------------------------------------------------------------------
+// RUN: %clang -### -target hexagon-unknown-elf \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: -gdwarf-2 \
+// RUN: -Wa,--noexecstack,--trap \
+// RUN: -Xassembler --keep-locals \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK029 %s
+// CHECK029: "{{.*}}clang{{.*}}" "-cc1"
+// CHECK029-NEXT: "{{.*}}/bin/hexagon-as"
+// CHECK029: "-gdwarf-2" "--noexecstack" "--trap" "--keep-locals"
+// CHECK029-NEXT: "{{.*}}/bin/hexagon-ld"
diff --git a/test/Driver/hexagon-toolchain.c b/test/Driver/hexagon-toolchain.c
new file mode 100644
index 000000000000..bfa627c421b4
--- /dev/null
+++ b/test/Driver/hexagon-toolchain.c
@@ -0,0 +1,564 @@
+// REQUIRES: hexagon-registered-target
+
+// -----------------------------------------------------------------------------
+// Test standard include paths
+// -----------------------------------------------------------------------------
+
+// RUN: %clang -### -target hexagon-unknown-linux \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK001 %s
+// CHECK001: "-cc1" {{.*}} "-internal-externc-isystem" "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/lib/gcc/hexagon/4.4.0/include"
+// CHECK001: "-internal-externc-isystem" "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/lib/gcc/hexagon/4.4.0/include-fixed"
+// CHECK001: "-internal-externc-isystem" "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/hexagon/include"
+// CHECK001-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin/hexagon-as"
+
+// RUN: %clang -ccc-cxx -x c++ -### -target hexagon-unknown-linux \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK002 %s
+// CHECK002: "-cc1" {{.*}} "-internal-isystem" "[[INSTALL_DIR:.*]]/Inputs/hexagon_tree/qc/bin/../../gnu/hexagon/include/c++/4.4.0"
+// CHECK002: "-internal-externc-isystem" "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/lib/gcc/hexagon/4.4.0/include"
+// CHECK002: "-internal-externc-isystem" "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/lib/gcc/hexagon/4.4.0/include-fixed"
+// CHECK002: "-internal-externc-isystem" "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/hexagon/include"
+// CHECK002-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin/hexagon-as"
+
+// -----------------------------------------------------------------------------
+// Test -nostdinc, -nostdlibinc, -nostdinc++
+// -----------------------------------------------------------------------------
+
+// RUN: %clang -### -target hexagon-unknown-linux \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: -nostdinc \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK003 %s
+// CHECK003: "-cc1"
+// CHECK003-NOT: "-internal-externc-isystem" "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/lib/gcc/hexagon/4.4.0/include"
+// CHECK003-NOT: "-internal-externc-isystem" "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/lib/gcc/hexagon/4.4.0/include-fixed"
+// CHECK003-NOT: "-internal-externc-isystem" "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/hexagon/include"
+// CHECK003-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin/hexagon-as"
+
+// RUN: %clang -### -target hexagon-unknown-linux \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: -nostdlibinc \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK004 %s
+// CHECK004: "-cc1"
+// CHECK004-NOT: "-internal-externc-isystem" "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/lib/gcc/hexagon/4.4.0/include"
+// CHECK004-NOT: "-internal-externc-isystem" "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/lib/gcc/hexagon/4.4.0/include-fixed"
+// CHECK004-NOT: "-internal-externc-isystem" "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/hexagon/include"
+// CHECK004-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin/hexagon-as"
+
+// RUN: %clang -ccc-cxx -x c++ -### -target hexagon-unknown-linux \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: -nostdlibinc \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK005 %s
+// CHECK005: "-cc1"
+// CHECK005-NOT: "-internal-isystem" "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/hexagon/include/c++/4.4.0"
+// CHECK005-NOT: "-internal-externc-isystem" "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/lib/gcc/hexagon/4.4.0/include"
+// CHECK005-NOT: "-internal-externc-isystem" "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/lib/gcc/hexagon/4.4.0/include-fixed"
+// CHECK005-NOT: "-internal-externc-isystem" "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/hexagon/include"
+// CHECK005-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin/hexagon-as"
+
+// RUN: %clang -ccc-cxx -x c++ -### -target hexagon-unknown-linux \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: -nostdinc++ \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK006 %s
+// CHECK006: "-cc1"
+// CHECK006-NOT: "-internal-isystem" "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/hexagon/include/c++/4.4.0"
+// CHECK006-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin/hexagon-as"
+
+// -----------------------------------------------------------------------------
+// Test -march=<archname> -mcpu=<archname> -mv<number>
+// -----------------------------------------------------------------------------
+// RUN: %clang -### -target hexagon-unknown-linux \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: -march=hexagonv3 \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK007 %s
+// CHECK007: "-cc1" {{.*}} "-target-cpu" "hexagonv3"
+// CHECK007-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin/hexagon-as"{{.*}} "-march=v3"
+// CHECK007-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin/hexagon-ld"{{.*}} "-mv3"
+
+// RUN: %clang -### -target hexagon-unknown-linux \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: -mcpu=hexagonv5 \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK008 %s
+// CHECK008: "-cc1" {{.*}} "-target-cpu" "hexagonv5"
+// CHECK008-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin/hexagon-as"{{.*}} "-march=v5"
+// CHECK008-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin/hexagon-ld"{{.*}} "-mv5"
+
+// RUN: %clang -### -target hexagon-unknown-linux \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: -mv2 \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK009 %s
+// CHECK009: "-cc1" {{.*}} "-target-cpu" "hexagonv2"
+// CHECK009-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin/hexagon-as"{{.*}} "-march=v2"
+// CHECK009-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin/hexagon-ld"{{.*}} "-mv2"
+
+// RUN: %clang -### -target hexagon-unknown-linux \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK010 %s
+// CHECK010: "-cc1" {{.*}} "-target-cpu" "hexagonv4"
+// CHECK010-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin/hexagon-as"{{.*}} "-march=v4"
+// CHECK010-NEXT: "{{.*}}/Inputs/hexagon_tree/qc/bin/../../gnu/bin/hexagon-ld"{{.*}} "-mv4"
+
+// RUN: %clang -march=hexagonv2 -target hexagon-unknown-linux \
+// RUN: %s 2>&1 | FileCheck -check-prefix=CHECK-UNKNOWN-V2 %s
+// RUN: %clang -mcpu=hexagonv2 -target hexagon-unknown-linux \
+// RUN: %s 2>&1 | FileCheck -check-prefix=CHECK-UNKNOWN-V2 %s
+// RUN: %clang -mv2 -target hexagon-unknown-linux \
+// RUN: %s 2>&1 | FileCheck -check-prefix=CHECK-UNKNOWN-V2 %s
+// CHECK-UNKNOWN-V2: error: unknown target CPU 'hexagonv2'
+
+// RUN: %clang -march=hexagonv3 -target hexagon-unknown-linux \
+// RUN: %s 2>&1 | FileCheck -check-prefix=CHECK-UNKNOWN-V3 %s
+// RUN: %clang -mcpu=hexagonv3 -target hexagon-unknown-linux \
+// RUN: %s 2>&1 | FileCheck -check-prefix=CHECK-UNKNOWN-V3 %s
+// RUN: %clang -mv3 -target hexagon-unknown-linux \
+// RUN: %s 2>&1 | FileCheck -check-prefix=CHECK-UNKNOWN-V3 %s
+// CHECK-UNKNOWN-V3: error: unknown target CPU 'hexagonv3'
+
+// -----------------------------------------------------------------------------
+// Test Linker related args
+// -----------------------------------------------------------------------------
+
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+// Defaults for C
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+// RUN: %clang -### -target hexagon-unknown-linux \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK011 %s
+// CHECK011: "{{.*}}clang{{.*}}" "-cc1"
+// CHECK011-NEXT: "{{.*}}/bin/hexagon-as"{{.*}}
+// CHECK011-NEXT: "{{.*}}/bin/hexagon-ld"
+// CHECK011-NOT: "-static"
+// CHECK011-NOT: "-shared"
+// CHECK011: "{{.*}}/hexagon/lib/v4/crt0_standalone.o"
+// CHECK011: "{{.*}}/hexagon/lib/v4/crt0.o"
+// CHECK011: "{{.*}}/hexagon/lib/v4/init.o"
+// CHECK011: "-L{{.*}}/lib/gcc/hexagon/4.4.0/v4"
+// CHECK011: "-L{{.*}}/lib/gcc/hexagon/4.4.0"
+// CHECK011: "-L{{.*}}/lib/gcc"
+// CHECK011: "-L{{.*}}/hexagon/lib/v4"
+// CHECK011: "-L{{.*}}/hexagon/lib"
+// CHECK011: "{{[^"]+}}.o"
+// CHECK011: "--start-group" "-lstandalone" "-lc" "-lgcc" "--end-group"
+// CHECK011: "{{.*}}/hexagon/lib/v4/fini.o"
+
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+// Defaults for C++
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+// RUN: %clang -ccc-cxx -x c++ -### -target hexagon-unknown-linux \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK012 %s
+// CHECK012: "{{.*}}clang{{.*}}" "-cc1"
+// CHECK012-NEXT: "{{.*}}/bin/hexagon-as"{{.*}}
+// CHECK012-NEXT: "{{.*}}/bin/hexagon-ld"
+// CHECK012-NOT: "-static"
+// CHECK012-NOT: "-shared"
+// CHECK012: "{{.*}}/hexagon/lib/v4/crt0_standalone.o"
+// CHECK012: "{{.*}}/hexagon/lib/v4/crt0.o"
+// CHECK012: "{{.*}}/hexagon/lib/v4/init.o"
+// CHECK012: "-L{{.*}}/lib/gcc/hexagon/4.4.0/v4"
+// CHECK012: "-L{{.*}}/lib/gcc/hexagon/4.4.0"
+// CHECK012: "-L{{.*}}/lib/gcc"
+// CHECK012: "-L{{.*}}/hexagon/lib/v4"
+// CHECK012: "-L{{.*}}/hexagon/lib"
+// CHECK012: "{{[^"]+}}.o"
+// CHECK012: "-lstdc++" "-lm"
+// CHECK012: "--start-group" "-lstandalone" "-lc" "-lgcc" "--end-group"
+// CHECK012: "{{.*}}/hexagon/lib/v4/fini.o"
+
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+// Additional Libraries (-L)
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+// RUN: %clang -### -target hexagon-unknown-linux \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: -Lone -L two -L three \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK013 %s
+// CHECK013: "{{.*}}clang{{.*}}" "-cc1"
+// CHECK013-NEXT: "{{.*}}/bin/hexagon-as"{{.*}}
+// CHECK013-NEXT: "{{.*}}/bin/hexagon-ld"
+// CHECK013: "{{.*}}/hexagon/lib/v4/crt0_standalone.o"
+// CHECK013: "{{.*}}/hexagon/lib/v4/crt0.o"
+// CHECK013: "{{.*}}/hexagon/lib/v4/init.o"
+// CHECK013: "-Lone" "-Ltwo" "-Lthree"
+// CHECK013: "-L{{.*}}/lib/gcc/hexagon/4.4.0/v4"
+// CHECK013: "-L{{.*}}/lib/gcc/hexagon/4.4.0"
+// CHECK013: "-L{{.*}}/lib/gcc"
+// CHECK013: "-L{{.*}}/hexagon/lib/v4"
+// CHECK013: "-L{{.*}}/hexagon/lib"
+// CHECK013: "{{[^"]+}}.o"
+// CHECK013: "--start-group" "-lstandalone" "-lc" "-lgcc" "--end-group"
+// CHECK013: "{{.*}}/hexagon/lib/v4/fini.o"
+
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+// -static, -shared
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+// RUN: %clang -### -target hexagon-unknown-linux \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: -static \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK014 %s
+// CHECK014: "{{.*}}clang{{.*}}" "-cc1"
+// CHECK014-NEXT: "{{.*}}/bin/hexagon-as"{{.*}}
+// CHECK014-NEXT: "{{.*}}/bin/hexagon-ld"
+// CHECK014: "-static"
+// CHECK014: "{{.*}}/hexagon/lib/v4/crt0_standalone.o"
+// CHECK014: "{{.*}}/hexagon/lib/v4/crt0.o"
+// CHECK014: "{{.*}}/hexagon/lib/v4/init.o"
+// CHECK014: "-L{{.*}}/lib/gcc/hexagon/4.4.0/v4"
+// CHECK014: "-L{{.*}}/lib/gcc/hexagon/4.4.0"
+// CHECK014: "-L{{.*}}/lib/gcc"
+// CHECK014: "-L{{.*}}/hexagon/lib/v4"
+// CHECK014: "-L{{.*}}/hexagon/lib"
+// CHECK014: "{{[^"]+}}.o"
+// CHECK014: "--start-group" "-lstandalone" "-lc" "-lgcc" "--end-group"
+// CHECK014: "{{.*}}/hexagon/lib/v4/fini.o"
+
+// RUN: %clang -### -target hexagon-unknown-linux \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: -shared \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK015 %s
+// CHECK015: "{{.*}}clang{{.*}}" "-cc1"
+// CHECK015-NEXT: "{{.*}}/bin/hexagon-as"{{.*}}
+// CHECK015-NEXT: "{{.*}}/bin/hexagon-ld"
+// CHECK015: "-shared" "-call_shared"
+// CHECK015-NOT: crt0_standalone.o
+// CHECK015-NOT: crt0.o
+// CHECK015: "{{.*}}/hexagon/lib/v4/G0/initS.o"
+// CHECK015: "-L{{.*}}/lib/gcc/hexagon/4.4.0/v4/G0"
+// CHECK015: "-L{{.*}}/lib/gcc/hexagon/4.4.0/G0"
+// CHECK015: "-L{{.*}}/lib/gcc/hexagon/4.4.0/v4"
+// CHECK015: "-L{{.*}}/lib/gcc/hexagon/4.4.0"
+// CHECK015: "-L{{.*}}/lib/gcc"
+// CHECK015: "-L{{.*}}/hexagon/lib/v4/G0"
+// CHECK015: "-L{{.*}}/hexagon/lib/G0"
+// CHECK015: "-L{{.*}}/hexagon/lib/v4"
+// CHECK015: "-L{{.*}}/hexagon/lib"
+// CHECK015: "{{[^"]+}}.o"
+// CHECK015: "--start-group"
+// CHECK015-NOT: "-lstandalone"
+// CHECK015-NOT: "-lc"
+// CHECK015: "-lgcc"
+// CHECK015: "--end-group"
+// CHECK015: "{{.*}}/hexagon/lib/v4/G0/finiS.o"
+
+// RUN: %clang -### -target hexagon-unknown-linux \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: -shared \
+// RUN: -static \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK016 %s
+// CHECK016: "{{.*}}clang{{.*}}" "-cc1"
+// CHECK016-NEXT: "{{.*}}/bin/hexagon-as"{{.*}}
+// CHECK016-NEXT: "{{.*}}/bin/hexagon-ld"
+// CHECK016: "-shared" "-call_shared" "-static"
+// CHECK016-NOT: crt0_standalone.o
+// CHECK016-NOT: crt0.o
+// CHECK016: "{{.*}}/hexagon/lib/v4/G0/init.o"
+// CHECK016: "-L{{.*}}/lib/gcc/hexagon/4.4.0/v4/G0"
+// CHECK016: "-L{{.*}}/lib/gcc/hexagon/4.4.0/G0"
+// CHECK016: "-L{{.*}}/lib/gcc/hexagon/4.4.0/v4"
+// CHECK016: "-L{{.*}}/lib/gcc/hexagon/4.4.0"
+// CHECK016: "-L{{.*}}/lib/gcc"
+// CHECK016: "-L{{.*}}/hexagon/lib/v4/G0"
+// CHECK016: "-L{{.*}}/hexagon/lib/G0"
+// CHECK016: "-L{{.*}}/hexagon/lib/v4"
+// CHECK016: "-L{{.*}}/hexagon/lib"
+// CHECK016: "{{[^"]+}}.o"
+// CHECK016: "--start-group"
+// CHECK016-NOT: "-lstandalone"
+// CHECK016-NOT: "-lc"
+// CHECK016: "-lgcc"
+// CHECK016: "--end-group"
+// CHECK016: "{{.*}}/hexagon/lib/v4/G0/fini.o"
+
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+// -nostdlib, -nostartfiles, -nodefaultlibs
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+// RUN: %clang -ccc-cxx -x c++ -### -target hexagon-unknown-linux \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: -nostdlib \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK017 %s
+// CHECK017: "{{.*}}clang{{.*}}" "-cc1"
+// CHECK017-NEXT: "{{.*}}/bin/hexagon-as"{{.*}}
+// CHECK017-NEXT: "{{.*}}/bin/hexagon-ld"
+// CHECK017-NOT: crt0_standalone.o
+// CHECK017-NOT: crt0.o
+// CHECK017-NOT: init.o
+// CHECK017: "-L{{.*}}/lib/gcc/hexagon/4.4.0/v4"
+// CHECK017: "-L{{.*}}/lib/gcc/hexagon/4.4.0"
+// CHECK017: "-L{{.*}}/lib/gcc"
+// CHECK017: "-L{{.*}}/hexagon/lib/v4"
+// CHECK017: "-L{{.*}}/hexagon/lib"
+// CHECK017: "{{[^"]+}}.o"
+// CHECK017-NOT: "-lstdc++"
+// CHECK017-NOT: "-lm"
+// CHECK017-NOT: "--start-group"
+// CHECK017-NOT: "-lstandalone"
+// CHECK017-NOT: "-lc"
+// CHECK017-NOT: "-lgcc"
+// CHECK017-NOT: "--end-group"
+// CHECK017-NOT: fini.o
+
+// RUN: %clang -ccc-cxx -x c++ -### -target hexagon-unknown-linux \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: -nostartfiles \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK018 %s
+// CHECK018: "{{.*}}clang{{.*}}" "-cc1"
+// CHECK018-NEXT: "{{.*}}/bin/hexagon-as"{{.*}}
+// CHECK018-NEXT: "{{.*}}/bin/hexagon-ld"
+// CHECK018-NOT: crt0_standalone.o
+// CHECK018-NOT: crt0.o
+// CHECK018-NOT: init.o
+// CHECK018: "-L{{.*}}/lib/gcc/hexagon/4.4.0/v4"
+// CHECK018: "-L{{.*}}/lib/gcc/hexagon/4.4.0"
+// CHECK018: "-L{{.*}}/lib/gcc"
+// CHECK018: "-L{{.*}}/hexagon/lib/v4"
+// CHECK018: "-L{{.*}}/hexagon/lib"
+// CHECK018: "{{[^"]+}}.o"
+// CHECK018: "-lstdc++"
+// CHECK018: "-lm"
+// CHECK018: "--start-group"
+// CHECK018: "-lstandalone"
+// CHECK018: "-lc"
+// CHECK018: "-lgcc"
+// CHECK018: "--end-group"
+// CHECK018-NOT: fini.o
+
+// RUN: %clang -ccc-cxx -x c++ -### -target hexagon-unknown-linux \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: -nodefaultlibs \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK019 %s
+// CHECK019: "{{.*}}clang{{.*}}" "-cc1"
+// CHECK019-NEXT: "{{.*}}/bin/hexagon-as"{{.*}}
+// CHECK019-NEXT: "{{.*}}/bin/hexagon-ld"
+// CHECK019: "{{.*}}/hexagon/lib/v4/crt0_standalone.o"
+// CHECK019: "{{.*}}/hexagon/lib/v4/crt0.o"
+// CHECK019: "{{.*}}/hexagon/lib/v4/init.o"
+// CHECK019: "-L{{.*}}/lib/gcc/hexagon/4.4.0/v4"
+// CHECK019: "-L{{.*}}/lib/gcc/hexagon/4.4.0"
+// CHECK019: "-L{{.*}}/lib/gcc"
+// CHECK019: "-L{{.*}}/hexagon/lib/v4"
+// CHECK019: "-L{{.*}}/hexagon/lib"
+// CHECK019: "{{[^"]+}}.o"
+// CHECK019-NOT: "-lstdc++"
+// CHECK019-NOT: "-lm"
+// CHECK019-NOT: "--start-group"
+// CHECK019-NOT: "-lstandalone"
+// CHECK019-NOT: "-lc"
+// CHECK019-NOT: "-lgcc"
+// CHECK019-NOT: "--end-group"
+// CHECK019: "{{.*}}/hexagon/lib/v4/fini.o"
+
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+// -moslib
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+// RUN: %clang -### -target hexagon-unknown-linux \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: -moslib=first -moslib=second \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK020 %s
+// CHECK020: "{{.*}}clang{{.*}}" "-cc1"
+// CHECK020-NEXT: "{{.*}}/bin/hexagon-as"{{.*}}
+// CHECK020-NEXT: "{{.*}}/bin/hexagon-ld"
+// CHECK020-NOT: "-static"
+// CHECK020-NOT: "-shared"
+// CHECK020-NOT: crt0_standalone.o
+// CHECK020: "{{.*}}/hexagon/lib/v4/crt0.o"
+// CHECK020: "{{.*}}/hexagon/lib/v4/init.o"
+// CHECK020: "-L{{.*}}/lib/gcc/hexagon/4.4.0/v4"
+// CHECK020: "-L{{.*}}/lib/gcc/hexagon/4.4.0"
+// CHECK020: "-L{{.*}}/lib/gcc"
+// CHECK020: "-L{{.*}}/hexagon/lib/v4"
+// CHECK020: "-L{{.*}}/hexagon/lib"
+// CHECK020: "{{[^"]+}}.o"
+// CHECK020: "--start-group"
+// CHECK020: "-lfirst" "-lsecond"
+// CHECK020-NOT: "-lstandalone"
+// CHECK020: "-lc" "-lgcc" "--end-group"
+// CHECK020: "{{.*}}/hexagon/lib/v4/fini.o"
+
+// RUN: %clang -### -target hexagon-unknown-linux \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: -moslib=first -moslib=second -moslib=standalone\
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK021 %s
+// CHECK021: "{{.*}}clang{{.*}}" "-cc1"
+// CHECK021-NEXT: "{{.*}}/bin/hexagon-as"{{.*}}
+// CHECK021-NEXT: "{{.*}}/bin/hexagon-ld"
+// CHECK021-NOT: "-static"
+// CHECK021-NOT: "-shared"
+// CHECK021: "{{.*}}/hexagon/lib/v4/crt0_standalone.o"
+// CHECK021: "{{.*}}/hexagon/lib/v4/crt0.o"
+// CHECK021: "{{.*}}/hexagon/lib/v4/init.o"
+// CHECK021: "-L{{.*}}/lib/gcc/hexagon/4.4.0/v4"
+// CHECK021: "-L{{.*}}/lib/gcc/hexagon/4.4.0"
+// CHECK021: "-L{{.*}}/lib/gcc"
+// CHECK021: "-L{{.*}}/hexagon/lib/v4"
+// CHECK021: "-L{{.*}}/hexagon/lib"
+// CHECK021: "{{[^"]+}}.o"
+// CHECK021: "--start-group"
+// CHECK021: "-lfirst" "-lsecond"
+// CHECK021: "-lstandalone"
+// CHECK021: "-lc" "-lgcc" "--end-group"
+// CHECK021: "{{.*}}/hexagon/lib/v4/fini.o"
+
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+// Other args to pass to linker
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+// RUN: %clang -ccc-cxx -x c++ -### -target hexagon-unknown-linux \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: -s \
+// RUN: -Tbss 0xdead -Tdata 0xbeef -Ttext 0xcafe \
+// RUN: -t \
+// RUN: -e start_here \
+// RUN: -uFoo -undefined Bar \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK022 %s
+// CHECK022: "{{.*}}clang{{.*}}" "-cc1"
+// CHECK022-NEXT: "{{.*}}/bin/hexagon-as"{{.*}}
+// CHECK022-NEXT: "{{.*}}/bin/hexagon-ld"
+// CHECK022: "{{.*}}/hexagon/lib/v4/crt0_standalone.o"
+// CHECK022: "{{.*}}/hexagon/lib/v4/crt0.o"
+// CHECK022: "{{.*}}/hexagon/lib/v4/init.o"
+// CHECK022: "-L{{.*}}/lib/gcc/hexagon/4.4.0/v4"
+// CHECK022: "-L{{.*}}/lib/gcc/hexagon/4.4.0"
+// CHECK022: "-L{{.*}}/lib/gcc"
+// CHECK022: "-L{{.*}}/hexagon/lib/v4"
+// CHECK022: "-L{{.*}}/hexagon/lib"
+// CHECK022: "-Tbss" "0xdead" "-Tdata" "0xbeef" "-Ttext" "0xcafe"
+// CHECK022: "-s"
+// CHECK022: "-t"
+// CHECK022: "-u" "Foo" "-undefined" "Bar"
+// CHECK022: "{{[^"]+}}.o"
+// CHECK022: "-lstdc++" "-lm"
+// CHECK022: "--start-group" "-lstandalone" "-lc" "-lgcc" "--end-group"
+// CHECK022: "{{.*}}/hexagon/lib/v4/fini.o"
+
+// -----------------------------------------------------------------------------
+// pic, small data threshold
+// -----------------------------------------------------------------------------
+// RUN: %clang -### -target hexagon-unknown-linux \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK023 %s
+// CHECK023: "{{.*}}clang{{.*}}" "-cc1"
+// CHECK023: "-mrelocation-model" "static"
+// CHECK023-NEXT: "{{.*}}/bin/hexagon-as"
+// CHECK023-NOT: "-G{{[0-9]+}}"
+// CHECK023-NEXT: "{{.*}}/bin/hexagon-ld"
+// CHECK023-NOT: "-G{{[0-9]+}}"
+
+// RUN: %clang -### -target hexagon-unknown-linux \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: -fpic \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK024 %s
+// RUN: %clang -### -target hexagon-unknown-linux \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: -fPIC \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK024 %s
+// RUN: %clang -### -target hexagon-unknown-linux \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: -fPIC \
+// RUN: -msmall_data_threshold=8 \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK024 %s
+// CHECK024: "{{.*}}clang{{.*}}" "-cc1"
+// CHECK024-NOT: "-mrelocation-model" "static"
+// CHECK024: "-pic-level" "{{[12]}}"
+// CHECK024: "-mllvm" "-hexagon-small-data-threshold=0"
+// CHECK024-NEXT: "{{.*}}/bin/hexagon-as"
+// CHECK024: "-G0"
+// CHECK024-NEXT: "{{.*}}/bin/hexagon-ld"
+// CHECK024: "-G0"
+
+// RUN: %clang -### -target hexagon-unknown-linux \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: -G=8 \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK025 %s
+// RUN: %clang -### -target hexagon-unknown-linux \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: -G 8 \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK025 %s
+// RUN: %clang -### -target hexagon-unknown-linux \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: -msmall-data-threshold=8 \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK025 %s
+// CHECK025: "{{.*}}clang{{.*}}" "-cc1"
+// CHECK025: "-mrelocation-model" "static"
+// CHECK025: "-mllvm" "-hexagon-small-data-threshold=8"
+// CHECK025-NEXT: "{{.*}}/bin/hexagon-as"
+// CHECK025: "-G8"
+// CHECK025-NEXT: "{{.*}}/bin/hexagon-ld"
+// CHECK025: "-G8"
+
+// -----------------------------------------------------------------------------
+// pie
+// -----------------------------------------------------------------------------
+// RUN: %clang -### -target hexagon-unknown-linux \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: -pie \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK026 %s
+// CHECK026: "{{.*}}clang{{.*}}" "-cc1"
+// CHECK026-NEXT: "{{.*}}/bin/hexagon-as"
+// CHECK026-NEXT: "{{.*}}/bin/hexagon-ld"
+// CHECK026: "-pie"
+
+// RUN: %clang -### -target hexagon-unknown-linux \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: -pie -shared \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK027 %s
+// CHECK027: "{{.*}}clang{{.*}}" "-cc1"
+// CHECK027-NEXT: "{{.*}}/bin/hexagon-as"
+// CHECK027-NEXT: "{{.*}}/bin/hexagon-ld"
+// CHECK027-NOT: "-pie"
+
+// -----------------------------------------------------------------------------
+// Misc Defaults
+// -----------------------------------------------------------------------------
+// RUN: %clang -### -target hexagon-unknown-linux \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK028 %s
+// CHECK028: "{{.*}}clang{{.*}}" "-cc1"
+// CHECK028: "-mqdsp6-compat"
+// CHECK028: "-Wreturn-type"
+// CHECK028-NEXT: "{{.*}}/bin/hexagon-as"
+// CHECK028-NEXT: "{{.*}}/bin/hexagon-ld"
+
+// -----------------------------------------------------------------------------
+// Test Assembler related args
+// -----------------------------------------------------------------------------
+// RUN: %clang -### -target hexagon-unknown-linux \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/qc/bin \
+// RUN: -gdwarf-2 \
+// RUN: -Wa,--noexecstack,--trap \
+// RUN: -Xassembler --keep-locals \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK029 %s
+// CHECK029: "{{.*}}clang{{.*}}" "-cc1"
+// CHECK029-NEXT: "{{.*}}/bin/hexagon-as"
+// CHECK029: "-gdwarf-2" "--noexecstack" "--trap" "--keep-locals"
+// CHECK029-NEXT: "{{.*}}/bin/hexagon-ld"
diff --git a/test/Driver/inhibit-downstream-commands.c b/test/Driver/inhibit-downstream-commands.c
new file mode 100644
index 000000000000..5e46708cfe89
--- /dev/null
+++ b/test/Driver/inhibit-downstream-commands.c
@@ -0,0 +1,6 @@
+// RUN: %clang -no-integrated-as %s 2>&1 | FileCheck %s
+// CHECK: error: unknown type name 'invalid'
+// CHECK-NOT: clang: error: assembler command failed
+// CHECK-NOT: clang: error: linker command failed
+// XFAIL: win32
+invalid C code!
diff --git a/test/Driver/integrated-as.c b/test/Driver/integrated-as.c
new file mode 100644
index 000000000000..2045e8b559c6
--- /dev/null
+++ b/test/Driver/integrated-as.c
@@ -0,0 +1,7 @@
+// RUN: %clang -### -c -save-temps -integrated-as %s 2>&1 | FileCheck %s
+
+// gcc is invoked instead of clang-cc1as with gcc-driver -save-temps.
+// REQUIRES: clang-driver
+
+// CHECK: cc1as
+// CHECK: -relax-all
diff --git a/test/Driver/integrated-as.s b/test/Driver/integrated-as.s
new file mode 100644
index 000000000000..d614418276b8
--- /dev/null
+++ b/test/Driver/integrated-as.s
@@ -0,0 +1,6 @@
+// RUN: %clang -### -c -integrated-as %s 2>&1 | FileCheck %s
+
+// REQUIRES: clang-driver
+
+// CHECK: cc1as
+// CHECK-NOT: -relax-all
diff --git a/test/Driver/linker-opts.c b/test/Driver/linker-opts.c
index 2a96a17c70d3..7668a7599076 100644
--- a/test/Driver/linker-opts.c
+++ b/test/Driver/linker-opts.c
@@ -2,4 +2,5 @@
// CHECK: "-L{{.*}}/test1"
// GCC driver is used as linker on cygming. It should be aware of LIBRARY_PATH.
-// XFAIL: cygwin,mingw32,win32
+// XFAIL: win32
+// REQUIRES: clang-driver
diff --git a/test/Driver/linux-header-search.cpp b/test/Driver/linux-header-search.cpp
index 065bd34566d7..d09f5b27ae9d 100644
--- a/test/Driver/linux-header-search.cpp
+++ b/test/Driver/linux-header-search.cpp
@@ -16,6 +16,34 @@
// CHECK-UBUNTU-11-04: "-internal-externc-isystem" "[[SYSROOT]]/include"
// CHECK-UBUNTU-11-04: "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
//
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
+// RUN: -target x86_64-unknown-linux-gnu \
+// RUN: --sysroot=%S/Inputs/ubuntu_13.04_multiarch_tree \
+// RUN: | FileCheck --check-prefix=CHECK-UBUNTU-13-04 %s
+// CHECK-UBUNTU-13-04: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
+// CHECK-UBUNTU-13-04: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-UBUNTU-13-04: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7"
+// CHECK-UBUNTU-13-04: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/backward"
+// CHECK-UBUNTU-13-04: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../include/x86_64-linux-gnu/c++/4.7"
+// CHECK-UBUNTU-13-04: "-internal-isystem" "[[SYSROOT]]/usr/local/include"
+// CHECK-UBUNTU-13-04: "-internal-isystem" "{{.*}}/lib{{(64|32)?}}/clang/{{[0-9]\.[0-9]}}/include"
+// CHECK-UBUNTU-13-04: "-internal-externc-isystem" "[[SYSROOT]]/usr/include/x86_64-linux-gnu"
+// CHECK-UBUNTU-13-04: "-internal-externc-isystem" "[[SYSROOT]]/include"
+// CHECK-UBUNTU-13-04: "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
+//
+// Test Ubuntu/Debian's new version of multiarch, with -m32.
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
+// RUN: -target x86_64-unknown-linux-gnu -m32 \
+// RUN: --sysroot=%S/Inputs/ubuntu_13.04_multiarch_tree \
+// RUN: | FileCheck --check-prefix=CHECK-UBUNTU-13-04-M32 %s
+// CHECK-UBUNTU-13-04-M32: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
+// CHECK-UBUNTU-13-04-M32: "-triple" "i386-unknown-linux-gnu"
+// CHECK-UBUNTU-13-04-M32: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-UBUNTU-13-04-M32: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7"
+// CHECK-UBUNTU-13-04-M32: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/x86_64-linux-gnu/32"
+// CHECK-UBUNTU-13-04-M32: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/backward"
+// CHECK-UBUNTU-13-04-M32: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../include/x86_64-linux-gnu/c++/4.7/32"
+//
// Thoroughly exercise the Debian multiarch environment.
// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
// RUN: -target i686-linux-gnu \
diff --git a/test/Driver/linux-ld.c b/test/Driver/linux-ld.c
index 72370297f40e..79282cbf4108 100644
--- a/test/Driver/linux-ld.c
+++ b/test/Driver/linux-ld.c
@@ -5,6 +5,7 @@
// RUN: -target i386-unknown-linux \
// RUN: --sysroot=%S/Inputs/basic_linux_tree \
// RUN: | FileCheck --check-prefix=CHECK-LD-32 %s
+// CHECK-LD-32-NOT: warning:
// CHECK-LD-32: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
// CHECK-LD-32: "{{.*}}/usr/lib/gcc/i386-unknown-linux/4.6.0/crtbegin.o"
// CHECK-LD-32: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0"
@@ -17,13 +18,66 @@
// RUN: -target x86_64-unknown-linux \
// RUN: --sysroot=%S/Inputs/basic_linux_tree \
// RUN: | FileCheck --check-prefix=CHECK-LD-64 %s
+// CHECK-LD-64-NOT: warning:
// CHECK-LD-64: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-LD-64: "--eh-frame-hdr"
+// CHECK-LD-64: "-m" "elf_x86_64"
+// CHECK-LD-64: "-dynamic-linker"
// CHECK-LD-64: "{{.*}}/usr/lib/gcc/x86_64-unknown-linux/4.6.0/crtbegin.o"
// CHECK-LD-64: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0"
// CHECK-LD-64: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../../../x86_64-unknown-linux/lib"
// CHECK-LD-64: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../.."
// CHECK-LD-64: "-L[[SYSROOT]]/lib"
// CHECK-LD-64: "-L[[SYSROOT]]/usr/lib"
+// CHECK-LD-64: "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed"
+// CHECK-LD-64: "-lc"
+// CHECK-LD-64: "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target x86_64-unknown-linux \
+// RUN: -static-libgcc \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN: | FileCheck --check-prefix=CHECK-LD-64-STATIC-LIBGCC %s
+// CHECK-LD-64-STATIC-LIBGCC-NOT: warning:
+// CHECK-LD-64-STATIC-LIBGCC: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-LD-64-STATIC-LIBGCC: "--eh-frame-hdr"
+// CHECK-LD-64-STATIC-LIBGCC: "-m" "elf_x86_64"
+// CHECK-LD-64-STATIC-LIBGCC: "-dynamic-linker"
+// CHECK-LD-64-STATIC-LIBGCC: "{{.*}}/usr/lib/gcc/x86_64-unknown-linux/4.6.0/crtbegin.o"
+// CHECK-LD-64-STATIC-LIBGCC: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0"
+// CHECK-LD-64-STATIC-LIBGCC: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../../../x86_64-unknown-linux/lib"
+// CHECK-LD-64-STATIC-LIBGCC: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../.."
+// CHECK-LD-64-STATIC-LIBGCC: "-L[[SYSROOT]]/lib"
+// CHECK-LD-64-STATIC-LIBGCC: "-L[[SYSROOT]]/usr/lib"
+// CHECK-LD-64-STATIC-LIBGCC: "-lgcc" "-lgcc_eh"
+// CHECK-LD-64-STATIC-LIBGCC: "-lc"
+// CHECK-LD-64-STATIC-LIBGCC: "-lgcc" "-lgcc_eh"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target x86_64-unknown-linux \
+// RUN: -static \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN: | FileCheck --check-prefix=CHECK-LD-64-STATIC %s
+// CHECK-LD-64-STATIC-NOT: warning:
+// CHECK-LD-64-STATIC: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-LD-64-STATIC-NOT: "--eh-frame-hdr"
+// CHECK-LD-64-STATIC: "-m" "elf_x86_64"
+// CHECK-LD-64-STATIC-NOT: "-dynamic-linker"
+// CHECK-LD-64-STATIC: "-static"
+// CHECK-LD-64-STATIC: "{{.*}}/usr/lib/gcc/x86_64-unknown-linux/4.6.0/crtbeginT.o"
+// CHECK-LD-64-STATIC: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0"
+// CHECK-LD-64-STATIC: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../../../x86_64-unknown-linux/lib"
+// CHECK-LD-64-STATIC: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../.."
+// CHECK-LD-64-STATIC: "-L[[SYSROOT]]/lib"
+// CHECK-LD-64-STATIC: "-L[[SYSROOT]]/usr/lib"
+// CHECK-LD-64-STATIC: "--start-group" "-lgcc" "-lgcc_eh" "-lc" "--end-group"
+//
+// Check that flags can be combined. The -static dominates.
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target x86_64-unknown-linux \
+// RUN: -static-libgcc -static \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN: | FileCheck --check-prefix=CHECK-LD-64-STATIC %s
//
// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
// RUN: -target i386-unknown-linux -m32 \
@@ -420,6 +474,7 @@
// CHECK-ANDROID: "-L[[SYSROOT]]/usr/lib"
// CHECK-ANDROID-NOT: "gcc_s"
// CHECK-ANDROID: "-lgcc"
+// CHECK-ANDROID: "-ldl"
// CHECK-ANDROID-NOT: "gcc_s"
// CHECK-ANDROID: "{{.*}}/crtend_android.o"
// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
@@ -448,6 +503,7 @@
// CHECK-ANDROID-SO: "-L[[SYSROOT]]/usr/lib"
// CHECK-ANDROID-SO-NOT: "gcc_s"
// CHECK-ANDROID-SO: "-lgcc"
+// CHECK-ANDROID-SO: "-ldl"
// CHECK-ANDROID-SO-NOT: "gcc_s"
// CHECK-ANDROID-SO: "{{.*}}/crtend_so.o"
// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
@@ -475,6 +531,7 @@
// CHECK-ANDROID-STATIC: "-L[[SYSROOT]]/usr/lib"
// CHECK-ANDROID-STATIC-NOT: "gcc_s"
// CHECK-ANDROID-STATIC: "-lgcc"
+// CHECK-ANDROID-STATIC-NOT: "-ldl"
// CHECK-ANDROID-STATIC-NOT: "gcc_s"
// CHECK-ANDROID-STATIC: "{{.*}}/crtend_android.o"
// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
diff --git a/test/Driver/lit.local.cfg b/test/Driver/lit.local.cfg
new file mode 100644
index 000000000000..a62ea1a09983
--- /dev/null
+++ b/test/Driver/lit.local.cfg
@@ -0,0 +1 @@
+config.suffixes = ['.c', '.cpp', '.h', '.m', '.mm', '.S', '.s']
diff --git a/test/Driver/mips-as.c b/test/Driver/mips-as.c
index fbaf62fdadd5..146b1930c618 100644
--- a/test/Driver/mips-as.c
+++ b/test/Driver/mips-as.c
@@ -16,8 +16,8 @@
//
// RUN: %clang -target mipsel-linux-gnu -### \
// RUN: -no-integrated-as -c %s 2>&1 \
-// RUN: | FileCheck -check-prefix=MIPS32-EL-AS %s
-// MIPS32-EL-AS: as{{(.exe)?}}" "-march" "mips32" "-mabi" "32" "-EL"
+// RUN: | FileCheck -check-prefix=MIPS32-DEF-EL-AS %s
+// MIPS32-DEF-EL-AS: as{{(.exe)?}}" "-march" "mips32" "-mabi" "32" "-EL"
//
// RUN: %clang -target mips64-linux-gnu -### \
// RUN: -no-integrated-as -c %s 2>&1 \
@@ -26,8 +26,8 @@
//
// RUN: %clang -target mips64el-linux-gnu -### \
// RUN: -no-integrated-as -c %s 2>&1 \
-// RUN: | FileCheck -check-prefix=MIPS64-EL-AS %s
-// MIPS64-EL-AS: as{{(.exe)?}}" "-march" "mips64" "-mabi" "64" "-EL"
+// RUN: | FileCheck -check-prefix=MIPS64-DEF-EL-AS %s
+// MIPS64-DEF-EL-AS: as{{(.exe)?}}" "-march" "mips64" "-mabi" "64" "-EL"
//
// RUN: %clang -target mips-linux-gnu -mabi=eabi -### \
// RUN: -no-integrated-as -c %s 2>&1 \
@@ -39,6 +39,16 @@
// RUN: | FileCheck -check-prefix=MIPS-N32 %s
// MIPS-N32: as{{(.exe)?}}" "-march" "mips64" "-mabi" "n32" "-EB"
//
+// RUN: %clang -target mipsel-linux-gnu -mabi=32 -### \
+// RUN: -no-integrated-as -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix=MIPS32-EL-AS %s
+// MIPS32-EL-AS: as{{(.exe)?}}" "-march" "mips32" "-mabi" "32" "-EL"
+//
+// RUN: %clang -target mips64el-linux-gnu -mabi=64 -### \
+// RUN: -no-integrated-as -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix=MIPS64-EL-AS %s
+// MIPS64-EL-AS: as{{(.exe)?}}" "-march" "mips64" "-mabi" "64" "-EL"
+//
// RUN: %clang -target mips-linux-gnu -march=mips32r2 -### \
// RUN: -no-integrated-as -c %s 2>&1 \
// RUN: | FileCheck -check-prefix=MIPS-32R2 %s
diff --git a/test/Driver/mips-eleb.c b/test/Driver/mips-eleb.c
new file mode 100644
index 000000000000..8afe44f51c9a
--- /dev/null
+++ b/test/Driver/mips-eleb.c
@@ -0,0 +1,31 @@
+// REQUIRES: mips-registered-target
+//
+// Check that -EL/-EB options adjust the toolchain flags.
+//
+// RUN: %clang -target mips-unknown-linux-gnu -### \
+// RUN: -EL -no-integrated-as %s 2>&1 \
+// RUN: | FileCheck -check-prefix=MIPS32-EL %s
+// MIPS32-EL: "{{.*}}clang{{.*}}" "-cc1" "-triple" "mipsel-unknown-linux-gnu"
+// MIPS32-EL: "{{.*}}as{{(.exe)?}}" "-march" "mips32" "-mabi" "32" "-EL"
+// MIPS32-EL: "{{.*}}ld{{(.exe)?}}" {{.*}} "-m" "elf32ltsmip"
+//
+// RUN: %clang -target mips64-unknown-linux-gnu -### \
+// RUN: -EL -no-integrated-as %s 2>&1 \
+// RUN: | FileCheck -check-prefix=MIPS64-EL %s
+// MIPS64-EL: "{{.*}}clang{{.*}}" "-cc1" "-triple" "mips64el-unknown-linux-gnu"
+// MIPS64-EL: "{{.*}}as{{(.exe)?}}" "-march" "mips64" "-mabi" "64" "-EL"
+// MIPS64-EL: "{{.*}}ld{{(.exe)?}}" {{.*}} "-m" "elf64ltsmip"
+//
+// RUN: %clang -target mipsel-unknown-linux-gnu -### \
+// RUN: -EB -no-integrated-as %s 2>&1 \
+// RUN: | FileCheck -check-prefix=MIPS32-EB %s
+// MIPS32-EB: "{{.*}}clang{{.*}}" "-cc1" "-triple" "mips-unknown-linux-gnu"
+// MIPS32-EB: "{{.*}}as{{(.exe)?}}" "-march" "mips32" "-mabi" "32" "-EB"
+// MIPS32-EB: "{{.*}}ld{{(.exe)?}}" {{.*}} "-m" "elf32btsmip"
+//
+// RUN: %clang -target mips64el-unknown-linux-gnu -### \
+// RUN: -EB -no-integrated-as %s 2>&1 \
+// RUN: | FileCheck -check-prefix=MIPS64-EB %s
+// MIPS64-EB: "{{.*}}clang{{.*}}" "-cc1" "-triple" "mips64-unknown-linux-gnu"
+// MIPS64-EB: "{{.*}}as{{(.exe)?}}" "-march" "mips64" "-mabi" "64" "-EB"
+// MIPS64-EB: "{{.*}}ld{{(.exe)?}}" {{.*}} "-m" "elf64btsmip"
diff --git a/test/Driver/mips-features.c b/test/Driver/mips-features.c
index 28048e7740f2..3bebffc11bb3 100644
--- a/test/Driver/mips-features.c
+++ b/test/Driver/mips-features.c
@@ -38,6 +38,18 @@
// RUN: | FileCheck --check-prefix=CHECK-NOMDSPR2 %s
// CHECK-NOMDSPR2: "-target-feature" "-dspr2"
//
+// -mxgot
+// RUN: %clang -target mips-linux-gnu -### -c %s \
+// RUN: -mno-xgot -mxgot 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-XGOT %s
+// CHECK-XGOT: "-mllvm" "-mxgot"
+//
+// -mno-xgot
+// RUN: %clang -target mips-linux-gnu -### -c %s \
+// RUN: -mxgot -mno-xgot 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NOXGOT %s
+// CHECK-NOXGOT-NOT: "-mllvm" "-mxgot"
+//
// -G
// RUN: %clang -target mips-linux-gnu -### -c %s \
// RUN: -G 16 2>&1 \
diff --git a/test/Driver/mips-float.c b/test/Driver/mips-float.c
index 886c3355a963..5c16b9b06351 100644
--- a/test/Driver/mips-float.c
+++ b/test/Driver/mips-float.c
@@ -41,3 +41,44 @@
// RUN: -target mips-linux-gnu -mfloat-abi=single \
// RUN: | FileCheck --check-prefix=CHECK-ABI-SINGLE %s
// CHECK-ABI-SINGLE: "-target-feature" "+single-float"
+//
+// Default -mips16
+// RUN: %clang -c %s -### -o %t.o 2>&1 \
+// RUN: -target mips-linux-gnu -mips16 \
+// RUN: | FileCheck --check-prefix=CHECK-DEF-MIPS16 %s
+// CHECK-DEF-MIPS16: "-mfloat-abi" "soft"
+// CHECK-DEF-MIPS16: "-mllvm" "-mips16-hard-float"
+//
+// -mhard-float -mips16
+// RUN: %clang -c %s -### -o %t.o 2>&1 \
+// RUN: -target mips-linux-gnu -mhard-float -mips16 \
+// RUN: | FileCheck --check-prefix=CHECK-HARD-MIPS16 %s
+// CHECK-HARD-MIPS16: "-msoft-float"
+// CHECK-HARD-MIPS16: "-mfloat-abi" "soft"
+// CHECK-HARD-MIPS16: "-target-feature" "+soft-float"
+// CHECK-HARD-MIPS16: "-mllvm" "-mips16-hard-float"
+//
+// -msoft-float -mips16
+// RUN: %clang -c %s -### -o %t.o 2>&1 \
+// RUN: -target mips-linux-gnu -msoft-float -mips16 \
+// RUN: | FileCheck --check-prefix=CHECK-SOFT-MIPS16 %s
+// CHECK-SOFT-MIPS16: "-msoft-float"
+// CHECK-SOFT-MIPS16: "-mfloat-abi" "soft"
+// CHECK-SOFT-MIPS16: "-target-feature" "+soft-float"
+//
+// -mfloat-abi=hard -mips16
+// RUN: %clang -c %s -### -o %t.o 2>&1 \
+// RUN: -target mips-linux-gnu -mfloat-abi=hard -mips16 \
+// RUN: | FileCheck --check-prefix=CHECK-ABI-HARD-MIPS16 %s
+// CHECK-ABI-HARD-MIPS16: "-msoft-float"
+// CHECK-ABI-HARD-MIPS16: "-mfloat-abi" "soft"
+// CHECK-ABI-HARD-MIPS16: "-target-feature" "+soft-float"
+// CHECK-ABI-HARD-MIPS16: "-mllvm" "-mips16-hard-float"
+//
+// -mfloat-abi=soft -mips16
+// RUN: %clang -c %s -### -o %t.o 2>&1 \
+// RUN: -target mips-linux-gnu -mfloat-abi=soft -mips16 \
+// RUN: | FileCheck --check-prefix=CHECK-ABI-SOFT-MIPS16 %s
+// CHECK-ABI-SOFT-MIPS16: "-msoft-float"
+// CHECK-ABI-SOFT-MIPS16: "-mfloat-abi" "soft"
+// CHECK-ABI-SOFT-MIPS16: "-target-feature" "+soft-float"
diff --git a/test/Driver/mips-long-double.c b/test/Driver/mips-long-double.c
new file mode 100644
index 000000000000..09de38c6b707
--- /dev/null
+++ b/test/Driver/mips-long-double.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -triple mips64-unknown-freebsd -std=c11 -verify %s
+// RUN: %clang_cc1 -triple mips-unknown-freebsd -std=c11 -verify %s
+// RUN: %clang_cc1 -triple mips-unknown-linux -std=c11 -verify %s
+// RUN: %clang_cc1 -triple mips64-unknown-linux -std=c11 -verify %s
+// expected-no-diagnostics
+
+#ifdef _ABI64
+# ifdef __FreeBSD__
+_Static_assert(sizeof(long double) == 8, "sizeof long double is wrong");
+_Static_assert(_Alignof(long double) == 8, "alignof long double is wrong");
+# else
+_Static_assert(sizeof(long double) == 16, "sizeof long double is wrong");
+_Static_assert(_Alignof(long double) == 16, "alignof long double is wrong");
+# endif
+#else
+_Static_assert(sizeof(long double) == 8, "sizeof long double is wrong");
+_Static_assert(_Alignof(long double) == 8, "alignof long double is wrong");
+#endif
+
diff --git a/test/Driver/modules.m b/test/Driver/modules.m
index b93054dbf87f..69c79fca7248 100644
--- a/test/Driver/modules.m
+++ b/test/Driver/modules.m
@@ -4,3 +4,9 @@
// RUN: %clang -fmodules -fno-modules -fmodules -### %s 2>&1 | FileCheck -check-prefix=CHECK-HAS-MODULES %s
// CHECK-HAS-MODULES: -fmodules
+// RUN: %clang -target x86_64-apple-darwin10 -fmodules -fno-modules -fmodules -### %s 2>&1 | FileCheck -check-prefix=CHECK-HAS-AUTOLINK %s
+// CHECK-HAS-AUTOLINK: -fmodules-autolink
+
+// RUN: %clang -fmodules -fno-modules -fno-modules-autolink -fmodules -### %s 2>&1 | FileCheck -check-prefix=CHECK-NO-AUTOLINK %s
+// CHECK-NO-AUTOLINK-NOT: -fmodules-autolink
+
diff --git a/test/Driver/modules_integrated_as.c b/test/Driver/modules_integrated_as.c
new file mode 100644
index 000000000000..0abd18fc5fe0
--- /dev/null
+++ b/test/Driver/modules_integrated_as.c
@@ -0,0 +1,6 @@
+// RUN: %clang -fsyntax-only modules_integrated_as.c -fmodules -no-integrated-as -### 2>&1 | FileCheck %s
+
+// Test that the autolinking feature is disabled with *not* using the
+// integrated assembler.
+
+// CHECK-NOT: -fmodules-autolink
diff --git a/test/Driver/ms-inline-asm.c b/test/Driver/ms-inline-asm.c
new file mode 100644
index 000000000000..03835647c336
--- /dev/null
+++ b/test/Driver/ms-inline-asm.c
@@ -0,0 +1,15 @@
+// RUN: %clang -target x86_64-apple-darwin10 \
+// RUN: -### -fsyntax-only -fasm-blocks %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-BLOCKS < %t %s
+
+// RUN: %clang -target x86_64-apple-darwin10 \
+// RUN: -### -fsyntax-only -fno-asm-blocks -fasm-blocks %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-BLOCKS < %t %s
+
+// CHECK-BLOCKS: "-fasm-blocks"
+
+// RUN: %clang -target x86_64-apple-darwin10 \
+// RUN: -### -fsyntax-only -fasm-blocks -fno-asm-blocks %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-NO-BLOCKS < %t %s
+
+// CHECK-NO-BLOCKS-NOT: "-fasm-blocks"
diff --git a/test/Driver/no-integrated-as-win.c b/test/Driver/no-integrated-as-win.c
new file mode 100644
index 000000000000..0d6c2958e57a
--- /dev/null
+++ b/test/Driver/no-integrated-as-win.c
@@ -0,0 +1,3 @@
+// RUN: %clang -target x86_64-pc-win32 -### -no-integrated-as %s -c 2>&1 | FileCheck %s
+
+// CHECK: there is no external assembler we can use on windows
diff --git a/test/Driver/nodefaultlib.c b/test/Driver/nodefaultlib.c
index 518928a8850a..f9462fd27a3d 100644
--- a/test/Driver/nodefaultlib.c
+++ b/test/Driver/nodefaultlib.c
@@ -2,7 +2,7 @@
// RUN: FileCheck < %t %s
//
// CHECK-NOT: start-group
-// CHECK-NOT: -lgcc
-// CHECK-NOT: -lc
+// CHECK-NOT: "-lgcc"
+// CHECK-NOT: "-lc"
// CHECK: crtbegin
// CHECK: crtend
diff --git a/test/Driver/objc++-cpp-output.mm b/test/Driver/objc++-cpp-output.mm
index 9c4d55379ad1..63b15d8c18b2 100644
--- a/test/Driver/objc++-cpp-output.mm
+++ b/test/Driver/objc++-cpp-output.mm
@@ -1,4 +1,5 @@
// RUN: %clang -x objc++-cpp-output -c %s -o /dev/null
+// RUN: %clang -x objc++-cpp-output -c %s -o /dev/null -### 2>&1 | FileCheck %s
// PR13820
// REQUIRES: LP64
@@ -9,3 +10,8 @@
@end
void f() {}
class C {};
+
+// Make sure the driver is passing all the necessary exception flags.
+// CHECK: "-fobjc-exceptions"
+// CHECK: "-fcxx-exceptions"
+// CHECK: "-fexceptions"
diff --git a/test/Driver/objc_default_synth.m b/test/Driver/objc_default_synth.m
new file mode 100644
index 000000000000..a8c7f7e546db
--- /dev/null
+++ b/test/Driver/objc_default_synth.m
@@ -0,0 +1,6 @@
+// We should be synthesizing properties by default on all platforms now.
+// RUN: %clang -### -target armv7-unknown-freebsd %s 2>&1 | FileCheck %s
+// RUN: %clang -### -target armv7-apple-ios %s 2>&1 | FileCheck %s
+// RUN: %clang -### -target i686-apple-macosx %s 2>&1 | FileCheck %s
+// REQUIRES: clang-driver
+// CHECK: -fobjc-default-synthesize
diff --git a/test/Driver/openbsd.c b/test/Driver/openbsd.c
index afd8b5ade921..4fd5b6a41b57 100644
--- a/test/Driver/openbsd.c
+++ b/test/Driver/openbsd.c
@@ -6,4 +6,22 @@
// RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd -pg -pthread %s -### 2>&1 \
// RUN: | FileCheck --check-prefix=CHECK-PG %s
// CHECK-PG: clang{{.*}}" "-cc1" "-triple" "i686-pc-openbsd"
-// CHECK-PG: ld{{.*}}" "-e" "__start" "--eh-frame-hdr" "-Bdynamic" "-dynamic-linker" "{{.*}}ld.so" "-o" "a.out" "{{.*}}crt0.o" "{{.*}}crtbegin.o" "{{.*}}.o" "-lgcc" "-lpthread_p" "-lc_p" "-lgcc" "{{.*}}crtend.o"
+// CHECK-PG: ld{{.*}}" "-e" "__start" "--eh-frame-hdr" "-Bdynamic" "-dynamic-linker" "{{.*}}ld.so" "-o" "a.out" "{{.*}}gcrt0.o" "{{.*}}crtbegin.o" "{{.*}}.o" "-lgcc" "-lpthread_p" "-lc_p" "-lgcc" "{{.*}}crtend.o"
+
+// Check that the new linker flags are passed to OpenBSD
+// RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd -r %s -### 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-LD-R %s
+// RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd -s %s -### 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-LD-S %s
+// RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd -t %s -### 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-LD-T %s
+// RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd -Z %s -### 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-LD-Z %s
+// CHECK-LD-R: clang{{.*}}" "-cc1" "-triple" "i686-pc-openbsd"
+// CHECK-LD-R: ld{{.*}}" "-e" "__start" "--eh-frame-hdr" "-Bdynamic" "-dynamic-linker" "{{.*}}ld.so" "-o" "a.out" "{{.*}}crt0.o" "{{.*}}crtbegin.o" "-L{{.*}}" "-r" "{{.*}}.o" "-lgcc" "-lc" "-lgcc" "{{.*}}crtend.o"
+// CHECK-LD-S: clang{{.*}}" "-cc1" "-triple" "i686-pc-openbsd"
+// CHECK-LD-S: ld{{.*}}" "-e" "__start" "--eh-frame-hdr" "-Bdynamic" "-dynamic-linker" "{{.*}}ld.so" "-o" "a.out" "{{.*}}crt0.o" "{{.*}}crtbegin.o" "-L{{.*}}" "-s" "{{.*}}.o" "-lgcc" "-lc" "-lgcc" "{{.*}}crtend.o"
+// CHECK-LD-T: clang{{.*}}" "-cc1" "-triple" "i686-pc-openbsd"
+// CHECK-LD-T: ld{{.*}}" "-e" "__start" "--eh-frame-hdr" "-Bdynamic" "-dynamic-linker" "{{.*}}ld.so" "-o" "a.out" "{{.*}}crt0.o" "{{.*}}crtbegin.o" "-L{{.*}}" "-t" "{{.*}}.o" "-lgcc" "-lc" "-lgcc" "{{.*}}crtend.o"
+// CHECK-LD-Z: clang{{.*}}" "-cc1" "-triple" "i686-pc-openbsd"
+// CHECK-LD-Z: ld{{.*}}" "-e" "__start" "--eh-frame-hdr" "-Bdynamic" "-dynamic-linker" "{{.*}}ld.so" "-o" "a.out" "{{.*}}crt0.o" "{{.*}}crtbegin.o" "-L{{.*}}" "-Z" "{{.*}}.o" "-lgcc" "-lc" "-lgcc" "{{.*}}crtend.o"
diff --git a/test/Driver/output-file-cleanup.c b/test/Driver/output-file-cleanup.c
index 0a0c96001b59..0aee5f8fa96a 100644
--- a/test/Driver/output-file-cleanup.c
+++ b/test/Driver/output-file-cleanup.c
@@ -1,16 +1,16 @@
-// RUN: touch %t.o
-// RUN: not %clang -DCRASH -o %t.o -MMD -MF %t.d %s
-// RUN: test ! -f %t.o
+// RUN: touch %t.s
+// RUN: not %clang -S -DCRASH -o %t.s -MMD -MF %t.d %s
+// RUN: test ! -f %t.s
// RUN: test ! -f %t.d
-// RUN: touch %t.o
-// RUN: not %clang -DMISSING -o %t.o -MMD -MF %t.d %s
-// RUN: test ! -f %t.o
+// RUN: touch %t.s
+// RUN: not %clang -S -DMISSING -o %t.s -MMD -MF %t.d %s
+// RUN: test ! -f %t.s
// RUN: test ! -f %t.d
-// RUN: touch %t.o
-// RUN: not %clang -o %t.o -MMD -MF %t.d %s
-// RUN: test ! -f %t.o
+// RUN: touch %t.s
+// RUN: not %clang -S -o %t.s -MMD -MF %t.d %s
+// RUN: test ! -f %t.s
// RUN: test -f %t.d
// REQUIRES: shell
@@ -23,3 +23,28 @@
#else
invalid C code
#endif
+
+// RUN: touch %t1.c
+// RUN: echo "invalid C code" > %t2.c
+// RUN: cd %T && not %clang -S %t1.c %t2.c
+// RUN: test -f %t1.s
+// RUN: test ! -f %t2.s
+
+// RUN: touch %t1.c
+// RUN: touch %t2.c
+// RUN: chmod -r %t2.c
+// RUN: cd %T && not %clang -S %t1.c %t2.c
+// RUN: test -f %t1.s
+// RUN: test ! -f %t2.s
+
+// RUN: touch %t1.c
+// RUN: echo "invalid C code" > %t2.c
+// RUN: touch %t3.c
+// RUN: echo "invalid C code" > %t4.c
+// RUN: touch %t5.c
+// RUN: cd %T && not %clang -S %t1.c %t2.c %t3.c %t4.c %t5.c
+// RUN: test -f %t1.s
+// RUN: test ! -f %t2.s
+// RUN: test -f %t3.s
+// RUN: test ! -f %t4.s
+// RUN: test -f %t5.s
diff --git a/test/Driver/output-file-is-dir.c b/test/Driver/output-file-is-dir.c
new file mode 100644
index 000000000000..c1fec56eac03
--- /dev/null
+++ b/test/Driver/output-file-is-dir.c
@@ -0,0 +1,7 @@
+// RUN: rm -rf %t.dir
+// RUN: mkdir -p %t.dir/a.out
+// RUN: cd %t.dir && not %clang %s
+// RUN: test -d %t.dir/a.out
+// REQUIRES: shell
+
+int main() { return 0; }
diff --git a/test/Driver/pic.c b/test/Driver/pic.c
index 54e5982c085f..8ba931954b1d 100644
--- a/test/Driver/pic.c
+++ b/test/Driver/pic.c
@@ -34,6 +34,8 @@
//
// CHECK-NON-DARWIN-DYNAMIC-NO-PIC: error: unsupported option '-mdynamic-no-pic' for target 'i386-unknown-unknown'
//
+// CHECK-NO-PIE-NOT: "-pie"
+//
// RUN: %clang -c %s -target i386-unknown-unknown -### 2>&1 \
// RUN: | FileCheck %s --check-prefix=CHECK-NO-PIC
// RUN: %clang -c %s -target i386-unknown-unknown -fpic -### 2>&1 \
@@ -127,6 +129,10 @@
// RUN: %clang -c %s -target i386-unknown-unknown -static -fPIC -### 2>&1 \
// RUN: | FileCheck %s --check-prefix=CHECK-NO-PIC
//
+// On Linux, disregard -pie if we have -shared.
+// RUN: %clang %s -target i386-unknown-linux -shared -pie -### 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-NO-PIE
+//
// Darwin is a beautiful and unique snowflake when it comes to these flags.
// When targetting a 32-bit darwin system, the -fno-* flag variants work and
// disable PIC, but any other flag enables PIC (*not* PIE) even if the flag
diff --git a/test/Driver/ppc-features.cpp b/test/Driver/ppc-features.cpp
new file mode 100644
index 000000000000..be78e19861b3
--- /dev/null
+++ b/test/Driver/ppc-features.cpp
@@ -0,0 +1,88 @@
+// Check that we error when -faltivec is specified on non-ppc platforms.
+
+// RUN: %clang -target powerpc-unk-unk -faltivec -fsyntax-only %s
+// RUN: %clang -target powerpc64-linux-gnu -faltivec -fsyntax-only %s
+// RUN: %clang -target powerpc64-linux-gnu -maltivec -fsyntax-only %s
+
+// RUN: %clang -target i386-pc-win32 -faltivec -fsyntax-only %s 2>&1 | FileCheck %s
+// RUN: %clang -target x86_64-unknown-freebsd -faltivec -fsyntax-only %s 2>&1 | FileCheck %s
+// RUN: %clang -target armv6-apple-darwin -faltivec -fsyntax-only %s 2>&1 | FileCheck %s
+// RUN: %clang -target armv7-apple-darwin -faltivec -fsyntax-only %s 2>&1 | FileCheck %s
+// RUN: %clang -target mips-linux-gnu -faltivec -fsyntax-only %s 2>&1 | FileCheck %s
+// RUN: %clang -target mips64-linux-gnu -faltivec -fsyntax-only %s 2>&1 | FileCheck %s
+// RUN: %clang -target sparc-unknown-solaris -faltivec -fsyntax-only %s 2>&1 | FileCheck %s
+
+// CHECK: invalid argument '-faltivec' only allowed with 'ppc/ppc64'
+
+// Check that -fno-altivec and -mno-altivec correctly disable the altivec
+// target feature on powerpc.
+
+// RUN: %clang -target powerpc64-unknown-linux-gnu %s -fno-altivec -### -o %t.o 2>&1 | FileCheck --check-prefix=CHECK-1 %s
+// CHECK-1: "-target-feature" "-altivec"
+
+// RUN: %clang -target powerpc64-unknown-linux-gnu %s -mno-altivec -### -o %t.o 2>&1 | FileCheck --check-prefix=CHECK-2 %s
+// CHECK-2: "-target-feature" "-altivec"
+
+// RUN: %clang -target powerpc64-unknown-linux-gnu %s -faltivec -mno-altivec -### -o %t.o 2>&1 | FileCheck --check-prefix=CHECK-3 %s
+// CHECK-3: "-target-feature" "-altivec"
+
+// RUN: %clang -target powerpc64-unknown-linux-gnu %s -maltivec -fno-altivec -### -o %t.o 2>&1 | FileCheck --check-prefix=CHECK-4 %s
+// CHECK-4: "-target-feature" "-altivec"
+
+// RUN: %clang -target powerpc64-unknown-linux-gnu %s -mno-altivec -faltivec -### -o %t.o 2>&1 | FileCheck --check-prefix=CHECK-5 %s
+// CHECK-5-NOT: "-target-feature" "-altivec"
+
+// RUN: %clang -target powerpc64-unknown-linux-gnu %s -fno-altivec -maltivec -### -o %t.o 2>&1 | FileCheck --check-prefix=CHECK-6 %s
+// CHECK-6-NOT: "-target-feature" "-altivec"
+
+// RUN: %clang -target powerpc64-unknown-linux-gnu %s -fno-altivec -mcpu=7400 -### -o %t.o 2>&1 | FileCheck --check-prefix=CHECK-7 %s
+// CHECK-7: "-target-feature" "-altivec"
+
+// RUN: %clang -target powerpc64-unknown-linux-gnu %s -fno-altivec -mcpu=g4 -### -o %t.o 2>&1 | FileCheck --check-prefix=CHECK-8 %s
+// CHECK-8: "-target-feature" "-altivec"
+
+// RUN: %clang -target powerpc64-unknown-linux-gnu %s -fno-altivec -mcpu=7450 -### -o %t.o 2>&1 | FileCheck --check-prefix=CHECK-9 %s
+// CHECK-9: "-target-feature" "-altivec"
+
+// RUN: %clang -target powerpc64-unknown-linux-gnu %s -fno-altivec -mcpu=g4+ -### -o %t.o 2>&1 | FileCheck --check-prefix=CHECK-10 %s
+// CHECK-10: "-target-feature" "-altivec"
+
+// RUN: %clang -target powerpc64-unknown-linux-gnu %s -fno-altivec -mcpu=970 -### -o %t.o 2>&1 | FileCheck --check-prefix=CHECK-11 %s
+// CHECK-11: "-target-feature" "-altivec"
+
+// RUN: %clang -target powerpc64-unknown-linux-gnu %s -fno-altivec -mcpu=g5 -### -o %t.o 2>&1 | FileCheck --check-prefix=CHECK-12 %s
+// CHECK-12: "-target-feature" "-altivec"
+
+// RUN: %clang -target powerpc64-unknown-linux-gnu %s -fno-altivec -mcpu=pwr6 -### -o %t.o 2>&1 | FileCheck --check-prefix=CHECK-13 %s
+// CHECK-13: "-target-feature" "-altivec"
+
+// RUN: %clang -target powerpc64-unknown-linux-gnu %s -fno-altivec -mcpu=pwr7 -### -o %t.o 2>&1 | FileCheck --check-prefix=CHECK-14 %s
+// CHECK-14: "-target-feature" "-altivec"
+
+// RUN: %clang -target powerpc64-unknown-linux-gnu %s -fno-altivec -mcpu=ppc64 -### -o %t.o 2>&1 | FileCheck --check-prefix=CHECK-15 %s
+// CHECK-15: "-target-feature" "-altivec"
+
+// RUN: %clang -target powerpc64-unknown-linux-gnu %s -mno-qpx -### -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOQPX %s
+// CHECK-NOQPX: "-target-feature" "-qpx"
+
+// RUN: %clang -target powerpc64-unknown-linux-gnu %s -mno-qpx -mqpx -### -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-QPX %s
+// CHECK-QPX-NOT: "-target-feature" "-qpx"
+
+// RUN: %clang -target powerpc64-unknown-linux-gnu %s -mno-mfcrf -### -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOMFCRF %s
+// CHECK-NOMFCRF: "-target-feature" "-mfocrf"
+
+// RUN: %clang -target powerpc64-unknown-linux-gnu %s -mno-mfcrf -mmfcrf -### -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-MFCRF %s
+// CHECK-MFCRF: "-target-feature" "+mfocrf"
+
+// RUN: %clang -target powerpc64-unknown-linux-gnu %s -mno-popcntd -### -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOPOPCNTD %s
+// CHECK-NOPOPCNTD: "-target-feature" "-popcntd"
+
+// RUN: %clang -target powerpc64-unknown-linux-gnu %s -mno-popcntd -mpopcntd -### -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-POPCNTD %s
+// CHECK-POPCNTD: "-target-feature" "+popcntd"
+
+// RUN: %clang -target powerpc64-unknown-linux-gnu %s -mno-fprnd -### -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOFPRND %s
+// CHECK-NOFPRND: "-target-feature" "-fprnd"
+
+// RUN: %clang -target powerpc64-unknown-linux-gnu %s -mno-fprnd -mfprnd -### -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-FPRND %s
+// CHECK-FPRND: "-target-feature" "+fprnd"
+
diff --git a/test/Driver/qa_override.c b/test/Driver/qa_override.c
index 5f96976ee98e..f89815739b12 100644
--- a/test/Driver/qa_override.c
+++ b/test/Driver/qa_override.c
@@ -1,6 +1,16 @@
// RUN: env QA_OVERRIDE_GCC3_OPTIONS="#+-Os +-Oz +-O +-O3 +-Oignore +a +b +c xb Xa Omagic ^-ccc-print-options " %clang x -O2 b -O3 2>&1 | FileCheck %s
+// RUN: env QA_OVERRIDE_GCC3_OPTIONS="x-Werror +-mfoo" %clang -Werror %s -c 2>&1 | FileCheck %s -check-prefix=RM-WERROR
+
+// FIXME: It seems doesn't work with gcc-driver.
+// REQUIRES: clang-driver
+
// CHECK-NOT: ###
// CHECK: Option 0 - Name: "-ccc-print-options", Values: {}
// CHECK-NEXT: Option 1 - Name: "<input>", Values: {"x"}
// CHECK-NEXT: Option 2 - Name: "-O", Values: {"ignore"}
// CHECK-NEXT: Option 3 - Name: "-O", Values: {"magic"}
+
+// RM-WERROR: ### QA_OVERRIDE_GCC3_OPTIONS: x-Werror +-mfoo
+// RM-WERROR-NEXT: ### Deleting argument -Werror
+// RM-WERROR-NEXT: ### Adding argument -mfoo at end
+// RM-WERROR-NEXT: warning: argument unused during compilation: '-mfoo'
diff --git a/test/Driver/r600-mcpu.cl b/test/Driver/r600-mcpu.cl
new file mode 100644
index 000000000000..70e811650e2b
--- /dev/null
+++ b/test/Driver/r600-mcpu.cl
@@ -0,0 +1,50 @@
+// Check that -mcpu works for all supported GPUs
+
+// RUN: %clang -### -target r600 -x cl -S -emit-llvm -mcpu=r600 %s -o - 2>&1 | FileCheck --check-prefix=R600-CHECK %s
+// RUN: %clang -### -target r600 -x cl -S -emit-llvm -mcpu=rv610 %s -o - 2>&1 | FileCheck --check-prefix=R600-CHECK %s
+// RUN: %clang -### -target r600 -x cl -S -emit-llvm -mcpu=rv620 %s -o - 2>&1 | FileCheck --check-prefix=R600-CHECK %s
+// RUN: %clang -### -target r600 -x cl -S -emit-llvm -mcpu=rv630 %s -o - 2>&1 | FileCheck --check-prefix=R600-CHECK %s
+// RUN: %clang -### -target r600 -x cl -S -emit-llvm -mcpu=rv635 %s -o - 2>&1 | FileCheck --check-prefix=R600-CHECK %s
+// RUN: %clang -### -target r600 -x cl -S -emit-llvm -mcpu=rs780 %s -o - 2>&1 | FileCheck --check-prefix=R600-CHECK %s
+// RUN: %clang -### -target r600 -x cl -S -emit-llvm -mcpu=rs880 %s -o - 2>&1 | FileCheck --check-prefix=R600-CHECK %s
+// RUN: %clang -### -target r600 -x cl -S -emit-llvm -mcpu=rv670 %s -o - 2>&1 | FileCheck --check-prefix=RV670-CHECK %s
+// RUN: %clang -### -target r600 -x cl -S -emit-llvm -mcpu=rv710 %s -o - 2>&1 | FileCheck --check-prefix=RV710-CHECK %s
+// RUN: %clang -### -target r600 -x cl -S -emit-llvm -mcpu=rv730 %s -o - 2>&1 | FileCheck --check-prefix=RV730-CHECK %s
+// RUN: %clang -### -target r600 -x cl -S -emit-llvm -mcpu=rv740 %s -o - 2>&1 | FileCheck --check-prefix=RV770-CHECK %s
+// RUN: %clang -### -target r600 -x cl -S -emit-llvm -mcpu=rv770 %s -o - 2>&1 | FileCheck --check-prefix=RV770-CHECK %s
+// RUN: %clang -### -target r600 -x cl -S -emit-llvm -mcpu=palm %s -o - 2>&1 | FileCheck --check-prefix=CEDAR-CHECK %s
+// RUN: %clang -### -target r600 -x cl -S -emit-llvm -mcpu=cedar %s -o - 2>&1 | FileCheck --check-prefix=CEDAR-CHECK %s
+// RUN: %clang -### -target r600 -x cl -S -emit-llvm -mcpu=sumo %s -o - 2>&1 | FileCheck --check-prefix=REDWOOD-CHECK %s
+// RUN: %clang -### -target r600 -x cl -S -emit-llvm -mcpu=sumo2 %s -o - 2>&1 | FileCheck --check-prefix=REDWOOD-CHECK %s
+// RUN: %clang -### -target r600 -x cl -S -emit-llvm -mcpu=redwood %s -o - 2>&1 | FileCheck --check-prefix=REDWOOD-CHECK %s
+// RUN: %clang -### -target r600 -x cl -S -emit-llvm -mcpu=juniper %s -o - 2>&1 | FileCheck --check-prefix=JUNIPER-CHECK %s
+// RUN: %clang -### -target r600 -x cl -S -emit-llvm -mcpu=juniper %s -o - 2>&1 | FileCheck --check-prefix=JUNIPER-CHECK %s
+// RUN: %clang -### -target r600 -x cl -S -emit-llvm -mcpu=hemlock %s -o - 2>&1 | FileCheck --check-prefix=CYPRESS-CHECK %s
+// RUN: %clang -### -target r600 -x cl -S -emit-llvm -mcpu=cypress %s -o - 2>&1 | FileCheck --check-prefix=CYPRESS-CHECK %s
+// RUN: %clang -### -target r600 -x cl -S -emit-llvm -mcpu=barts %s -o - 2>&1 | FileCheck --check-prefix=BARTS-CHECK %s
+// RUN: %clang -### -target r600 -x cl -S -emit-llvm -mcpu=turks %s -o - 2>&1 | FileCheck --check-prefix=TURKS-CHECK %s
+// RUN: %clang -### -target r600 -x cl -S -emit-llvm -mcpu=caicos %s -o - 2>&1 | FileCheck --check-prefix=CAICOS-CHECK %s
+// RUN: %clang -### -target r600 -x cl -S -emit-llvm -mcpu=cayman %s -o - 2>&1 | FileCheck --check-prefix=CAYMAN-CHECK %s
+// RUN: %clang -### -target r600 -x cl -S -emit-llvm -mcpu=aruba %s -o - 2>&1 | FileCheck --check-prefix=CAYMAN-CHECK %s
+// RUN: %clang -### -target r600 -x cl -S -emit-llvm -mcpu=tahiti %s -o - 2>&1 | FileCheck --check-prefix=TAHITI-CHECK %s
+// RUN: %clang -### -target r600 -x cl -S -emit-llvm -mcpu=pitcairn %s -o - 2>&1 | FileCheck --check-prefix=PITCAIRN-CHECK %s
+// RUN: %clang -### -target r600 -x cl -S -emit-llvm -mcpu=verde %s -o - 2>&1 | FileCheck --check-prefix=VERDE-CHECK %s
+// RUN: %clang -### -target r600 -x cl -S -emit-llvm -mcpu=oland %s -o - 2>&1 | FileCheck --check-prefix=OLAND-CHECK %s
+
+// R600-CHECK: "-target-cpu" "r600"
+// RV670-CHECK: "-target-cpu" "rv670"
+// RV710-CHECK: "-target-cpu" "rv710"
+// RV730-CHECK: "-target-cpu" "rv730"
+// RV770-CHECK: "-target-cpu" "rv770"
+// CEDAR-CHECK: "-target-cpu" "cedar"
+// REDWOOD-CHECK: "-target-cpu" "redwood"
+// JUNIPER-CHECK: "-target-cpu" "juniper"
+// CYPRESS-CHECK: "-target-cpu" "cypress"
+// BARTS-CHECK: "-target-cpu" "barts"
+// TURKS-CHECK: "-target-cpu" "turks"
+// CAICOS-CHECK: "-target-cpu" "caicos"
+// CAYMAN-CHECK: "-target-cpu" "cayman"
+// TAHITI-CHECK: "-target-cpu" "tahiti"
+// PITCAIRN-CHECK: "-target-cpu" "pitcairn"
+// VERDE-CHECK: "-target-cpu" "verde"
+// OLAND-CHECK: "-target-cpu" "oland"
diff --git a/test/Driver/sanitizer-ld.c b/test/Driver/sanitizer-ld.c
new file mode 100644
index 000000000000..fd68b579a105
--- /dev/null
+++ b/test/Driver/sanitizer-ld.c
@@ -0,0 +1,151 @@
+// Test sanitizers ld flags.
+
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target i386-unknown-linux -fsanitize=address \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN: | FileCheck --check-prefix=CHECK-ASAN-LINUX %s
+//
+// CHECK-ASAN-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
+// CHECK-ASAN-LINUX-NOT: "-lc"
+// CHECK-ASAN-LINUX: libclang_rt.asan-i386.a"
+// CHECK-ASAN-LINUX: "-lpthread"
+// CHECK-ASAN-LINUX: "-ldl"
+// CHECK-ASAN-LINUX-NOT: "-export-dynamic"
+// CHECK-ASAN-LINUX: "--dynamic-list={{.*}}libclang_rt.asan-i386.a.syms"
+
+// RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target i386-unknown-linux -fsanitize=address \
+// RUN: -resource-dir=%S/Inputs/empty_resource_dir \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN: | FileCheck --check-prefix=CHECK-ASAN-LINUX-CXX %s
+//
+// CHECK-ASAN-LINUX-CXX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
+// CHECK-ASAN-LINUX-CXX-NOT: "-lc"
+// CHECK-ASAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.asan-i386.a" "-no-whole-archive"
+// CHECK-ASAN-LINUX-CXX: "-lpthread"
+// CHECK-ASAN-LINUX-CXX: "-ldl"
+// CHECK-ASAN-LINUX-CXX: "-export-dynamic"
+// CHECK-ASAN-LINUX-CXX-NOT: "--dynamic-list"
+// CHECK-ASAN-LINUX-CXX: stdc++
+
+// RUN: %clang -no-canonical-prefixes %s -### -o /dev/null -fsanitize=address \
+// RUN: -target i386-unknown-linux --sysroot=%S/Inputs/basic_linux_tree \
+// RUN: -lstdc++ -static 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-ASAN-LINUX-CXX-STATIC %s
+//
+// CHECK-ASAN-LINUX-CXX-STATIC: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
+// CHECK-ASAN-LINUX-CXX-STATIC-NOT: stdc++
+// CHECK-ASAN-LINUX-CXX-STATIC: "-whole-archive" "{{.*}}libclang_rt.asan-i386.a" "-no-whole-archive"
+// CHECK-ASAN-LINUX-CXX-STATIC: stdc++
+
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target arm-linux-androideabi -fsanitize=address \
+// RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \
+// RUN: | FileCheck --check-prefix=CHECK-ASAN-ANDROID %s
+//
+// CHECK-ASAN-ANDROID: "{{(.*[^.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
+// CHECK-ASAN-ANDROID-NOT: "-lc"
+// CHECK-ASAN-ANDROID: libclang_rt.asan-arm-android.so"
+// CHECK-ASAN-ANDROID-NOT: "-lpthread"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target arm-linux-androideabi -fsanitize=address \
+// RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \
+// RUN: -shared \
+// RUN: | FileCheck --check-prefix=CHECK-ASAN-ANDROID-SHARED %s
+//
+// CHECK-ASAN-ANDROID-SHARED: "{{(.*[^.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
+// CHECK-ASAN-ANDROID-SHARED-NOT: "-lc"
+// CHECK-ASAN-ANDROID-SHARED: libclang_rt.asan-arm-android.so"
+// CHECK-ASAN-ANDROID-SHARED-NOT: "-lpthread"
+
+// RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target x86_64-unknown-linux -lstdc++ -fsanitize=thread \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN: | FileCheck --check-prefix=CHECK-TSAN-LINUX-CXX %s
+//
+// CHECK-TSAN-LINUX-CXX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
+// CHECK-TSAN-LINUX-CXX-NOT: stdc++
+// CHECK-TSAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.tsan-x86_64.a" "-no-whole-archive"
+// CHECK-TSAN-LINUX-CXX: "-lpthread"
+// CHECK-TSAN-LINUX-CXX: "-ldl"
+// CHECK-TSAN-LINUX-CXX-NOT: "-export-dynamic"
+// CHECK-TSAN-LINUX-CXX: "--dynamic-list={{.*}}libclang_rt.tsan-x86_64.a.syms"
+// CHECK-TSAN-LINUX-CXX: stdc++
+
+// RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target x86_64-unknown-linux -lstdc++ -fsanitize=memory \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN: | FileCheck --check-prefix=CHECK-MSAN-LINUX-CXX %s
+//
+// CHECK-MSAN-LINUX-CXX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
+// CHECK-MSAN-LINUX-CXX-NOT: stdc++
+// CHECK-MSAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.msan-x86_64.a" "-no-whole-archive"
+// CHECK-MSAN-LINUX-CXX: "-lpthread"
+// CHECK-MSAN-LINUX-CXX: "-ldl"
+// CHECK-MSAN-LINUX-CXX-NOT: "-export-dynamic"
+// CHECK-MSAN-LINUX-CXX: "--dynamic-list={{.*}}libclang_rt.msan-x86_64.a.syms"
+// CHECK-MSAN-LINUX-CXX: stdc++
+
+// RUN: %clang -fsanitize=undefined %s -### -o %t.o 2>&1 \
+// RUN: -target i386-unknown-linux \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN: | FileCheck --check-prefix=CHECK-UBSAN-LINUX %s
+// CHECK-UBSAN-LINUX: "{{.*}}ld{{(.exe)?}}"
+// CHECK-UBSAN-LINUX-NOT: libclang_rt.asan
+// CHECK-UBSAN-LINUX: "-whole-archive" "{{.*}}libclang_rt.san-i386.a" "-no-whole-archive"
+// CHECK-UBSAN-LINUX-NOT: libclang_rt.asan
+// CHECK-UBSAN-LINUX: "-whole-archive" "{{.*}}libclang_rt.ubsan-i386.a" "-no-whole-archive"
+// CHECK-UBSAN-LINUX-NOT: libclang_rt.ubsan_cxx
+// CHECK-UBSAN-LINUX: "-lpthread"
+// CHECK-UBSAN-LINUX-NOT: "-lstdc++"
+
+// RUN: %clangxx -fsanitize=undefined %s -### -o %t.o 2>&1 \
+// RUN: -target i386-unknown-linux \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN: | FileCheck --check-prefix=CHECK-UBSAN-LINUX-CXX %s
+// CHECK-UBSAN-LINUX-CXX: "{{.*}}ld{{(.exe)?}}"
+// CHECK-UBSAN-LINUX-CXX-NOT: libclang_rt.asan
+// CHECK-UBSAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.san-i386.a" "-no-whole-archive"
+// CHECK-UBSAN-LINUX-CXX-NOT: libclang_rt.asan
+// CHECK-UBSAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.ubsan-i386.a" "-no-whole-archive"
+// CHECK-UBSAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.ubsan_cxx-i386.a" "-no-whole-archive"
+// CHECK-UBSAN-LINUX-CXX: "-lpthread"
+// CHECK-UBSAN-LINUX-CXX: "-lstdc++"
+
+// RUN: %clang -fsanitize=address,undefined %s -### -o %t.o 2>&1 \
+// RUN: -target i386-unknown-linux \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN: | FileCheck --check-prefix=CHECK-ASAN-UBSAN-LINUX %s
+// CHECK-ASAN-UBSAN-LINUX: "{{.*}}ld{{(.exe)?}}"
+// CHECK-ASAN-UBSAN-LINUX-NOT: libclang_rt.san
+// CHECK-ASAN-UBSAN-LINUX: "-whole-archive" "{{.*}}libclang_rt.asan-i386.a" "-no-whole-archive"
+// CHECK-ASAN-UBSAN-LINUX-NOT: libclang_rt.san
+// CHECK-ASAN-UBSAN-LINUX: "-whole-archive" "{{.*}}libclang_rt.ubsan-i386.a" "-no-whole-archive"
+// CHECK-ASAN-UBSAN-LINUX-NOT: libclang_rt.ubsan_cxx
+// CHECK-ASAN-UBSAN-LINUX: "-lpthread"
+// CHECK-ASAN-UBSAN-LINUX-NOT: "-lstdc++"
+
+// RUN: %clangxx -fsanitize=address,undefined %s -### -o %t.o 2>&1 \
+// RUN: -target i386-unknown-linux \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN: | FileCheck --check-prefix=CHECK-ASAN-UBSAN-LINUX-CXX %s
+// CHECK-ASAN-UBSAN-LINUX-CXX: "{{.*}}ld{{(.exe)?}}"
+// CHECK-ASAN-UBSAN-LINUX-CXX-NOT: libclang_rt.san
+// CHECK-ASAN-UBSAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.asan-i386.a" "-no-whole-archive"
+// CHECK-ASAN-UBSAN-LINUX-CXX-NOT: libclang_rt.san
+// CHECK-ASAN-UBSAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.ubsan-i386.a" "-no-whole-archive"
+// CHECK-ASAN-UBSAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.ubsan_cxx-i386.a" "-no-whole-archive"
+// CHECK-ASAN-UBSAN-LINUX-CXX: "-lpthread"
+// CHECK-ASAN-UBSAN-LINUX-CXX: "-lstdc++"
+
+// RUN: %clang -fsanitize=undefined %s -### -o %t.o 2>&1 \
+// RUN: -target i386-unknown-linux \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN: -shared \
+// RUN: | FileCheck --check-prefix=CHECK-UBSAN-LINUX-SHARED %s
+// CHECK-UBSAN-LINUX-SHARED: "{{.*}}ld{{(.exe)?}}"
+// CHECK-UBSAN-LINUX-SHARED-NOT: libclang_rt.ubsan-i386.a"
diff --git a/test/Driver/split-debug.c b/test/Driver/split-debug.c
new file mode 100644
index 000000000000..d8a9fe841e27
--- /dev/null
+++ b/test/Driver/split-debug.c
@@ -0,0 +1,25 @@
+// Check that we split debug output properly
+//
+// REQUIRES: asserts
+// RUN: %clang -target x86_64-unknown-linux-gnu -gsplit-dwarf -c -### %s 2> %t
+// RUN: FileCheck -check-prefix=CHECK-ACTIONS < %t %s
+//
+// CHECK-ACTIONS: objcopy{{.*}}--extract-dwo{{.*}}"split-debug.dwo"
+// CHECK-ACTIONS: objcopy{{.*}}--strip-dwo{{.*}}"split-debug.o"
+
+
+// RUN: %clang -target x86_64-macosx -gsplit-dwarf -c -### %s 2> %t
+// RUN: FileCheck -check-prefix=CHECK-NO-ACTIONS < %t %s
+//
+// CHECK-NO-ACTIONS-NOT: -split-dwarf
+
+
+// RUN: %clang -target x86_64-unknown-linux-gnu -gsplit-dwarf -o Bad.x -### %s 2> %t
+// RUN: FileCheck -check-prefix=CHECK-BAD < %t %s
+//
+// CHECK-BAD-NOT: "Bad.dwo"
+
+// RUN: %clang -target x86_64-unknown-linux-gnu -gsplit-dwarf -c -### %s 2> %t
+// RUN: FileCheck -check-prefix=CHECK-OPTION < %t %s
+//
+// CHECK-OPTION: "-split-dwarf-file" "split-debug.dwo"
diff --git a/test/Driver/target-as.s b/test/Driver/target-as.s
new file mode 100644
index 000000000000..adb3d10f14ea
--- /dev/null
+++ b/test/Driver/target-as.s
@@ -0,0 +1,8 @@
+// REQUIRES: clang-driver
+
+// Make sure the -march is passed down to cc1as.
+// RUN: %clang -target i386-unknown-freebsd -### -c -integrated-as %s \
+// RUN: -march=geode 2>&1 | FileCheck -check-prefix=TARGET %s
+//
+// TARGET: "-cc1as"
+// TARGET: "-target-cpu" "geode"
diff --git a/test/Driver/ubsan-ld.c b/test/Driver/ubsan-ld.c
deleted file mode 100644
index 775e6699443f..000000000000
--- a/test/Driver/ubsan-ld.c
+++ /dev/null
@@ -1,10 +0,0 @@
-// Test UndefinedBehaviorSanitizer ld flags.
-
-// RUN: %clang -fcatch-undefined-behavior %s -### -o %t.o 2>&1 \
-// RUN: -target i386-unknown-linux \
-// RUN: --sysroot=%S/Inputs/basic_linux_tree \
-// RUN: | FileCheck --check-prefix=CHECK-LINUX %s
-// CHECK-LINUX: "{{.*}}ld{{(.exe)?}}"
-// CHECK-LINUX-NOT: "-lc"
-// CHECK-LINUX: libclang_rt.ubsan-i386.a"
-// CHECK-LINUX: "-lpthread"
diff --git a/test/Driver/unknown-arg.c b/test/Driver/unknown-arg.c
index 5d0f7afc5113..0fab8a50b99e 100644
--- a/test/Driver/unknown-arg.c
+++ b/test/Driver/unknown-arg.c
@@ -1,4 +1,6 @@
-// RUN: not %clang_cc1 %s -cake-is-lie 2> %t.log
+// RUN: not %clang_cc1 %s -cake-is-lie -%0 -%d 2> %t.log
// RUN: FileCheck %s -input-file=%t.log
// CHECK: unknown argument
+// CHECK: unknown argument
+// CHECK: unknown argument
diff --git a/test/Driver/unknown-gcc-arch.c b/test/Driver/unknown-gcc-arch.c
index 5e4746babdda..dcd17d4f467a 100644
--- a/test/Driver/unknown-gcc-arch.c
+++ b/test/Driver/unknown-gcc-arch.c
@@ -1,8 +1,32 @@
-// RUN: %clang -target x86_64-unknown-unknown -c -x assembler %s -### 2> %t.log
-// RUN: grep '.*gcc.*"-m64"' %t.log
-// RUN: %clang -target x86_64-unknown-unknown -c -x assembler %s -### -m32 2> %t.log
-// RUN: grep '.*gcc.*"-m32"' %t.log
-// RUN: %clang -target i386-unknown-unknown -c -x assembler %s -### 2> %t.log
-// RUN: grep '.*gcc.*"-m32"' %t.log
-// RUN: %clang -target i386-unknown-unknown -c -x assembler %s -### -m64 2> %t.log
-// RUN: grep '.*gcc.*"-m64"' %t.log
+// RUN: %clang -target x86_64-unknown-unknown -c -x assembler %s -### 2>&1 \
+// RUN: | FileCheck -check-prefix=X86_64 %s
+// X86_64: {{.*gcc.*-m64}}
+
+// RUN: %clang -target x86_64-unknown-unknown -c -x assembler %s -### -m32 2>&1 \
+// RUN: | FileCheck -check-prefix=X86_64-M32 %s
+// X86_64-M32: {{.*gcc.*-m32}}
+
+// RUN: %clang -target i386-unknown-unknown -c -x assembler %s -### 2>&1 \
+// RUN: | FileCheck -check-prefix=I386 %s
+// I386: {{.*gcc.*-m32}}
+
+// RUN: %clang -target i386-unknown-unknown -c -x assembler %s -### -m64 2>&1 \
+// RUN: | FileCheck -check-prefix=I386-M64 %s
+// I386-M64: {{.*gcc.*-m64}}
+
+
+// RUN: %clang -target powerpc64-unknown-unknown -c -x assembler %s -### 2>&1 \
+// RUN: | FileCheck -check-prefix=PPC64 %s
+// PPC64: {{.*gcc.*-m64}}
+
+// RUN: %clang -target powerpc64-unknown-unknown -c -x assembler %s -### -m32 2>&1 \
+// RUN: | FileCheck -check-prefix=PPC64-M32 %s
+// PPC64-M32: {{.*gcc.*-m32}}
+
+// RUN: %clang -target powerpc-unknown-unknown -c -x assembler %s -### 2>&1 \
+// RUN: | FileCheck -check-prefix=PPC %s
+// PPC: {{.*gcc.*-m32}}
+
+// RUN: %clang -target powerpc-unknown-unknown -c -x assembler %s -### -m64 2>&1 \
+// RUN: | FileCheck -check-prefix=PPC-M64 %s
+// PPC-M64: {{.*gcc.*-m64}}
diff --git a/test/Driver/visibility.cpp b/test/Driver/visibility.cpp
new file mode 100644
index 000000000000..cdbef97aadc9
--- /dev/null
+++ b/test/Driver/visibility.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang -### -S -fvisibility=hidden -fvisibility=default %s 2> %t.log
+// RUN: FileCheck -check-prefix=CHECK-1 %s < %t.log
+// CHECK-NOT: "-ftype-visibility"
+// CHECK-1: "-fvisibility" "default"
+// CHECK-NOT: "-ftype-visibility"
+
+// RUN: %clang -### -S -fvisibility=default -fvisibility=hidden %s 2> %t.log
+// RUN: FileCheck -check-prefix=CHECK-2 %s < %t.log
+// CHECK-NOT: "-ftype-visibility"
+// CHECK-2: "-fvisibility" "hidden"
+// CHECK-NOT: "-ftype-visibility"
+
+// RUN: %clang -### -S -fvisibility-ms-compat -fvisibility=hidden %s 2> %t.log
+// RUN: FileCheck -check-prefix=CHECK-3 %s < %t.log
+// CHECK-NOT: "-ftype-visibility"
+// CHECK-3: "-fvisibility" "hidden"
+// CHECK-NOT: "-ftype-visibility"
+
+// RUN: %clang -### -S -fvisibility-ms-compat -fvisibility=default %s 2> %t.log
+// RUN: FileCheck -check-prefix=CHECK-4 %s < %t.log
+// CHECK-NOT: "-ftype-visibility"
+// CHECK-4: "-fvisibility" "default"
+// CHECK-NOT: "-ftype-visibility"
+
+// RUN: %clang -### -S -fvisibility=hidden -fvisibility-ms-compat %s 2> %t.log
+// RUN: FileCheck -check-prefix=CHECK-5 %s < %t.log
+// CHECK-5: "-fvisibility" "hidden"
+// CHECK-5: "-ftype-visibility" "default"
+
+// RUN: %clang -### -S -fvisibility=default -fvisibility-ms-compat %s 2> %t.log
+// RUN: FileCheck -check-prefix=CHECK-6 %s < %t.log
+// CHECK-6: "-fvisibility" "hidden"
+// CHECK-6: "-ftype-visibility" "default"
+
diff --git a/test/Driver/warning-options.cpp b/test/Driver/warning-options.cpp
index cce88e65c259..f1a335d2139d 100644
--- a/test/Driver/warning-options.cpp
+++ b/test/Driver/warning-options.cpp
@@ -3,13 +3,11 @@
// RUN: %clang -### -Wlarge-by-value-copy=128 %s 2>&1 | FileCheck -check-prefix=LARGE_VALUE_COPY_JOINED %s
// LARGE_VALUE_COPY_JOINED: -Wlarge-by-value-copy=128
-// RUN: %clang -### -c -Wmonkey -Wno-monkey -Wno-unused-command-line-arguments \
-// RUN: -Wno-unused-command-line-argument %s 2>&1 | FileCheck %s
-// CHECK: unknown warning option '-Wmonkey'
-// CHECK: unknown warning option '-Wno-monkey'
-// CHECK: unknown warning option '-Wno-unused-command-line-arguments'; did you mean '-Wno-unused-command-line-argument'?
-
// FIXME: Remove this together with -Warc-abi once an Xcode is released that doesn't pass this flag.
// RUN: %clang -### -Warc-abi -Wno-arc-abi %s 2>&1 | FileCheck -check-prefix=ARCABI %s
// ARCABI-NOT: unknown warning option '-Warc-abi'
// ARCABI-NOT: unknown warning option '-Wno-arc-abi'
+
+// Check that -isysroot warns on nonexistent paths.
+// RUN: %clang -### -c -target i386-apple-darwin10 -isysroot /FOO %s 2>&1 | FileCheck --check-prefix=CHECK-ISYSROOT %s
+// CHECK-ISYSROOT: warning: no such sysroot directory: '{{([A-Za-z]:.*)?}}/FOO'
diff --git a/test/Driver/warning-options_pedantic.cpp b/test/Driver/warning-options_pedantic.cpp
index c6d11be73d1f..e40f7716f413 100644
--- a/test/Driver/warning-options_pedantic.cpp
+++ b/test/Driver/warning-options_pedantic.cpp
@@ -4,4 +4,4 @@
// RUN: %clang -### -pedantic -pedantic -no-pedantic -pedantic %s 2>&1 | FileCheck -check-prefix=PEDANTIC %s
// RUN: %clang -### -pedantic -pedantic -no-pedantic -Wpedantic %s 2>&1 | FileCheck -check-prefix=NO_PEDANTIC %s
// PEDANTIC: -pedantic
-// XFAIL: cygwin,mingw32
+// REQUIRES: clang-driver
diff --git a/test/Driver/x86_64-nacl-defines.cpp b/test/Driver/x86_64-nacl-defines.cpp
index caa9a74d2db6..b7c894036cd4 100644
--- a/test/Driver/x86_64-nacl-defines.cpp
+++ b/test/Driver/x86_64-nacl-defines.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang -target x86_64-unknown-nacl -ccc-echo %s -emit-llvm-only -c 2>&1 | FileCheck %s -check-prefix=ECHO
+// RUN: %clang -target x86_64-unknown-nacl -ccc-echo %s -emit-llvm-only -c -o %t.o 2>&1 | FileCheck %s -check-prefix=ECHO
// RUN: %clang -target x86_64-unknown-nacl %s -emit-llvm -S -c -o - | FileCheck %s
// RUN: %clang -target x86_64-unknown-nacl %s -emit-llvm -S -c -pthread -o - | FileCheck %s -check-prefix=THREADS