1 // REQUIRES: shell
2 // REQUIRES: x86-registered-target
3 
4 // RUN: rm -rf %t && mkdir %t
5 
6 //--- If config file is specified by relative path (workdir/cfg-s2), it is searched for by that path.
7 
8 // RUN: mkdir -p %t/workdir/subdir
9 // RUN: echo "@subdir/cfg-s2" > %t/workdir/cfg-1
10 // RUN: echo "-Wundefined-var-template" > %t/workdir/subdir/cfg-s2
11 //
12 // RUN: ( cd %t && %clang --config workdir/cfg-1 -c %s -### 2>&1 | FileCheck %s -check-prefix CHECK-REL )
13 //
14 // CHECK-REL: Configuration file: {{.*}}/workdir/cfg-1
15 // CHECK-REL: -Wundefined-var-template
16 
17 
18 //--- Invocation qqq-clang-g++ tries to find config file qqq-clang-g++.cfg first.
19 //
20 // RUN: mkdir %t/testdmode
21 // RUN: ln -s %clang %t/testdmode/qqq-clang-g++
22 // RUN: echo "-Wundefined-func-template" > %t/testdmode/qqq-clang-g++.cfg
23 // RUN: echo "-Werror" > %t/testdmode/qqq.cfg
24 // RUN: %t/testdmode/qqq-clang-g++ --config-system-dir= --config-user-dir= -c -no-canonical-prefixes %s -### 2>&1 | FileCheck %s -check-prefix FULL-NAME
25 //
26 // FULL-NAME: Configuration file: {{.*}}/testdmode/qqq-clang-g++.cfg
27 // FULL-NAME: -Wundefined-func-template
28 // FULL-NAME-NOT: -Werror
29 //
30 //--- Invocation qqq-clang-g++ tries to find config file qqq-clang-g++.cfg even without -no-canonical-prefixes.
31 // (As the clang executable and symlink are in different directories, this
32 // requires specifying the path via --config-*-dir= though.)
33 //
34 // RUN: %t/testdmode/qqq-clang-g++ --config-system-dir= --config-user-dir=%t/testdmode -c %s -### 2>&1 | FileCheck %s -check-prefix SYMLINK
35 //
36 // SYMLINK: Configuration file: {{.*}}/testdmode/qqq-clang-g++.cfg
37 //
38 //--- File specified by --config overrides config inferred from clang executable.
39 //
40 // RUN: %t/testdmode/qqq-clang-g++ --config-system-dir=%S/Inputs/config --config-user-dir= --config i386-qqq -c -no-canonical-prefixes %s -### 2>&1 | FileCheck %s -check-prefix CHECK-EXPLICIT
41 //
42 // CHECK-EXPLICIT: Configuration file: {{.*}}/Inputs/config/i386-qqq.cfg
43 //
44 //--- Invocation qqq-clang-g++ tries to find config file qqq.cfg if qqq-clang-g++.cfg is not found.
45 //
46 // RUN: rm %t/testdmode/qqq-clang-g++.cfg
47 // RUN: %t/testdmode/qqq-clang-g++ --config-system-dir= --config-user-dir= -c -no-canonical-prefixes %s -### 2>&1 | FileCheck %s -check-prefix SHORT-NAME
48 //
49 // SHORT-NAME: Configuration file: {{.*}}/testdmode/qqq.cfg
50 // SHORT-NAME: -Werror
51 // SHORT-NAME-NOT: -Wundefined-func-template
52 
53 
54 //--- Config files are searched for in binary directory as well.
55 //
56 // RUN: mkdir %t/testbin
57 // RUN: ln -s %clang %t/testbin/clang
58 // RUN: echo "-Werror" > %t/testbin/aaa.cfg
59 // RUN: %t/testbin/clang --config-system-dir= --config-user-dir= --config aaa.cfg -c -no-canonical-prefixes %s -### 2>&1 | FileCheck %s -check-prefix CHECK-BIN
60 //
61 // CHECK-BIN: Configuration file: {{.*}}/testbin/aaa.cfg
62 // CHECK-BIN: -Werror
63 
64 
65 //--- If command line contains options that change triple (for instance, -m32), clang tries
66 //    reloading config file.
67 
68 //--- When reloading config file, x86_64-clang-g++ tries to find config i386-clang-g++.cfg first.
69 //
70 // RUN: mkdir %t/testreload
71 // RUN: ln -s %clang %t/testreload/x86_64-clang-g++
72 // RUN: echo "-Wundefined-func-template" > %t/testreload/i386-clang-g++.cfg
73 // RUN: echo "-Werror" > %t/testreload/i386.cfg
74 // RUN: %t/testreload/x86_64-clang-g++ --config-system-dir= --config-user-dir= -c -m32 -no-canonical-prefixes %s -### 2>&1 | FileCheck %s -check-prefix CHECK-RELOAD
75 //
76 // CHECK-RELOAD: Configuration file: {{.*}}/testreload/i386-clang-g++.cfg
77 // CHECK-RELOAD: -Wundefined-func-template
78 // CHECK-RELOAD-NOT: -Werror
79 
80 //--- If config file is specified by --config and its name does not start with architecture, it is used without reloading.
81 //
82 // RUN: %t/testreload/x86_64-clang-g++ --config-system-dir=%S/Inputs --config-user-dir= --config config-3 -c -m32 -no-canonical-prefixes %s -### 2>&1 | FileCheck %s -check-prefix CHECK-RELOAD1a
83 //
84 // CHECK-RELOAD1a: Configuration file: {{.*}}/Inputs/config-3.cfg
85 //
86 // RUN: %t/testreload/x86_64-clang-g++ --config-system-dir=%S/Inputs --config-user-dir= --config config-3 -c -target i386 -no-canonical-prefixes %s -### 2>&1 | FileCheck %s -check-prefix CHECK-RELOAD1b
87 //
88 // CHECK-RELOAD1b: Configuration file: {{.*}}/Inputs/config-3.cfg
89 
90 //--- If config file is specified by --config and its name starts with architecture, it is reloaded.
91 //
92 // RUN: %t/testreload/x86_64-clang-g++ --config-system-dir=%S/Inputs/config --config-user-dir= --config x86_64-qqq -c -m32 -no-canonical-prefixes %s -### 2>&1 | FileCheck %s -check-prefix CHECK-RELOAD1c
93 //
94 // CHECK-RELOAD1c: Configuration file: {{.*}}/Inputs/config/i386-qqq.cfg
95 
96 //--- x86_64-clang-g++ tries to find config i386.cfg if i386-clang-g++.cfg is not found.
97 //
98 // RUN: rm %t/testreload/i386-clang-g++.cfg
99 // RUN: %t/testreload/x86_64-clang-g++ --config-system-dir= --config-user-dir= -c -m32 -no-canonical-prefixes %s -### 2>&1 | FileCheck %s -check-prefix CHECK-RELOAD1d
100 //
101 // CHECK-RELOAD1d: Configuration file: {{.*}}/testreload/i386.cfg
102 // CHECK-RELOAD1d: -Werror
103 // CHECK-RELOAD1d-NOT: -Wundefined-func-template
104 
105