Debian Codegraph @

clang/test/Driver/debug-options.c

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