ldionne created this revision.
ldionne added reviewers: jfb, rsmith.
Herald added subscribers: cfe-commits, dexonsmith, jkorous.
Herald added a project: clang.

Otherwise, the unit tests seem to be confused on Windows. Note that it
would in theory be better to always use the platform's path, however we
don't seem to have a good way of handling that with FileCheck right now.
This change makes the handling of paths on Darwin consistent with what
we do on Linux, and also with what we used to do (for several paths)
before the refactoring in r361278.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D62493

Files:
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/test/Driver/darwin-header-search-libcxx.cpp
  clang/test/Driver/darwin-header-search-libstdcxx.cpp
  clang/test/Driver/darwin-header-search-system.cpp

Index: clang/test/Driver/darwin-header-search-system.cpp
===================================================================
--- clang/test/Driver/darwin-header-search-system.cpp
+++ clang/test/Driver/darwin-header-search-system.cpp
@@ -1,5 +1,3 @@
-// UNSUPPORTED: system-windows
-
 // General tests that the system header search paths detected by the driver
 // and passed to CC1 are correct on Darwin platforms.
 
@@ -11,18 +9,14 @@
 // RUN:     -ccc-install-dir %S/Inputs/basic_darwin_toolchain_no_libcxx/usr/bin \
 // RUN:     -resource-dir=%S/Inputs/resource_dir \
 // RUN:     -isysroot %S/Inputs/basic_darwin_sdk_usr_and_usr_local \
-// RUN:   | FileCheck -DSYSROOT=%S/Inputs/basic_darwin_sdk_usr_and_usr_local \
-// RUN:               -DRESOURCE=%S/Inputs/resource_dir \
-// RUN:               --check-prefix=CHECK-SYSTEM %s
+// RUN:   | FileCheck --check-prefix=CHECK-SYSTEM %s
 //
 // RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
 // RUN:     -target x86_64-apple-darwin \
 // RUN:     -ccc-install-dir %S/Inputs/basic_darwin_toolchain_no_libcxx/usr/bin \
 // RUN:     -resource-dir=%S/Inputs/resource_dir \
 // RUN:     --sysroot %S/Inputs/basic_darwin_sdk_usr_and_usr_local \
-// RUN:   | FileCheck -DSYSROOT=%S/Inputs/basic_darwin_sdk_usr_and_usr_local \
-// RUN:               -DRESOURCE=%S/Inputs/resource_dir \
-// RUN:               --check-prefix=CHECK-SYSTEM %s
+// RUN:   | FileCheck --check-prefix=CHECK-SYSTEM %s
 //
 // RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
 // RUN:     -target x86_64-apple-darwin \
@@ -30,11 +24,10 @@
 // RUN:     -resource-dir=%S/Inputs/resource_dir \
 // RUN:     -isysroot %S/Inputs/basic_darwin_sdk_usr_and_usr_local \
 // RUN:     --sysroot / \
-// RUN:   | FileCheck -DSYSROOT=%S/Inputs/basic_darwin_sdk_usr_and_usr_local \
-// RUN:               -DRESOURCE=%S/Inputs/resource_dir \
-// RUN:               --check-prefix=CHECK-SYSTEM %s
-//
+// RUN:   | FileCheck --check-prefix=CHECK-SYSTEM %s
 // CHECK-SYSTEM: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
+// CHECK-SYSTEM: "-resource-dir" "[[RESOURCE:[^"]+]]"
+// CHECK-SYSTEM: "-isysroot" "[[SYSROOT:[^"]+]]"
 // CHECK-SYSTEM: "-internal-isystem" "[[SYSROOT]]/usr/local/include"
 // CHECK-SYSTEM: "-internal-isystem" "[[RESOURCE]]/include"
 // CHECK-SYSTEM: "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
@@ -47,10 +40,10 @@
 // RUN:     -resource-dir=%S/Inputs/resource_dir \
 // RUN:     -isysroot %S/Inputs/basic_darwin_sdk_usr_and_usr_local \
 // RUN:     -nobuiltininc \
-// RUN:   | FileCheck -DSYSROOT=%S/Inputs/basic_darwin_sdk_usr_and_usr_local \
-// RUN:               -DRESOURCE=%S/Inputs/resource_dir \
-// RUN:               --check-prefix=CHECK-NOBUILTININC %s
+// RUN:   | FileCheck --check-prefix=CHECK-NOBUILTININC %s
 // CHECK-NOBUILTININC: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
