annotate clang/test/Driver/cl-pch.cpp @ 221:79ff65ed7e25

LLVM12 Original
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 15 Jun 2021 19:15:29 +0900
parents 1d019706d866
children 1f2b6ac9f198
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 // Note: %s and %S must be preceded by --, otherwise it may be interpreted as a
anatofuz
parents:
diff changeset
2 // command-line option, e.g. on Mac where %s is commonly under /Users.
anatofuz
parents:
diff changeset
3
anatofuz
parents:
diff changeset
4 // /Yc
anatofuz
parents:
diff changeset
5 // RUN: %clang_cl -Werror /Ycpchfile.h /FIpchfile.h /c -### -- %s 2>&1 \
anatofuz
parents:
diff changeset
6 // RUN: | FileCheck -check-prefix=CHECK-YC %s
anatofuz
parents:
diff changeset
7 // 1. Build .pch file.
anatofuz
parents:
diff changeset
8 // CHECK-YC: cc1
anatofuz
parents:
diff changeset
9 // CHECK-YC: -emit-pch
anatofuz
parents:
diff changeset
10 // CHECK-YC: -building-pch-with-obj
anatofuz
parents:
diff changeset
11 // CHECK-YC: -o
anatofuz
parents:
diff changeset
12 // CHECK-YC: pchfile.pch
anatofuz
parents:
diff changeset
13 // CHECK-YC: -x
anatofuz
parents:
diff changeset
14 // CHECK-YC: "c++-header"
anatofuz
parents:
diff changeset
15 // 2. Use .pch file.
anatofuz
parents:
diff changeset
16 // CHECK-YC: cc1
anatofuz
parents:
diff changeset
17 // CHECK-YC: -emit-obj
anatofuz
parents:
diff changeset
18 // CHECK-YC: -building-pch-with-obj
anatofuz
parents:
diff changeset
19 // CHECK-YC: -include-pch
anatofuz
parents:
diff changeset
20 // CHECK-YC: pchfile.pch
anatofuz
parents:
diff changeset
21
anatofuz
parents:
diff changeset
22 // /Yc /Fo
anatofuz
parents:
diff changeset
23 // /Fo overrides the .obj output filename, but not the .pch filename
anatofuz
parents:
diff changeset
24 // RUN: %clang_cl -Werror /Fomyobj.obj /Ycpchfile.h /FIpchfile.h /c -### -- %s 2>&1 \
anatofuz
parents:
diff changeset
25 // RUN: | FileCheck -check-prefix=CHECK-YCO %s
anatofuz
parents:
diff changeset
26 // 1. Build .pch file.
anatofuz
parents:
diff changeset
27 // CHECK-YCO: cc1
anatofuz
parents:
diff changeset
28 // CHECK-YCO: -emit-pch
anatofuz
parents:
diff changeset
29 // CHECK-YCO: -building-pch-with-obj
anatofuz
parents:
diff changeset
30 // CHECK-YCO: -o
anatofuz
parents:
diff changeset
31 // CHECK-YCO: pchfile.pch
anatofuz
parents:
diff changeset
32 // 2. Use .pch file.
anatofuz
parents:
diff changeset
33 // CHECK-YCO: cc1
anatofuz
parents:
diff changeset
34 // CHECK-YCO: -emit-obj
anatofuz
parents:
diff changeset
35 // CHECK-YCO: -building-pch-with-obj
anatofuz
parents:
diff changeset
36 // CHECK-YCO: -include-pch
anatofuz
parents:
diff changeset
37 // CHECK-YCO: pchfile.pch
anatofuz
parents:
diff changeset
38 // CHECK-YCO: -o
anatofuz
parents:
diff changeset
39 // CHECK-YCO: myobj.obj
anatofuz
parents:
diff changeset
40
anatofuz
parents:
diff changeset
41 // /Yc /Y-
anatofuz
parents:
diff changeset
42 // /Y- disables pch generation
anatofuz
parents:
diff changeset
43 // RUN: %clang_cl -Werror /Y- /Ycpchfile.h /FIpchfile.h /c -### -- %s 2>&1 \
anatofuz
parents:
diff changeset
44 // RUN: | FileCheck -check-prefix=CHECK-YC-Y_ %s
anatofuz
parents:
diff changeset
45 // CHECK-YC-Y_-NOT: -emit-pch
anatofuz
parents:
diff changeset
46 // CHECK-YC-Y_-NOT: -include-pch
anatofuz
parents:
diff changeset
47
anatofuz
parents:
diff changeset
48 // /Yu
anatofuz
parents:
diff changeset
49 // RUN: %clang_cl -Werror /Yupchfile.h /FIpchfile.h /c -### -- %s 2>&1 \
anatofuz
parents:
diff changeset
50 // RUN: | FileCheck -check-prefix=CHECK-YU %s
anatofuz
parents:
diff changeset
51 // Use .pch file, but don't build it.
anatofuz
parents:
diff changeset
52 // CHECK-YU-NOT: -emit-pch
anatofuz
parents:
diff changeset
53 // CHECK-YU-NOT: -building-pch-with-obj
anatofuz
parents:
diff changeset
54 // CHECK-YU: cc1
anatofuz
parents:
diff changeset
55 // CHECK-YU: -emit-obj
anatofuz
parents:
diff changeset
56 // CHECK-YU: -include-pch
anatofuz
parents:
diff changeset
57 // CHECK-YU: pchfile.pch
anatofuz
parents:
diff changeset
58
anatofuz
parents:
diff changeset
59 // /Yu /Y-
anatofuz
parents:
diff changeset
60 // RUN: %clang_cl -Werror /Y- /Yupchfile.h /FIpchfile.h /c -### -- %s 2>&1 \
anatofuz
parents:
diff changeset
61 // RUN: | FileCheck -check-prefix=CHECK-YU-Y_ %s
anatofuz
parents:
diff changeset
62 // CHECK-YU-Y_-NOT: -emit-pch
anatofuz
parents:
diff changeset
63 // CHECK-YU-Y_-NOT: -include-pch
anatofuz
parents:
diff changeset
64
anatofuz
parents:
diff changeset
65 // /Yc /Yu -- /Yc overrides /Yc if they both refer to the same file
anatofuz
parents:
diff changeset
66 // RUN: %clang_cl -Werror /Ycpchfile.h /Yupchfile.h /FIpchfile.h /c -### -- %s 2>&1 \
anatofuz
parents:
diff changeset
67 // RUN: | FileCheck -check-prefix=CHECK-YC-YU %s
anatofuz
parents:
diff changeset
68 // 1. Build .pch file.
anatofuz
parents:
diff changeset
69 // CHECK-YC-YU: cc1
anatofuz
parents:
diff changeset
70 // CHECK-YC-YU: -emit-pch
anatofuz
parents:
diff changeset
71 // CHECK-YC-YU: -building-pch-with-obj
anatofuz
parents:
diff changeset
72 // CHECK-YC-YU: -o
anatofuz
parents:
diff changeset
73 // CHECK-YC-YU: pchfile.pch
anatofuz
parents:
diff changeset
74 // 2. Use .pch file.
anatofuz
parents:
diff changeset
75 // CHECK-YC-YU: cc1
anatofuz
parents:
diff changeset
76 // CHECK-YC-YU: -emit-obj
anatofuz
parents:
diff changeset
77 // CHECK-YC-YU: -include-pch
anatofuz
parents:
diff changeset
78 // CHECK-YC-YU: pchfile.pch
anatofuz
parents:
diff changeset
79
anatofuz
parents:
diff changeset
80 // If /Yc /Yu refer to different files, semantics are pretty wonky. Since this
anatofuz
parents:
diff changeset
81 // doesn't seem like something that's important in practice, just punt for now.
anatofuz
parents:
diff changeset
82 // RUN: %clang_cl -Werror /Ycfoo1.h /Yufoo2.h /FIfoo1.h /FIfoo2.h /c -### -- %s 2>&1 \
anatofuz
parents:
diff changeset
83 // RUN: | FileCheck -check-prefix=CHECK-YC-YU-MISMATCH %s
anatofuz
parents:
diff changeset
84 // CHECK-YC-YU-MISMATCH: error: support for '/Yc' and '/Yu' with different filenames not implemented yet; flags ignored
anatofuz
parents:
diff changeset
85
anatofuz
parents:
diff changeset
86 // Similarly, punt on /Yc with more than one input file.
anatofuz
parents:
diff changeset
87 // RUN: %clang_cl -Werror /Ycfoo1.h /FIfoo1.h /c -### -- %s %s 2>&1 \
anatofuz
parents:
diff changeset
88 // RUN: | FileCheck -check-prefix=CHECK-YC-MULTIINPUT %s
anatofuz
parents:
diff changeset
89 // CHECK-YC-MULTIINPUT: error: support for '/Yc' with more than one source file not implemented yet; flag ignored
anatofuz
parents:
diff changeset
90
anatofuz
parents:
diff changeset
91 // /Yc /Yu /Y-
anatofuz
parents:
diff changeset
92 // RUN: %clang_cl -Werror /Ycpchfile.h /Yupchfile.h /FIpchfile.h /Y- /c -### -- %s 2>&1 \
anatofuz
parents:
diff changeset
93 // RUN: | FileCheck -check-prefix=CHECK-YC-YU-Y_ %s
anatofuz
parents:
diff changeset
94 // CHECK-YC-YU-Y_-NOT: -emit-pch
anatofuz
parents:
diff changeset
95 // CHECK-YC-YU-Y_-NOT: -include-pch
anatofuz
parents:
diff changeset
96
anatofuz
parents:
diff changeset
97 // Test computation of pch filename in various cases.
anatofuz
parents:
diff changeset
98
anatofuz
parents:
diff changeset
99 // /Yu /Fpout.pch => out.pch is filename
anatofuz
parents:
diff changeset
100 // RUN: %clang_cl -Werror /Yupchfile.h /FIpchfile.h /Fpout.pch /c -### -- %s 2>&1 \
anatofuz
parents:
diff changeset
101 // RUN: | FileCheck -check-prefix=CHECK-YUFP1 %s
anatofuz
parents:
diff changeset
102 // Use .pch file, but don't build it.
anatofuz
parents:
diff changeset
103 // CHECK-YUFP1: -include-pch
anatofuz
parents:
diff changeset
104 // CHECK-YUFP1: out.pch
anatofuz
parents:
diff changeset
105
anatofuz
parents:
diff changeset
106 // /Yu /Fpout => out.pch is filename (.pch gets added if no extension present)
anatofuz
parents:
diff changeset
107 // RUN: %clang_cl -Werror /Yupchfile.h /FIpchfile.h /Fpout.pch /c -### -- %s 2>&1 \
anatofuz
parents:
diff changeset
108 // RUN: | FileCheck -check-prefix=CHECK-YUFP2 %s
anatofuz
parents:
diff changeset
109 // Use .pch file, but don't build it.
anatofuz
parents:
diff changeset
110 // CHECK-YUFP2: -include-pch
anatofuz
parents:
diff changeset
111 // CHECK-YUFP2: out.pch
anatofuz
parents:
diff changeset
112
anatofuz
parents:
diff changeset
113 // /Yu /Fpout.bmp => out.bmp is filename (.pch not added when extension present)
anatofuz
parents:
diff changeset
114 // RUN: %clang_cl -Werror /Yupchfile.h /FIpchfile.h /Fpout.bmp /c -### -- %s 2>&1 \
anatofuz
parents:
diff changeset
115 // RUN: | FileCheck -check-prefix=CHECK-YUFP3 %s
anatofuz
parents:
diff changeset
116 // Use .pch file, but don't build it.
anatofuz
parents:
diff changeset
117 // CHECK-YUFP3: -include-pch
anatofuz
parents:
diff changeset
118 // CHECK-YUFP3: out.bmp
anatofuz
parents:
diff changeset
119
anatofuz
parents:
diff changeset
120 // /Yusub/dir.h => sub/dir.pch
anatofuz
parents:
diff changeset
121 // RUN: %clang_cl -Werror /Yusub/pchfile.h /FIsub/pchfile.h /c -### -- %s 2>&1 \
anatofuz
parents:
diff changeset
122 // RUN: | FileCheck -check-prefix=CHECK-YUFP4 %s
anatofuz
parents:
diff changeset
123 // Use .pch file, but don't build it.
anatofuz
parents:
diff changeset
124 // CHECK-YUFP4: -include-pch
anatofuz
parents:
diff changeset
125 // CHECK-YUFP4: sub/pchfile.pch
anatofuz
parents:
diff changeset
126
anatofuz
parents:
diff changeset
127 // /Yudir.h /Isub => dir.pch
anatofuz
parents:
diff changeset
128 // RUN: %clang_cl -Werror /Yupchfile.h /FIpchfile.h /Isub /c -### -- %s 2>&1 \
anatofuz
parents:
diff changeset
129 // RUN: | FileCheck -check-prefix=CHECK-YUFP5 %s
anatofuz
parents:
diff changeset
130 // Use .pch file, but don't build it.
anatofuz
parents:
diff changeset
131 // CHECK-YUFP5: -include-pch
anatofuz
parents:
diff changeset
132 // CHECK-YUFP5: pchfile.pch
anatofuz
parents:
diff changeset
133
anatofuz
parents:
diff changeset
134 // FIXME: /Fpdir: use dir/VCx0.pch when dir is directory, where x is major MSVS
anatofuz
parents:
diff changeset
135 // version in use.
anatofuz
parents:
diff changeset
136
anatofuz
parents:
diff changeset
137 // Spot-check one use of /Fp with /Yc too, else trust the /Yu test cases above
anatofuz
parents:
diff changeset
138 // also all assume to /Yc.
anatofuz
parents:
diff changeset
139 // RUN: %clang_cl -Werror /Ycpchfile.h /FIpchfile.h /Fpsub/file.pch /c -### -- %s 2>&1 \
anatofuz
parents:
diff changeset
140 // RUN: | FileCheck -check-prefix=CHECK-YCFP %s
anatofuz
parents:
diff changeset
141 // 1. Build .pch file.
anatofuz
parents:
diff changeset
142 // CHECK-YCFP: cc1
anatofuz
parents:
diff changeset
143 // CHECK-YCFP: -emit-pch
anatofuz
parents:
diff changeset
144 // CHECK-YCFP: -o
anatofuz
parents:
diff changeset
145 // CHECK-YCFP: sub/file.pch
anatofuz
parents:
diff changeset
146 // 2. Use .pch file.
anatofuz
parents:
diff changeset
147 // CHECK-YCFP: cc1
anatofuz
parents:
diff changeset
148 // CHECK-YCFP: -emit-obj
anatofuz
parents:
diff changeset
149 // CHECK-YCFP: -include-pch
anatofuz
parents:
diff changeset
150 // CHECK-YCFP: sub/file.pch
anatofuz
parents:
diff changeset
151
anatofuz
parents:
diff changeset
152 // /Ycfoo2.h /FIfoo1.h /FIfoo2.h /FIfoo3.h
anatofuz
parents:
diff changeset
153 // => foo1 and foo2 go into pch, foo3 into main compilation
anatofuz
parents:
diff changeset
154 // /Yc
anatofuz
parents:
diff changeset
155 // RUN: %clang_cl -Werror /Ycfoo2.h /FIfoo1.h /FIfoo2.h /FIfoo3.h /c -### -- %s 2>&1 \
anatofuz
parents:
diff changeset
156 // RUN: | FileCheck -check-prefix=CHECK-YCFIFIFI %s
anatofuz
parents:
diff changeset
157 // 1. Build .pch file: Includes foo1.h (but NOT foo3.h) and compiles foo2.h
anatofuz
parents:
diff changeset
158 // CHECK-YCFIFIFI: cc1
anatofuz
parents:
diff changeset
159 // CHECK-YCFIFIFI: -emit-pch
anatofuz
parents:
diff changeset
160 // CHECK-YCFIFIFI: -pch-through-header=foo2.h
anatofuz
parents:
diff changeset
161 // CHECK-YCFIFIFI: -include
anatofuz
parents:
diff changeset
162 // CHECK-YCFIFIFI: foo1.h
anatofuz
parents:
diff changeset
163 // CHECK-YCFIFIFI: -include
anatofuz
parents:
diff changeset
164 // CHECK-YCFIFIFI: foo2.h
anatofuz
parents:
diff changeset
165 // CHECK-YCFIFIFI: -include
anatofuz
parents:
diff changeset
166 // CHECK-YCFIFIFI: foo3.h
anatofuz
parents:
diff changeset
167 // CHECK-YCFIFIFI: -o
anatofuz
parents:
diff changeset
168 // CHECK-YCFIFIFI: foo2.pch
anatofuz
parents:
diff changeset
169 // CHECK-YCFIFIFI: -x
anatofuz
parents:
diff changeset
170 // CHECK-YCFIFIFI: "c++-header"
anatofuz
parents:
diff changeset
171 // CHECK-YCFIFIFI: cl-pch.cpp
anatofuz
parents:
diff changeset
172 // 2. Use .pch file: Inlucdes foo2.pch and foo3.h
anatofuz
parents:
diff changeset
173 // CHECK-YCFIFIFI: cc1
anatofuz
parents:
diff changeset
174 // CHECK-YCFIFIFI: -emit-obj
anatofuz
parents:
diff changeset
175 // CHECK-YCFIFIFI: -include-pch
anatofuz
parents:
diff changeset
176 // CHECK-YCFIFIFI: foo2.pch
anatofuz
parents:
diff changeset
177 // CHECK-YCFIFIFI: -pch-through-header=foo2.h
anatofuz
parents:
diff changeset
178 // CHECK-YCFIFIFI: -include
anatofuz
parents:
diff changeset
179 // CHECK-YCFIFIFI: foo1.h
anatofuz
parents:
diff changeset
180 // CHECK-YCFIFIFI: -include
anatofuz
parents:
diff changeset
181 // CHECK-YCFIFIFI: foo2.h
anatofuz
parents:
diff changeset
182 // CHECK-YCFIFIFI: -include
anatofuz
parents:
diff changeset
183 // CHECK-YCFIFIFI: foo3.h
anatofuz
parents:
diff changeset
184 // CHECK-YCFIFIFI: -o
anatofuz
parents:
diff changeset
185 // CHECK-YCFIFIFI: cl-pch.obj
anatofuz
parents:
diff changeset
186 // CHECK-YCFIFIFI: -x
anatofuz
parents:
diff changeset
187 // CHECK-YCFIFIFI: "c++"
anatofuz
parents:
diff changeset
188 // CHECK-YCFIFIFI: cl-pch.cpp
anatofuz
parents:
diff changeset
189
anatofuz
parents:
diff changeset
190 // /Yufoo2.h /FIfoo1.h /FIfoo2.h /FIfoo3.h
anatofuz
parents:
diff changeset
191 // => foo1 foo2 filtered out, foo3 into main compilation
anatofuz
parents:
diff changeset
192 // RUN: %clang_cl -Werror /Yufoo2.h /FIfoo1.h /FIfoo2.h /FIfoo3.h /c -### -- %s 2>&1 \
anatofuz
parents:
diff changeset
193 // RUN: | FileCheck -check-prefix=CHECK-YUFIFIFI %s
anatofuz
parents:
diff changeset
194 // Use .pch file, but don't build it.
anatofuz
parents:
diff changeset
195 // CHECK-YUFIFIFI-NOT: -emit-pch
anatofuz
parents:
diff changeset
196 // CHECK-YUFIFIFI: cc1
anatofuz
parents:
diff changeset
197 // CHECK-YUFIFIFI: -emit-obj
anatofuz
parents:
diff changeset
198 // CHECK-YUFIFIFI: -include-pch
anatofuz
parents:
diff changeset
199 // CHECK-YUFIFIFI: foo2.pch
anatofuz
parents:
diff changeset
200 // CHECK-YUFIFIFI: -pch-through-header=foo2.h
anatofuz
parents:
diff changeset
201 // CHECK-YUFIFIFI: -include
anatofuz
parents:
diff changeset
202 // CHECK-YUFIFIFI: foo1.h
anatofuz
parents:
diff changeset
203 // CHECK-YUFIFIFI: -include
anatofuz
parents:
diff changeset
204 // CHECK-YUFIFIFI: foo2.h
anatofuz
parents:
diff changeset
205 // CHECK-YUFIFIFI: -include
anatofuz
parents:
diff changeset
206 // CHECK-YUFIFIFI: foo3.h
anatofuz
parents:
diff changeset
207
anatofuz
parents:
diff changeset
208 // Test /Ycfoo.h / /Yufoo.h without /FIfoo.h
anatofuz
parents:
diff changeset
209 // RUN: %clang_cl -Werror /Ycfoo.h /c -### -- %s 2>&1 \
anatofuz
parents:
diff changeset
210 // RUN: | FileCheck -check-prefix=CHECK-YC-NOFI %s
anatofuz
parents:
diff changeset
211 // 1. Precompile
anatofuz
parents:
diff changeset
212 // CHECK-YC-NOFI: cc1
anatofuz
parents:
diff changeset
213 // CHECK-YC-NOFI: -emit-pch
anatofuz
parents:
diff changeset
214 // CHECK-YC-NOFI: -pch-through-header=foo.h
anatofuz
parents:
diff changeset
215 // CHECK-YC-NOFI: -o
anatofuz
parents:
diff changeset
216 // CHECK-YC-NOFI: foo.pch
anatofuz
parents:
diff changeset
217 // CHECK-YC-NOFI: -x
anatofuz
parents:
diff changeset
218 // CHECK-YC-NOFI: c++-header
anatofuz
parents:
diff changeset
219 // CHECK-YC-NOFI: cl-pch.cpp
anatofuz
parents:
diff changeset
220 // 2. Build PCH object
anatofuz
parents:
diff changeset
221 // CHECK-YC-NOFI: cc1
anatofuz
parents:
diff changeset
222 // CHECK-YC-NOFI: -emit-obj
anatofuz
parents:
diff changeset
223 // CHECK-YC-NOFI: -include-pch
anatofuz
parents:
diff changeset
224 // CHECK-YC-NOFI: foo.pch
anatofuz
parents:
diff changeset
225 // CHECK-YC-NOFI: -pch-through-header=foo.h
anatofuz
parents:
diff changeset
226 // CHECK-YC-NOFI: -x
anatofuz
parents:
diff changeset
227 // CHECK-YC-NOFI: c++
anatofuz
parents:
diff changeset
228 // CHECK-YC-NOFI: cl-pch.cpp
anatofuz
parents:
diff changeset
229 // RUN: %clang_cl -Werror /Yufoo.h /c -### -- %s 2>&1 \
anatofuz
parents:
diff changeset
230 // RUN: | FileCheck -check-prefix=CHECK-YU-NOFI %s
anatofuz
parents:
diff changeset
231 // CHECK-YU-NOFI: cc1
anatofuz
parents:
diff changeset
232 // CHECK-YU-NOFI: -emit-obj
anatofuz
parents:
diff changeset
233 // CHECK-YU-NOFI: -include-pch
anatofuz
parents:
diff changeset
234 // CHECK-YU-NOFI: foo.pch
anatofuz
parents:
diff changeset
235 // CHECK-YU-NOFI: -pch-through-header=foo.h
anatofuz
parents:
diff changeset
236 // CHECK-YU-NOFI: -x
anatofuz
parents:
diff changeset
237 // CHECK-YU-NOFI: c++
anatofuz
parents:
diff changeset
238 // CHECK-YU-NOFI: cl-pch.cpp
anatofuz
parents:
diff changeset
239
anatofuz
parents:
diff changeset
240 // With an actual /I argument.
anatofuz
parents:
diff changeset
241 // RUN: %clang_cl -Werror /Ifoo /Ycpchfile.h /FIpchfile.h /c -### -- %s 2>&1 \
anatofuz
parents:
diff changeset
242 // RUN: | FileCheck -check-prefix=CHECK-YC-I3 %s
anatofuz
parents:
diff changeset
243 // 1. This writes pchfile.pch into the root dir, even if this will pick up
anatofuz
parents:
diff changeset
244 // foo/pchfile.h
anatofuz
parents:
diff changeset
245 // CHECK-YC-I3: cc1
anatofuz
parents:
diff changeset
246 // CHECK-YC-I3: -emit-pch
anatofuz
parents:
diff changeset
247 // CHECK-YC-I3: -o
anatofuz
parents:
diff changeset
248 // CHECK-YC-I3: pchfile.pch
anatofuz
parents:
diff changeset
249 // 2. Use .pch file.
anatofuz
parents:
diff changeset
250 // CHECK-YC-I3: cc1
anatofuz
parents:
diff changeset
251 // CHECK-YC-I3: -emit-obj
anatofuz
parents:
diff changeset
252 // CHECK-YC-I3: -include-pch
anatofuz
parents:
diff changeset
253 // CHECK-YC-I3: pchfile.pch
anatofuz
parents:
diff changeset
254
anatofuz
parents:
diff changeset
255 // But /FIfoo/bar.h /Ycfoo\bar.h does work, as does /FIfOo.h /Ycfoo.H
anatofuz
parents:
diff changeset
256 // RUN: %clang_cl -Werror /YupchFILE.h /FI./pchfile.h /c -### -- %s 2>&1 \
anatofuz
parents:
diff changeset
257 // RUN: | FileCheck -check-prefix=CHECK-YU-CASE %s
anatofuz
parents:
diff changeset
258 // CHECK-YU-CASE: -pch-through-header=pchFILE.h
anatofuz
parents:
diff changeset
259 // CHECK-YU-CASE: -include
anatofuz
parents:
diff changeset
260 // CHECK-YU-CASE: "./pchfile.h"
anatofuz
parents:
diff changeset
261 // RUN: %clang_cl -Werror /Yu./pchfile.h /FI.\\pchfile.h /c -### -- %s 2>&1 \
anatofuz
parents:
diff changeset
262 // RUN: | FileCheck -check-prefix=CHECK-YU-SLASH %s
anatofuz
parents:
diff changeset
263 // CHECK-YU-SLASH: -pch-through-header=./pchfile.h
anatofuz
parents:
diff changeset
264 // CHECK-YU-SLASH: -include
anatofuz
parents:
diff changeset
265 // CHECK-YU-SLASH: ".{{[/\\]+}}pchfile.h"
anatofuz
parents:
diff changeset
266
anatofuz
parents:
diff changeset
267 // /Yc without an argument creates a PCH from the code before #pragma hdrstop.
anatofuz
parents:
diff changeset
268 // /Yu without an argument uses a PCH and starts compiling after the
anatofuz
parents:
diff changeset
269 // #pragma hdrstop.
anatofuz
parents:
diff changeset
270 // RUN: %clang_cl -Werror /Yc /Fpycnoarg.pch /c -### -- %s 2>&1 \
anatofuz
parents:
diff changeset
271 // RUN: | FileCheck -check-prefix=CHECK-YC-NOARG %s
anatofuz
parents:
diff changeset
272 // 1. Create .pch file
anatofuz
parents:
diff changeset
273 // CHECK-YC-NOARG: cc1
anatofuz
parents:
diff changeset
274 // CHECK-YC-NOARG: -emit-pch
anatofuz
parents:
diff changeset
275 // CHECK-YC-NOARG: -pch-through-hdrstop-create
anatofuz
parents:
diff changeset
276 // CHECK-YC-NOARG: -o
anatofuz
parents:
diff changeset
277 // CHECK-YC-NOARG: ycnoarg.pch
anatofuz
parents:
diff changeset
278 // CHECK-YC-NOARG: -x
anatofuz
parents:
diff changeset
279 // CHECK-YC-NOARG: "c++-header"
anatofuz
parents:
diff changeset
280 // CHECK-YC-NOARG: cl-pch.cpp
anatofuz
parents:
diff changeset
281 // 2. Use .pch file: Includes ycnoarg.pch
anatofuz
parents:
diff changeset
282 // CHECK-YC-NOARG: cc1
anatofuz
parents:
diff changeset
283 // CHECK-YC-NOARG: -emit-obj
anatofuz
parents:
diff changeset
284 // CHECK-YC-NOARG: -include-pch
anatofuz
parents:
diff changeset
285 // CHECK-YC-NOARG: ycnoarg.pch
anatofuz
parents:
diff changeset
286 // CHECK-YC-NOARG: -pch-through-hdrstop-create
anatofuz
parents:
diff changeset
287 // CHECK-YC-NOARG: -o
anatofuz
parents:
diff changeset
288 // CHECK-YC-NOARG: cl-pch.obj
anatofuz
parents:
diff changeset
289 // CHECK-YC-NOARG: -x
anatofuz
parents:
diff changeset
290 // CHECK-YC-NOARG: "c++"
anatofuz
parents:
diff changeset
291 // CHECK-YC-NOARG: cl-pch.cpp
anatofuz
parents:
diff changeset
292
anatofuz
parents:
diff changeset
293 // RUN: %clang_cl -Werror /Yu /Fpycnoarg.pch /c -### -- %s 2>&1 \
anatofuz
parents:
diff changeset
294 // RUN: | FileCheck -check-prefix=CHECK-YU-NOARG %s
anatofuz
parents:
diff changeset
295 // Use .pch file, but don't build it.
anatofuz
parents:
diff changeset
296 // CHECK-YU-NOARG-NOT: -emit-pch
anatofuz
parents:
diff changeset
297 // CHECK-YU-NOARG: cc1
anatofuz
parents:
diff changeset
298 // CHECK-YU-NOARG: -emit-obj
anatofuz
parents:
diff changeset
299 // CHECK-YU-NOARG: -include-pch
anatofuz
parents:
diff changeset
300 // CHECK-YU-NOARG: ycnoarg.pch
anatofuz
parents:
diff changeset
301 // CHECK-YU-NOARG: -pch-through-hdrstop-use
anatofuz
parents:
diff changeset
302 // CHECK-YU-NOARG: -o
anatofuz
parents:
diff changeset
303 // CHECK-YU-NOARG: cl-pch.obj
anatofuz
parents:
diff changeset
304 // CHECK-YU-NOARG: -x
anatofuz
parents:
diff changeset
305 // CHECK-YU-NOARG: "c++"
anatofuz
parents:
diff changeset
306 // CHECK-YU-NOARG: cl-pch.cpp
anatofuz
parents:
diff changeset
307
anatofuz
parents:
diff changeset
308 // /Yc with no argument and no /FP
anatofuz
parents:
diff changeset
309 // RUN: %clang_cl -Werror /Yc /c -### -- %s 2>&1 \
anatofuz
parents:
diff changeset
310 // RUN: | FileCheck -check-prefix=CHECK-YC-NOARG-NOFP %s
anatofuz
parents:
diff changeset
311 // 1. Create .pch file
anatofuz
parents:
diff changeset
312 // CHECK-YC-NOARG-NOFP: cc1
anatofuz
parents:
diff changeset
313 // CHECK-YC-NOARG-NOFP: -emit-pch
anatofuz
parents:
diff changeset
314 // CHECK-YC-NOARG-NOFP: -pch-through-hdrstop-create
anatofuz
parents:
diff changeset
315 // CHECK-YC-NOARG-NOFP: -o
anatofuz
parents:
diff changeset
316 // CHECK-YC-NOARG-NOFP: cl-pch.pch
anatofuz
parents:
diff changeset
317 // CHECK-YC-NOARG-NOFP: -x
anatofuz
parents:
diff changeset
318 // CHECK-YC-NOARG-NOFP: "c++-header"
anatofuz
parents:
diff changeset
319 // CHECK-YC-NOARG-NOFP: cl-pch.cpp
anatofuz
parents:
diff changeset
320 // 2. Use .pch file: Includes cl-pch.pch
anatofuz
parents:
diff changeset
321 // CHECK-YC-NOARG-NOFP: cc1
anatofuz
parents:
diff changeset
322 // CHECK-YC-NOARG-NOFP: -emit-obj
anatofuz
parents:
diff changeset
323 // CHECK-YC-NOARG-NOFP: -include-pch
anatofuz
parents:
diff changeset
324 // CHECK-YC-NOARG-NOFP: cl-pch.pch
anatofuz
parents:
diff changeset
325 // CHECK-YC-NOARG-NOFP: -pch-through-hdrstop-create
anatofuz
parents:
diff changeset
326 // CHECK-YC-NOARG-NOFP: -o
anatofuz
parents:
diff changeset
327 // CHECK-YC-NOARG-NOFP: cl-pch.obj
anatofuz
parents:
diff changeset
328 // CHECK-YC-NOARG-NOFP: -x
anatofuz
parents:
diff changeset
329 // CHECK-YC-NOARG-NOFP: "c++"
anatofuz
parents:
diff changeset
330 // CHECK-YC-NOARG-NOFP: cl-pch.cpp
anatofuz
parents:
diff changeset
331
anatofuz
parents:
diff changeset
332 // cl.exe warns on multiple /Yc, /Yu, /Fp arguments, but clang-cl silently just
anatofuz
parents:
diff changeset
333 // uses the last one. This is true for e.g. /Fo too, so not warning on this
anatofuz
parents:
diff changeset
334 // is self-consistent with clang-cl's flag handling.
anatofuz
parents:
diff changeset
335
anatofuz
parents:
diff changeset
336 // /FI without /Yu => pch file not used, even if it exists (different from
anatofuz
parents:
diff changeset
337 // -include, which picks up .gch files if they exist).
anatofuz
parents:
diff changeset
338 // RUN: touch %t.pch
anatofuz
parents:
diff changeset
339 // RUN: %clang_cl -Werror /FI%t.pch /Fp%t.pch /c -### -- %s 2>&1 \
anatofuz
parents:
diff changeset
340 // RUN: | FileCheck -check-prefix=CHECK-FI %s
anatofuz
parents:
diff changeset
341 // CHECK-FI-NOT: -include-pch
anatofuz
parents:
diff changeset
342 // CHECK-FI: -include
anatofuz
parents:
diff changeset
343
anatofuz
parents:
diff changeset
344 // Test interaction of /Yc with language mode flags.
anatofuz
parents:
diff changeset
345
anatofuz
parents:
diff changeset
346 // If /TC changes the input language to C, a c pch file should be produced.
anatofuz
parents:
diff changeset
347 // RUN: %clang_cl /TC -Werror /Ycpchfile.h /FIpchfile.h /c -### -- %s 2>&1 \
anatofuz
parents:
diff changeset
348 // RUN: | FileCheck -check-prefix=CHECK-YCTC %s
anatofuz
parents:
diff changeset
349 // CHECK-YCTC: cc1
anatofuz
parents:
diff changeset
350 // CHECK-YCTC: -emit-pch
anatofuz
parents:
diff changeset
351 // CHECK-YCTC: -o
anatofuz
parents:
diff changeset
352 // CHECK-YCTC: pchfile.pch
anatofuz
parents:
diff changeset
353 // CHECK-YCTC: -x
anatofuz
parents:
diff changeset
354 // CHECK-YCTC: "c"
anatofuz
parents:
diff changeset
355
anatofuz
parents:
diff changeset
356 // Also check lower-case /Tc variant.
anatofuz
parents:
diff changeset
357 // RUN: %clang_cl -Werror /Ycpchfile.h /FIpchfile.h /c -### /Tc%s 2>&1 \
anatofuz
parents:
diff changeset
358 // RUN: | FileCheck -check-prefix=CHECK-YCTc %s
anatofuz
parents:
diff changeset
359 // CHECK-YCTc: cc1
anatofuz
parents:
diff changeset
360 // CHECK-YCTc: -emit-pch
anatofuz
parents:
diff changeset
361 // CHECK-YCTc: -o
anatofuz
parents:
diff changeset
362 // CHECK-YCTc: pchfile.pch
anatofuz
parents:
diff changeset
363 // CHECK-YCTc: -x
anatofuz
parents:
diff changeset
364 // CHECK-YCTc: "c"
anatofuz
parents:
diff changeset
365
anatofuz
parents:
diff changeset
366 // Don't crash when a non-source file is passed.
anatofuz
parents:
diff changeset
367 // RUN: %clang_cl -Werror /Ycpchfile.h /FIpchfile.h /c -### -- %S/Inputs/file.prof 2>&1 \
anatofuz
parents:
diff changeset
368 // RUN: | FileCheck -check-prefix=CHECK-NoSource %s
anatofuz
parents:
diff changeset
369 // CHECK-NoSource: file.prof:{{.*}}input unused
anatofuz
parents:
diff changeset
370
anatofuz
parents:
diff changeset
371 // ...but if an explicit flag turns the file into a source file, handle it:
anatofuz
parents:
diff changeset
372 // RUN: %clang_cl /TP -Werror /Ycpchfile.h /FIpchfile.h /c -### -- %S/Inputs/file.prof 2>&1 \
anatofuz
parents:
diff changeset
373 // RUN: | FileCheck -check-prefix=CHECK-NoSourceTP %s
anatofuz
parents:
diff changeset
374 // CHECK-NoSourceTP: cc1
anatofuz
parents:
diff changeset
375 // CHECK-NoSourceTP: -emit-pch
anatofuz
parents:
diff changeset
376 // CHECK-NoSourceTP: -o
anatofuz
parents:
diff changeset
377 // CHECK-NoSourceTP: pchfile.pch
anatofuz
parents:
diff changeset
378 // CHECK-NoSourceTP: -x
anatofuz
parents:
diff changeset
379 // CHECK-NoSourceTP: "c++"
anatofuz
parents:
diff changeset
380
anatofuz
parents:
diff changeset
381 // If only preprocessing, PCH options are ignored.
anatofuz
parents:
diff changeset
382 // RUN: %clang_cl /P /Ycpchfile.h /FIpchfile.h /c -### -- %s 2>&1 \
anatofuz
parents:
diff changeset
383 // RUN: | FileCheck -check-prefix=CHECK-YC-P %s
anatofuz
parents:
diff changeset
384 // CHECK-YC-P-NOT: -emit-pch
anatofuz
parents:
diff changeset
385 // CHECK-YC-P-NOT: -include-pch
anatofuz
parents:
diff changeset
386
anatofuz
parents:
diff changeset
387 // RUN: %clang_cl /E /Ycpchfile.h /FIpchfile.h /c -### -- %s 2>&1 \
anatofuz
parents:
diff changeset
388 // RUN: | FileCheck -check-prefix=CHECK-YC-E %s
anatofuz
parents:
diff changeset
389 // CHECK-YC-E-NOT: -emit-pch
anatofuz
parents:
diff changeset
390 // CHECK-YC-E-NOT: -include-pch
anatofuz
parents:
diff changeset
391
anatofuz
parents:
diff changeset
392 // RUN: %clang_cl /P /Ycpchfile.h /FIpchfile.h /c -### -- %s 2>&1 \
anatofuz
parents:
diff changeset
393 // RUN: | FileCheck -check-prefix=CHECK-YU-P %s
anatofuz
parents:
diff changeset
394 // CHECK-YU-P-NOT: -emit-pch
anatofuz
parents:
diff changeset
395 // CHECK-YU-P-NOT: -include-pch
anatofuz
parents:
diff changeset
396
anatofuz
parents:
diff changeset
397 // RUN: %clang_cl /E /Ycpchfile.h /FIpchfile.h /c -### -- %s 2>&1 \
anatofuz
parents:
diff changeset
398 // RUN: | FileCheck -check-prefix=CHECK-YU-E %s
anatofuz
parents:
diff changeset
399 // CHECK-YU-E-NOT: -emit-pch
anatofuz
parents:
diff changeset
400 // CHECK-YU-E-NOT: -include-pch