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.
7 // RUN: %clang_cl /c -### -- %s 2>&1 | FileCheck -check-prefix=c %s
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'
13 // RUN: %clang_cl /C /P -### -- %s 2>&1 | FileCheck -check-prefix=C_P %s
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
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
27 // D: "-D" "MYDEF=value"
28 // D: "-D" "MYDEF2=foo#bar"
29 // D: "-D" "MYDEF3=a=b"
32 // RUN: %clang_cl /E -### -- %s 2>&1 | FileCheck -check-prefix=E %s
36 // RUN: %clang_cl /EP -### -- %s 2>&1 | FileCheck -check-prefix=EP %s
41 // RUN: %clang_cl /external:Ipath -### -- %s 2>&1 | FileCheck -check-prefix=EXTERNAL_I %s
42 // RUN: %clang_cl /external:I path -### -- %s 2>&1 | FileCheck -check-prefix=EXTERNAL_I %s
43 // EXTERNAL_I: "-isystem" "path"
45 // RUN: %clang_cl /fp:fast /fp:except -### -- %s 2>&1 | FileCheck -check-prefix=fpexcept %s
46 // fpexcept-NOT: -menable-unsafe-fp-math
48 // RUN: %clang_cl /fp:fast /fp:except /fp:except- -### -- %s 2>&1 | FileCheck -check-prefix=fpexcept_ %s
49 // fpexcept_: -menable-unsafe-fp-math
51 // RUN: %clang_cl /fp:precise /fp:fast -### -- %s 2>&1 | FileCheck -check-prefix=fpfast %s
52 // fpfast: -menable-unsafe-fp-math
53 // fpfast: -ffast-math
55 // RUN: %clang_cl /fp:fast /fp:precise -### -- %s 2>&1 | FileCheck -check-prefix=fpprecise %s
56 // fpprecise-NOT: -menable-unsafe-fp-math
57 // fpprecise-NOT: -ffast-math
59 // RUN: %clang_cl /fp:fast /fp:strict -### -- %s 2>&1 | FileCheck -check-prefix=fpstrict %s
60 // fpstrict-NOT: -menable-unsafe-fp-math
61 // fpstrict-NOT: -ffast-math
63 // RUN: %clang_cl /fsanitize=address -### -- %s 2>&1 | FileCheck -check-prefix=fsanitize_address %s
64 // fsanitize_address: -fsanitize=address
66 // RUN: %clang_cl -### /FA -fprofile-instr-generate -- %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-INSTR-GENERATE %s
67 // RUN: %clang_cl -### /FA -fprofile-instr-generate=/tmp/somefile.profraw -- %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-INSTR-GENERATE-FILE %s
68 // CHECK-PROFILE-INSTR-GENERATE: "-fprofile-instrument=clang" "--dependent-lib=clang_rt.profile{{[^"]*}}.lib"
69 // CHECK-PROFILE-INSTR-GENERATE-FILE: "-fprofile-instrument-path=/tmp/somefile.profraw"
71 // RUN: %clang_cl -### /FA -fprofile-generate -- %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-GENERATE %s
72 // CHECK-PROFILE-GENERATE: "-fprofile-instrument=llvm" "--dependent-lib=clang_rt.profile{{[^"]*}}.lib"
74 // RUN: %clang_cl -### /FA -fprofile-instr-generate -fprofile-instr-use -- %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-GEN-USE %s
75 // RUN: %clang_cl -### /FA -fprofile-instr-generate -fprofile-instr-use=file -- %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-GEN-USE %s
76 // CHECK-NO-MIX-GEN-USE: '{{[a-z=-]*}}' not allowed with '{{[a-z=-]*}}'
78 // RUN: %clang_cl -### /FA -fprofile-instr-use -- %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-USE %s
79 // RUN: %clang_cl -### /FA -fprofile-use -- %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-USE %s
80 // RUN: %clang_cl -### /FA -fprofile-instr-use=/tmp/somefile.prof -- %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-USE-FILE %s
81 // RUN: %clang_cl -### /FA -fprofile-use=/tmp/somefile.prof -- %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-USE-FILE %s
82 // CHECK-PROFILE-USE: "-fprofile-instrument-use-path=default.profdata"
83 // CHECK-PROFILE-USE-FILE: "-fprofile-instrument-use-path=/tmp/somefile.prof"
85 // RUN: %clang_cl /GA -### -- %s 2>&1 | FileCheck -check-prefix=GA %s
86 // GA: -ftls-model=local-exec
88 // RTTI is on by default; just check that we don't error.
89 // RUN: %clang_cl /Zs /GR -- %s 2>&1
91 // RUN: %clang_cl /GR- -### -- %s 2>&1 | FileCheck -check-prefix=GR_ %s
94 // Security Buffer Check is on by default.
95 // RUN: %clang_cl -### -- %s 2>&1 | FileCheck -check-prefix=GS-default %s
96 // GS-default: "-stack-protector" "2"
98 // RUN: %clang_cl /GS -### -- %s 2>&1 | FileCheck -check-prefix=GS %s
99 // GS: "-stack-protector" "2"
101 // RUN: %clang_cl /GS- -### -- %s 2>&1 | FileCheck -check-prefix=GS_ %s
102 // GS_-NOT: -stack-protector
104 // RUN: %clang_cl /Gy -### -- %s 2>&1 | FileCheck -check-prefix=Gy %s
105 // Gy: -ffunction-sections
107 // RUN: %clang_cl /Gy /Gy- -### -- %s 2>&1 | FileCheck -check-prefix=Gy_ %s
108 // Gy_-NOT: -ffunction-sections
110 // RUN: %clang_cl /Gs -### -- %s 2>&1 | FileCheck -check-prefix=Gs %s
111 // Gs: "-mstack-probe-size=4096"
112 // RUN: %clang_cl /Gs0 -### -- %s 2>&1 | FileCheck -check-prefix=Gs0 %s
113 // Gs0: "-mstack-probe-size=0"
114 // RUN: %clang_cl /Gs4096 -### -- %s 2>&1 | FileCheck -check-prefix=Gs4096 %s
115 // Gs4096: "-mstack-probe-size=4096"
117 // RUN: %clang_cl /Gw -### -- %s 2>&1 | FileCheck -check-prefix=Gw %s
118 // Gw: -fdata-sections
120 // RUN: %clang_cl /Gw /Gw- -### -- %s 2>&1 | FileCheck -check-prefix=Gw_ %s
121 // Gw_-NOT: -fdata-sections
123 // RUN: %clang_cl /hotpatch -### -- %s 2>&1 | FileCheck -check-prefix=hotpatch %s
124 // hotpatch: -fms-hotpatch
126 // RUN: %clang_cl /Imyincludedir -### -- %s 2>&1 | FileCheck -check-prefix=SLASH_I %s
127 // RUN: %clang_cl /I myincludedir -### -- %s 2>&1 | FileCheck -check-prefix=SLASH_I %s
128 // SLASH_I: "-I" "myincludedir"
130 // RUN: %clang_cl /imsvcmyincludedir -### -- %s 2>&1 | FileCheck -check-prefix=SLASH_imsvc %s
131 // RUN: %clang_cl /imsvc myincludedir -### -- %s 2>&1 | FileCheck -check-prefix=SLASH_imsvc %s
132 // Clang's resource header directory should be first:
133 // SLASH_imsvc: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
134 // SLASH_imsvc: "-internal-isystem" "[[RESOURCE_DIR]]{{[/\\]+}}include"
135 // SLASH_imsvc: "-internal-isystem" "myincludedir"
137 // RUN: %clang_cl /J -### -- %s 2>&1 | FileCheck -check-prefix=J %s
138 // J: -fno-signed-char
140 // RUN: %clang_cl /Ofoo -### -- %s 2>&1 | FileCheck -check-prefix=O %s
143 // RUN: %clang_cl /Ob0 -### -- %s 2>&1 | FileCheck -check-prefix=Ob0 %s
146 // RUN: %clang_cl /Ob2 -### -- %s 2>&1 | FileCheck -check-prefix=Ob2 %s
147 // RUN: %clang_cl /Odb2 -### -- %s 2>&1 | FileCheck -check-prefix=Ob2 %s
148 // RUN: %clang_cl /O2 /Ob2 -### -- %s 2>&1 | FileCheck -check-prefix=Ob2 %s
149 // Ob2-NOT: warning: argument unused during compilation: '/O2'
150 // Ob2: -finline-functions
152 // RUN: %clang_cl /Ob1 -### -- %s 2>&1 | FileCheck -check-prefix=Ob1 %s
153 // RUN: %clang_cl /Odb1 -### -- %s 2>&1 | FileCheck -check-prefix=Ob1 %s
154 // Ob1: -finline-hint-functions
156 // RUN: %clang_cl /Od -### -- %s 2>&1 | FileCheck -check-prefix=Od %s
159 // RUN: %clang_cl /Oi- /Oi -### -- %s 2>&1 | FileCheck -check-prefix=Oi %s
160 // Oi-NOT: -fno-builtin
162 // RUN: %clang_cl /Oi- -### -- %s 2>&1 | FileCheck -check-prefix=Oi_ %s
165 // RUN: %clang_cl /Os --target=i686-pc-windows-msvc -### -- %s 2>&1 | FileCheck -check-prefix=Os %s
166 // RUN: %clang_cl /Os --target=x86_64-pc-windows-msvc -### -- %s 2>&1 | FileCheck -check-prefix=Os %s
167 // Os: -mframe-pointer=none
170 // RUN: %clang_cl /Ot --target=i686-pc-windows-msvc -### -- %s 2>&1 | FileCheck -check-prefix=Ot %s
171 // RUN: %clang_cl /Ot --target=x86_64-pc-windows-msvc -### -- %s 2>&1 | FileCheck -check-prefix=Ot %s
172 // Ot: -mframe-pointer=none
175 // RUN: %clang_cl /Ox --target=i686-pc-windows-msvc -### -- %s 2>&1 | FileCheck -check-prefix=Ox %s
176 // RUN: %clang_cl /Ox --target=x86_64-pc-windows-msvc -### -- %s 2>&1 | FileCheck -check-prefix=Ox %s
177 // Ox: -mframe-pointer=none
180 // RUN: %clang_cl --target=i686-pc-win32 /O2sy- -### -- %s 2>&1 | FileCheck -check-prefix=PR24003 %s
181 // PR24003: -mframe-pointer=all
184 // RUN: %clang_cl --target=i686-pc-win32 -Werror /Oy- /O2 -### -- %s 2>&1 | FileCheck -check-prefix=Oy_2 %s
185 // Oy_2: -mframe-pointer=all
188 // RUN: %clang_cl --target=aarch64-pc-windows-msvc -Werror /Oy- /O2 -### -- %s 2>&1 | FileCheck -check-prefix=Oy_aarch64 %s
189 // Oy_aarch64: -mframe-pointer=non-leaf
192 // RUN: %clang_cl --target=i686-pc-win32 -Werror /O2 /O2 -### -- %s 2>&1 | FileCheck -check-prefix=O2O2 %s
195 // RUN: %clang_cl /Zs -Werror /Oy -- %s 2>&1
197 // RUN: %clang_cl --target=i686-pc-win32 -Werror /Oy- -### -- %s 2>&1 | FileCheck -check-prefix=Oy_ %s
198 // Oy_: -mframe-pointer=all
200 // RUN: %clang_cl /Qvec -### -- %s 2>&1 | FileCheck -check-prefix=Qvec %s
201 // Qvec: -vectorize-loops
203 // RUN: %clang_cl /Qvec /Qvec- -### -- %s 2>&1 | FileCheck -check-prefix=Qvec_ %s
204 // Qvec_-NOT: -vectorize-loops
206 // RUN: %clang_cl /showIncludes -### -- %s 2>&1 | FileCheck -check-prefix=showIncludes_ %s
207 // showIncludes_: --show-includes
208 // showIncludes_: -sys-header-deps
210 // RUN: %clang_cl /showIncludes:user -### -- %s 2>&1 | FileCheck -check-prefix=showIncludesUser %s
211 // showIncludesUser: --show-includes
212 // showIncludesUser-NOT: -sys-header-deps
214 // RUN: %clang_cl /E /showIncludes -### -- %s 2>&1 | FileCheck -check-prefix=showIncludes_E %s
215 // RUN: %clang_cl /E /showIncludes:user -### -- %s 2>&1 | FileCheck -check-prefix=showIncludes_E %s
216 // RUN: %clang_cl /EP /showIncludes -### -- %s 2>&1 | FileCheck -check-prefix=showIncludes_E %s
217 // RUN: %clang_cl /E /EP /showIncludes -### -- %s 2>&1 | FileCheck -check-prefix=showIncludes_E %s
218 // RUN: %clang_cl /EP /P /showIncludes -### -- %s 2>&1 | FileCheck -check-prefix=showIncludes_E %s
219 // showIncludes_E-NOT: warning: argument unused during compilation: '--show-includes'
221 // /source-charset: should warn on everything except UTF-8.
222 // RUN: %clang_cl /source-charset:utf-16 -### -- %s 2>&1 | FileCheck -check-prefix=source-charset-utf-16 %s
223 // source-charset-utf-16: invalid value 'utf-16' in '/source-charset:utf-16'
225 // /execution-charset: should warn on everything except UTF-8.
226 // RUN: %clang_cl /execution-charset:utf-16 -### -- %s 2>&1 | FileCheck -check-prefix=execution-charset-utf-16 %s
227 // execution-charset-utf-16: invalid value 'utf-16' in '/execution-charset:utf-16'
229 // RUN: %clang_cl /Umymacro -### -- %s 2>&1 | FileCheck -check-prefix=U %s
230 // RUN: %clang_cl /U mymacro -### -- %s 2>&1 | FileCheck -check-prefix=U %s
233 // RUN: %clang_cl /validate-charset -### -- %s 2>&1 | FileCheck -check-prefix=validate-charset %s
234 // validate-charset: -Winvalid-source-encoding
236 // RUN: %clang_cl /validate-charset- -### -- %s 2>&1 | FileCheck -check-prefix=validate-charset_ %s
237 // validate-charset_: -Wno-invalid-source-encoding
239 // RUN: %clang_cl /vd2 -### -- %s 2>&1 | FileCheck -check-prefix=VD2 %s
240 // VD2: -vtordisp-mode=2
242 // RUN: %clang_cl /vmg -### -- %s 2>&1 | FileCheck -check-prefix=VMG %s
243 // VMG: "-fms-memptr-rep=virtual"
245 // RUN: %clang_cl /vmg /vms -### -- %s 2>&1 | FileCheck -check-prefix=VMS %s
246 // VMS: "-fms-memptr-rep=single"
248 // RUN: %clang_cl /vmg /vmm -### -- %s 2>&1 | FileCheck -check-prefix=VMM %s
249 // VMM: "-fms-memptr-rep=multiple"
251 // RUN: %clang_cl /vmg /vmv -### -- %s 2>&1 | FileCheck -check-prefix=VMV %s
252 // VMV: "-fms-memptr-rep=virtual"
254 // RUN: %clang_cl /vmg /vmb -### -- %s 2>&1 | FileCheck -check-prefix=VMB %s
255 // VMB: '/vmg' not allowed with '/vmb'
257 // RUN: %clang_cl /vmg /vmm /vms -### -- %s 2>&1 | FileCheck -check-prefix=VMX %s
258 // VMX: '/vms' not allowed with '/vmm'
260 // RUN: %clang_cl /volatile:iso -### -- %s 2>&1 | FileCheck -check-prefix=VOLATILE-ISO %s
261 // VOLATILE-ISO-NOT: "-fms-volatile"
263 // RUN: %clang_cl /volatile:ms -### -- %s 2>&1 | FileCheck -check-prefix=VOLATILE-MS %s
264 // VOLATILE-MS: "-fms-volatile"
266 // RUN: %clang_cl /W0 -### -- %s 2>&1 | FileCheck -check-prefix=W0 %s
269 // RUN: %clang_cl /W1 -### -- %s 2>&1 | FileCheck -check-prefix=W1 %s
270 // RUN: %clang_cl /W2 -### -- %s 2>&1 | FileCheck -check-prefix=W1 %s
271 // RUN: %clang_cl /W3 -### -- %s 2>&1 | FileCheck -check-prefix=W1 %s
272 // RUN: %clang_cl /W4 -### -- %s 2>&1 | FileCheck -check-prefix=W4 %s
273 // RUN: %clang_cl /Wall -### -- %s 2>&1 | FileCheck -check-prefix=Weverything %s
276 // Weverything: -Weverything
278 // RUN: %clang_cl /WX -### -- %s 2>&1 | FileCheck -check-prefix=WX %s
281 // RUN: %clang_cl /WX- -### -- %s 2>&1 | FileCheck -check-prefix=WX_ %s
284 // RUN: %clang_cl /w -### -- %s 2>&1 | FileCheck -check-prefix=w %s
287 // RUN: %clang_cl /Zp -### -- %s 2>&1 | FileCheck -check-prefix=ZP %s
288 // ZP: -fpack-struct=1
290 // RUN: %clang_cl /Zp2 -### -- %s 2>&1 | FileCheck -check-prefix=ZP2 %s
291 // ZP2: -fpack-struct=2
293 // RUN: %clang_cl /Zs -### -- %s 2>&1 | FileCheck -check-prefix=Zs %s
296 // RUN: %clang_cl /FIasdf.h -### -- %s 2>&1 | FileCheck -check-prefix=FI %s
297 // FI: "-include" "asdf.h"
299 // RUN: %clang_cl /FI asdf.h -### -- %s 2>&1 | FileCheck -check-prefix=FI_ %s
300 // FI_: "-include" "asdf.h"
302 // RUN: %clang_cl /TP /c -### -- %s 2>&1 | FileCheck -check-prefix=NO-GX %s
303 // NO-GX-NOT: "-fcxx-exceptions" "-fexceptions"
305 // RUN: %clang_cl /TP /c /GX -### -- %s 2>&1 | FileCheck -check-prefix=GX %s
306 // GX: "-fcxx-exceptions" "-fexceptions"
308 // RUN: %clang_cl /TP /c /GX /GX- -### -- %s 2>&1 | FileCheck -check-prefix=GX_ %s
309 // GX_-NOT: "-fcxx-exceptions" "-fexceptions"
311 // RUN: %clang_cl /d1PP -### -- %s 2>&1 | FileCheck -check-prefix=d1PP %s
314 // RUN: %clang_cl --target=i686-pc-windows-msvc /c /QIntel-jcc-erratum -### -- %s 2>&1 | FileCheck -check-prefix=jcceratum %s
315 // jcceratum: "-mllvm" "-x86-branches-within-32B-boundaries"
318 // We forward any unrecognized -W diagnostic options to cc1.
319 // RUN: %clang_cl -Wunused-pragmas -### -- %s 2>&1 | FileCheck -check-prefix=WJoined %s
321 // WJoined: "-Wunused-pragmas"
323 // We recognize -f[no-]strict-aliasing.
324 // RUN: %clang_cl -c -### -- %s 2>&1 | FileCheck -check-prefix=DEFAULTSTRICT %s
325 // DEFAULTSTRICT: "-relaxed-aliasing"
326 // RUN: %clang_cl -c -fstrict-aliasing -### -- %s 2>&1 | FileCheck -check-prefix=STRICT %s
327 // STRICT-NOT: "-relaxed-aliasing"
328 // RUN: %clang_cl -c -fno-strict-aliasing -### -- %s 2>&1 | FileCheck -check-prefix=NOSTRICT %s
329 // NOSTRICT: "-relaxed-aliasing"
331 // We recognize -f[no-]delete-null-pointer-checks.
332 // RUN: %clang_cl -c -### -- %s 2>&1 | FileCheck -check-prefix=DEFAULTNULL %s
333 // DEFAULTNULL-NOT: "-fno-delete-null-pointer-checks"
334 // RUN: %clang_cl -c -fdelete-null-pointer-checks -### -- %s 2>&1 | FileCheck -check-prefix=NULL %s
335 // NULL-NOT: "-fno-delete-null-pointer-checks"
336 // RUN: %clang_cl -c -fno-delete-null-pointer-checks -### -- %s 2>&1 | FileCheck -check-prefix=NONULL %s
337 // NONULL: "-fno-delete-null-pointer-checks"
339 // We recognize -f[no-]delayed-template-parsing.
340 // /Zc:twoPhase[-] has the opposite meaning.
341 // RUN: %clang_cl -c -### -- %s 2>&1 | FileCheck -check-prefix=DELAYEDDEFAULT %s
342 // DELAYEDDEFAULT: "-fdelayed-template-parsing"
343 // RUN: %clang_cl -c -fdelayed-template-parsing -### -- %s 2>&1 | FileCheck -check-prefix=DELAYEDON %s
344 // RUN: %clang_cl -c /Zc:twoPhase- -### -- %s 2>&1 | FileCheck -check-prefix=DELAYEDON %s
345 // DELAYEDON: "-fdelayed-template-parsing"
346 // RUN: %clang_cl -c -fno-delayed-template-parsing -### -- %s 2>&1 | FileCheck -check-prefix=DELAYEDOFF %s
347 // RUN: %clang_cl -c /Zc:twoPhase -### -- %s 2>&1 | FileCheck -check-prefix=DELAYEDOFF %s
348 // DELAYEDOFF-NOT: "-fdelayed-template-parsing"
350 // RUN: %clang_cl -c -### /std:c++latest -- %s 2>&1 | FileCheck -check-prefix CHECK-LATEST-CHAR8_T %s
351 // CHECK-LATEST-CHAR8_T-NOT: "-fchar8_t"
352 // RUN: %clang_cl -c -### /Zc:char8_t -- %s 2>&1 | FileCheck -check-prefix CHECK-CHAR8_T %s
353 // CHECK-CHAR8_T: "-fchar8_t"
354 // RUN: %clang_cl -c -### /Zc:char8_t- -- %s 2>&1 | FileCheck -check-prefix CHECK-CHAR8_T_ %s
355 // CHECK-CHAR8_T_: "-fno-char8_t"
357 // RUN: %clang_cl -c -### /std:c11 -- %s 2>&1 | FileCheck -check-prefix CHECK-C11 %s
358 // CHECK-C11: -std=c11
360 // For some warning ids, we can map from MSVC warning to Clang warning.
361 // RUN: %clang_cl -wd4005 -wd4100 -wd4910 -wd4996 -wd12345678 -### -- %s 2>&1 | FileCheck -check-prefix=Wno %s
363 // Wno: "-Wno-macro-redefined"
364 // Wno: "-Wno-unused-parameter"
365 // Wno: "-Wno-dllexport-explicit-instantiation-decl"
366 // Wno: "-Wno-deprecated-declarations"
369 // Ignored options. Check that we don't get "unused during compilation" errors.
370 // RUN: %clang_cl /c \
373 // RUN: /cgthreads4 \
374 // RUN: /cgthreads8 \
375 // RUN: /d2FastFail \
377 // RUN: /errorReport:foo \
378 // RUN: /execution-charset:utf-8 \
389 // RUN: /permissive- \
393 // RUN: /source-charset:utf-8 \
396 // RUN: /volatile:iso \
401 // RUN: /Zc:__cplusplus \
403 // RUN: /Zc:forScope \
405 // RUN: /Zc:rvalueCast \
406 // RUN: /Zc:ternary \
407 // RUN: /Zc:wchar_t \
410 // RUN: /ZH:SHA_256 \
414 // RUN: -### -- %s 2>&1 | FileCheck -check-prefix=IGNORED %s
415 // IGNORED-NOT: argument unused during compilation
416 // IGNORED-NOT: no such file or directory
417 // Don't confuse /openmp- with the /o flag:
418 // IGNORED-NOT: "-o" "penmp-.obj"
420 // Ignored options and compile-only options are ignored for link jobs.
422 // RUN: %clang_cl /nologo -### -- %t.obj 2>&1 | FileCheck -check-prefix=LINKUNUSED %s
423 // RUN: %clang_cl /Dfoo -### -- %t.obj 2>&1 | FileCheck -check-prefix=LINKUNUSED %s
424 // RUN: %clang_cl /MD -### -- %t.obj 2>&1 | FileCheck -check-prefix=LINKUNUSED %s
425 // LINKUNUSED-NOT: argument unused during compilation
427 // Support ignoring warnings about unused arguments.
428 // RUN: %clang_cl /Abracadabra -Qunused-arguments -### -- %s 2>&1 | FileCheck -check-prefix=UNUSED %s
429 // UNUSED-NOT: argument unused during compilation
431 // Unsupported but parsed options. Check that we don't error on them.
432 // (/Zs is for syntax-only)
433 // RUN: %clang_cl /Zs \
435 // RUN: /await:strict \
436 // RUN: /constexpr:depth1000 /constexpr:backtrace1000 /constexpr:steps1000 \
438 // RUN: /AI foo_does_not_exist \
444 // RUN: /experimental:external \
445 // RUN: /experimental:module \
446 // RUN: /experimental:preprocessor \
447 // RUN: /exportHeader /headerName:foo \
448 // RUN: /external:anglebrackets \
449 // RUN: /external:env:var \
450 // RUN: /external:W0 \
451 // RUN: /external:W1 \
452 // RUN: /external:W2 \
453 // RUN: /external:W3 \
454 // RUN: /external:W4 \
455 // RUN: /external:templates- \
456 // RUN: /headerUnit foo.h=foo.ifc /headerUnit:quote foo.h=foo.ifc /headerUnit:angle foo.h=foo.ifc \
461 // RUN: /Fafilename \
464 // RUN: /favor:blend \
465 // RUN: /fno-sanitize-address-vcasan-lib \
468 // RUN: /FpDebug\main.pch \
492 // RUN: /homeparams \
499 // RUN: /openmp:experimental \
500 // RUN: /Qfast_transcendentals \
502 // RUN: /Qimprecise_fwaits \
504 // RUN: /Qpar-report:1 \
505 // RUN: /Qsafe_fp_loads \
507 // RUN: /Qspectre-load \
508 // RUN: /Qspectre-load-cf \
509 // RUN: /Qvec-report:2 \
510 // RUN: /reference foo=foo.ifc /reference foo.ifc \
511 // RUN: /sourceDependencies foo.json \
512 // RUN: /sourceDependencies:directives foo.json \
513 // RUN: /translateInclude \
516 // RUN: /volatile:ms \
523 // RUN: /Ycstdafx.h \
527 // RUN: /Yustdafx.h \
535 // RUN: /ZW:nostdlib \
538 // We support -Xclang for forwarding options to cc1.
539 // RUN: %clang_cl -Xclang hellocc1 -### -- %s 2>&1 | FileCheck -check-prefix=Xclang %s
541 // Xclang: "hellocc1"
543 // Files under /Users are often confused with the /U flag. (This could happen
544 // for other flags too, but this is the one people run into.)
545 // RUN: %clang_cl /c /Users/me/myfile.c -### 2>&1 | FileCheck -check-prefix=SlashU %s
546 // SlashU: warning: '/Users/me/myfile.c' treated as the '/U' option
547 // SlashU: note: use '--' to treat subsequent arguments as filenames
549 // RTTI is on by default. /GR- controls -fno-rtti-data.
550 // RUN: %clang_cl /c /GR- -### -- %s 2>&1 | FileCheck -check-prefix=NoRTTI %s
551 // NoRTTI: "-fno-rtti-data"
552 // NoRTTI-NOT: "-fno-rtti"
553 // RUN: %clang_cl /c /GR -### -- %s 2>&1 | FileCheck -check-prefix=RTTI %s
554 // RTTI-NOT: "-fno-rtti-data"
555 // RTTI-NOT: "-fno-rtti"
557 // thread safe statics are off for versions < 19.
558 // RUN: %clang_cl /c -### -fms-compatibility-version=18 -- %s 2>&1 | FileCheck -check-prefix=NoThreadSafeStatics %s
559 // RUN: %clang_cl /Zc:threadSafeInit /Zc:threadSafeInit- /c -### -- %s 2>&1 | FileCheck -check-prefix=NoThreadSafeStatics %s
560 // NoThreadSafeStatics: "-fno-threadsafe-statics"
562 // RUN: %clang_cl /Zc:threadSafeInit /c -### -- %s 2>&1 | FileCheck -check-prefix=ThreadSafeStatics %s
563 // ThreadSafeStatics-NOT: "-fno-threadsafe-statics"
565 // RUN: %clang_cl /Zc:dllexportInlines- /c -### -- %s 2>&1 | FileCheck -check-prefix=NoDllExportInlines %s
566 // NoDllExportInlines: "-fno-dllexport-inlines"
567 // RUN: %clang_cl /Zc:dllexportInlines /c -### -- %s 2>&1 | FileCheck -check-prefix=DllExportInlines %s
568 // DllExportInlines-NOT: "-fno-dllexport-inlines"
570 // RUN: %clang_cl /Zi /c -### -- %s 2>&1 | FileCheck -check-prefix=Zi %s
572 // Zi: "-debug-info-kind=constructor"
574 // RUN: %clang_cl /Z7 /c -### -- %s 2>&1 | FileCheck -check-prefix=Z7 %s
576 // Z7: "-debug-info-kind=constructor"
578 // RUN: %clang_cl -gline-tables-only /c -### -- %s 2>&1 | FileCheck -check-prefix=ZGMLT %s
579 // ZGMLT: "-gcodeview"
580 // ZGMLT: "-debug-info-kind=line-tables-only"
582 // RUN: %clang_cl /c -### -- %s 2>&1 | FileCheck -check-prefix=BreproDefault %s
583 // BreproDefault: "-mincremental-linker-compatible"
585 // RUN: %clang_cl /Brepro- /Brepro /c '-###' -- %s 2>&1 | FileCheck -check-prefix=Brepro %s
586 // Brepro-NOT: "-mincremental-linker-compatible"
588 // RUN: %clang_cl /Brepro /Brepro- /c '-###' -- %s 2>&1 | FileCheck -check-prefix=Brepro_ %s
589 // Brepro_: "-mincremental-linker-compatible"
591 // This test was super sneaky: "/Z7" means "line-tables", but "-gdwarf" occurs
592 // later on the command line, so it should win. Interestingly the cc1 arguments
593 // came out right, but had wrong semantics, because an invariant assumed by
594 // CompilerInvocation was violated: it expects that at most one of {gdwarfN,
595 // line-tables-only} appear. If you assume that, then you can safely use
596 // Args.hasArg to test whether a boolean flag is present without caring
597 // where it appeared. And for this test, it appeared to the left of -gdwarf
598 // which made it "win". This test could not detect that bug.
599 // RUN: %clang_cl /Z7 -gdwarf /c -### -- %s 2>&1 | FileCheck -check-prefix=Z7_gdwarf %s
600 // Z7_gdwarf: "-gcodeview"
601 // Z7_gdwarf: "-debug-info-kind=constructor"
602 // Z7_gdwarf: "-dwarf-version=
604 // RUN: %clang_cl -fmsc-version=1800 -TP -### -- %s 2>&1 | FileCheck -check-prefix=CXX11 %s
607 // RUN: %clang_cl -fmsc-version=1900 -TP -### -- %s 2>&1 | FileCheck -check-prefix=CXX14 %s
610 // RUN: %clang_cl -fmsc-version=1900 -TP -std:c++14 -### -- %s 2>&1 | FileCheck -check-prefix=STDCXX14 %s
611 // STDCXX14: -std=c++14
613 // RUN: %clang_cl -fmsc-version=1900 -TP -std:c++17 -### -- %s 2>&1 | FileCheck -check-prefix=STDCXX17 %s
614 // STDCXX17: -std=c++17
616 // RUN: %clang_cl -fmsc-version=1900 -TP -std:c++20 -### -- %s 2>&1 | FileCheck -check-prefix=STDCXX20 %s
617 // STDCXX20: -std=c++20
619 // RUN: %clang_cl -fmsc-version=1900 -TP -std:c++latest -### -- %s 2>&1 | FileCheck -check-prefix=STDCXXLATEST %s
620 // STDCXXLATEST: -std=c++2b
622 // RUN: env CL="/Gy" %clang_cl -### -- %s 2>&1 | FileCheck -check-prefix=ENV-CL %s
623 // ENV-CL: "-ffunction-sections"
625 // RUN: env CL="/Gy" _CL_="/Gy- -- %s" %clang_cl -### 2>&1 | FileCheck -check-prefix=ENV-_CL_ %s
626 // ENV-_CL_-NOT: "-ffunction-sections"
628 // RUN: env CL="%s" _CL_="%s" not %clang --rsp-quoting=windows -c
630 // RUN: %clang_cl -### /c -flto -- %s 2>&1 | FileCheck -check-prefix=LTO %s
633 // RUN: %clang_cl -### /c -flto -fno-lto -- %s 2>&1 | FileCheck -check-prefix=LTO-NO %s
634 // LTO-NO-NOT: "-flto"
636 // RUN: %clang_cl -### /c -flto=thin -- %s 2>&1 | FileCheck -check-prefix=LTO-THIN %s
637 // LTO-THIN: -flto=thin
639 // RUN: %clang_cl -### -Fe%t.exe -entry:main -flto -- %s 2>&1 | FileCheck -check-prefix=LTO-WITHOUT-LLD %s
640 // LTO-WITHOUT-LLD: LTO requires -fuse-ld=lld
642 // RUN: %clang_cl -### -- %s 2>&1 | FileCheck -check-prefix=NOCFGUARD %s
643 // RUN: %clang_cl /guard:cf- -### -- %s 2>&1 | FileCheck -check-prefix=NOCFGUARD %s
644 // NOCFGUARD-NOT: -cfguard
646 // RUN: %clang_cl /guard:cf -### -- %s 2>&1 | FileCheck -check-prefix=CFGUARD %s
648 // CFGUARD-NOT: -cfguard-no-checks
650 // RUN: %clang_cl /guard:cf,nochecks -### -- %s 2>&1 | FileCheck -check-prefix=CFGUARDNOCHECKS %s
651 // CFGUARDNOCHECKS: -cfguard-no-checks
653 // RUN: %clang_cl /guard:nochecks -### -- %s 2>&1 | FileCheck -check-prefix=CFGUARDNOCHECKSINVALID %s
654 // CFGUARDNOCHECKSINVALID: invalid value 'nochecks' in '/guard:'
656 // RUN: %clang_cl -### -- %s 2>&1 | FileCheck -check-prefix=NOEHCONTGUARD %s
657 // RUN: %clang_cl /guard:ehcont- -### -- %s 2>&1 | FileCheck -check-prefix=NOEHCONTGUARD %s
658 // NOEHCONTGUARD-NOT: -ehcontguard
660 // RUN: %clang_cl /guard:ehcont -### -- %s 2>&1 | FileCheck -check-prefix=EHCONTGUARD %s
661 // EHCONTGUARD: -ehcontguard
663 // RUN: %clang_cl /guard:foo -### -- %s 2>&1 | FileCheck -check-prefix=CFGUARDINVALID %s
664 // CFGUARDINVALID: invalid value 'foo' in '/guard:'
666 // Accept "core" clang options.
667 // (/Zs is for syntax-only, -Werror makes it fail hard on unknown options)
669 // RUN: --driver-mode=cl \
671 // RUN: -fcrash-diagnostics-dir=/foo \
672 // RUN: -fno-crash-diagnostics \
673 // RUN: -fno-blocks \
675 // RUN: -fno-builtin \
676 // RUN: -fno-builtin-strcpy \
677 // RUN: -fcolor-diagnostics \
678 // RUN: -fno-color-diagnostics \
679 // RUN: -fcoverage-mapping \
680 // RUN: -fno-coverage-mapping \
681 // RUN: -fdiagnostics-color \
682 // RUN: -fno-diagnostics-color \
683 // RUN: -fdebug-compilation-dir . \
684 // RUN: -fdebug-compilation-dir=. \
685 // RUN: -ffile-compilation-dir=. \
686 // RUN: -fdiagnostics-parseable-fixits \
687 // RUN: -fdiagnostics-absolute-paths \
688 // RUN: -ferror-limit=10 \
691 // RUN: -fmsc-version=1800 \
692 // RUN: -fno-strict-aliasing \
693 // RUN: -fstrict-aliasing \
694 // RUN: -fsyntax-only \
695 // RUN: -fms-compatibility \
696 // RUN: -fno-ms-compatibility \
697 // RUN: -fms-extensions \
698 // RUN: -fno-ms-extensions \
699 // RUN: -Xclang -disable-llvm-passes \
700 // RUN: -resource-dir asdf \
701 // RUN: -resource-dir=asdf \
702 // RUN: -Wunused-variable \
703 // RUN: -fmacro-backtrace-limit=0 \
704 // RUN: -fstandalone-debug \
705 // RUN: -flimit-debug-info \
707 // RUN: -fmerge-all-constants \
708 // RUN: -no-canonical-prefixes \
709 // RUN: -march=skylake \
710 // RUN: -fbracket-depth=123 \
711 // RUN: -fprofile-generate \
712 // RUN: -fprofile-generate=dir \
713 // RUN: -fno-profile-generate \
714 // RUN: -fno-profile-instr-generate \
715 // RUN: -fno-profile-instr-use \
716 // RUN: -fcs-profile-generate \
717 // RUN: -fcs-profile-generate=dir \
718 // RUN: -ftime-trace \
720 // RUN: -fno-modules \
721 // RUN: -fimplicit-module-maps \
722 // RUN: -fmodule-maps \
723 // RUN: -fmodule-name=foo \
724 // RUN: -fmodule-implementation-of \
725 // RUN: -fsystem-module \
726 // RUN: -fmodule-map-file=foo \
727 // RUN: -fmodule-file=foo \
728 // RUN: -fmodules-ignore-macro=foo \
729 // RUN: -fmodules-strict-decluse \
730 // RUN: -fmodules-decluse \
731 // RUN: -fno-modules-decluse \
732 // RUN: -fmodules-search-all \
733 // RUN: -fno-modules-search-all \
734 // RUN: -fimplicit-modules \
735 // RUN: -fno-implicit-modules \
736 // RUN: -ftrivial-auto-var-init=zero \
737 // RUN: -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang \
739 // RUN: -Werror /Zs -- %s 2>&1
741 // Accept clang options under the /clang: flag.
742 // The first test case ensures that the SLP vectorizer is on by default and that
743 // it's being turned off by the /clang:-fno-slp-vectorize flag.
745 // RUN: %clang_cl -O2 -### -- %s 2>&1 | FileCheck -check-prefix=NOCLANG %s
746 // NOCLANG: "--dependent-lib=libcmt"
747 // NOCLANG-SAME: "-vectorize-slp"
748 // NOCLANG-NOT: "--dependent-lib=msvcrt"
750 // 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
751 // CLANG: "--dependent-lib=msvcrt"
752 // CLANG-SAME: "-dependency-file" "my_dependency_file.dep"
753 // CLANG-NOT: "--dependent-lib=libcmt"
754 // CLANG-NOT: "-vectorize-slp"
756 // Cover PR42501: clang-cl /clang: pass-through causes read-after-free with aliased options.
757 // RUN: %clang_cl /clang:-save-temps /clang:-Wl,test1,test2 -### -- %s 2>&1 | FileCheck -check-prefix=SAVETEMPS %s
758 // SAVETEMPS: "-save-temps=cwd"
759 // SAVETEMPS: "test1" "test2"
761 // Validate that the default triple is used when run an empty tools dir is specified
762 // RUN: %clang_cl -vctoolsdir "" -### -- %s 2>&1 | FileCheck %s --check-prefix VCTOOLSDIR
763 // VCTOOLSDIR: "-triple" "{{[a-zA-Z0-9_-]*}}-pc-windows-msvc19.20.0"
765 // Validate that built-in include paths are based on the supplied path
766 // RUN: %clang_cl --target=aarch64-pc-windows-msvc -vctoolsdir "/fake" -winsdkdir "/foo" -winsdkversion 10.0.12345.0 -### -- %s 2>&1 | FileCheck %s --check-prefix FAKEDIR
767 // FAKEDIR: "-internal-isystem" "/fake{{/|\\\\}}include"
768 // FAKEDIR: "-internal-isystem" "/fake{{/|\\\\}}atlmfc{{/|\\\\}}include"
769 // FAKEDIR: "-internal-isystem" "/foo{{/|\\\\}}Include{{/|\\\\}}10.0.12345.0{{/|\\\\}}ucrt"
770 // FAKEDIR: "-internal-isystem" "/foo{{/|\\\\}}Include{{/|\\\\}}10.0.12345.0{{/|\\\\}}shared"
771 // FAKEDIR: "-internal-isystem" "/foo{{/|\\\\}}Include{{/|\\\\}}10.0.12345.0{{/|\\\\}}um"
772 // FAKEDIR: "-internal-isystem" "/foo{{/|\\\\}}Include{{/|\\\\}}10.0.12345.0{{/|\\\\}}winrt"
773 // FAKEDIR: "-libpath:/fake{{/|\\\\}}lib{{/|\\\\}}
774 // FAKEDIR: "-libpath:/fake{{/|\\\\}}atlmfc{{/|\\\\}}lib{{/|\\\\}}
775 // FAKEDIR: "-libpath:/foo{{/|\\\\}}Lib{{/|\\\\}}10.0.12345.0{{/|\\\\}}ucrt
776 // FAKEDIR: "-libpath:/foo{{/|\\\\}}Lib{{/|\\\\}}10.0.12345.0{{/|\\\\}}um
778 // Accept both the -target and --target= spellings.
779 // RUN: %clang_cl --target=i686-pc-windows-msvc19.14.0 -### -- %s 2>&1 | FileCheck -check-prefix=TARGET %s
780 // RUN: %clang_cl -target i686-pc-windows-msvc19.14.0 -### -- %s 2>&1 | FileCheck -check-prefix=TARGET %s
781 // TARGET: "-triple" "i686-pc-windows-msvc19.14.0"
783 // RUN: %clang_cl /JMC /c -### -- %s 2>&1 | FileCheck %s --check-prefix JMCWARN
784 // JMCWARN: /JMC requires debug info. Use '/Zi', '/Z7' or debug options that enable debugger's stepping function; option ignored
786 // RUN: %clang_cl /JMC /c -### -- %s 2>&1 | FileCheck %s --check-prefix NOJMC
787 // RUN: %clang_cl /JMC /Z7 /JMC- /c -### -- %s 2>&1 | FileCheck %s --check-prefix NOJMC
790 // RUN: %clang_cl /JMC /Z7 /c -### -- %s 2>&1 | FileCheck %s --check-prefix JMC