+// CHECK-NOBUILTININC: "-resource-dir" "[[RESOURCE:[^"]+]]"
+// CHECK-NOBUILTININC: "-isysroot" "[[SYSROOT:[^"]+]]"
 // CHECK-NOBUILTININC: "-internal-isystem" "[[SYSROOT]]/usr/local/include"
 // CHECK-NOBUILTININC-NOT: "-internal-isystem" "[[RESOURCE]]/include"
 // CHECK-NOBUILTININC: "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
@@ -64,10 +57,10 @@
 // RUN:     -resource-dir=%S/Inputs/resource_dir \
 // RUN:     -isysroot %S/Inputs/basic_darwin_sdk_usr_and_usr_local \
 // RUN:     -nostdlibinc \
-// RUN:   | FileCheck -DSYSROOT=%S/Inputs/basic_darwin_sdk_usr_and_usr_local \
-// RUN:               -DRESOURCE=%S/Inputs/resource_dir \
-// RUN:               --check-prefix=CHECK-NOSTDLIBINC %s
+// RUN:   | FileCheck --check-prefix=CHECK-NOSTDLIBINC %s
 // CHECK-NOSTDLIBINC: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
+// CHECK-NOSTDLIBINC: "-resource-dir" "[[RESOURCE:[^"]+]]"
+// CHECK-NOSTDLIBINC: "-isysroot" "[[SYSROOT:[^"]+]]"
 // CHECK-NOSTDLIBINC-NOT: "-internal-isystem" "[[SYSROOT]]/usr/local/include"
 // CHECK-NOSTDLIBINC: "-internal-isystem" "[[RESOURCE]]/include"
 // CHECK-NOSTDLIBINC-NOT: "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
@@ -81,10 +74,10 @@
 // RUN:     -resource-dir=%S/Inputs/resource_dir \
 // RUN:     -isysroot %S/Inputs/basic_darwin_sdk_usr_and_usr_local \
 // RUN:     -nostdinc \
-// RUN:   | FileCheck -DSYSROOT=%S/Inputs/basic_darwin_sdk_usr_and_usr_local \
-// RUN:               -DRESOURCE=%S/Inputs/resource_dir \
-// RUN:               --check-prefix=CHECK-NOSTDINC %s
+// RUN:   | FileCheck --check-prefix=CHECK-NOSTDINC %s
 // CHECK-NOSTDINC: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
+// CHECK-NOSTDINC: "-resource-dir" "[[RESOURCE:[^"]+]]"
+// CHECK-NOSTDINC: "-isysroot" "[[SYSROOT:[^"]+]]"
 // CHECK-NOSTDINC-NOT: "-internal-isystem" "[[SYSROOT]]/usr/local/include"
 // CHECK-NOSTDINC-NOT: "-internal-isystem" "[[RESOURCE]]/include"
 // CHECK-NOSTDINC-NOT: "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
@@ -95,9 +88,9 @@
 // RUN:     -target x86_64-apple-darwin \
 // RUN:     -ccc-install-dir %S/Inputs/basic_darwin_toolchain_no_libcxx/usr/bin \
 // RUN:     -resource-dir=%S/Inputs/resource_dir \
-// RUN:   | FileCheck -DRESOURCE=%S/Inputs/resource_dir \
-// RUN:               --check-prefix=CHECK-NOSYSROOT %s
+// RUN:   | FileCheck --check-prefix=CHECK-NOSYSROOT %s
 // CHECK-NOSYSROOT: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
+// CHECK-NOSYSROOT: "-resource-dir" "[[RESOURCE:[^"]+]]"
 // CHECK-NOSYSROOT: "-internal-isystem" "/usr/local/include"
 // CHECK-NOSYSROOT: "-internal-isystem" "[[RESOURCE]]/include"
 // CHECK-NOSYSROOT: "-internal-externc-isystem" "/usr/include"
Index: clang/test/Driver/darwin-header-search-libstdcxx.cpp
===================================================================
--- clang/test/Driver/darwin-header-search-libstdcxx.cpp
+++ clang/test/Driver/darwin-header-search-libstdcxx.cpp
@@ -1,5 +1,3 @@
-// UNSUPPORTED: system-windows
-
 // General tests that the header search paths for libstdc++ detected by the
 // driver and passed to CC1 are correct on Darwin platforms.
 
