Skip to content

Commit 4bd9ce3

Browse files
[test][Driver][clang] Fix darwin-embedded-search-paths.c when CLANG_DEFAULT_CXX_STDLIB is libc++
Split darwin-embedded-search-paths.c into two tests for the different values of CLANG_DEFAULT_CXX_STDLIB.
1 parent 29ed600 commit 4bd9ce3

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// REQUIRES: default-cxx-stdlib=libc++
2+
// UNSUPPORTED: system-windows
3+
// Windows is unsupported because we use the Unix path separator `/` in the test.
4+
5+
// Unlike the Darwin driver, the MachO driver doesn't add any framework search paths,
6+
// only the normal header ones.
7+
// RUN: %clang -x c -target arm64-apple-none-macho -isysroot %S/Inputs/MacOSX15.1.sdk -### -c %s 2>&1 \
8+
// RUN: | FileCheck --check-prefixes=CC1,NO-CXX,ULI,CI,UI,NO-FW -DSDKROOT=%S/Inputs/MacOSX15.1.sdk %s
9+
10+
// Unlike the Darwin driver, the MachO driver doesn't default to libc++, but when
11+
// CLANG_DEFAULT_CXX_STDLIB is libc++ then the MachO driver should find the search path.
12+
// RUN: %clang -x c++ -target arm64-apple-none-macho -isysroot %S/Inputs/MacOSX15.1.sdk -### -c %s 2>&1 \
13+
// RUN: | FileCheck --check-prefixes=CC1,CXX,ULI,CI,UI,NO-FW -DSDKROOT=%S/Inputs/MacOSX15.1.sdk %s
14+
15+
// If the user requests libc++, the MachO driver should still find the search path.
16+
// RUN: %clang -x c++ -stdlib=libc++ -target arm64-apple-none-macho -isysroot %S/Inputs/MacOSX15.1.sdk -### -c %s 2>&1 \
17+
// RUN: | FileCheck --check-prefixes=CC1,CXX,ULI,CI,UI,NO-FW -DSDKROOT=%S/Inputs/MacOSX15.1.sdk %s
18+
19+
// Verify that embedded uses can swap in alternate usr/include and usr/local/include directories.
20+
// usr/local/include is specified in the driver as -internal-isystem, however, the driver generated
21+
// paths come before the paths in the driver arguments. In order to keep usr/local/include in the
22+
// same position, -isystem has to be used instead of -Xclang -internal-isystem. There isn't an
23+
// -externc-isystem, but it's ok to use -Xclang -internal-externc-isystem since the driver doesn't
24+
// use that if -nostdlibinc or -nostdinc is passed.
25+
// RUN: %clang -x c++ -stdlib=libc++ -target arm64-apple-none-macho -isysroot %S/Inputs/MacOSX15.1.sdk \
26+
// RUN: -nostdlibinc -isystem %S/Inputs/MacOSX15.1.sdk/embedded/usr/local/include \
27+
// RUN: -Xclang -internal-externc-isystem -Xclang %S/Inputs/MacOSX15.1.sdk/embedded/usr/include \
28+
// RUN: -### -c %s 2>&1 | FileCheck --check-prefixes=CC1,NO-CXX,EULI,CI,EUI,NO-FW -DSDKROOT=%S/Inputs/MacOSX15.1.sdk %s
29+
30+
31+
// The ordering of these flags doesn't matter, and so this test is a little
32+
// fragile. i.e. all of the -internal-isystem paths will be searched before the
33+
// -internal-externc-isystem ones, and their order on the command line doesn't
34+
// matter. The line order here is just the current order that the driver writes
35+
// the cc1 arguments.
36+
37+
// CC1: "-cc1"
38+
// NO-CXX-NOT: "-internal-isystem" "{{.*}}/include/c++/v1"
39+
// CXX-SAME: "-internal-isystem" "{{.*}}/include/c++/v1"
40+
// ULI-SAME: "-internal-isystem" "[[SDKROOT]]/usr/local/include"
41+
// EULI-SAME: "-isystem" "[[SDKROOT]]/embedded/usr/local/include"
42+
// CI-SAME: "-internal-isystem" "{{.*}}/clang/{{[[:digit:].]*}}/include"
43+
// UI-SAME: "-internal-externc-isystem" "[[SDKROOT]]/usr/include"
44+
// EUI-SAME: "-internal-externc-isystem" "[[SDKROOT]]/embedded/usr/include"
45+
// NO-FW-NOT: "-internal-iframework"

clang/test/Driver/darwin-embedded-search-paths.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// REQUIRES: !(default-cxx-stdlib=libc++)
12
// UNSUPPORTED: system-windows
23
// Windows is unsupported because we use the Unix path separator `/` in the test.
34

@@ -6,7 +7,8 @@
67
// RUN: %clang -x c -target arm64-apple-none-macho -isysroot %S/Inputs/MacOSX15.1.sdk -### -c %s 2>&1 \
78
// RUN: | FileCheck --check-prefixes=CC1,NO-CXX,ULI,CI,UI,NO-FW -DSDKROOT=%S/Inputs/MacOSX15.1.sdk %s
89

9-
// Unlike the Darwin driver, the MachO driver doesn't default to libc++
10+
// Unlike the Darwin driver, the MachO driver doesn't default to libc++, and unless
11+
// CLANG_DEFAULT_CXX_STDLIB is libc++ it won't add any search paths.
1012
// RUN: %clang -x c++ -target arm64-apple-none-macho -isysroot %S/Inputs/MacOSX15.1.sdk -### -c %s 2>&1 \
1113
// RUN: | FileCheck --check-prefixes=CC1,NO-CXX,ULI,CI,UI,NO-FW -DSDKROOT=%S/Inputs/MacOSX15.1.sdk %s
1214

0 commit comments

Comments
 (0)