Clang Project

clang_source_code/test/Driver/cl-options.c
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 -### -- %s 2>&1 | FileCheck -check-prefix=d1reportAllClassLayout %s
18// d1reportAllClassLayout: -fdump-record-layouts
19
20// RUN: %clang_cl /Dfoo=bar /D bar=baz /DMYDEF#value /DMYDEF2=foo#bar /DMYDEF3#a=b /DMYDEF4# \
21// RUN:    -### -- %s 2>&1 | FileCheck -check-prefix=D %s
22// D: "-D" "foo=bar"
23// D: "-D" "bar=baz"
24// D: "-D" "MYDEF=value"
25// D: "-D" "MYDEF2=foo#bar"
26// D: "-D" "MYDEF3=a=b"
27// D: "-D" "MYDEF4="
28
29// RUN: %clang_cl /E -### -- %s 2>&1 | FileCheck -check-prefix=E %s
30// E: "-E"
31// E: "-o" "-"
32
33// RUN: %clang_cl /EP -### -- %s 2>&1 | FileCheck -check-prefix=EP %s
34// EP: "-E"
35// EP: "-P"
36// EP: "-o" "-"
37
38// RUN: %clang_cl /fp:fast /fp:except -### -- %s 2>&1 | FileCheck -check-prefix=fpexcept %s
39// fpexcept-NOT: -menable-unsafe-fp-math
40
41// RUN: %clang_cl /fp:fast /fp:except /fp:except- -### -- %s 2>&1 | FileCheck -check-prefix=fpexcept_ %s
42// fpexcept_: -menable-unsafe-fp-math
43
44// RUN: %clang_cl /fp:precise /fp:fast -### -- %s 2>&1 | FileCheck -check-prefix=fpfast %s
45// fpfast: -menable-unsafe-fp-math
46// fpfast: -ffast-math
47
48// RUN: %clang_cl /fp:fast /fp:precise -### -- %s 2>&1 | FileCheck -check-prefix=fpprecise %s
49// fpprecise-NOT: -menable-unsafe-fp-math
50// fpprecise-NOT: -ffast-math
51
52// RUN: %clang_cl /fp:fast /fp:strict -### -- %s 2>&1 | FileCheck -check-prefix=fpstrict %s
53// fpstrict-NOT: -menable-unsafe-fp-math
54// fpstrict-NOT: -ffast-math
55
56// RUN: %clang_cl /Z7 -gcolumn-info -### -- %s 2>&1 | FileCheck -check-prefix=gcolumn %s
57// gcolumn: -dwarf-column-info
58
59// RUN: %clang_cl /Z7 -gno-column-info -### -- %s 2>&1 | FileCheck -check-prefix=gnocolumn %s
60// gnocolumn-NOT: -dwarf-column-info
61
62// RUN: %clang_cl /Z7 -### -- %s 2>&1 | FileCheck -check-prefix=gdefcolumn %s
63// gdefcolumn-NOT: -dwarf-column-info
64
65// RUN: %clang_cl -### /FA -fprofile-instr-generate -- %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-GENERATE %s
66// RUN: %clang_cl -### /FA -fprofile-instr-generate=/tmp/somefile.profraw -- %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-GENERATE-FILE %s
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-PROFILE-GENERATE: "-fprofile-instrument=clang"
70// CHECK-PROFILE-GENERATE-FILE: "-fprofile-instrument-path=/tmp/somefile.profraw"
71// CHECK-NO-MIX-GEN-USE: '{{[a-z=-]*}}' not allowed with '{{[a-z=-]*}}'
72
73// RUN: %clang_cl -### /FA -fprofile-instr-use -- %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-USE %s
74// RUN: %clang_cl -### /FA -fprofile-instr-use=/tmp/somefile.prof -- %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-USE-FILE %s
75// CHECK-PROFILE-USE: "-fprofile-instrument-use-path=default.profdata"
76// CHECK-PROFILE-USE-FILE: "-fprofile-instrument-use-path=/tmp/somefile.prof"
77
78// RUN: %clang_cl /GA -### -- %s 2>&1 | FileCheck -check-prefix=GA %s
79// GA: -ftls-model=local-exec
80
81// RTTI is on by default; just check that we don't error.
82// RUN: %clang_cl /Zs /GR -- %s 2>&1
83
84// RUN: %clang_cl /GR- -### -- %s 2>&1 | FileCheck -check-prefix=GR_ %s
85// GR_: -fno-rtti
86
87// Security Buffer Check is on by default.
88// RUN: %clang_cl -### -- %s 2>&1 | FileCheck -check-prefix=GS-default %s
89// GS-default: "-stack-protector" "2"
90
91// RUN: %clang_cl /GS -### -- %s 2>&1 | FileCheck -check-prefix=GS %s
92// GS: "-stack-protector" "2"
93
94// RUN: %clang_cl /GS- -### -- %s 2>&1 | FileCheck -check-prefix=GS_ %s
95// GS_-NOT: -stack-protector
96
97// RUN: %clang_cl /Gy -### -- %s 2>&1 | FileCheck -check-prefix=Gy %s
98// Gy: -ffunction-sections
99
100// RUN: %clang_cl /Gy /Gy- -### -- %s 2>&1 | FileCheck -check-prefix=Gy_ %s
101// Gy_-NOT: -ffunction-sections
102
103// RUN: %clang_cl /Gs -### -- %s 2>&1 | FileCheck -check-prefix=Gs %s
104// Gs: "-mstack-probe-size=4096"
105// RUN: %clang_cl /Gs0 -### -- %s 2>&1 | FileCheck -check-prefix=Gs0 %s
106// Gs0: "-mstack-probe-size=0"
107// RUN: %clang_cl /Gs4096 -### -- %s 2>&1 | FileCheck -check-prefix=Gs4096 %s
108// Gs4096: "-mstack-probe-size=4096"
109
110// RUN: %clang_cl /Gw -### -- %s 2>&1 | FileCheck -check-prefix=Gw %s
111// Gw: -fdata-sections
112
113// RUN: %clang_cl /Gw /Gw- -### -- %s 2>&1 | FileCheck -check-prefix=Gw_ %s
114// Gw_-NOT: -fdata-sections
115
116// RUN: %clang_cl /Imyincludedir -### -- %s 2>&1 | FileCheck -check-prefix=SLASH_I %s
117// RUN: %clang_cl /I myincludedir -### -- %s 2>&1 | FileCheck -check-prefix=SLASH_I %s
118// SLASH_I: "-I" "myincludedir"
119
120// RUN: %clang_cl /imsvcmyincludedir -### -- %s 2>&1 | FileCheck -check-prefix=SLASH_imsvc %s
121// RUN: %clang_cl /imsvc myincludedir -### -- %s 2>&1 | FileCheck -check-prefix=SLASH_imsvc %s
122// Clang's resource header directory should be first:
123// SLASH_imsvc: "-internal-isystem" "{{[^"]*}}lib{{(64)?/|\\\\}}clang{{[^"]*}}include"
124// SLASH_imsvc: "-internal-isystem" "myincludedir"
125
126// RUN: %clang_cl /J -### -- %s 2>&1 | FileCheck -check-prefix=J %s
127// J: -fno-signed-char
128
129// RUN: %clang_cl /Ofoo -### -- %s 2>&1 | FileCheck -check-prefix=O %s
130// O: /Ofoo
131
132// RUN: %clang_cl /Ob0 -### -- %s 2>&1 | FileCheck -check-prefix=Ob0 %s
133// Ob0: -fno-inline
134
135// RUN: %clang_cl /Ob2 -### -- %s 2>&1 | FileCheck -check-prefix=Ob2 %s
136// RUN: %clang_cl /Odb2 -### -- %s 2>&1 | FileCheck -check-prefix=Ob2 %s
137// RUN: %clang_cl /O2 /Ob2 -### -- %s 2>&1 | FileCheck -check-prefix=Ob2 %s
138// Ob2-NOT: warning: argument unused during compilation: '/O2'
139// Ob2: -finline-functions
140
141// RUN: %clang_cl /Ob1 -### -- %s 2>&1 | FileCheck -check-prefix=Ob1 %s
142// RUN: %clang_cl /Odb1 -### -- %s 2>&1 | FileCheck -check-prefix=Ob1 %s
143// Ob1: -finline-hint-functions
144
145// RUN: %clang_cl /Od -### -- %s 2>&1 | FileCheck -check-prefix=Od %s
146// Od: -O0
147
148// RUN: %clang_cl /Oi- /Oi -### -- %s 2>&1 | FileCheck -check-prefix=Oi %s
149// Oi-NOT: -fno-builtin
150
151// RUN: %clang_cl /Oi- -### -- %s 2>&1 | FileCheck -check-prefix=Oi_ %s
152// Oi_: -fno-builtin
153
154// RUN: %clang_cl /Os --target=i686-pc-windows-msvc -### -- %s 2>&1 | FileCheck -check-prefix=Os %s
155// RUN: %clang_cl /Os --target=x86_64-pc-windows-msvc -### -- %s 2>&1 | FileCheck -check-prefix=Os %s
156// Os-NOT: -mdisable-fp-elim
157// Os: -momit-leaf-frame-pointer
158// Os: -Os
159
160// RUN: %clang_cl /Ot --target=i686-pc-windows-msvc -### -- %s 2>&1 | FileCheck -check-prefix=Ot %s
161// RUN: %clang_cl /Ot --target=x86_64-pc-windows-msvc -### -- %s 2>&1 | FileCheck -check-prefix=Ot %s
162// Ot-NOT: -mdisable-fp-elim
163// Ot: -momit-leaf-frame-pointer
164// Ot: -O2
165
166// RUN: %clang_cl /Ox --target=i686-pc-windows-msvc -### -- %s 2>&1 | FileCheck -check-prefix=Ox %s
167// RUN: %clang_cl /Ox --target=x86_64-pc-windows-msvc -### -- %s 2>&1 | FileCheck -check-prefix=Ox %s
168// Ox-NOT: -mdisable-fp-elim
169// Ox: -momit-leaf-frame-pointer
170// Ox: -O2
171
172// RUN: %clang_cl --target=i686-pc-win32 /O2sy- -### -- %s 2>&1 | FileCheck -check-prefix=PR24003 %s
173// PR24003: -mdisable-fp-elim
174// PR24003: -momit-leaf-frame-pointer
175// PR24003: -Os
176
177// RUN: %clang_cl --target=i686-pc-win32 -Werror /Oy- /O2 -### -- %s 2>&1 | FileCheck -check-prefix=Oy_2 %s
178// Oy_2: -momit-leaf-frame-pointer
179// Oy_2: -O2
180
181// RUN: %clang_cl --target=aarch64-pc-windows-msvc -Werror /Oy- /O2 -### -- %s 2>&1 | FileCheck -check-prefix=Oy_aarch64 %s
182// Oy_aarch64: -mdisable-fp-elim
183// Oy_aarch64: -O2
184
185// RUN: %clang_cl --target=i686-pc-win32 -Werror /O2 /O2 -### -- %s 2>&1 | FileCheck -check-prefix=O2O2 %s
186// O2O2: "-O2"
187
188// RUN: %clang_cl /Zs -Werror /Oy -- %s 2>&1
189
190// RUN: %clang_cl --target=i686-pc-win32 -Werror /Oy- -### -- %s 2>&1 | FileCheck -check-prefix=Oy_ %s
191// Oy_: -mdisable-fp-elim
192
193// RUN: %clang_cl /Qvec -### -- %s 2>&1 | FileCheck -check-prefix=Qvec %s
194// Qvec: -vectorize-loops
195
196// RUN: %clang_cl /Qvec /Qvec- -### -- %s 2>&1 | FileCheck -check-prefix=Qvec_ %s
197// Qvec_-NOT: -vectorize-loops
198
199// RUN: %clang_cl /showIncludes -### -- %s 2>&1 | FileCheck -check-prefix=showIncludes %s
200// showIncludes: --show-includes
201
202// RUN: %clang_cl /E /showIncludes -### -- %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'
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'
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-]delayed-template-parsing.
315// /Zc:twoPhase[-] has the opposite meaning.
316// RUN: %clang_cl -c -### -- %s 2>&1 | FileCheck -check-prefix=DELAYEDDEFAULT %s
317// DELAYEDDEFAULT: "-fdelayed-template-parsing"
318// RUN: %clang_cl -c -fdelayed-template-parsing -### -- %s 2>&1 | FileCheck -check-prefix=DELAYEDON %s
319// RUN: %clang_cl -c /Zc:twoPhase- -### -- %s 2>&1 | FileCheck -check-prefix=DELAYEDON %s
320// DELAYEDON: "-fdelayed-template-parsing"
321// RUN: %clang_cl -c -fno-delayed-template-parsing -### -- %s 2>&1 | FileCheck -check-prefix=DELAYEDOFF %s
322// RUN: %clang_cl -c /Zc:twoPhase -### -- %s 2>&1 | FileCheck -check-prefix=DELAYEDOFF %s
323// DELAYEDOFF-NOT: "-fdelayed-template-parsing"
324
325// For some warning ids, we can map from MSVC warning to Clang warning.
326// RUN: %clang_cl -wd4005 -wd4100 -wd4910 -wd4996 -### -- %s 2>&1 | FileCheck -check-prefix=Wno %s
327// Wno: "-cc1"
328// Wno: "-Wno-macro-redefined"
329// Wno: "-Wno-unused-parameter"
330// Wno: "-Wno-dllexport-explicit-instantiation-decl"
331// Wno: "-Wno-deprecated-declarations"
332
333// Ignored options. Check that we don't get "unused during compilation" errors.
334// RUN: %clang_cl /c \
335// RUN:    /analyze- \
336// RUN:    /bigobj \
337// RUN:    /cgthreads4 \
338// RUN:    /cgthreads8 \
339// RUN:    /d2FastFail \
340// RUN:    /d2Zi+ \
341// RUN:    /errorReport:foo \
342// RUN:    /execution-charset:utf-8 \
343// RUN:    /FC \
344// RUN:    /Fdfoo \
345// RUN:    /FS \
346// RUN:    /Gd \
347// RUN:    /GF \
348// RUN:    /GS- \
349// RUN:    /kernel- \
350// RUN:    /nologo \
351// RUN:    /Og \
352// RUN:    /openmp- \
353// RUN:    /permissive- \
354// RUN:    /RTC1 \
355// RUN:    /sdl \
356// RUN:    /sdl- \
357// RUN:    /source-charset:utf-8 \
358// RUN:    /utf-8 \
359// RUN:    /vmg \
360// RUN:    /volatile:iso \
361// RUN:    /w12345 \
362// RUN:    /wd1234 \
363// RUN:    /Zc:__cplusplus \
364// RUN:    /Zc:auto \
365// RUN:    /Zc:forScope \
366// RUN:    /Zc:inline \
367// RUN:    /Zc:rvalueCast \
368// RUN:    /Zc:ternary \
369// RUN:    /Zc:wchar_t \
370// RUN:    /Zm \
371// RUN:    /Zo \
372// RUN:    /Zo- \
373// RUN:    -### -- %s 2>&1 | FileCheck -check-prefix=IGNORED %s
374// IGNORED-NOT: argument unused during compilation
375// IGNORED-NOT: no such file or directory
376// Don't confuse /openmp- with the /o flag:
377// IGNORED-NOT: "-o" "penmp-.obj"
378
379// Ignored options and compile-only options are ignored for link jobs.
380// RUN: touch %t.obj
381// RUN: %clang_cl /nologo -### -- %t.obj 2>&1 | FileCheck -check-prefix=LINKUNUSED %s
382// RUN: %clang_cl /Dfoo -### -- %t.obj 2>&1 | FileCheck -check-prefix=LINKUNUSED %s
383// RUN: %clang_cl /MD -### -- %t.obj 2>&1 | FileCheck -check-prefix=LINKUNUSED %s
384// LINKUNUSED-NOT: argument unused during compilation
385
386// Support ignoring warnings about unused arguments.
387// RUN: %clang_cl /Abracadabra -Qunused-arguments -### -- %s 2>&1 | FileCheck -check-prefix=UNUSED %s
388// UNUSED-NOT: argument unused during compilation
389
390// Unsupported but parsed options. Check that we don't error on them.
391// (/Zs is for syntax-only)
392// RUN: %clang_cl /Zs \
393// RUN:     /await \
394// RUN:     /constexpr:depth1000 /constexpr:backtrace1000 /constexpr:steps1000 \
395// RUN:     /AIfoo \
396// RUN:     /AI foo_does_not_exist \
397// RUN:     /Bt \
398// RUN:     /Bt+ \
399// RUN:     /clr:pure \
400// RUN:     /d2FH4 \
401// RUN:     /docname \
402// RUN:     /EHsc \
403// RUN:     /F \
404// RUN:     /FA \
405// RUN:     /FAc \
406// RUN:     /Fafilename \
407// RUN:     /FAs \
408// RUN:     /FAu \
409// RUN:     /favor:blend \
410// RUN:     /Fifoo \
411// RUN:     /Fmfoo \
412// RUN:     /FpDebug\main.pch \
413// RUN:     /Frfoo \
414// RUN:     /FRfoo \
415// RUN:     /FU foo \
416// RUN:     /Fx \
417// RUN:     /G1 \
418// RUN:     /G2 \
419// RUN:     /GA \
420// RUN:     /Gd \
421// RUN:     /Ge \
422// RUN:     /Gh \
423// RUN:     /GH \
424// RUN:     /GL \
425// RUN:     /GL- \
426// RUN:     /Gm \
427// RUN:     /Gm- \
428// RUN:     /Gr \
429// RUN:     /GS \
430// RUN:     /GT \
431// RUN:     /GX \
432// RUN:     /Gv \
433// RUN:     /Gz \
434// RUN:     /GZ \
435// RUN:     /H \
436// RUN:     /homeparams \
437// RUN:     /hotpatch \
438// RUN:     /JMC \
439// RUN:     /kernel \
440// RUN:     /LN \
441// RUN:     /MP \
442// RUN:     /o foo.obj \
443// RUN:     /ofoo.obj \
444// RUN:     /openmp \
445// RUN:     /Qfast_transcendentals \
446// RUN:     /QIfist \
447// RUN:     /Qimprecise_fwaits \
448// RUN:     /Qpar \
449// RUN:     /Qpar-report:1 \
450// RUN:     /Qsafe_fp_loads \
451// RUN:     /Qspectre \
452// RUN:     /Qvec-report:2 \
453// RUN:     /u \
454// RUN:     /V \
455// RUN:     /volatile:ms \
456// RUN:     /wfoo \
457// RUN:     /WL \
458// RUN:     /Wp64 \
459// RUN:     /X \
460// RUN:     /Y- \
461// RUN:     /Yc \
462// RUN:     /Ycstdafx.h \
463// RUN:     /Yd \
464// RUN:     /Yl- \
465// RUN:     /Ylfoo \
466// RUN:     /Yustdafx.h \
467// RUN:     /Z7 \
468// RUN:     /Za \
469// RUN:     /Ze \
470// RUN:     /Zg \
471// RUN:     /Zi \
472// RUN:     /ZI \
473// RUN:     /Zl \
474// RUN:     /ZW:nostdlib \
475// RUN:     -- %s 2>&1
476
477// We support -Xclang for forwarding options to cc1.
478// RUN: %clang_cl -Xclang hellocc1 -### -- %s 2>&1 | FileCheck -check-prefix=Xclang %s
479// Xclang: "-cc1"
480// Xclang: "hellocc1"
481
482// Files under /Users are often confused with the /U flag. (This could happen
483// for other flags too, but this is the one people run into.)
484// RUN: %clang_cl /c /Users/me/myfile.c -### 2>&1 | FileCheck -check-prefix=SlashU %s
485// SlashU: warning: '/Users/me/myfile.c' treated as the '/U' option
486// SlashU: note: Use '--' to treat subsequent arguments as filenames
487
488// RTTI is on by default. /GR- controls -fno-rtti-data.
489// RUN: %clang_cl /c /GR- -### -- %s 2>&1 | FileCheck -check-prefix=NoRTTI %s
490// NoRTTI: "-fno-rtti-data"
491// NoRTTI-NOT: "-fno-rtti"
492// RUN: %clang_cl /c /GR -### -- %s 2>&1 | FileCheck -check-prefix=RTTI %s
493// RTTI-NOT: "-fno-rtti-data"
494// RTTI-NOT: "-fno-rtti"
495
496// thread safe statics are off for versions < 19.
497// RUN: %clang_cl /c -### -fms-compatibility-version=18 -- %s 2>&1 | FileCheck -check-prefix=NoThreadSafeStatics %s
498// RUN: %clang_cl /Zc:threadSafeInit /Zc:threadSafeInit- /c -### -- %s 2>&1 | FileCheck -check-prefix=NoThreadSafeStatics %s
499// NoThreadSafeStatics: "-fno-threadsafe-statics"
500
501// RUN: %clang_cl /Zc:threadSafeInit /c -### -- %s 2>&1 | FileCheck -check-prefix=ThreadSafeStatics %s
502// ThreadSafeStatics-NOT: "-fno-threadsafe-statics"
503
504// RUN: %clang_cl /Zc:dllexportInlines- /c -### -- %s 2>&1 | FileCheck -check-prefix=NoDllExportInlines %s
505// NoDllExportInlines: "-fno-dllexport-inlines"
506// RUN: %clang_cl /Zc:dllexportInlines /c -### -- %s 2>&1 | FileCheck -check-prefix=DllExportInlines %s
507// DllExportInlines-NOT: "-fno-dllexport-inlines"
508// RUN: %clang_cl /fallback /Zc:dllexportInlines- /c -### -- %s 2>&1 | FileCheck -check-prefix=DllExportInlinesFallback %s
509// DllExportInlinesFallback: error: option '/Zc:dllexportInlines-' is ABI-changing and not compatible with '/fallback'
510
511// RUN: %clang_cl /Zi /c -### -- %s 2>&1 | FileCheck -check-prefix=Zi %s
512// Zi: "-gcodeview"
513// Zi: "-debug-info-kind=limited"
514
515// RUN: %clang_cl /Z7 /c -### -- %s 2>&1 | FileCheck -check-prefix=Z7 %s
516// Z7: "-gcodeview"
517// Z7: "-debug-info-kind=limited"
518
519// RUN: %clang_cl /Zd /c -### -- %s 2>&1 | FileCheck -check-prefix=Z7GMLT %s
520// Z7GMLT: "-gcodeview"
521// Z7GMLT: "-debug-info-kind=line-tables-only"
522
523// RUN: %clang_cl -gline-tables-only /c -### -- %s 2>&1 | FileCheck -check-prefix=ZGMLT %s
524// ZGMLT: "-gcodeview"
525// ZGMLT: "-debug-info-kind=line-tables-only"
526
527// RUN: %clang_cl /c -### -- %s 2>&1 | FileCheck -check-prefix=BreproDefault %s
528// BreproDefault: "-mincremental-linker-compatible"
529
530// RUN: %clang_cl /Brepro- /Brepro /c '-###' -- %s 2>&1 | FileCheck -check-prefix=Brepro %s
531// Brepro-NOT: "-mincremental-linker-compatible"
532
533// RUN: %clang_cl /Brepro /Brepro- /c '-###' -- %s 2>&1 | FileCheck -check-prefix=Brepro_ %s
534// Brepro_: "-mincremental-linker-compatible"
535
536// This test was super sneaky: "/Z7" means "line-tables", but "-gdwarf" occurs
537// later on the command line, so it should win. Interestingly the cc1 arguments
538// came out right, but had wrong semantics, because an invariant assumed by
539// CompilerInvocation was violated: it expects that at most one of {gdwarfN,
540// line-tables-only} appear. If you assume that, then you can safely use
541// Args.hasArg to test whether a boolean flag is present without caring
542// where it appeared. And for this test, it appeared to the left of -gdwarf
543// which made it "win". This test could not detect that bug.
544// RUN: %clang_cl /Z7 -gdwarf /c -### -- %s 2>&1 | FileCheck -check-prefix=Z7_gdwarf %s
545// Z7_gdwarf: "-gcodeview"
546// Z7_gdwarf: "-debug-info-kind=limited"
547// Z7_gdwarf: "-dwarf-version=4"
548
549// RUN: %clang_cl -fmsc-version=1800 -TP -### -- %s 2>&1 | FileCheck -check-prefix=CXX11 %s
550// CXX11: -std=c++11
551
552// RUN: %clang_cl -fmsc-version=1900 -TP -### -- %s 2>&1 | FileCheck -check-prefix=CXX14 %s
553// CXX14: -std=c++14
554
555// RUN: %clang_cl -fmsc-version=1900 -TP -std:c++14 -### -- %s 2>&1 | FileCheck -check-prefix=STDCXX14 %s
556// STDCXX14: -std=c++14
557
558// RUN: %clang_cl -fmsc-version=1900 -TP -std:c++17 -### -- %s 2>&1 | FileCheck -check-prefix=STDCXX17 %s
559// STDCXX17: -std=c++17
560
561// RUN: %clang_cl -fmsc-version=1900 -TP -std:c++latest -### -- %s 2>&1 | FileCheck -check-prefix=STDCXXLATEST %s
562// STDCXXLATEST: -std=c++2a
563
564// RUN: env CL="/Gy" %clang_cl -### -- %s 2>&1 | FileCheck -check-prefix=ENV-CL %s
565// ENV-CL: "-ffunction-sections"
566
567// RUN: env CL="/Gy" _CL_="/Gy- -- %s" %clang_cl -### 2>&1 | FileCheck -check-prefix=ENV-_CL_ %s
568// ENV-_CL_-NOT: "-ffunction-sections"
569
570// RUN: env CL="%s" _CL_="%s" not %clang --rsp-quoting=windows -c
571
572// RUN: %clang_cl -### /c -flto -- %s 2>&1 | FileCheck -check-prefix=LTO %s
573// LTO: -flto
574
575// RUN: %clang_cl -### /c -flto=thin -- %s 2>&1 | FileCheck -check-prefix=LTO-THIN %s
576// LTO-THIN: -flto=thin
577
578// RUN: %clang_cl -### -Fe%t.exe -entry:main -flto -- %s 2>&1 | FileCheck -check-prefix=LTO-WITHOUT-LLD %s
579// LTO-WITHOUT-LLD: LTO requires -fuse-ld=lld
580
581// RUN: %clang_cl  -### -- %s 2>&1 | FileCheck -check-prefix=NOCFGUARD %s
582// RUN: %clang_cl /guard:cf- -### -- %s 2>&1 | FileCheck -check-prefix=NOCFGUARD %s
583// NOCFGUARD-NOT: -cfguard
584
585// RUN: %clang_cl /guard:cf -### -- %s 2>&1 | FileCheck -check-prefix=CFGUARD %s
586// RUN: %clang_cl /guard:cf,nochecks -### -- %s 2>&1 | FileCheck -check-prefix=CFGUARD %s
587// RUN: %clang_cl /guard:nochecks -### -- %s 2>&1 | FileCheck -check-prefix=CFGUARD %s
588// CFGUARD: -cfguard
589
590// RUN: %clang_cl /guard:foo -### -- %s 2>&1 | FileCheck -check-prefix=CFGUARDINVALID %s
591// CFGUARDINVALID: invalid value 'foo' in '/guard:'
592
593// Accept "core" clang options.
594// (/Zs is for syntax-only, -Werror makes it fail hard on unknown options)
595// RUN: %clang_cl \
596// RUN:     --driver-mode=cl \
597// RUN:     -fblocks \
598// RUN:     -fcrash-diagnostics-dir=/foo \
599// RUN:     -fno-crash-diagnostics \
600// RUN:     -fno-blocks \
601// RUN:     -fbuiltin \
602// RUN:     -fno-builtin \
603// RUN:     -fno-builtin-strcpy \
604// RUN:     -fcolor-diagnostics \
605// RUN:     -fno-color-diagnostics \
606// RUN:     -fcoverage-mapping \
607// RUN:     -fno-coverage-mapping \
608// RUN:     -fdiagnostics-color \
609// RUN:     -fno-diagnostics-color \
610// RUN:     -fdiagnostics-parseable-fixits \
611// RUN:     -fdiagnostics-absolute-paths \
612// RUN:     -ferror-limit=10 \
613// RUN:     -fmsc-version=1800 \
614// RUN:     -fno-strict-aliasing \
615// RUN:     -fstrict-aliasing \
616// RUN:     -fsyntax-only \
617// RUN:     -fms-compatibility \
618// RUN:     -fno-ms-compatibility \
619// RUN:     -fms-extensions \
620// RUN:     -fno-ms-extensions \
621// RUN:     -Xclang -disable-llvm-passes \
622// RUN:     -resource-dir asdf \
623// RUN:     -resource-dir=asdf \
624// RUN:     -Wunused-variable \
625// RUN:     -fmacro-backtrace-limit=0 \
626// RUN:     -fstandalone-debug \
627// RUN:     -flimit-debug-info \
628// RUN:     -flto \
629// RUN:     -fmerge-all-constants \
630// RUN:     -no-canonical-prefixes \
631// RUN:     -march=skylake \
632// RUN:     -fbracket-depth=123 \
633// RUN:     --version \
634// RUN:     -Werror /Zs -- %s 2>&1
635
636// Accept clang options under the /clang: flag.
637// The first test case ensures that the SLP vectorizer is on by default and that
638// it's being turned off by the /clang:-fno-slp-vectorize flag.
639
640// RUN: %clang_cl -O2 -### -- %s 2>&1 | FileCheck -check-prefix=NOCLANG %s
641// NOCLANG: "--dependent-lib=libcmt"
642// NOCLANG-SAME: "-vectorize-slp"
643// NOCLANG-NOT: "--dependent-lib=msvcrt"
644
645// 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
646// CLANG: "--dependent-lib=msvcrt"
647// CLANG-SAME: "-dependency-file" "my_dependency_file.dep"
648// CLANG-NOT: "--dependent-lib=libcmt"
649// CLANG-NOT: "-vectorize-slp"
650
651void f() { }
652