@@ -9,8 +7,9 @@
 // RUN:     -target ppc-apple-darwin \
 // RUN:     -stdlib=libstdc++ \
 // RUN:     -isysroot %S/Inputs/basic_darwin_sdk_libstdcxx_ppc \
-// RUN:   | FileCheck -DSYSROOT=%S/Inputs/basic_darwin_sdk_libstdcxx_ppc --check-prefix=CHECK-LIBSTDCXX-PPC %s
+// RUN:   | FileCheck --check-prefix=CHECK-LIBSTDCXX-PPC %s
 // CHECK-LIBSTDCXX-PPC: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
+// CHECK-LIBSTDCXX-PPC: "-isysroot" "[[SYSROOT:[^"]+]]"
 // CHECK-LIBSTDCXX-PPC: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/4.2.1
 // CHECK-LIBSTDCXX-PPC: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/4.2.1/powerpc-apple-darwin10"
 // CHECK-LIBSTDCXX-PPC: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/4.2.1/backward"
@@ -22,8 +21,9 @@
 // RUN:     -target ppc64-apple-darwin \
 // RUN:     -stdlib=libstdc++ \
 // RUN:     -isysroot %S/Inputs/basic_darwin_sdk_libstdcxx_ppc \
-// RUN:   | FileCheck -DSYSROOT=%S/Inputs/basic_darwin_sdk_libstdcxx_ppc --check-prefix=CHECK-LIBSTDCXX-PPC64 %s
+// RUN:   | FileCheck --check-prefix=CHECK-LIBSTDCXX-PPC64 %s
 // CHECK-LIBSTDCXX-PPC64: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
+// CHECK-LIBSTDCXX-PPC64: "-isysroot" "[[SYSROOT:[^"]+]]"
 // CHECK-LIBSTDCXX-PPC64: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/4.2.1"
 // CHECK-LIBSTDCXX-PPC64: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/4.2.1/powerpc-apple-darwin10/ppc64"
 // CHECK-LIBSTDCXX-PPC64: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/4.2.1/backward"
@@ -37,8 +37,9 @@
 // RUN:     -target i686-apple-darwin \
 // RUN:     -stdlib=libstdc++ \
 // RUN:     -isysroot %S/Inputs/basic_darwin_sdk_libstdcxx_x86 \
-// RUN:   | FileCheck -DSYSROOT=%S/Inputs/basic_darwin_sdk_libstdcxx_x86 --check-prefix=CHECK-LIBSTDCXX-X86 %s
+// RUN:   | FileCheck --check-prefix=CHECK-LIBSTDCXX-X86 %s
 // CHECK-LIBSTDCXX-X86: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
+// CHECK-LIBSTDCXX-X86: "-isysroot" "[[SYSROOT:[^"]+]]"
 // CHECK-LIBSTDCXX-X86: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/4.2.1"
 // CHECK-LIBSTDCXX-X86: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/4.2.1/i686-apple-darwin10"
 // CHECK-LIBSTDCXX-X86: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/4.2.1/backward"
@@ -50,8 +51,9 @@
 // RUN:     -target x86_64-apple-darwin \
 // RUN:     -stdlib=libstdc++ \
 // RUN:     -isysroot %S/Inputs/basic_darwin_sdk_libstdcxx_x86 \
-// RUN:   | FileCheck -DSYSROOT=%S/Inputs/basic_darwin_sdk_libstdcxx_x86 --check-prefix=CHECK-LIBSTDCXX-X86_64 %s
+// RUN:   | FileCheck --check-prefix=CHECK-LIBSTDCXX-X86_64 %s
 // CHECK-LIBSTDCXX-X86_64: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
+// CHECK-LIBSTDCXX-X86_64: "-isysroot" "[[SYSROOT:[^"]+]]"
 // CHECK-LIBSTDCXX-X86_64: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/4.2.1"
 // CHECK-LIBSTDCXX-X86_64: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/4.2.1/i686-apple-darwin10/x86_64"
 // CHECK-LIBSTDCXX-X86_64: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/4.2.1/backward"
@@ -65,8 +67,9 @@
 // RUN:     -target arm-apple-darwin \
 // RUN:     -stdlib=libstdc++ \
 // RUN:     -isysroot %S/Inputs/basic_darwin_sdk_libstdcxx_arm \
