blob: 3bec1e141d10bcf1cbe257b7012a1abdec7d0abd [file] [log] [blame]
Chad Rosierc2bf3382011-11-04 19:28:44 +00001// Check to make sure clang is somewhat picky about -g options.
2// rdar://10383444
3
Adrian Prantl3e23c042016-10-17 20:14:23 +00004// Linux.
Manman Ren825e8e412013-07-03 20:45:07 +00005// RUN: %clang -### -c -g %s -target x86_64-linux-gnu 2>&1 \
Paul Robinson0334a042015-12-19 19:41:48 +00006// RUN: | FileCheck -check-prefix=G -check-prefix=G_GDB %s
Manman Ren825e8e412013-07-03 20:45:07 +00007// RUN: %clang -### -c -g2 %s -target x86_64-linux-gnu 2>&1 \
Filipe Cabecinhascc2f70b2015-07-16 05:22:17 +00008// RUN: | FileCheck -check-prefix=G %s
Manman Ren825e8e412013-07-03 20:45:07 +00009// RUN: %clang -### -c -g3 %s -target x86_64-linux-gnu 2>&1 \
Filipe Cabecinhascc2f70b2015-07-16 05:22:17 +000010// RUN: | FileCheck -check-prefix=G %s
Manman Ren825e8e412013-07-03 20:45:07 +000011// RUN: %clang -### -c -ggdb %s -target x86_64-linux-gnu 2>&1 \
Paul Robinson0334a042015-12-19 19:41:48 +000012// RUN: | FileCheck -check-prefix=G -check-prefix=G_GDB %s
Manman Ren825e8e412013-07-03 20:45:07 +000013// RUN: %clang -### -c -ggdb1 %s -target x86_64-linux-gnu 2>&1 \
Paul Robinson0334a042015-12-19 19:41:48 +000014// RUN: | FileCheck -check-prefix=GLTO_ONLY -check-prefix=G_GDB %s
Manman Ren825e8e412013-07-03 20:45:07 +000015// RUN: %clang -### -c -ggdb3 %s -target x86_64-linux-gnu 2>&1 \
Filipe Cabecinhascc2f70b2015-07-16 05:22:17 +000016// RUN: | FileCheck -check-prefix=G %s
Paul Robinson0334a042015-12-19 19:41:48 +000017// RUN: %clang -### -c -glldb %s -target x86_64-linux-gnu 2>&1 \
18// RUN: | FileCheck -check-prefix=G -check-prefix=G_LLDB %s
19// RUN: %clang -### -c -gsce %s -target x86_64-linux-gnu 2>&1 \
Manman Ren825e8e412013-07-03 20:45:07 +000020
Adrian Prantl3e23c042016-10-17 20:14:23 +000021// Darwin.
22// RUN: | FileCheck -check-prefix=G -check-prefix=G_SCE %s
Manman Ren825e8e412013-07-03 20:45:07 +000023// RUN: %clang -### -c -g %s -target x86_64-apple-darwin 2>&1 \
Adrian Prantl3e23c042016-10-17 20:14:23 +000024// RUN: | FileCheck -check-prefix=G_STANDALONE \
25// RUN: -check-prefix=G_DWARF2 \
26// RUN: -check-prefix=G_LLDB %s
Adrian Prantld50d56c2016-10-17 19:36:18 +000027// RUN: %clang -### -c -g %s -target x86_64-apple-darwin16 2>&1 \
Adrian Prantl3e23c042016-10-17 20:14:23 +000028// RUN: | FileCheck -check-prefix=G_STANDALONE \
29// RUN: -check-prefix=G_DWARF4 \
30// RUN: -check-prefix=G_LLDB %s
Adrian Prantld50d56c2016-10-17 19:36:18 +000031// RUN: %clang -### -c -g2 %s -target x86_64-apple-darwin16 2>&1 \
Adrian Prantl3e23c042016-10-17 20:14:23 +000032// RUN: | FileCheck -check-prefix=G_STANDALONE \
33// RUN: -check-prefix=G_DWARF4 %s
Adrian Prantld50d56c2016-10-17 19:36:18 +000034// RUN: %clang -### -c -g3 %s -target x86_64-apple-darwin16 2>&1 \
Adrian Prantl3e23c042016-10-17 20:14:23 +000035// RUN: | FileCheck -check-prefix=G_STANDALONE \
36// RUN: -check-prefix=G_DWARF4 %s
Adrian Prantld50d56c2016-10-17 19:36:18 +000037// RUN: %clang -### -c -ggdb %s -target x86_64-apple-darwin16 2>&1 \
Adrian Prantl3e23c042016-10-17 20:14:23 +000038// RUN: | FileCheck -check-prefix=G_STANDALONE \
39// RUN: -check-prefix=G_DWARF4 \
40// RUN: -check-prefix=G_GDB %s
Adrian Prantld50d56c2016-10-17 19:36:18 +000041// RUN: %clang -### -c -ggdb1 %s -target x86_64-apple-darwin16 2>&1 \
Adrian Prantl432d3d22016-09-09 21:10:35 +000042// RUN: | FileCheck -check-prefix=GLTO_ONLY %s
Adrian Prantld50d56c2016-10-17 19:36:18 +000043// RUN: %clang -### -c -ggdb3 %s -target x86_64-apple-darwin16 2>&1 \
Adrian Prantl3e23c042016-10-17 20:14:23 +000044// RUN: | FileCheck -check-prefix=G_STANDALONE \
45// RUN: -check-prefix=G_DWARF4 %s
Adrian Prantld50d56c2016-10-17 19:36:18 +000046// RUN: %clang -### -c -g %s -target x86_64-apple-macosx10.11 2>&1 \
Adrian Prantl3e23c042016-10-17 20:14:23 +000047// RUN: | FileCheck -check-prefix=G_STANDALONE \
48// RUN: -check-prefix=G_DWARF4 %s
Adrian Prantld50d56c2016-10-17 19:36:18 +000049// RUN: %clang -### -c -g %s -target x86_64-apple-macosx10.10 2>&1 \
50// RUN: | FileCheck -check-prefix=G_ONLY_DWARF2 %s
51// RUN: %clang -### -c -g %s -target armv7-apple-ios9.0 2>&1 \
Adrian Prantl3e23c042016-10-17 20:14:23 +000052// RUN: | FileCheck -check-prefix=G_STANDALONE \
53// RUN: -check-prefix=G_DWARF4 %s
Adrian Prantld50d56c2016-10-17 19:36:18 +000054// RUN: %clang -### -c -g %s -target armv7-apple-ios8.0 2>&1 \
55// RUN: | FileCheck -check-prefix=G_ONLY_DWARF2 %s
56// RUN: %clang -### -c -g %s -target armv7k-apple-watchos 2>&1 \
Adrian Prantl3e23c042016-10-17 20:14:23 +000057// RUN: | FileCheck -check-prefix=G_STANDALONE \
58// RUN: -check-prefix=G_DWARF4 %s
Adrian Prantld50d56c2016-10-17 19:36:18 +000059// RUN: %clang -### -c -g %s -target arm64-apple-tvos9.0 2>&1 \
Adrian Prantl3e23c042016-10-17 20:14:23 +000060// RUN: | FileCheck -check-prefix=G_STANDALONE \
61// RUN: -check-prefix=G_DWARF4 %s
Manman Ren825e8e412013-07-03 20:45:07 +000062
Adrian Prantl3e23c042016-10-17 20:14:23 +000063// FreeBSD.
Paul Robinson0334a042015-12-19 19:41:48 +000064// RUN: %clang -### -c -g %s -target x86_64-pc-freebsd10.0 2>&1 \
Dimitry Andric72132002016-01-07 22:09:47 +000065// RUN: | FileCheck -check-prefix=G_GDB %s
Paul Robinson0334a042015-12-19 19:41:48 +000066
Filipe Cabecinhasc888e192015-10-14 12:25:43 +000067// On the PS4, -g defaults to -gno-column-info, and we always generate the
68// arange section.
69// RUN: %clang -### -c %s -target x86_64-scei-ps4 2>&1 \
Filipe Cabecinhas2432ff52015-10-14 14:45:36 +000070// RUN: | FileCheck -check-prefix=NOG_PS4 %s
Filipe Cabecinhasc888e192015-10-14 12:25:43 +000071// RUN: %clang -### -c %s -g -target x86_64-scei-ps4 2>&1 \
72// RUN: | FileCheck -check-prefix=G_PS4 %s
73// RUN: %clang -### -c %s -g -target x86_64-scei-ps4 2>&1 \
Paul Robinson0334a042015-12-19 19:41:48 +000074// RUN: | FileCheck -check-prefix=G_SCE %s
75// RUN: %clang -### -c %s -g -target x86_64-scei-ps4 2>&1 \
Filipe Cabecinhasc888e192015-10-14 12:25:43 +000076// RUN: | FileCheck -check-prefix=NOCI %s
77// RUN: %clang -### -c %s -g -gcolumn-info -target x86_64-scei-ps4 2>&1 \
78// RUN: | FileCheck -check-prefix=CI %s
Paul Robinsona8280812017-09-29 21:25:07 +000079// RUN: %clang -### -c %s -gsce -target x86_64-unknown-linux 2>&1 \
80// RUN: | FileCheck -check-prefix=NOCI %s
Filipe Cabecinhasc888e192015-10-14 12:25:43 +000081
Adrian Prantl3e23c042016-10-17 20:14:23 +000082// RUN: %clang -### -c -gdwarf-2 %s 2>&1 \
83// RUN: | FileCheck -check-prefix=G_ONLY_DWARF2 %s
Alexey Samsonovf50a9ff2012-06-21 08:22:39 +000084//
Serge Pavlovb43573b2017-05-24 14:57:17 +000085// RUN: not %clang -### -c -gfoo %s 2>&1 | FileCheck -check-prefix=G_ERR %s
Alexey Samsonovf50a9ff2012-06-21 08:22:39 +000086// RUN: %clang -### -c -g -g0 %s 2>&1 | FileCheck -check-prefix=G_NO %s
87// RUN: %clang -### -c -ggdb0 %s 2>&1 | FileCheck -check-prefix=G_NO %s
Paul Robinson0334a042015-12-19 19:41:48 +000088// RUN: %clang -### -c -glldb -g0 %s 2>&1 | FileCheck -check-prefix=G_NO %s
89// RUN: %clang -### -c -glldb -g1 %s 2>&1 \
90// RUN: | FileCheck -check-prefix=GLTO_ONLY -check-prefix=G_LLDB %s
91//
92// PS4 defaults to sce; -ggdb0 changes tuning but turns off debug info,
93// then -g turns it back on without affecting tuning.
94// RUN: %clang -### -c -ggdb0 -g -target x86_64-scei-ps4 %s 2>&1 \
95// RUN: | FileCheck -check-prefix=G -check-prefix=G_GDB %s
Alexey Samsonovf50a9ff2012-06-21 08:22:39 +000096//
Hal Finkel4add5dc2014-10-21 19:20:21 +000097// RUN: %clang -### -c -g1 %s 2>&1 \
98// RUN: | FileCheck -check-prefix=GLTO_ONLY %s
David Blaikie29559b12014-03-11 21:05:26 +000099// RUN: %clang -### -c -gmlt %s 2>&1 \
100// RUN: | FileCheck -check-prefix=GLTO_ONLY %s
Alexey Samsonov74a38682012-05-04 07:39:27 +0000101// RUN: %clang -### -c -gline-tables-only %s 2>&1 \
Alexey Samsonovf50a9ff2012-06-21 08:22:39 +0000102// RUN: | FileCheck -check-prefix=GLTO_ONLY %s
Manman Ren17bdb0f2013-11-20 20:22:14 +0000103// RUN: %clang -### -c -gline-tables-only %s -target x86_64-apple-darwin 2>&1 \
Adrian Prantl432d3d22016-09-09 21:10:35 +0000104// RUN: | FileCheck -check-prefix=GLTO_ONLY %s
Brad Smith378e7f9b2014-06-13 03:35:37 +0000105// RUN: %clang -### -c -gline-tables-only %s -target i686-pc-openbsd 2>&1 \
106// RUN: | FileCheck -check-prefix=GLTO_ONLY_DWARF2 %s
107// RUN: %clang -### -c -gline-tables-only %s -target x86_64-pc-freebsd10.0 2>&1 \
108// RUN: | FileCheck -check-prefix=GLTO_ONLY_DWARF2 %s
Manman Ren825e8e412013-07-03 20:45:07 +0000109// RUN: %clang -### -c -gline-tables-only -g %s -target x86_64-linux-gnu 2>&1 \
Alexey Samsonovf50a9ff2012-06-21 08:22:39 +0000110// RUN: | FileCheck -check-prefix=G_ONLY %s
Adrian Prantld50d56c2016-10-17 19:36:18 +0000111// RUN: %clang -### -c -gline-tables-only -g %s -target x86_64-apple-darwin16 2>&1 \
Adrian Prantl3e23c042016-10-17 20:14:23 +0000112// RUN: | FileCheck -check-prefix=G_STANDALONE -check-prefix=G_DWARF4 %s
Brad Smith378e7f9b2014-06-13 03:35:37 +0000113// RUN: %clang -### -c -gline-tables-only -g %s -target i686-pc-openbsd 2>&1 \
114// RUN: | FileCheck -check-prefix=G_ONLY_DWARF2 %s
115// RUN: %clang -### -c -gline-tables-only -g %s -target x86_64-pc-freebsd10.0 2>&1 \
116// RUN: | FileCheck -check-prefix=G_ONLY_DWARF2 %s
Alexander Eremin670c6272014-10-16 05:55:24 +0000117// RUN: %clang -### -c -gline-tables-only -g %s -target i386-pc-solaris 2>&1 \
118// RUN: | FileCheck -check-prefix=G_ONLY_DWARF2 %s
Alexey Samsonovdda3a7f2012-05-29 08:10:34 +0000119// RUN: %clang -### -c -gline-tables-only -g0 %s 2>&1 \
Alexey Samsonovf50a9ff2012-06-21 08:22:39 +0000120// RUN: | FileCheck -check-prefix=GLTO_NO %s
121//
Eric Christopherca325172017-03-29 23:34:20 +0000122// RUN: %clang -### -c -grecord-gcc-switches %s 2>&1 \
123// | FileCheck -check-prefix=GRECORD %s
124// RUN: %clang -### -c -gno-record-gcc-switches %s 2>&1 \
125// | FileCheck -check-prefix=GNO_RECORD %s
126// RUN: %clang -### -c -grecord-gcc-switches -gno-record-gcc-switches %s 2>&1 \
127// | FileCheck -check-prefix=GNO_RECORD %s/
128// RUN: %clang -### -c -grecord-gcc-switches -o - %s 2>&1 \
129// | FileCheck -check-prefix=GRECORD_O %s
130// RUN: %clang -### -c -O3 -ffunction-sections -grecord-gcc-switches %s 2>&1 \
131// | FileCheck -check-prefix=GRECORD_OPT %s
132//
133// RUN: %clang -### -c -gstrict-dwarf -gno-strict-dwarf %s 2>&1 \
Eric Christopher2062ec62013-06-18 00:03:46 +0000134// RUN: | FileCheck -check-prefix=GIGNORE %s
Chad Rosierc2bf3382011-11-04 19:28:44 +0000135//
Eric Christopher138c32b2013-09-13 22:37:55 +0000136// RUN: %clang -### -c -ggnu-pubnames %s 2>&1 | FileCheck -check-prefix=GOPT %s
137//
Eric Christopher0d403d22014-02-14 01:27:03 +0000138// RUN: %clang -### -c -gdwarf-aranges %s 2>&1 | FileCheck -check-prefix=GARANGE %s
139//
David Blaikied74be702014-01-18 02:02:06 +0000140// RUN: %clang -### -fdebug-types-section %s 2>&1 \
141// RUN: | FileCheck -check-prefix=FDTS %s
142//
David Blaikief36d9ba2014-01-27 18:52:43 +0000143// RUN: %clang -### -fdebug-types-section -fno-debug-types-section %s 2>&1 \
144// RUN: | FileCheck -check-prefix=NOFDTS %s
145//
Diego Novillo94b276d2014-07-10 23:29:28 +0000146// RUN: %clang -### -g -gno-column-info %s 2>&1 \
147// RUN: | FileCheck -check-prefix=NOCI %s
148//
Filipe Cabecinhasc888e192015-10-14 12:25:43 +0000149// RUN: %clang -### -g -target x86_64-unknown-unknown %s 2>&1 \
150// | FileCheck -check-prefix=CI %s
David Blaikief36d9ba2014-01-27 18:52:43 +0000151//
Adrian Prantl6b21ab22015-08-27 19:46:20 +0000152// RUN: %clang -### -gmodules %s 2>&1 \
153// RUN: | FileCheck -check-prefix=GEXTREFS %s
154//
Adrian Prantle941fc12016-10-10 21:56:20 +0000155// RUN: %clang -### -gmodules -g %s 2>&1 \
156// RUN: | FileCheck -check-prefix=GEXTREFS %s
157//
158// RUN: %clang -### -gline-tables-only -gmodules %s 2>&1 \
159// RUN: | FileCheck -check-prefix=GEXTREFS %s
160//
161// RUN: %clang -### -gmodules -gline-tables-only %s 2>&1 \
162// RUN: | FileCheck -check-prefix=GLTO_ONLY %s
163//
Chad Rosierc2bf3382011-11-04 19:28:44 +0000164// G: "-cc1"
Douglas Katzman3459ce22015-10-08 04:24:12 +0000165// G: "-debug-info-kind=limited"
Manman Ren825e8e412013-07-03 20:45:07 +0000166//
Filipe Cabecinhas2432ff52015-10-14 14:45:36 +0000167// NOG_PS4: "-cc1"
168// NOG_PS4-NOT "-dwarf-version=
169// NOG_PS4: "-generate-arange-section"
170// NOG_PS4-NOT: "-dwarf-version=
171//
Filipe Cabecinhasc888e192015-10-14 12:25:43 +0000172// G_PS4: "-cc1"
Filipe Cabecinhas2432ff52015-10-14 14:45:36 +0000173// G_PS4: "-dwarf-version=
Filipe Cabecinhasc888e192015-10-14 12:25:43 +0000174// G_PS4: "-generate-arange-section"
175//
Serge Pavlovb43573b2017-05-24 14:57:17 +0000176// G_ERR: error: unknown argument:
177//
Alexey Samsonovf50a9ff2012-06-21 08:22:39 +0000178// G_NO: "-cc1"
Douglas Katzman3459ce22015-10-08 04:24:12 +0000179// G_NO-NOT: -debug-info-kind=
Chad Rosier2ad368f2012-02-28 20:49:04 +0000180//
Alexey Samsonovf50a9ff2012-06-21 08:22:39 +0000181// GLTO_ONLY: "-cc1"
Adrian Prantle941fc12016-10-10 21:56:20 +0000182// GLTO_ONLY-NOT: "-dwarf-ext-refs"
Douglas Katzman3459ce22015-10-08 04:24:12 +0000183// GLTO_ONLY: "-debug-info-kind=line-tables-only"
Adrian Prantle941fc12016-10-10 21:56:20 +0000184// GLTO_ONLY-NOT: "-dwarf-ext-refs"
Chad Rosierc2bf3382011-11-04 19:28:44 +0000185//
Brad Smith378e7f9b2014-06-13 03:35:37 +0000186// GLTO_ONLY_DWARF2: "-cc1"
Douglas Katzman3459ce22015-10-08 04:24:12 +0000187// GLTO_ONLY_DWARF2: "-debug-info-kind=line-tables-only"
188// GLTO_ONLY_DWARF2: "-dwarf-version=2"
Adrian Prantl549c5142014-02-17 17:40:52 +0000189//
Alexey Samsonovf50a9ff2012-06-21 08:22:39 +0000190// G_ONLY: "-cc1"
Douglas Katzman3459ce22015-10-08 04:24:12 +0000191// G_ONLY: "-debug-info-kind=limited"
Chad Rosierc2bf3382011-11-04 19:28:44 +0000192//
Douglas Katzman3459ce22015-10-08 04:24:12 +0000193// These tests assert that "-gline-tables-only" "-g" uses the latter,
194// but otherwise not caring about the DebugInfoKind.
Brad Smith378e7f9b2014-06-13 03:35:37 +0000195// G_ONLY_DWARF2: "-cc1"
Douglas Katzman3459ce22015-10-08 04:24:12 +0000196// G_ONLY_DWARF2: "-debug-info-kind={{standalone|limited}}"
197// G_ONLY_DWARF2: "-dwarf-version=2"
Adrian Prantl549c5142014-02-17 17:40:52 +0000198//
Adrian Prantl3e23c042016-10-17 20:14:23 +0000199// G_STANDALONE: "-cc1"
200// G_STANDALONE: "-debug-info-kind=standalone"
201// G_DWARF4: "-dwarf-version=4"
Adrian Prantl432d3d22016-09-09 21:10:35 +0000202//
Adrian Prantld50d56c2016-10-17 19:36:18 +0000203// G_GDB: "-debugger-tuning=gdb"
204// G_LLDB: "-debugger-tuning=lldb"
205// G_SCE: "-debugger-tuning=sce"
206//
Douglas Katzman3459ce22015-10-08 04:24:12 +0000207// This tests asserts that "-gline-tables-only" "-g0" disables debug info.
Alexey Samsonovf50a9ff2012-06-21 08:22:39 +0000208// GLTO_NO: "-cc1"
Douglas Katzman3459ce22015-10-08 04:24:12 +0000209// GLTO_NO-NOT: -debug-info-kind=
Eric Christopher2062ec62013-06-18 00:03:46 +0000210//
Eric Christopherca325172017-03-29 23:34:20 +0000211// GRECORD: "-dwarf-debug-flags"
212// GRECORD: -### -c -grecord-gcc-switches
213//
214// GNO_RECORD-NOT: "-dwarf-debug-flags"
215// GNO_RECORD-NOT: -### -c -grecord-gcc-switches
216//
217// GRECORD_O: "-dwarf-debug-flags"
218// GRECORD_O: -### -c -grecord-gcc-switches -o -
219//
220// GRECORD_OPT: -### -c -O3 -ffunction-sections -grecord-gcc-switches
221//
Eric Christopher2062ec62013-06-18 00:03:46 +0000222// GIGNORE-NOT: "argument unused during compilation"
Eric Christopher138c32b2013-09-13 22:37:55 +0000223//
Peter Collingbourneb52e2362017-09-12 21:50:41 +0000224// GOPT: -ggnu-pubnames
David Blaikied74be702014-01-18 02:02:06 +0000225//
Eric Christopher0d403d22014-02-14 01:27:03 +0000226// GARANGE: -generate-arange-section
227//
David Blaikied74be702014-01-18 02:02:06 +0000228// FDTS: "-backend-option" "-generate-type-units"
David Blaikief36d9ba2014-01-27 18:52:43 +0000229//
230// NOFDTS-NOT: "-backend-option" "-generate-type-units"
Diego Novillo94b276d2014-07-10 23:29:28 +0000231//
232// CI: "-dwarf-column-info"
233//
234// NOCI-NOT: "-dwarf-column-info"
Adrian Prantl6b21ab22015-08-27 19:46:20 +0000235//
Douglas Katzman6d6a9422015-10-08 05:02:24 +0000236// GEXTREFS: "-dwarf-ext-refs" "-fmodule-format=obj" "-debug-info-kind={{standalone|limited}}"
Douglas Katzmana2ef81f2016-01-06 01:37:57 +0000237
238// RUN: not %clang -cc1 -debug-info-kind=watkind 2>&1 | FileCheck -check-prefix=BADSTRING1 %s
239// BADSTRING1: error: invalid value 'watkind' in '-debug-info-kind=watkind'
240// RUN: not %clang -cc1 -debugger-tuning=gmodal 2>&1 | FileCheck -check-prefix=BADSTRING2 %s
241// BADSTRING2: error: invalid value 'gmodal' in '-debugger-tuning=gmodal'
Amjad Aboud546bc112017-02-09 22:07:24 +0000242
243// RUN: %clang -### -fdebug-macro %s 2>&1 | FileCheck -check-prefix=MACRO %s
244// RUN: %clang -### -fno-debug-macro %s 2>&1 | FileCheck -check-prefix=NOMACRO %s
245// RUN: %clang -### %s 2>&1 | FileCheck -check-prefix=NOMACRO %s
246// MACRO: "-debug-info-macro"
247// NOMACRO-NOT: "-debug-info-macro"