1 // Check to make sure clang is somewhat picky about -g options.
2 // rdar://10383444
3 
4 // Linux.
5 // RUN: %clang -### -c -g %s -target x86_64-linux-gnu 2>&1 \
6 // RUN:             | FileCheck -check-prefix=G_LIMITED -check-prefix=G_GDB %s
7 // RUN: %clang -### -c -g2 %s -target x86_64-linux-gnu 2>&1 \
8 // RUN:             | FileCheck -check-prefix=G_LIMITED -check-prefix=G_GDB %s
9 // RUN: %clang -### -c -g3 %s -target x86_64-linux-gnu 2>&1 \
10 // RUN:             | FileCheck -check-prefix=G_LIMITED -check-prefix=G_GDB %s
11 // RUN: %clang -### -c -ggdb %s -target x86_64-linux-gnu 2>&1 \
12 // RUN:             | FileCheck -check-prefix=G_LIMITED -check-prefix=G_GDB %s
13 // RUN: %clang -### -c -ggdb1 %s -target x86_64-linux-gnu 2>&1 \
14 // RUN:             | FileCheck -check-prefix=GLTO_ONLY -check-prefix=G_GDB %s
15 // RUN: %clang -### -c -ggdb3 %s -target x86_64-linux-gnu 2>&1 \
16 // RUN:             | FileCheck -check-prefix=G_LIMITED -check-prefix=G_GDB %s
17 // RUN: %clang -### -c -glldb %s -target x86_64-linux-gnu 2>&1 \
18 // RUN:             | FileCheck -check-prefix=G_STANDALONE -check-prefix=G_LLDB %s
19 // RUN: %clang -### -c -gsce %s -target x86_64-linux-gnu 2>&1 \
20 // RUN:             | FileCheck -check-prefix=G_LIMITED -check-prefix=G_SCE %s
21 // RUN: %clang -### -c -gdbx %s -target x86_64-linux-gnu 2>&1 \
22 // RUN:             | FileCheck -check-prefix=G_LIMITED -check-prefix=G_DBX %s
23 
24 // Android.
25 // Android should always generate DWARF4.
26 // RUN: %clang -### -c -g %s -target arm-linux-androideabi 2>&1 \
27 // RUN:             | FileCheck -check-prefix=G_LIMITED -check-prefix=G_DWARF4 %s
28 
29 // Darwin.
30 // RUN: %clang -### -c -g %s -target x86_64-apple-darwin14 2>&1 \
31 // RUN:             | FileCheck -check-prefix=G_STANDALONE \
32 // RUN:                         -check-prefix=G_DWARF2 \
33 // RUN:                         -check-prefix=G_LLDB %s
34 // RUN: %clang -### -c -g %s -target x86_64-apple-darwin16 2>&1 \
35 // RUN:             | FileCheck -check-prefix=G_STANDALONE \
36 // RUN:                         -check-prefix=G_DWARF4 \
37 // RUN:                         -check-prefix=G_LLDB %s
38 // RUN: %clang -### -c -g2 %s -target x86_64-apple-darwin16 2>&1 \
39 // RUN:             | FileCheck -check-prefix=G_STANDALONE \
40 // RUN:                         -check-prefix=G_DWARF4 %s
41 // RUN: %clang -### -c -g3 %s -target x86_64-apple-darwin16 2>&1 \
42 // RUN:             | FileCheck -check-prefix=G_STANDALONE \
43 // RUN:                         -check-prefix=G_DWARF4 %s
44 // RUN: %clang -### -c -ggdb %s -target x86_64-apple-darwin16 2>&1 \
45 // RUN:             | FileCheck -check-prefix=G_STANDALONE \
46 // RUN:                         -check-prefix=G_DWARF4 \
47 // RUN:                         -check-prefix=G_GDB %s
48 // RUN: %clang -### -c -ggdb1 %s -target x86_64-apple-darwin16 2>&1 \
49 // RUN:             | FileCheck -check-prefix=GLTO_ONLY %s
50 // RUN: %clang -### -c -ggdb3 %s -target x86_64-apple-darwin16 2>&1 \
51 // RUN:             | FileCheck -check-prefix=G_STANDALONE \
52 // RUN:                         -check-prefix=G_DWARF4 %s
53 // RUN: %clang -### -c -g %s -target x86_64-apple-macosx10.11 2>&1 \
54 // RUN:             | FileCheck -check-prefix=G_STANDALONE \
55 // RUN:                         -check-prefix=G_DWARF4 %s
56 // RUN: %clang -### -c -g %s -target x86_64-apple-macosx10.10 2>&1 \
57 // RUN:             | FileCheck -check-prefix=G_ONLY_DWARF2 %s
58 // RUN: %clang -### -c -g %s -target armv7-apple-ios9.0 2>&1 \
59 // RUN:             | FileCheck -check-prefix=G_STANDALONE \
60 // RUN:                         -check-prefix=G_DWARF4 %s
61 // RUN: %clang -### -c -g %s -target armv7-apple-ios8.0 2>&1 \
62 // RUN:             | FileCheck -check-prefix=G_ONLY_DWARF2 %s
63 // RUN: %clang -### -c -g %s -target armv7k-apple-watchos 2>&1 \
64 // RUN:             | FileCheck -check-prefix=G_STANDALONE \
65 // RUN:                         -check-prefix=G_DWARF4 %s
66 // RUN: %clang -### -c -g %s -target arm64-apple-tvos9.0 2>&1 \
67 // RUN:             | FileCheck -check-prefix=G_STANDALONE \
68 // RUN:                         -check-prefix=G_DWARF4 %s
69 // RUN: %clang -### -c -fsave-optimization-record %s \
70 // RUN:        -target x86_64-apple-darwin 2>&1 \
71 // RUN:             | FileCheck -check-prefix=GLTO_ONLY %s
72 // RUN: %clang -### -c -g -fsave-optimization-record %s \
73 // RUN:        -target x86_64-apple-darwin 2>&1 \
74 // RUN:             | FileCheck -check-prefix=G_STANDALONE %s
75 
76 // FreeBSD.
77 // RUN: %clang -### -c -g %s -target x86_64-pc-freebsd11.0 2>&1 \
78 // RUN:             | FileCheck -check-prefix=G_GDB \
79 // RUN:                         -check-prefix=G_DWARF2 %s
80 // RUN: %clang -### -c -g %s -target x86_64-pc-freebsd12.0 2>&1 \
81 // RUN:             | FileCheck -check-prefix=G_GDB \
82 // RUN:                         -check-prefix=G_DWARF4 %s
83 
84 // Windows.
85 // RUN: %clang -### -c -g %s -target x86_64-w64-windows-gnu 2>&1 \
86 // RUN:             | FileCheck -check-prefix=G_GDB %s
87 // RUN: %clang -### -c -g %s -target x86_64-windows-msvc 2>&1 \
88 // RUN:             | FileCheck -check-prefix=G_NOTUNING %s
89 // RUN: %clang_cl -### -c -Z7 -target x86_64-windows-msvc -- %s 2>&1 \
90 // RUN:             | FileCheck -check-prefix=G_NOTUNING %s
91 
92 // On the PS4, -g defaults to -gno-column-info, and we always generate the
93 // arange section.
94 // RUN: %clang -### -c %s -target x86_64-scei-ps4 2>&1 \
95 // RUN:             | FileCheck -check-prefix=NOG_PS4 %s
96 // RUN: %clang -### -c %s -g -target x86_64-scei-ps4 2>&1 \
97 // RUN:             | FileCheck -check-prefix=G_PS4 %s
98 // RUN: %clang -### -c %s -g -target x86_64-scei-ps4 2>&1 \
99 // RUN:             | FileCheck -check-prefix=G_SCE %s
100 // RUN: %clang -### -c %s -g -target x86_64-scei-ps4 2>&1 \
101 // RUN:             | FileCheck -check-prefix=NOCI %s
102 // RUN: %clang -### -c %s -g -gcolumn-info -target x86_64-scei-ps4 2>&1 \
103 // RUN:             | FileCheck -check-prefix=CI %s
104 // RUN: %clang -### -c %s -gsce -target x86_64-unknown-linux 2>&1 \
105 // RUN:             | FileCheck -check-prefix=NOCI %s
106 
107 // On the AIX, -g defaults to -gdbx and limited debug info.
108 // RUN: %clang -### -c -g %s -target powerpc-ibm-aix-xcoff 2>&1 \
109 // RUN:             | FileCheck -check-prefix=G_LIMITED -check-prefix=G_DBX %s
110 // RUN: %clang -### -c -g %s -target powerpc64-ibm-aix-xcoff 2>&1 \
111 // RUN:             | FileCheck -check-prefix=G_LIMITED -check-prefix=G_DBX %s
112 
113 // For DBX, -g defaults to -gstrict-dwarf.
114 // RUN: %clang -### -c -g %s -target powerpc-ibm-aix-xcoff 2>&1 \
115 // RUN:             | FileCheck -check-prefix=STRICT %s
116 // RUN: %clang -### -c -g %s -target powerpc64-ibm-aix-xcoff 2>&1 \
117 // RUN:             | FileCheck -check-prefix=STRICT %s
118 // RUN: %clang -### -c -g -gno-strict-dwarf %s -target powerpc-ibm-aix-xcoff \
119 // RUN:             2>&1 | FileCheck -check-prefix=NOSTRICT %s
120 // RUN: %clang -### -c -g %s -target x86_64-linux-gnu 2>&1 \
121 // RUN:             | FileCheck -check-prefix=NOSTRICT %s
122 // RUN: %clang -### -c -g -ggdb %s -target powerpc-ibm-aix-xcoff 2>&1 \
123 // RUN:             | FileCheck -check-prefix=NOSTRICT %s
124 
125 // On the AIX, -g defaults to -gno-column-info.
126 // RUN: %clang -### -c -g %s -target powerpc-ibm-aix-xcoff 2>&1 \
127 // RUN:             | FileCheck -check-prefix=NOCI %s
128 // RUN: %clang -### -c -g %s -target powerpc64-ibm-aix-xcoff 2>&1 \
129 // RUN:             | FileCheck -check-prefix=NOCI %s
130 // RUN: %clang -### -c -g %s -target powerpc-ibm-aix-xcoff -gcolumn-info 2>&1 \
131 // RUN:             | FileCheck -check-prefix=CI %s
132 // RUN: %clang -### -c -g %s -target powerpc64-ibm-aix-xcoff -gcolumn-info \
133 // RUN:             2>&1 | FileCheck -check-prefix=CI %s
134 
135 // WebAssembly.
136 // WebAssembly should default to DWARF4.
137 // RUN: %clang -### -c -g %s -target wasm32 2>&1 \
138 // RUN:             | FileCheck -check-prefix=G_DWARF4 %s
139 // RUN: %clang -### -c -g %s -target wasm64 2>&1 \
140 // RUN:             | FileCheck -check-prefix=G_DWARF4 %s
141 
142 // RUN: %clang -### -c -gdwarf-2 %s 2>&1 \
143 // RUN:             | FileCheck -check-prefix=G_ONLY_DWARF2 %s
144 //
145 // RUN: not %clang -### -c -gfoo %s 2>&1 | FileCheck -check-prefix=G_ERR %s
146 // RUN: %clang -### -c -g -g0 %s 2>&1 | FileCheck -check-prefix=G_NO %s
147 // RUN: %clang -### -c -ggdb0 %s 2>&1 | FileCheck -check-prefix=G_NO %s
148 // RUN: %clang -### -c -glldb -g0 %s 2>&1 | FileCheck -check-prefix=G_NO %s
149 // RUN: %clang -### -c -glldb -g1 %s 2>&1 \
150 // RUN:             | FileCheck -check-prefix=GLTO_ONLY -check-prefix=G_LLDB %s
151 //
152 // PS4 defaults to sce; -ggdb0 changes tuning but turns off debug info,
153 // then -g turns it back on without affecting tuning.
154 // RUN: %clang -### -c -ggdb0 -g -target x86_64-scei-ps4 %s 2>&1 \
155 // RUN:             | FileCheck -check-prefix=G_GDB %s
156 //
157 // RUN: %clang -### -c -g1 %s 2>&1 \
158 // RUN:             | FileCheck -check-prefix=GLTO_ONLY %s
159 // RUN: %clang -### -c -gmlt %s 2>&1 \
160 // RUN:             | FileCheck -check-prefix=GLTO_ONLY %s
161 // RUN: %clang -### -c -gline-tables-only %s 2>&1 \
162 // RUN:             | FileCheck -check-prefix=GLTO_ONLY %s
163 // RUN: %clang -### -c -gline-tables-only %s -target x86_64-apple-darwin 2>&1 \
164 // RUN:             | FileCheck -check-prefix=GLTO_ONLY %s
165 // RUN: %clang -### -c -gline-tables-only %s -target i686-pc-openbsd 2>&1 \
166 // RUN:             | FileCheck -check-prefix=GLTO_ONLY_DWARF2 %s
167 // RUN: %clang -### -c -gline-tables-only %s -target x86_64-pc-freebsd10.0 2>&1 \
168 // RUN:             | FileCheck -check-prefix=GLTO_ONLY_DWARF2 %s
169 // RUN: %clang -### -c -gline-tables-only -g %s -target x86_64-linux-gnu 2>&1 \
170 // RUN:             | FileCheck -check-prefix=G_ONLY %s
171 // RUN: %clang -### -c -gline-tables-only -g %s -target x86_64-apple-darwin16 2>&1 \
172 // RUN:             | FileCheck -check-prefix=G_STANDALONE -check-prefix=G_DWARF4 %s
173 // RUN: %clang -### -c -gline-tables-only -g %s -target i686-pc-openbsd 2>&1 \
174 // RUN:             | FileCheck -check-prefix=G_ONLY_DWARF2 %s
175 // RUN: %clang -### -c -gline-tables-only -g %s -target x86_64-pc-freebsd10.0 2>&1 \
176 // RUN:             | FileCheck -check-prefix=G_ONLY_DWARF2 %s
177 // RUN: %clang -### -c -gline-tables-only -g %s -target i386-pc-solaris 2>&1 \
178 // RUN:             | FileCheck -check-prefix=G_ONLY_DWARF2 %s
179 // RUN: %clang -### -c -gline-tables-only -g0 %s 2>&1 \
180 // RUN:             | FileCheck -check-prefix=GLTO_NO %s
181 //
182 // RUN: %clang -### -c -gline-directives-only %s -target x86_64-apple-darwin 2>&1 \
183 // RUN:             | FileCheck -check-prefix=GLIO_ONLY %s
184 // RUN: %clang -### -c -gline-directives-only %s -target i686-pc-openbsd 2>&1 \
185 // RUN:             | FileCheck -check-prefix=GLIO_ONLY_DWARF2 %s
186 // RUN: %clang -### -c -gline-directives-only %s -target x86_64-pc-freebsd10.0 2>&1 \
187 // RUN:             | FileCheck -check-prefix=GLIO_ONLY_DWARF2 %s
188 // RUN: %clang -### -c -gline-directives-only -g %s -target x86_64-linux-gnu 2>&1 \
189 // RUN:             | FileCheck -check-prefix=G_ONLY %s
190 // RUN: %clang -### -c -gline-directives-only -g %s -target x86_64-apple-darwin16 2>&1 \
191 // RUN:             | FileCheck -check-prefix=G_STANDALONE -check-prefix=G_DWARF4 %s
192 // RUN: %clang -### -c -gline-directives-only -g %s -target i686-pc-openbsd 2>&1 \
193 // RUN:             | FileCheck -check-prefix=G_ONLY_DWARF2 %s
194 // RUN: %clang -### -c -gline-directives-only -g %s -target x86_64-pc-freebsd10.0 2>&1 \
195 // RUN:             | FileCheck -check-prefix=G_ONLY_DWARF2 %s
196 // RUN: %clang -### -c -gline-directives-only -g %s -target i386-pc-solaris 2>&1 \
197 // RUN:             | FileCheck -check-prefix=G_ONLY_DWARF2 %s
198 // RUN: %clang -### -c -gline-directives-only -g0 %s 2>&1 \
199 // RUN:             | FileCheck -check-prefix=GLIO_NO %s
200 //
201 // RUN: %clang -### -c -grecord-gcc-switches %s 2>&1 \
202 //             | FileCheck -check-prefix=GRECORD %s
203 // RUN: %clang -### -c -gno-record-gcc-switches %s 2>&1 \
204 //             | FileCheck -check-prefix=GNO_RECORD %s
205 // RUN: %clang -### -c -grecord-gcc-switches -gno-record-gcc-switches %s 2>&1 \
206 //             | FileCheck -check-prefix=GNO_RECORD %s/
207 // RUN: %clang -### -c -grecord-gcc-switches -o - %s 2>&1 \
208 //             | FileCheck -check-prefix=GRECORD_O %s
209 // RUN: %clang -### -c -O3 -ffunction-sections -grecord-gcc-switches %s 2>&1 \
210 //             | FileCheck -check-prefix=GRECORD_OPT %s
211 //
212 // RUN: %clang -### -c -grecord-command-line %s 2>&1 \
213 //             | FileCheck -check-prefix=GRECORD %s
214 // RUN: %clang -### -c -gno-record-command-line %s 2>&1 \
215 //             | FileCheck -check-prefix=GNO_RECORD %s
216 // RUN: %clang -### -c -grecord-command-line -gno-record-command-line %s 2>&1 \
217 //             | FileCheck -check-prefix=GNO_RECORD %s/
218 // RUN: %clang -### -c -grecord-command-line -o - %s 2>&1 \
219 //             | FileCheck -check-prefix=GRECORD_O %s
220 // RUN: %clang -### -c -O3 -ffunction-sections -grecord-command-line %s 2>&1 \
221 //             | FileCheck -check-prefix=GRECORD_OPT %s
222 //
223 // RUN: %clang -### -c -gstrict-dwarf -gno-strict-dwarf %s 2>&1 \
224 // RUN:        | FileCheck -check-prefix=GIGNORE %s
225 //
226 // RUN: %clang -### -c -ggnu-pubnames %s 2>&1 | FileCheck -check-prefix=GPUB %s
227 // RUN: %clang -### -c -ggdb %s 2>&1 | FileCheck -check-prefix=NOPUB %s
228 // RUN: %clang -### -c -ggnu-pubnames -gno-gnu-pubnames %s 2>&1 | FileCheck -check-prefix=NOPUB %s
229 // RUN: %clang -### -c -ggnu-pubnames -gno-pubnames %s 2>&1 | FileCheck -check-prefix=NOPUB %s
230 //
231 // RUN: %clang -### -c -gpubnames %s 2>&1 | FileCheck -check-prefix=PUB %s
232 // RUN: %clang -### -c -ggdb %s 2>&1 | FileCheck -check-prefix=NOPUB %s
233 // RUN: %clang -### -c -gpubnames -gno-gnu-pubnames %s 2>&1 | FileCheck -check-prefix=NOPUB %s
234 // RUN: %clang -### -c -gpubnames -gno-pubnames %s 2>&1 | FileCheck -check-prefix=NOPUB %s
235 //
236 // RUN: %clang -### -c -gsplit-dwarf -g -gno-pubnames %s 2>&1 | FileCheck -check-prefix=NOPUB %s
237 //
238 // RUN: %clang -### -c -fdebug-ranges-base-address %s 2>&1 | FileCheck -check-prefix=RNGBSE %s
239 // RUN: %clang -### -c %s 2>&1 | FileCheck -check-prefix=NORNGBSE %s
240 // RUN: %clang -### -c -fdebug-ranges-base-address -fno-debug-ranges-base-address %s 2>&1 | FileCheck -check-prefix=NORNGBSE %s
241 //
242 // RUN: %clang -### -c -glldb %s 2>&1 | FileCheck -check-prefix=NOPUB %s
243 // RUN: %clang -### -c -glldb -gno-pubnames %s 2>&1 | FileCheck -check-prefix=NOPUB %s
244 //
245 // RUN: %clang -### -c -gdwarf-aranges %s 2>&1 | FileCheck -check-prefix=GARANGE %s
246 //
247 // RUN: %clang -### -fdebug-types-section -target x86_64-unknown-linux %s 2>&1 \
248 // RUN:        | FileCheck -check-prefix=FDTS %s
249 //
250 // RUN: %clang -### -fdebug-types-section -fno-debug-types-section -target x86_64-unknown-linux %s 2>&1 \
251 // RUN:        | FileCheck -check-prefix=NOFDTS %s
252 //
253 // RUN: %clang -### -fdebug-types-section -target wasm32-unknown-unknown %s 2>&1 \
254 // RUN:        | FileCheck -check-prefix=FDTS %s
255 //
256 // RUN: %clang -### -fdebug-types-section -target x86_64-apple-darwin %s 2>&1 \
257 // RUN:        | FileCheck -check-prefix=FDTSE %s
258 //
259 // RUN: %clang -### -fdebug-types-section -fno-debug-types-section -target x86_64-apple-darwin %s 2>&1 \
260 // RUN:        | FileCheck -check-prefix=NOFDTSE %s
261 //
262 // RUN: %clang -### -g -gno-column-info %s 2>&1 \
263 // RUN:        | FileCheck -check-prefix=NOCI %s
264 //
265 // RUN: %clang -### -g -target x86_64-unknown-unknown %s 2>&1 \
266 //             | FileCheck -check-prefix=CI %s
267 //
268 // RUN: %clang -### -gmodules %s 2>&1 \
269 // RUN:        | FileCheck -check-prefix=GEXTREFS %s
270 //
271 // RUN: %clang -### -gmodules -g %s 2>&1 \
272 // RUN:        | FileCheck -check-prefix=GEXTREFS %s
273 //
274 // RUN: %clang -### -gline-tables-only -gmodules %s 2>&1 \
275 // RUN:        | FileCheck -check-prefix=GEXTREFS %s
276 //
277 // RUN: %clang -### -gmodules -gline-tables-only %s 2>&1 \
278 // RUN:        | FileCheck -check-prefix=GLTO_ONLY %s
279 //
280 // RUN: %clang -### -target %itanium_abi_triple -gmodules -gline-directives-only %s 2>&1 \
281 // RUN:        | FileCheck -check-prefix=GLIO_ONLY %s
282 //
283 // NOG_PS4: "-cc1"
284 // NOG_PS4-NOT: "-dwarf-version=
285 // NOG_PS4: "-generate-arange-section"
286 // NOG_PS4-NOT: "-dwarf-version=
287 //
288 // G_PS4: "-cc1"
289 /// PS4 will stay on v4 even if the generic default version changes.
290 // G_PS4: "-dwarf-version=4"
291 // G_PS4: "-generate-arange-section"
292 //
293 // G_ERR: error: unknown argument:
294 //
295 // G_NO: "-cc1"
296 // G_NO-NOT: -debug-info-kind=
297 //
298 // GLTO_ONLY: "-cc1"
299 // GLTO_ONLY-NOT: "-dwarf-ext-refs"
300 // GLTO_ONLY: "-debug-info-kind=line-tables-only"
301 // GLTO_ONLY-NOT: "-dwarf-ext-refs"
302 //
303 // GLTO_ONLY_DWARF2: "-cc1"
304 // GLTO_ONLY_DWARF2: "-debug-info-kind=line-tables-only"
305 // GLTO_ONLY_DWARF2: "-dwarf-version=2"
306 //
307 // GLIO_ONLY: "-cc1"
308 // GLIO_ONLY-NOT: "-dwarf-ext-refs"
309 // GLIO_ONLY: "-debug-info-kind=line-directives-only"
310 // GLIO_ONLY-NOT: "-dwarf-ext-refs"
311 //
312 // GLIO_ONLY_DWARF2: "-cc1"
313 // GLIO_ONLY_DWARF2: "-debug-info-kind=line-directives-only"
314 // GLIO_ONLY_DWARF2: "-dwarf-version=2"
315 //
316 // G_ONLY: "-cc1"
317 // G_ONLY: "-debug-info-kind=constructor"
318 //
319 // These tests assert that "-gline-tables-only" "-g" uses the latter,
320 // but otherwise not caring about the DebugInfoKind.
321 // G_ONLY_DWARF2: "-cc1"
322 // G_ONLY_DWARF2: "-debug-info-kind={{standalone|constructor}}"
323 // G_ONLY_DWARF2: "-dwarf-version=2"
324 //
325 // G_STANDALONE: "-cc1"
326 // G_STANDALONE: "-debug-info-kind=standalone"
327 // G_LIMITED: "-cc1"
328 // G_LIMITED: "-debug-info-kind=constructor"
329 // G_DWARF2: "-dwarf-version=2"
330 // G_DWARF4: "-dwarf-version=4"
331 //
332 // G_GDB:  "-debugger-tuning=gdb"
333 // G_LLDB: "-debugger-tuning=lldb"
334 // G_SCE:  "-debugger-tuning=sce"
335 // G_DBX:  "-debugger-tuning=dbx"
336 //
337 // STRICT:  "-gstrict-dwarf"
338 // NOSTRICT-NOT:  "-gstrict-dwarf"
339 //
340 // G_NOTUNING: "-cc1"
341 // G_NOTUNING-NOT: "-debugger-tuning="
342 //
343 // This tests asserts that "-gline-tables-only" "-g0" disables debug info.
344 // GLTO_NO: "-cc1"
345 // GLTO_NO-NOT: -debug-info-kind=
346 //
347 // This tests asserts that "-gline-directives-only" "-g0" disables debug info.
348 // GLIO_NO: "-cc1"
349 // GLIO_NO-NOT: -debug-info-kind=
350 //
351 // GRECORD: "-dwarf-debug-flags"
352 // GRECORD: -### -c -grecord-gcc-switches
353 //
354 // GNO_RECORD-NOT: "-dwarf-debug-flags"
355 // GNO_RECORD-NOT: -### -c -grecord-gcc-switches
356 //
357 // GRECORD_O: "-dwarf-debug-flags"
358 // GRECORD_O: -### -c -grecord-gcc-switches -o -
359 //
360 // GRECORD_OPT: -### -c -O3 -ffunction-sections -grecord-gcc-switches
361 //
362 // GIGNORE-NOT: "argument unused during compilation"
363 //
364 // GPUB: -ggnu-pubnames
365 // NOPUB-NOT: -ggnu-pubnames
366 // NOPUB-NOT: -gpubnames
367 //
368 // PUB: -gpubnames
369 //
370 // RNGBSE: -fdebug-ranges-base-address
371 // NORNGBSE-NOT: -fdebug-ranges-base-address
372 //
373 // GARANGE: -generate-arange-section
374 //
375 // FDTS: "-mllvm" "-generate-type-units"
376 // FDTSE: error: unsupported option '-fdebug-types-section' for target 'x86_64-apple-darwin'
377 //
378 // NOFDTS-NOT: "-mllvm" "-generate-type-units"
379 // NOFDTSE-NOT: error: unsupported option '-fdebug-types-section' for target 'x86_64-apple-darwin'
380 //
381 // CI-NOT: "-gno-column-info"
382 //
383 // NOCI: "-gno-column-info"
384 //
385 // GEXTREFS: "-dwarf-ext-refs" "-fmodule-format=obj"
386 // GEXTREFS: "-debug-info-kind={{standalone|constructor}}"
387 
388 // RUN: not %clang -cc1 -debug-info-kind=watkind 2>&1 | FileCheck -check-prefix=BADSTRING1 %s
389 // BADSTRING1: error: invalid value 'watkind' in '-debug-info-kind=watkind'
390 // RUN: not %clang -cc1 -debugger-tuning=gmodal 2>&1 | FileCheck -check-prefix=BADSTRING2 %s
391 // BADSTRING2: error: invalid value 'gmodal' in '-debugger-tuning=gmodal'
392 
393 // RUN: %clang -### -fdebug-macro    %s 2>&1 | FileCheck -check-prefix=MACRO %s
394 // RUN: %clang -### -fno-debug-macro %s 2>&1 | FileCheck -check-prefix=NOMACRO %s
395 // RUN: %clang -###                  %s 2>&1 | FileCheck -check-prefix=NOMACRO %s
396 // MACRO: "-debug-info-macro"
397 // NOMACRO-NOT: "-debug-info-macro"
398 //
399 // RUN: %clang -### -gdwarf-5 -gembed-source %s 2>&1 | FileCheck -check-prefix=GEMBED_5 %s
400 // RUN: %clang -### -gdwarf-2 -gembed-source %s 2>&1 | FileCheck -check-prefix=GEMBED_2 %s
401 // RUN: %clang -### -gdwarf-5 -gno-embed-source %s 2>&1 | FileCheck -check-prefix=NOGEMBED_5 %s
402 // RUN: %clang -### -gdwarf-2 -gno-embed-source %s 2>&1 | FileCheck -check-prefix=NOGEMBED_2 %s
403 //
404 // GEMBED_5:  "-gembed-source"
405 // GEMBED_2:  error: invalid argument '-gembed-source' only allowed with '-gdwarf-5'
406 // NOGEMBED_5-NOT:  "-gembed-source"
407 // NOGEMBED_2-NOT:  error: invalid argument '-gembed-source' only allowed with '-gdwarf-5'
408 //
409 // RUN: %clang -### -g -fno-eliminate-unused-debug-types -c %s 2>&1 \
410 // RUN:        | FileCheck -check-prefix=DEBUG_UNUSED_TYPES %s
411 // DEBUG_UNUSED_TYPES: "-debug-info-kind=unused-types"
412 // DEBUG_UNUSED_TYPES-NOT: "-debug-info-kind=limited"
413 // RUN: %clang -### -g -feliminate-unused-debug-types -c %s 2>&1 \
414 // RUN:        | FileCheck -check-prefix=NO_DEBUG_UNUSED_TYPES %s
415 // RUN: %clang -### -fno-eliminate-unused-debug-types -g1 -c %s 2>&1 \
416 // RUN:        | FileCheck -check-prefix=NO_DEBUG_UNUSED_TYPES %s
417 // NO_DEBUG_UNUSED_TYPES: "-debug-info-kind={{constructor|line-tables-only|standalone}}"
418 // NO_DEBUG_UNUSED_TYPES-NOT: "-debug-info-kind=unused-types"
419 //
420 // RUN: %clang -### -c -gdwarf-5 -gdwarf64 -target x86_64 %s 2>&1 | FileCheck -check-prefix=GDWARF64_ON %s
421 // RUN: %clang -### -c -gdwarf-4 -gdwarf64 -target x86_64 %s 2>&1 | FileCheck -check-prefix=GDWARF64_ON %s
422 // RUN: %clang -### -c -gdwarf-3 -gdwarf64 -target x86_64 %s 2>&1 | FileCheck -check-prefix=GDWARF64_ON %s
423 // RUN: %clang -### -c -gdwarf-2 -gdwarf64 -target x86_64 %s 2>&1 | FileCheck -check-prefix=GDWARF64_VER %s
424 // RUN: %clang -### -c -gdwarf-4 -gdwarf64 -target x86_64 -target x86_64 %s 2>&1 \
425 // RUN:       | FileCheck -check-prefix=GDWARF64_ON %s
426 // RUN: %clang -### -c -gdwarf-4 -gdwarf64 -target i386-linux-gnu %s 2>&1 \
427 // RUN:       | FileCheck -check-prefix=GDWARF64_32ARCH %s
428 // RUN: %clang -### -c -gdwarf-4 -gdwarf64 -target x86_64-apple-darwin %s 2>&1 \
429 // RUN:       | FileCheck -check-prefix=GDWARF64_ELF %s
430 //
431 // GDWARF64_ON:  "-gdwarf64"
432 // GDWARF64_VER:  error: invalid argument '-gdwarf64' only allowed with 'DWARFv3 or greater'
433 // GDWARF64_32ARCH: error: invalid argument '-gdwarf64' only allowed with '64 bit architecture'
434 // GDWARF64_ELF: error: invalid argument '-gdwarf64' only allowed with 'ELF platforms'
435 
436 /// Default to -fno-dwarf-directory-asm for -fno-integrated-as before DWARF v5.
437 // RUN: %clang -### -target x86_64 -c -gdwarf-2 %s 2>&1 | FileCheck --check-prefix=DIRECTORY %s
438 // RUN: %clang -### -target x86_64 -c -gdwarf-5 %s 2>&1 | FileCheck --check-prefix=DIRECTORY %s
439 // RUN: %clang -### -target x86_64 -c -gdwarf-4 -fno-integrated-as %s 2>&1 | FileCheck --check-prefix=NODIRECTORY %s
440 // RUN: %clang -### -target x86_64 -c -gdwarf-5 -fno-integrated-as %s 2>&1 | FileCheck --check-prefix=DIRECTORY %s
441 
442 // RUN: %clang -### -target x86_64 -c -gdwarf-4 -fno-dwarf-directory-asm %s 2>&1 | FileCheck --check-prefix=NODIRECTORY %s
443 
444 // DIRECTORY-NOT: "-fno-dwarf-directory-asm"
445 // NODIRECTORY: "-fno-dwarf-directory-asm"
446 
447 // RUN: %clang -### -target x86_64 -c -g -gsimple-template-names %s 2>&1 | FileCheck --check-prefix=SIMPLE_TEMP_NAMES %s
448 // SIMPLE_TEMP_NAMES: -gsimple-template-names=simple
449 // SIMPLE_TEMP_NAMES: -debug-forward-template-params
450 // RUN: not %clang -### -target x86_64 -c -g -gsimple-template-names=mangled %s 2>&1 | FileCheck --check-prefix=MANGLED_TEMP_NAMES %s
451 // MANGLED_TEMP_NAMES: error: unknown argument: '-gsimple-template-names=mangled'
452 // RUN: %clang -### -target x86_64 -c -g %s 2>&1 | FileCheck --check-prefix=FULL_TEMP_NAMES --implicit-check-not=debug-forward-template-params %s
453 // FULL_TEMP_NAMES-NOT: -gsimple-template-names
454