-// RUN:   | FileCheck -DSYSROOT=%S/Inputs/basic_darwin_sdk_libstdcxx_arm --check-prefix=CHECK-LIBSTDCXX-ARM %s
+// RUN:   | FileCheck --check-prefix=CHECK-LIBSTDCXX-ARM %s
 // CHECK-LIBSTDCXX-ARM: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
+// CHECK-LIBSTDCXX-ARM: "-isysroot" "[[SYSROOT:[^"]+]]"
 // CHECK-LIBSTDCXX-ARM: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/4.2.1"
 // CHECK-LIBSTDCXX-ARM: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/4.2.1/arm-apple-darwin10/v7"
 // CHECK-LIBSTDCXX-ARM: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/4.2.1/backward"
@@ -78,8 +81,9 @@
 // RUN:     -target arm-apple-darwin \
 // RUN:     -stdlib=libstdc++ \
 // RUN:     -isysroot %S/Inputs/basic_darwin_sdk_libstdcxx_arm \
-// RUN:   | FileCheck -DSYSROOT=%S/Inputs/basic_darwin_sdk_libstdcxx_arm --check-prefix=CHECK-LIBSTDCXX-THUMB %s
+// RUN:   | FileCheck --check-prefix=CHECK-LIBSTDCXX-THUMB %s
 // CHECK-LIBSTDCXX-THUMB: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
+// CHECK-LIBSTDCXX-THUMB: "-isysroot" "[[SYSROOT:[^"]+]]"
 // CHECK-LIBSTDCXX-THUMB: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/4.2.1"
 // CHECK-LIBSTDCXX-THUMB: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/4.2.1/arm-apple-darwin10/v7"
 // CHECK-LIBSTDCXX-THUMB: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/4.2.1/backward"
@@ -93,8 +97,9 @@
 // RUN:     -target arm64-apple-darwin \
 // RUN:     -stdlib=libstdc++ \
 // RUN:     -isysroot %S/Inputs/basic_darwin_sdk_libstdcxx_aarch64 \
-// RUN:   | FileCheck -DSYSROOT=%S/Inputs/basic_darwin_sdk_libstdcxx_aarch64 --check-prefix=CHECK-LIBSTDCXX-AARCH64 %s
+// RUN:   | FileCheck --check-prefix=CHECK-LIBSTDCXX-AARCH64 %s
 // CHECK-LIBSTDCXX-AARCH64: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
+// CHECK-LIBSTDCXX-AARCH64: "-isysroot" "[[SYSROOT:[^"]+]]"
 // CHECK-LIBSTDCXX-AARCH64: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/4.2.1"
 // CHECK-LIBSTDCXX-AARCH64: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/4.2.1/arm64-apple-darwin10"
 // CHECK-LIBSTDCXX-AARCH64: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/4.2.1/backward"
Index: clang/test/Driver/darwin-header-search-libcxx.cpp
===================================================================
--- clang/test/Driver/darwin-header-search-libcxx.cpp
+++ clang/test/Driver/darwin-header-search-libcxx.cpp
@@ -1,5 +1,3 @@
-// UNSUPPORTED: system-windows
-
 // General tests that the header search paths for libc++ detected by the driver
 // and passed to CC1 are correct on Darwin platforms.
 
@@ -9,7 +7,7 @@
 // RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
 // RUN:     -target x86_64-apple-darwin \
 // RUN:     -stdlib=libc++ \
-// RUN:     -ccc-install-dir %S/Inputs/basic_darwin_toolchain_no_libcxx/usr/bin \
+// RUN:     -ccc-install-dir %/S/Inputs/basic_darwin_toolchain_no_libcxx/usr/bin \
 // RUN:   | FileCheck --check-prefix=CHECK-LIBCXX-NONE %s
 // CHECK-LIBCXX-NONE: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
 
@@ -19,8 +17,9 @@
 // RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
 // RUN:     -target x86_64-apple-darwin \
 // RUN:     -stdlib=libc++ \
