1 // Note: %s must be preceded by --, otherwise it may be interpreted as a
2 // command-line option, e.g. on Mac where %s is commonly under /Users.
3 
4 
5 // Alias options:
6 
7 // RUN: %clang_cl /c -### -- %s 2>&1 | FileCheck -check-prefix=c %s
8 // c: -c
9 
10 // RUN: %clang_cl /C -### -- %s 2>&1 | FileCheck -check-prefix=C %s
11 // C: error: invalid argument '/C' only allowed with '/E, /P or /EP'
12 
13 // RUN: %clang_cl /C /P -### -- %s 2>&1 | FileCheck -check-prefix=C_P %s
14 // C_P: "-E"
15 // C_P: "-C"
16 
17 // RUN: %clang_cl /d1reportAllClassLayout -### /c /WX -- %s 2>&1 | \
18 // RUN:     FileCheck -check-prefix=d1reportAllClassLayout %s
19 // d1reportAllClassLayout-NOT: warning:
20 // d1reportAllClassLayout-NOT: error:
21 // d1reportAllClassLayout: -fdump-record-layouts
22 
23 // RUN: %clang_cl /Dfoo=bar /D bar=baz /DMYDEF#value /DMYDEF2=foo#bar /DMYDEF3#a=b /DMYDEF4# \
24 // RUN:    -### -- %s 2>&1 | FileCheck -check-prefix=D %s
25 // D: "-D" "foo=bar"
26 // D: "-D" "bar=baz"
27 // D: "-D" "MYDEF=value"
28 // D: "-D" "MYDEF2=foo#bar"
29 // D: "-D" "MYDEF3=a=b"
30 // D: "-D" "MYDEF4="
31 
32 // RUN: %clang_cl /E -### -- %s 2>&1 | FileCheck -check-prefix=E %s
33 // E: "-E"
34 // E: "-o" "-"
35 
36 // RUN: %clang_cl /EP -### -- %s 2>&1 | FileCheck -check-prefix=EP %s
37 // EP: "-E"
38 // EP: "-P"
39 // EP: "-o" "-"
40 
41 // RUN: %clang_cl /fp:fast /fp:except -### -- %s 2>&1 | FileCheck -check-prefix=fpexcept %s
42 // fpexcept-NOT: -menable-unsafe-fp-math
43 
44 // RUN: %clang_cl /fp:fast /fp:except /fp:except- -### -- %s 2>&1 | FileCheck -check-prefix=fpexcept_ %s
45 // fpexcept_: -menable-unsafe-fp-math
46 
47 // RUN: %clang_cl /fp:precise /fp:fast -### -- %s 2>&1 | FileCheck -check-prefix=fpfast %s
48 // fpfast: -menable-unsafe-fp-math
49 // fpfast: -ffast-math
50 
51 // RUN: %clang_cl /fp:fast /fp:precise -### -- %s 2>&1 | FileCheck -check-prefix=fpprecise %s
52 // fpprecise-NOT: -menable-unsafe-fp-math
53 // fpprecise-NOT: -ffast-math
54 
55 // RUN: %clang_cl /fp:fast /fp:strict -### -- %s 2>&1 | FileCheck -check-prefix=fpstrict %s
56 // fpstrict-NOT: -menable-unsafe-fp-math
57 // fpstrict-NOT: -ffast-math
58 
59 // RUN: %clang_cl -### /FA -fprofile-instr-generate -- %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-INSTR-GENERATE %s
60 // RUN: %clang_cl -### /FA -fprofile-instr-generate=/tmp/somefile.profraw -- %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-INSTR-GENERATE-FILE %s
61 // CHECK-PROFILE-INSTR-GENERATE: "-fprofile-instrument=clang" "--dependent-lib=clang_rt.profile-{{[^"]*}}.lib"
62 // CHECK-PROFILE-INSTR-GENERATE-FILE: "-fprofile-instrument-path=/tmp/somefile.profraw"
63 
64 // RUN: %clang_cl -### /FA -fprofile-generate -- %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-GENERATE %s
65 // CHECK-PROFILE-GENERATE: "-fprofile-instrument=llvm" "--dependent-lib=clang_rt.profile-{{[^"]*}}.lib"
66 
67 // RUN: %clang_cl -### /FA -fprofile-instr-generate -fprofile-instr-use -- %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-GEN-USE %s
68 // RUN: %clang_cl -### /FA -fprofile-instr-generate -fprofile-instr-use=file -- %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-GEN-USE %s
69 // CHECK-NO-MIX-GEN-USE: '{{[a-z=-]*}}' not allowed with '{{[a-z=-]*}}'
70 
71 // RUN: %clang_cl -### /FA -fprofile-instr-use -- %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-USE %s
72 // RUN: %clang_cl -### /FA -fprofile-instr-use=/tmp/somefile.prof -- %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-USE-FILE %s
73 // CHECK-PROFILE-USE: "-fprofile-instrument-use-path=default.profdata"
74 // CHECK-PROFILE-USE-FILE: "-fprofile-instrument-use-path=/tmp/somefile.prof"
75 
76 // RUN: %clang_cl /GA -### -- %s 2>&1 | FileCheck -check-prefix=GA %s
77 // GA: -ftls-model=local-exec
78 
79 // RTTI is on by default; just check that we don't error.
80 // RUN: %clang_cl /Zs /GR -- %s 2>&1
81 
82 // RUN: %clang_cl /GR- -### -- %s 2>&1 | FileCheck -check-prefix=GR_ %s
83 // GR_: -fno-rtti
84 
85 // Security Buffer Check is on by default.
86 // RUN: %clang_cl -### -- %s 2>&1 | FileCheck -check-prefix=GS-default %s
87 // GS-default: "-stack-protector" "2"
88 
89 // RUN: %clang_cl /GS -### -- %s 2>&1 | FileCheck -check-prefix=GS %s
90 // GS: "-stack-protector" "2"
91 
92 // RUN: %clang_cl /GS- -### -- %s 2>&1 | FileCheck -check-prefix=GS_ %s
93 // GS_-NOT: -stack-protector
94 
95 // RUN: %clang_cl /Gy -### -- %s 2>&1 | FileCheck -check-prefix=Gy %s
96 // Gy: -ffunction-sections
97 
98 // RUN: %clang_cl /Gy /Gy- -### -- %s 2>&1 | FileCheck -check-prefix=Gy_ %s
99 // Gy_-NOT: -ffunction-sections
100 
101 // RUN: %clang_cl /Gs -### -- %s 2>&1 | FileCheck -check-prefix=Gs %s
102 // Gs: "-mstack-probe-size=4096"
103 // RUN: %clang_cl /Gs0 -### -- %s 2>&1 | FileCheck -check-prefix=Gs0 %s
104 // Gs0: "-mstack-probe-size=0"
105 // RUN: %clang_cl /Gs4096 -### -- %s 2>&1 | FileCheck -check-prefix=Gs4096 %s
106 // Gs4096: "-mstack-probe-size=4096"
107 
108 // RUN: %clang_cl /Gw -### -- %s 2>&1 | FileCheck -check-prefix=Gw %s
109 // Gw: -fdata-sections
110 
111 // RUN: %clang_cl /Gw /Gw- -### -- %s 2>&1 | FileCheck -check-prefix=Gw_ %s
112 // Gw_-NOT: -fdata-sections
113 
114 // RUN: %clang_cl /Imyincludedir -### -- %s 2>&1 | FileCheck -check-prefix=SLASH_I %s
115 // RUN: %clang_cl /I myincludedir -### -- %s 2>&1 | FileCheck -check-prefix=SLASH_I %s
116 // SLASH_I: "-I" "myincludedir"
117 
118 // RUN: %clang_cl /imsvcmyincludedir -### -- %s 2>&1 | FileCheck -check-prefix=SLASH_imsvc %s
119 // RUN: %clang_cl /imsvc myincludedir -### -- %s 2>&1 | FileCheck -check-prefix=SLASH_imsvc %s
120 // Clang's resource header directory should be first:
121 // SLASH_imsvc: "-internal-isystem" "{{[^"]*}}lib{{(64)?/|\\\\}}clang{{[^"]*}}include"
122 // SLASH_imsvc: "-internal-isystem" "myincludedir"
123 
124 // RUN: %clang_cl /J -### -- %s 2>&1 | FileCheck -check-prefix=J %s
125 // J: -fno-signed-char
126 
127 // RUN: %clang_cl /Ofoo -### -- %s 2>&1 | FileCheck -check-prefix=O %s
128 // O: /Ofoo
129 
130 // RUN: %clang_cl /Ob0 -### -- %s 2>&1 | FileCheck -check-prefix=Ob0 %s
131 // Ob0: -fno-inline
132 
133 // RUN: %clang_cl /Ob2 -### -- %s 2>&1 | FileCheck -check-prefix=Ob2 %s
134 // RUN: %clang_cl /Odb2 -### -- %s 2>&1 | FileCheck -check-prefix=Ob2 %s
135 // RUN: %clang_cl /O2 /Ob2 -### -- %s 2>&1 | FileCheck -check-prefix=Ob2 %s
136 // Ob2-NOT: warning: argument unused during compilation: '/O2'
137 // Ob2: -finline-functions
138 
139 // RUN: %clang_cl /Ob1 -### -- %s 2>&1 | FileCheck -check-prefix=Ob1 %s
140 // RUN: %clang_cl /Odb1 -### -- %s 2>&1 | FileCheck -check-prefix=Ob1 %s
141 // Ob1: -finline-hint-functions
142 
143 // RUN: %clang_cl /Od -### -- %s 2>&1 | FileCheck -check-prefix=Od %s
144 // Od: -O0
145 
146 // RUN: %clang_cl /Oi- /Oi -### -- %s 2>&1 | FileCheck -check-prefix=Oi %s
147 // Oi-NOT: -fno-builtin
148 
149 // RUN: %clang_cl /Oi- -### -- %s 2>&1 | FileCheck -check-prefix=Oi_ %s
150 // Oi_: -fno-builtin
151 
152 // RUN: %clang_cl /Os --target=i686-pc-windows-msvc -### -- %s 2>&1 | FileCheck -check-prefix=Os %s
153 // RUN: %clang_cl /Os --target=x86_64-pc-windows-msvc -### -- %s 2>&1 | FileCheck -check-prefix=Os %s
154 // Os: -mframe-pointer=none
155 // Os: -Os
156 
157 // RUN: %clang_cl /Ot --target=i686-pc-windows-msvc -### -- %s 2>&1 | FileCheck -check-prefix=Ot %s
158 // RUN: %clang_cl /Ot --target=x86_64-pc-windows-msvc -### -- %s 2>&1 | FileCheck -check-prefix=Ot %s
159 // Ot: -mframe-pointer=none
160 // Ot: -O2
161 
162 // RUN: %clang_cl /Ox --target=i686-pc-windows-msvc -### -- %s 2>&1 | FileCheck -check-prefix=Ox %s
163 // RUN: %clang_cl /Ox --target=x86_64-pc-windows-msvc -### -- %s 2>&1 | FileCheck -check-prefix=Ox %s
164 // Ox: -mframe-pointer=none
165 // Ox: -O2
166 
167 // RUN: %clang_cl --target=i686-pc-win32 /O2sy- -### -- %s 2>&1 | FileCheck -check-prefix=PR24003 %s
168 // PR24003: -mframe-pointer=all
169 // PR24003: -Os
170 
171 // RUN: %clang_cl --target=i686-pc-win32 -Werror /Oy- /O2 -### -- %s 2>&1 | FileCheck -check-prefix=Oy_2 %s
172 // Oy_2: -mframe-pointer=all
173 // Oy_2: -O2
174 
175 // RUN: %clang_cl --target=aarch64-pc-windows-msvc -Werror /Oy- /O2 -### -- %s 2>&1 | FileCheck -check-prefix=Oy_aarch64 %s
176 // Oy_aarch64: -mframe-pointer=non-leaf
177 // Oy_aarch64: -O2
178 
179 // RUN: %clang_cl --target=i686-pc-win32 -Werror /O2 /O2 -### -- %s 2>&1 | FileCheck -check-prefix=O2O2 %s
180 // O2O2: "-O2"
181 
182 // RUN: %clang_cl /Zs -Werror /Oy -- %s 2>&1
183 
184 // RUN: %clang_cl --target=i686-pc-win32 -Werror /Oy- -### -- %s 2>&1 | FileCheck -check-prefix=Oy_ %s
185 // Oy_: -mframe-pointer=all
186 
187 // RUN: %clang_cl /Qvec -### -- %s 2>&1 | FileCheck -check-prefix=Qvec %s
188 // Qvec: -vectorize-loops
189 
190 // RUN: %clang_cl /Qvec /Qvec- -### -- %s 2>&1 | FileCheck -check-prefix=Qvec_ %s
191 // Qvec_-NOT: -vectorize-loops
192 
193 // RUN: %clang_cl /showIncludes -### -- %s 2>&1 | FileCheck -check-prefix=showIncludes_ %s
194 // showIncludes_: --show-includes
195 // showIncludes_: -sys-header-deps
196 
197 // RUN: %clang_cl /showIncludes:user -### -- %s 2>&1 | FileCheck -check-prefix=showIncludesUser %s
198 // showIncludesUser: --show-includes
199 // showIncludesUser-NOT: -sys-header-deps
200 
201 // RUN: %clang_cl /E /showIncludes -### -- %s 2>&1 | FileCheck -check-prefix=showIncludes_E %s
202 // RUN: %clang_cl /E /showIncludes:user -### -- %s 2>&1 | FileCheck -check-prefix=showIncludes_E %s
203 // RUN: %clang_cl /EP /showIncludes -### -- %s 2>&1 | FileCheck -check-prefix=showIncludes_E %s
204 // RUN: %clang_cl /E /EP /showIncludes -### -- %s 2>&1 | FileCheck -check-prefix=showIncludes_E %s
205 // RUN: %clang_cl /EP /P /showIncludes -### -- %s 2>&1 | FileCheck -check-prefix=showIncludes_E %s
206 // showIncludes_E-NOT: warning: argument unused during compilation: '--show-includes'
207 
208 // /source-charset: should warn on everything except UTF-8.
209 // RUN: %clang_cl /source-charset:utf-16 -### -- %s 2>&1 | FileCheck -check-prefix=source-charset-utf-16 %s
210 // source-charset-utf-16: invalid value 'utf-16' in '/source-charset:utf-16'
211 
212 // /execution-charset: should warn on everything except UTF-8.
213 // RUN: %clang_cl /execution-charset:utf-16 -### -- %s 2>&1 | FileCheck -check-prefix=execution-charset-utf-16 %s
214 // execution-charset-utf-16: invalid value 'utf-16' in '/execution-charset:utf-16'
215 //
216 // RUN: %clang_cl /Umymacro -### -- %s 2>&1 | FileCheck -check-prefix=U %s
217 // RUN: %clang_cl /U mymacro -### -- %s 2>&1 | FileCheck -check-prefix=U %s
218 // U: "-U" "mymacro"
219 
220 // RUN: %clang_cl /validate-charset -### -- %s 2>&1 | FileCheck -check-prefix=validate-charset %s
221 // validate-charset: -Winvalid-source-encoding
222 
223 // RUN: %clang_cl /validate-charset- -### -- %s 2>&1 | FileCheck -check-prefix=validate-charset_ %s
224 // validate-charset_: -Wno-invalid-source-encoding
225 
226 // RUN: %clang_cl /vd2 -### -- %s 2>&1 | FileCheck -check-prefix=VD2 %s
227 // VD2: -vtordisp-mode=2
228 
229 // RUN: %clang_cl /vmg -### -- %s 2>&1 | FileCheck -check-prefix=VMG %s
230 // VMG: "-fms-memptr-rep=virtual"
231 
232 // RUN: %clang_cl /vmg /vms -### -- %s 2>&1 | FileCheck -check-prefix=VMS %s
233 // VMS: "-fms-memptr-rep=single"
234 
235 // RUN: %clang_cl /vmg /vmm -### -- %s 2>&1 | FileCheck -check-prefix=VMM %s
236 // VMM: "-fms-memptr-rep=multiple"
237 
238 // RUN: %clang_cl /vmg /vmv -### -- %s 2>&1 | FileCheck -check-prefix=VMV %s
239 // VMV: "-fms-memptr-rep=virtual"
240 
241 // RUN: %clang_cl /vmg /vmb -### -- %s 2>&1 | FileCheck -check-prefix=VMB %s
242 // VMB: '/vmg' not allowed with '/vmb'
243 
244 // RUN: %clang_cl /vmg /vmm /vms -### -- %s 2>&1 | FileCheck -check-prefix=VMX %s
245 // VMX: '/vms' not allowed with '/vmm'
246 
247 // RUN: %clang_cl /volatile:iso -### -- %s 2>&1 | FileCheck -check-prefix=VOLATILE-ISO %s
248 // VOLATILE-ISO-NOT: "-fms-volatile"
249 
250 // RUN: %clang_cl /volatile:ms -### -- %s 2>&1 | FileCheck -check-prefix=VOLATILE-MS %s
251 // VOLATILE-MS: "-fms-volatile"
252 
253 // RUN: %clang_cl /W0 -### -- %s 2>&1 | FileCheck -check-prefix=W0 %s
254 // W0: -w
255 
256 // RUN: %clang_cl /W1 -### -- %s 2>&1 | FileCheck -check-prefix=W1 %s
257 // RUN: %clang_cl /W2 -### -- %s 2>&1 | FileCheck -check-prefix=W1 %s
258 // RUN: %clang_cl /W3 -### -- %s 2>&1 | FileCheck -check-prefix=W1 %s
259 // RUN: %clang_cl /W4 -### -- %s 2>&1 | FileCheck -check-prefix=W4 %s
260 // RUN: %clang_cl /Wall -### -- %s 2>&1 | FileCheck -check-prefix=Weverything %s
261 // W1: -Wall
262 // W4: -WCL4
263 // Weverything: -Weverything
264 
265 // RUN: %clang_cl /WX -### -- %s 2>&1 | FileCheck -check-prefix=WX %s
266 // WX: -Werror
267 
268 // RUN: %clang_cl /WX- -### -- %s 2>&1 | FileCheck -check-prefix=WX_ %s
269 // WX_: -Wno-error
270 
271 // RUN: %clang_cl /w -### -- %s 2>&1 | FileCheck -check-prefix=w %s
272 // w: -w
273 
274 // RUN: %clang_cl /Zp -### -- %s 2>&1 | FileCheck -check-prefix=ZP %s
275 // ZP: -fpack-struct=1
276 
277 // RUN: %clang_cl /Zp2 -### -- %s 2>&1 | FileCheck -check-prefix=ZP2 %s
278 // ZP2: -fpack-struct=2
279 
280 // RUN: %clang_cl /Zs -### -- %s 2>&1 | FileCheck -check-prefix=Zs %s
281 // Zs: -fsyntax-only
282 
283 // RUN: %clang_cl /FIasdf.h -### -- %s 2>&1 | FileCheck -check-prefix=FI %s
284 // FI: "-include" "asdf.h"
285 
286 // RUN: %clang_cl /FI asdf.h -### -- %s 2>&1 | FileCheck -check-prefix=FI_ %s
287 // FI_: "-include" "asdf.h"
288 
289 // RUN: %clang_cl /TP /c -### -- %s 2>&1 | FileCheck -check-prefix=NO-GX %s
290 // NO-GX-NOT: "-fcxx-exceptions" "-fexceptions"
291 
292 // RUN: %clang_cl /TP /c /GX -### -- %s 2>&1 | FileCheck -check-prefix=GX %s
293 // GX: "-fcxx-exceptions" "-fexceptions"
294 
295 // RUN: %clang_cl /TP /c /GX /GX- -### -- %s 2>&1 | FileCheck -check-prefix=GX_ %s
296 // GX_-NOT: "-fcxx-exceptions" "-fexceptions"
297 
298 // RUN: %clang_cl /d1PP -### -- %s 2>&1 | FileCheck -check-prefix=d1PP %s
299 // d1PP: -dD
300 
301 // We forward any unrecognized -W diagnostic options to cc1.
302 // RUN: %clang_cl -Wunused-pragmas -### -- %s 2>&1 | FileCheck -check-prefix=WJoined %s
303 // WJoined: "-cc1"
304 // WJoined: "-Wunused-pragmas"
305 
306 // We recognize -f[no-]strict-aliasing.
307 // RUN: %clang_cl -c -### -- %s 2>&1 | FileCheck -check-prefix=DEFAULTSTRICT %s
308 // DEFAULTSTRICT: "-relaxed-aliasing"
309 // RUN: %clang_cl -c -fstrict-aliasing -### -- %s 2>&1 | FileCheck -check-prefix=STRICT %s
310 // STRICT-NOT: "-relaxed-aliasing"
311 // RUN: %clang_cl -c -fno-strict-aliasing -### -- %s 2>&1 | FileCheck -check-prefix=NOSTRICT %s
312 // NOSTRICT: "-relaxed-aliasing"
313 
314 // We recognize -f[no-]delete-null-pointer-checks.
315 // RUN: %clang_cl -c -### -- %s 2>&1 | FileCheck -check-prefix=DEFAULTNULL %s
316 // DEFAULTNULL-NOT: "-fno-delete-null-pointer-checks"
317 // RUN: %clang_cl -c -fdelete-null-pointer-checks -### -- %s 2>&1 | FileCheck -check-prefix=NULL %s
318 // NULL-NOT: "-fno-delete-null-pointer-checks"
319 // RUN: %clang_cl -c -fno-delete-null-pointer-checks -### -- %s 2>&1 | FileCheck -check-prefix=NONULL %s
320 // NONULL: "-fno-delete-null-pointer-checks"
321 
322 // We recognize -f[no-]delayed-template-parsing.
323 // /Zc:twoPhase[-] has the opposite meaning.
324 // RUN: %clang_cl -c -### -- %s 2>&1 | FileCheck -check-prefix=DELAYEDDEFAULT %s
325 // DELAYEDDEFAULT: "-fdelayed-template-parsing"
326 // RUN: %clang_cl -c -fdelayed-template-parsing -### -- %s 2>&1 | FileCheck -check-prefix=DELAYEDON %s
327 // RUN: %clang_cl -c /Zc:twoPhase- -### -- %s 2>&1 | FileCheck -check-prefix=DELAYEDON %s
328 // DELAYEDON: "-fdelayed-template-parsing"
329 // RUN: %clang_cl -c -fno-delayed-template-parsing -### -- %s 2>&1 | FileCheck -check-prefix=DELAYEDOFF %s
330 // RUN: %clang_cl -c /Zc:twoPhase -### -- %s 2>&1 | FileCheck -check-prefix=DELAYEDOFF %s
331 // DELAYEDOFF-NOT: "-fdelayed-template-parsing"
332 
333 // RUN: %clang_cl -c -### /std:c++latest -- %s 2>&1 | FileCheck -check-prefix CHECK-LATEST-CHAR8_T %s
334 // CHECK-LATEST-CHAR8_T-NOT: "-fchar8_t"
335 // RUN: %clang_cl -c -### /Zc:char8_t -- %s 2>&1 | FileCheck -check-prefix CHECK-CHAR8_T %s
336 // CHECK-CHAR8_T: "-fchar8_t"
337 // RUN: %clang_cl -c -### /Zc:char8_t- -- %s 2>&1 | FileCheck -check-prefix CHECK-CHAR8_T_ %s
338 // CHECK-CHAR8_T_: "-fno-char8_t"
339 
340 // For some warning ids, we can map from MSVC warning to Clang warning.
341 // RUN: %clang_cl -wd4005 -wd4100 -wd4910 -wd4996 -### -- %s 2>&1 | FileCheck -check-prefix=Wno %s
342 // Wno: "-cc1"
343 // Wno: "-Wno-macro-redefined"
344 // Wno: "-Wno-unused-parameter"
345 // Wno: "-Wno-dllexport-explicit-instantiation-decl"
346 // Wno: "-Wno-deprecated-declarations"
347 
348 // Ignored options. Check that we don't get "unused during compilation" errors.
349 // RUN: %clang_cl /c \
350 // RUN:    /analyze- \
351 // RUN:    /bigobj \
352 // RUN:    /cgthreads4 \
353 // RUN:    /cgthreads8 \
354 // RUN:    /d2FastFail \
355 // RUN:    /d2Zi+ \
356 // RUN:    /errorReport:foo \
357 // RUN:    /execution-charset:utf-8 \
358 // RUN:    /FC \
359 // RUN:    /Fdfoo \
360 // RUN:    /FS \
361 // RUN:    /Gd \
362 // RUN:    /GF \
363 // RUN:    /GS- \
364 // RUN:    /kernel- \
365 // RUN:    /nologo \
366 // RUN:    /Og \
367 // RUN:    /openmp- \
368 // RUN:    /permissive- \
369 // RUN:    /RTC1 \
370 // RUN:    /sdl \
371 // RUN:    /sdl- \
372 // RUN:    /source-charset:utf-8 \
373 // RUN:    /utf-8 \
374 // RUN:    /vmg \
375 // RUN:    /volatile:iso \
376 // RUN:    /w12345 \
377 // RUN:    /wd1234 \
378 // RUN:    /Zc:__cplusplus \
379 // RUN:    /Zc:auto \
380 // RUN:    /Zc:forScope \
381 // RUN:    /Zc:inline \
382 // RUN:    /Zc:rvalueCast \
383 // RUN:    /Zc:ternary \
384 // RUN:    /Zc:wchar_t \
385 // RUN:    /ZH:MD5 \
386 // RUN:    /ZH:SHA1 \
387 // RUN:    /ZH:SHA_256 \
388 // RUN:    /Zm \
389 // RUN:    /Zo \
390 // RUN:    /Zo- \
391 // RUN:    -### -- %s 2>&1 | FileCheck -check-prefix=IGNORED %s
392 // IGNORED-NOT: argument unused during compilation
393 // IGNORED-NOT: no such file or directory
394 // Don't confuse /openmp- with the /o flag:
395 // IGNORED-NOT: "-o" "penmp-.obj"
396 
397 // Ignored options and compile-only options are ignored for link jobs.
398 // RUN: touch %t.obj
399 // RUN: %clang_cl /nologo -### -- %t.obj 2>&1 | FileCheck -check-prefix=LINKUNUSED %s
400 // RUN: %clang_cl /Dfoo -### -- %t.obj 2>&1 | FileCheck -check-prefix=LINKUNUSED %s
401 // RUN: %clang_cl /MD -### -- %t.obj 2>&1 | FileCheck -check-prefix=LINKUNUSED %s
402 // LINKUNUSED-NOT: argument unused during compilation
403 
404 // Support ignoring warnings about unused arguments.
405 // RUN: %clang_cl /Abracadabra -Qunused-arguments -### -- %s 2>&1 | FileCheck -check-prefix=UNUSED %s
406 // UNUSED-NOT: argument unused during compilation
407 
408 // Unsupported but parsed options. Check that we don't error on them.
409 // (/Zs is for syntax-only)
410 // RUN: %clang_cl /Zs \
411 // RUN:     /await \
412 // RUN:     /constexpr:depth1000 /constexpr:backtrace1000 /constexpr:steps1000 \
413 // RUN:     /AIfoo \
414 // RUN:     /AI foo_does_not_exist \
415 // RUN:     /Bt \
416 // RUN:     /Bt+ \
417 // RUN:     /clr:pure \
418 // RUN:     /d2FH4 \
419 // RUN:     /docname \
420 // RUN:     /EHsc \
421 // RUN:     /F 42 \
422 // RUN:     /FA \
423 // RUN:     /FAc \
424 // RUN:     /Fafilename \
425 // RUN:     /FAs \
426 // RUN:     /FAu \
427 // RUN:     /favor:blend \
428 // RUN:     /Fifoo \
429 // RUN:     /Fmfoo \
430 // RUN:     /FpDebug\main.pch \
431 // RUN:     /Frfoo \
432 // RUN:     /FRfoo \
433 // RUN:     /FU foo \
434 // RUN:     /Fx \
435 // RUN:     /G1 \
436 // RUN:     /G2 \
437 // RUN:     /GA \
438 // RUN:     /Gd \
439 // RUN:     /Ge \
440 // RUN:     /Gh \
441 // RUN:     /GH \
442 // RUN:     /GL \
443 // RUN:     /GL- \
444 // RUN:     /Gm \
445 // RUN:     /Gm- \
446 // RUN:     /Gr \
447 // RUN:     /GS \
448 // RUN:     /GT \
449 // RUN:     /GX \
450 // RUN:     /Gv \
451 // RUN:     /Gz \
452 // RUN:     /GZ \
453 // RUN:     /H \
454 // RUN:     /homeparams \
455 // RUN:     /hotpatch \
456 // RUN:     /JMC \
457 // RUN:     /kernel \
458 // RUN:     /LN \
459 // RUN:     /MP \
460 // RUN:     /o foo.obj \
461 // RUN:     /ofoo.obj \
462 // RUN:     /openmp \
463 // RUN:     /openmp:experimental \
464 // RUN:     /Qfast_transcendentals \
465 // RUN:     /QIfist \
466 // RUN:     /QIntel-jcc-erratum \
467 // RUN:     /Qimprecise_fwaits \
468 // RUN:     /Qpar \
469 // RUN:     /Qpar-report:1 \
470 // RUN:     /Qsafe_fp_loads \
471 // RUN:     /Qspectre \
472 // RUN:     /Qspectre-load \
473 // RUN:     /Qspectre-load-cf \
474 // RUN:     /Qvec-report:2 \
475 // RUN:     /u \
476 // RUN:     /V \
477 // RUN:     /volatile:ms \
478 // RUN:     /wfoo \
479 // RUN:     /WL \
480 // RUN:     /Wp64 \
481 // RUN:     /X \
482 // RUN:     /Y- \
483 // RUN:     /Yc \
484 // RUN:     /Ycstdafx.h \
485 // RUN:     /Yd \
486 // RUN:     /Yl- \
487 // RUN:     /Ylfoo \
488 // RUN:     /Yustdafx.h \
489 // RUN:     /Z7 \
490 // RUN:     /Za \
491 // RUN:     /Ze \
492 // RUN:     /Zg \
493 // RUN:     /Zi \
494 // RUN:     /ZI \
495 // RUN:     /Zl \
496 // RUN:     /ZW:nostdlib \
497 // RUN:     -- %s 2>&1
498 
499 // We support -Xclang for forwarding options to cc1.
500 // RUN: %clang_cl -Xclang hellocc1 -### -- %s 2>&1 | FileCheck -check-prefix=Xclang %s
501 // Xclang: "-cc1"
502 // Xclang: "hellocc1"
503 
504 // Files under /Users are often confused with the /U flag. (This could happen
505 // for other flags too, but this is the one people run into.)
506 // RUN: %clang_cl /c /Users/me/myfile.c -### 2>&1 | FileCheck -check-prefix=SlashU %s
507 // SlashU: warning: '/Users/me/myfile.c' treated as the '/U' option
508 // SlashU: note: Use '--' to treat subsequent arguments as filenames
509 
510 // RTTI is on by default. /GR- controls -fno-rtti-data.
511 // RUN: %clang_cl /c /GR- -### -- %s 2>&1 | FileCheck -check-prefix=NoRTTI %s
512 // NoRTTI: "-fno-rtti-data"
513 // NoRTTI-NOT: "-fno-rtti"
514 // RUN: %clang_cl /c /GR -### -- %s 2>&1 | FileCheck -check-prefix=RTTI %s
515 // RTTI-NOT: "-fno-rtti-data"
516 // RTTI-NOT: "-fno-rtti"
517 
518 // thread safe statics are off for versions < 19.
519 // RUN: %clang_cl /c -### -fms-compatibility-version=18 -- %s 2>&1 | FileCheck -check-prefix=NoThreadSafeStatics %s
520 // RUN: %clang_cl /Zc:threadSafeInit /Zc:threadSafeInit- /c -### -- %s 2>&1 | FileCheck -check-prefix=NoThreadSafeStatics %s
521 // NoThreadSafeStatics: "-fno-threadsafe-statics"
522 
523 // RUN: %clang_cl /Zc:threadSafeInit /c -### -- %s 2>&1 | FileCheck -check-prefix=ThreadSafeStatics %s
524 // ThreadSafeStatics-NOT: "-fno-threadsafe-statics"
525 
526 // RUN: %clang_cl /Zc:dllexportInlines- /c -### -- %s 2>&1 | FileCheck -check-prefix=NoDllExportInlines %s
527 // NoDllExportInlines: "-fno-dllexport-inlines"
528 // RUN: %clang_cl /Zc:dllexportInlines /c -### -- %s 2>&1 | FileCheck -check-prefix=DllExportInlines %s
529 // DllExportInlines-NOT: "-fno-dllexport-inlines"
530 // RUN: %clang_cl /fallback /Zc:dllexportInlines- /c -### -- %s 2>&1 | FileCheck -check-prefix=DllExportInlinesFallback %s
531 // DllExportInlinesFallback: error: option '/Zc:dllexportInlines-' is ABI-changing and not compatible with '/fallback'
532 
533 // RUN: %clang_cl /Zi /c -### -- %s 2>&1 | FileCheck -check-prefix=Zi %s
534 // Zi: "-gcodeview"
535 // Zi: "-debug-info-kind=limited"
536 
537 // RUN: %clang_cl /Z7 /c -### -- %s 2>&1 | FileCheck -check-prefix=Z7 %s
538 // Z7: "-gcodeview"
539 // Z7: "-debug-info-kind=limited"
540 
541 // RUN: %clang_cl /Zd /c -### -- %s 2>&1 | FileCheck -check-prefix=Z7GMLT %s
542 // Z7GMLT: "-gcodeview"
543 // Z7GMLT: "-debug-info-kind=line-tables-only"
544 
545 // RUN: %clang_cl -gline-tables-only /c -### -- %s 2>&1 | FileCheck -check-prefix=ZGMLT %s
546 // ZGMLT: "-gcodeview"
547 // ZGMLT: "-debug-info-kind=line-tables-only"
548 
549 // RUN: %clang_cl /c -### -- %s 2>&1 | FileCheck -check-prefix=BreproDefault %s
550 // BreproDefault: "-mincremental-linker-compatible"
551 
552 // RUN: %clang_cl /Brepro- /Brepro /c '-###' -- %s 2>&1 | FileCheck -check-prefix=Brepro %s
553 // Brepro-NOT: "-mincremental-linker-compatible"
554 
555 // RUN: %clang_cl /Brepro /Brepro- /c '-###' -- %s 2>&1 | FileCheck -check-prefix=Brepro_ %s
556 // Brepro_: "-mincremental-linker-compatible"
557 
558 // This test was super sneaky: "/Z7" means "line-tables", but "-gdwarf" occurs
559 // later on the command line, so it should win. Interestingly the cc1 arguments
560 // came out right, but had wrong semantics, because an invariant assumed by
561 // CompilerInvocation was violated: it expects that at most one of {gdwarfN,
562 // line-tables-only} appear. If you assume that, then you can safely use
563 // Args.hasArg to test whether a boolean flag is present without caring
564 // where it appeared. And for this test, it appeared to the left of -gdwarf
565 // which made it "win". This test could not detect that bug.
566 // RUN: %clang_cl /Z7 -gdwarf /c -### -- %s 2>&1 | FileCheck -check-prefix=Z7_gdwarf %s
567 // Z7_gdwarf: "-gcodeview"
568 // Z7_gdwarf: "-debug-info-kind=limited"
569 // Z7_gdwarf: "-dwarf-version=4"
570 
571 // RUN: %clang_cl -fmsc-version=1800 -TP -### -- %s 2>&1 | FileCheck -check-prefix=CXX11 %s
572 // CXX11: -std=c++11
573 
574 // RUN: %clang_cl -fmsc-version=1900 -TP -### -- %s 2>&1 | FileCheck -check-prefix=CXX14 %s
575 // CXX14: -std=c++14
576 
577 // RUN: %clang_cl -fmsc-version=1900 -TP -std:c++14 -### -- %s 2>&1 | FileCheck -check-prefix=STDCXX14 %s
578 // STDCXX14: -std=c++14
579 
580 // RUN: %clang_cl -fmsc-version=1900 -TP -std:c++17 -### -- %s 2>&1 | FileCheck -check-prefix=STDCXX17 %s
581 // STDCXX17: -std=c++17
582 
583 // RUN: %clang_cl -fmsc-version=1900 -TP -std:c++latest -### -- %s 2>&1 | FileCheck -check-prefix=STDCXXLATEST %s
584 // STDCXXLATEST: -std=c++20
585 
586 // RUN: env CL="/Gy" %clang_cl -### -- %s 2>&1 | FileCheck -check-prefix=ENV-CL %s
587 // ENV-CL: "-ffunction-sections"
588 
589 // RUN: env CL="/Gy" _CL_="/Gy- -- %s" %clang_cl -### 2>&1 | FileCheck -check-prefix=ENV-_CL_ %s
590 // ENV-_CL_-NOT: "-ffunction-sections"
591 
592 // RUN: env CL="%s" _CL_="%s" not %clang --rsp-quoting=windows -c
593 
594 // RUN: %clang_cl -### /c -flto -- %s 2>&1 | FileCheck -check-prefix=LTO %s
595 // LTO: -flto
596 
597 // RUN: %clang_cl -### /c -flto -fno-lto -- %s 2>&1 | FileCheck -check-prefix=LTO-NO %s
598 // LTO-NO-NOT: "-flto"
599 
600 // RUN: %clang_cl -### /c -flto=thin -- %s 2>&1 | FileCheck -check-prefix=LTO-THIN %s
601 // LTO-THIN: -flto=thin
602 
603 // RUN: %clang_cl -### -Fe%t.exe -entry:main -flto -- %s 2>&1 | FileCheck -check-prefix=LTO-WITHOUT-LLD %s
604 // LTO-WITHOUT-LLD: LTO requires -fuse-ld=lld
605 
606 // RUN: %clang_cl  -### -- %s 2>&1 | FileCheck -check-prefix=NOCFGUARD %s
607 // RUN: %clang_cl /guard:cf- -### -- %s 2>&1 | FileCheck -check-prefix=NOCFGUARD %s
608 // NOCFGUARD-NOT: -cfguard
609 
610 // RUN: %clang_cl /guard:cf -### -- %s 2>&1 | FileCheck -check-prefix=CFGUARD %s
611 // CFGUARD: -cfguard
612 // CFGUARD-NOT: -cfguard-no-checks
613 
614 // RUN: %clang_cl /guard:cf,nochecks -### -- %s 2>&1 | FileCheck -check-prefix=CFGUARDNOCHECKS %s
615 // CFGUARDNOCHECKS: -cfguard-no-checks
616 
617 // RUN: %clang_cl /guard:nochecks -### -- %s 2>&1 | FileCheck -check-prefix=CFGUARDNOCHECKSINVALID %s
618 // CFGUARDNOCHECKSINVALID: invalid value 'nochecks' in '/guard:'
619 
620 // RUN: %clang_cl /guard:foo -### -- %s 2>&1 | FileCheck -check-prefix=CFGUARDINVALID %s
621 // CFGUARDINVALID: invalid value 'foo' in '/guard:'
622 
623 // Accept "core" clang options.
624 // (/Zs is for syntax-only, -Werror makes it fail hard on unknown options)
625 // RUN: %clang_cl \
626 // RUN:     --driver-mode=cl \
627 // RUN:     -fblocks \
628 // RUN:     -fcrash-diagnostics-dir=/foo \
629 // RUN:     -fno-crash-diagnostics \
630 // RUN:     -fno-blocks \
631 // RUN:     -fbuiltin \
632 // RUN:     -fno-builtin \
633 // RUN:     -fno-builtin-strcpy \
634 // RUN:     -fcolor-diagnostics \
635 // RUN:     -fno-color-diagnostics \
636 // RUN:     -fcoverage-mapping \
637 // RUN:     -fno-coverage-mapping \
638 // RUN:     -fdiagnostics-color \
639 // RUN:     -fno-diagnostics-color \
640 // RUN:     -fdebug-compilation-dir . \
641 // RUN:     -fdebug-compilation-dir=. \
642 // RUN:     -fdiagnostics-parseable-fixits \
643 // RUN:     -fdiagnostics-absolute-paths \
644 // RUN:     -ferror-limit=10 \
645 // RUN:     -fmsc-version=1800 \
646 // RUN:     -fno-strict-aliasing \
647 // RUN:     -fstrict-aliasing \
648 // RUN:     -fsyntax-only \
649 // RUN:     -fms-compatibility \
650 // RUN:     -fno-ms-compatibility \
651 // RUN:     -fms-extensions \
652 // RUN:     -fno-ms-extensions \
653 // RUN:     -Xclang -disable-llvm-passes \
654 // RUN:     -resource-dir asdf \
655 // RUN:     -resource-dir=asdf \
656 // RUN:     -Wunused-variable \
657 // RUN:     -fmacro-backtrace-limit=0 \
658 // RUN:     -fstandalone-debug \
659 // RUN:     -flimit-debug-info \
660 // RUN:     -flto \
661 // RUN:     -fmerge-all-constants \
662 // RUN:     -no-canonical-prefixes \
663 // RUN:     -march=skylake \
664 // RUN:     -fbracket-depth=123 \
665 // RUN:     -fprofile-generate \
666 // RUN:     -fprofile-generate=dir \
667 // RUN:     -fno-profile-generate \
668 // RUN:     -fno-profile-instr-generate \
669 // RUN:     -fno-profile-instr-use \
670 // RUN:     -fcs-profile-generate \
671 // RUN:     -fcs-profile-generate=dir \
672 // RUN:     -ftime-trace \
673 // RUN:     -ftrivial-auto-var-init=zero \
674 // RUN:     -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang \
675 // RUN:     --version \
676 // RUN:     -Werror /Zs -- %s 2>&1
677 
678 // Accept clang options under the /clang: flag.
679 // The first test case ensures that the SLP vectorizer is on by default and that
680 // it's being turned off by the /clang:-fno-slp-vectorize flag.
681 
682 // RUN: %clang_cl -O2 -### -- %s 2>&1 | FileCheck -check-prefix=NOCLANG %s
683 // NOCLANG: "--dependent-lib=libcmt"
684 // NOCLANG-SAME: "-vectorize-slp"
685 // NOCLANG-NOT: "--dependent-lib=msvcrt"
686 
687 // RUN: %clang_cl -O2 -MD /clang:-fno-slp-vectorize /clang:-MD /clang:-MF /clang:my_dependency_file.dep -### -- %s 2>&1 | FileCheck -check-prefix=CLANG %s
688 // CLANG: "--dependent-lib=msvcrt"
689 // CLANG-SAME: "-dependency-file" "my_dependency_file.dep"
690 // CLANG-NOT: "--dependent-lib=libcmt"
691 // CLANG-NOT: "-vectorize-slp"
692 
693 // Validate that the default triple is used when run an empty tools dir is specified
694 // RUN: %clang_cl -vctoolsdir "" -### -- %s 2>&1 | FileCheck %s --check-prefix VCTOOLSDIR
695 // VCTOOLSDIR: "-triple" "{{[a-zA-Z0-9_-]*}}-pc-windows-msvc19.11.0"
696 
697 // Validate that built-in include paths are based on the supplied path
698 // RUN: %clang_cl -vctoolsdir "/fake" -### -- %s 2>&1 | FileCheck %s --check-prefix FAKEDIR
699 // FAKEDIR: "-internal-isystem" "/fake{{/|\\\\}}include"
700 // FAKEDIR: "-internal-isystem" "/fake{{/|\\\\}}atlmfc{{/|\\\\}}include"
701 
f()702 void f() { }
703