-// RUN:     -ccc-install-dir %S/Inputs/basic_darwin_toolchain/usr/bin \
-// RUN:   | FileCheck -DTOOLCHAIN=%S/Inputs/basic_darwin_toolchain --check-prefix=CHECK-LIBCXX-TOOLCHAIN-1 %s
+// RUN:     -ccc-install-dir %/S/Inputs/basic_darwin_toolchain/usr/bin \
+// RUN:   | FileCheck -DTOOLCHAIN=%/S/Inputs/basic_darwin_toolchain \
+// RUN:               --check-prefix=CHECK-LIBCXX-TOOLCHAIN-1 %s
 // CHECK-LIBCXX-TOOLCHAIN-1: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
 // CHECK-LIBCXX-TOOLCHAIN-1: "-internal-isystem" "[[TOOLCHAIN]]/usr/bin/../include/c++/v1"
 // CHECK-LIBCXX-TOOLCHAIN-1: "-internal-isystem" "/usr/include/c++/v1"
@@ -28,9 +27,10 @@
 // RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
 // RUN:     -target x86_64-apple-darwin \
 // RUN:     -stdlib=libc++ \
-// RUN:     -ccc-install-dir %S/Inputs/basic_darwin_toolchain/usr/bin \
-// RUN:     -isysroot %S/Inputs/basic_darwin_sdk_no_libcxx \
-// RUN:   | FileCheck -DTOOLCHAIN=%S/Inputs/basic_darwin_toolchain --check-prefix=CHECK-LIBCXX-TOOLCHAIN-2 %s
+// RUN:     -ccc-install-dir %/S/Inputs/basic_darwin_toolchain/usr/bin \
+// RUN:     -isysroot %/S/Inputs/basic_darwin_sdk_no_libcxx \
+// RUN:   | FileCheck -DTOOLCHAIN=%/S/Inputs/basic_darwin_toolchain \
+// RUN:               --check-prefix=CHECK-LIBCXX-TOOLCHAIN-2 %s
 // CHECK-LIBCXX-TOOLCHAIN-2: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
 // CHECK-LIBCXX-TOOLCHAIN-2: "-internal-isystem" "[[TOOLCHAIN]]/usr/bin/../include/c++/v1"
 
@@ -41,35 +41,32 @@
 // RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
 // RUN:     -target x86_64-apple-darwin \
 // RUN:     -stdlib=libc++ \
-// RUN:     -ccc-install-dir %S/Inputs/basic_darwin_toolchain/usr/bin \
-// RUN:     -resource-dir=%S/Inputs/resource_dir \
-// RUN:     -isysroot %S/Inputs/basic_darwin_sdk_usr \
-// RUN:   | FileCheck -DSYSROOT=%S/Inputs/basic_darwin_sdk_usr \
-// RUN:               -DTOOLCHAIN=%S/Inputs/basic_darwin_toolchain \
+// RUN:     -ccc-install-dir %/S/Inputs/basic_darwin_toolchain/usr/bin \
+// RUN:     -resource-dir=%/S/Inputs/resource_dir \
+// RUN:     -isysroot %/S/Inputs/basic_darwin_sdk_usr \
+// RUN:   | FileCheck -DTOOLCHAIN=%/S/Inputs/basic_darwin_toolchain \
 // RUN:               --check-prefix=CHECK-LIBCXX-SYSROOT_AND_TOOLCHAIN-1 %s
 //
 // RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
 // RUN:     -target x86_64-apple-darwin \
 // RUN:     -stdlib=libc++ \
-// RUN:     -ccc-install-dir %S/Inputs/basic_darwin_toolchain/usr/bin \
-// RUN:     -resource-dir=%S/Inputs/resource_dir \
-// RUN:     --sysroot %S/Inputs/basic_darwin_sdk_usr \
-// RUN:   | FileCheck -DSYSROOT=%S/Inputs/basic_darwin_sdk_usr \
-// RUN:               -DTOOLCHAIN=%S/Inputs/basic_darwin_toolchain \
+// RUN:     -ccc-install-dir %/S/Inputs/basic_darwin_toolchain/usr/bin \
+// RUN:     -resource-dir=%/S/Inputs/resource_dir \
+// RUN:     --sysroot %/S/Inputs/basic_darwin_sdk_usr \
+// RUN:   | FileCheck -DTOOLCHAIN=%/S/Inputs/basic_darwin_toolchain \
 // RUN:               --check-prefix=CHECK-LIBCXX-SYSROOT_AND_TOOLCHAIN-1 %s
 //
 // RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
 // RUN:     -target x86_64-apple-darwin \
 // RUN:     -stdlib=libc++ \
-// RUN:     -ccc-install-dir %S/Inputs/basic_darwin_toolchain/usr/bin \
-// RUN:     -resource-dir=%S/Inputs/resource_dir \
-// RUN:     -isysroot %S/Inputs/basic_darwin_sdk_usr \
-// RUN:     --sysroot %S/Inputs/basic_darwin_sdk_no_libcxx \
-// RUN:   | FileCheck -DSYSROOT=%S/Inputs/basic_darwin_sdk_usr \
-// RUN:               -DTOOLCHAIN=%S/Inputs/basic_darwin_toolchain \
+// RUN:     -ccc-install-dir %/S/Inputs/basic_darwin_toolchain/usr/bin \
+// RUN:     -resource-dir=%/S/Inputs/resource_dir \
+// RUN:     -isysroot %/S/Inputs/basic_darwin_sdk_usr \
+// RUN:     --sysroot %/S/Inputs/basic_darwin_sdk_no_libcxx \
+// RUN:   | FileCheck -DTOOLCHAIN=%/S/Inputs/basic_darwin_toolchain \
 // RUN:               --check-prefix=CHECK-LIBCXX-SYSROOT_AND_TOOLCHAIN-1 %s
-//
 // CHECK-LIBCXX-SYSROOT_AND_TOOLCHAIN-1: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
+// CHECK-LIBCXX-SYSROOT_AND_TOOLCHAIN-1: "-isysroot" "[[SYSROOT:[^"]+]]"
 // CHECK-LIBCXX-SYSROOT_AND_TOOLCHAIN-1: "-internal-isystem" "[[TOOLCHAIN]]/usr/bin/../include/c++/v1"
 // CHECK-LIBCXX-SYSROOT_AND_TOOLCHAIN-1: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/v1"
 
@@ -78,28 +75,28 @@
 //
 // RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
 // RUN:     -target x86_64-apple-darwin16 \
-// RUN:     -ccc-install-dir %S/Inputs/basic_darwin_toolchain/usr/bin \
-// RUN:     -resource-dir=%S/Inputs/resource_dir \
-// RUN:     -isysroot %S/Inputs/basic_darwin_sdk_usr \
+// RUN:     -ccc-install-dir %/S/Inputs/basic_darwin_toolchain/usr/bin \
+// RUN:     -resource-dir=%/S/Inputs/resource_dir \
+// RUN:     -isysroot %/S/Inputs/basic_darwin_sdk_usr \
 // RUN:     -stdlib=platform \
 // RUN:     -nostdinc \
-// RUN:   | FileCheck -DSYSROOT=%S/Inputs/basic_darwin_sdk_usr \
-// RUN:               -DTOOLCHAIN=%S/Inputs/basic_darwin_toolchain \
+// RUN:   | FileCheck -DTOOLCHAIN=%/S/Inputs/basic_darwin_toolchain \
 // RUN:               --check-prefix=CHECK-LIBCXX-NOSTDINC %s
 // CHECK-LIBCXX-NOSTDINC: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
+// CHECK-LIBCXX-NOSTDINC: "-isysroot" "[[SYSROOT:[^"]+]]"
 // CHECK-LIBCXX-NOSTDINC: "-internal-isystem" "[[TOOLCHAIN]]/usr/bin/../include/c++/v1"
 // CHECK-LIBCXX-NOSTDINC-NOT: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/v1"
 //
 // RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
 // RUN:     -target x86_64-apple-darwin16 \
-// RUN:     -ccc-install-dir %S/Inputs/basic_darwin_toolchain/usr/bin \
-// RUN:     -resource-dir=%S/Inputs/resource_dir \
-// RUN:     -isysroot %S/Inputs/basic_darwin_sdk_usr \
+// RUN:     -ccc-install-dir %/S/Inputs/basic_darwin_toolchain/usr/bin \
+// RUN:     -resource-dir=%/S/Inputs/resource_dir \
+// RUN:     -isysroot %/S/Inputs/basic_darwin_sdk_usr \
 // RUN:     -stdlib=platform \
 // RUN:     -nostdinc \
-// RUN:   | FileCheck -DSYSROOT=%S/Inputs/basic_darwin_sdk_usr \
-// RUN:               -DTOOLCHAIN=%S/Inputs/basic_darwin_toolchain \
+// RUN:   | FileCheck -DTOOLCHAIN=%/S/Inputs/basic_darwin_toolchain \
 // RUN:               --check-prefix=CHECK-LIBCXX-NOSTDLIBINC %s
 // CHECK-LIBCXX-NOSTDLIBINC: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
+// CHECK-LIBCXX-NOSTDLIBINC: "-isysroot" "[[SYSROOT:[^"]+]]"
 // CHECK-LIBCXX-NOSTDLIBINC: "-internal-isystem" "[[TOOLCHAIN]]/usr/bin/../include/c++/v1"
 // CHECK-LIBCXX-NOSTDLIBINC-NOT: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/v1"
Index: clang/lib/Driver/ToolChains/Darwin.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -1812,7 +1812,7 @@
     return DriverArgs.getLastArgValue(options::OPT_isysroot);
   if (!getDriver().SysRoot.empty())
     return getDriver().SysRoot;
-  return "/";
+  return "";
 }
 
 void DarwinClang::AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
@@ -1828,14 +1828,14 @@
   // Add <sysroot>/usr/local/include
   if (!NoStdInc && !NoStdlibInc) {
       SmallString<128> P(Sysroot);
-      llvm::sys::path::append(P, "usr", "local", "include");
+      P += "/usr/local/include";
       addSystemInclude(DriverArgs, CC1Args, P);
   }
 
   // Add the Clang builtin headers (<resource>/include)
   if (!NoStdInc && !NoBuiltinInc) {
     SmallString<128> P(D.ResourceDir);
-    llvm::sys::path::append(P, "include");
+    P += "/include";
     addSystemInclude(DriverArgs, CC1Args, P);
   }
 
@@ -1855,7 +1855,7 @@
   } else {
     // Otherwise, add <sysroot>/usr/include.
     SmallString<128> P(Sysroot);
-    llvm::sys::path::append(P, "usr", "include");
+    P += "/usr/include";
     addExternCSystemInclude(DriverArgs, CC1Args, P.str());
   }
 }
@@ -1866,7 +1866,8 @@
                                               llvm::StringRef Version,
                                               llvm::StringRef ArchDir,
                                               llvm::StringRef BitDir) const {
-  llvm::sys::path::append(Base, Version);
+  Base += "/";
+  Base += Version;
 
   // Add the base dir
   addSystemInclude(DriverArgs, CC1Args, Base);
@@ -1874,17 +1875,22 @@
   // Add the multilib dirs
   {
     llvm::SmallString<128> P = Base;
-    if (!ArchDir.empty())
-      llvm::sys::path::append(P, ArchDir);
-    if (!BitDir.empty())
-      llvm::sys::path::append(P, BitDir);
+    if (!ArchDir.empty()) {
+      P += "/";
+      P += ArchDir;
+    }
+    if (!BitDir.empty()) {
+      P += "/";
+      P += BitDir;
+    }
+
     addSystemInclude(DriverArgs, CC1Args, P);
   }
 
   // Add the backward dir
   {
     llvm::SmallString<128> P = Base;
-    llvm::sys::path::append(P, "backward");
+    P += "/backward";
     addSystemInclude(DriverArgs, CC1Args, P);
   }
 
@@ -1914,14 +1920,14 @@
     {
       llvm::SmallString<128> P = llvm::StringRef(getDriver().getInstalledDir());
       // Note that P can be relative, so we have to '..' and not parent_path.
-      llvm::sys::path::append(P, "..", "include", "c++", "v1");
+      P += "/../include/c++/v1";
       addSystemInclude(DriverArgs, CC1Args, P);
     }
     // Also add <sysroot>/usr/include/c++/v1 unless -nostdinc is used,
     // to match the legacy behavior in CC1.
     if (!DriverArgs.hasArg(options::OPT_nostdinc)) {
       llvm::SmallString<128> P = Sysroot;
-      llvm::sys::path::append(P, "usr", "include", "c++", "v1");
+      P += "/usr/include/c++/v1";
       addSystemInclude(DriverArgs, CC1Args, P);
     }
     break;
@@ -1929,7 +1935,7 @@
 
   case ToolChain::CST_Libstdcxx:
     llvm::SmallString<128> UsrIncludeCxx = Sysroot;
-    llvm::sys::path::append(UsrIncludeCxx, "usr", "include", "c++");
+    UsrIncludeCxx += "/usr/include/c++";
 
     llvm::Triple::ArchType arch = getTriple().getArch();
     bool IsBaseFound = true;
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
  • [PATCH] D62493: [D... Louis Dionne via Phabricator via cfe-commits

Reply via email to