blob: be50ee8af701d250d255a53ce18c7bf472956c5a [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
79
Adrian Prantl3e23c042016-10-17 20:14:23 +000080// RUN: %clang -### -c -gdwarf-2 %s 2>&1 \
81// RUN: | FileCheck -check-prefix=G_ONLY_DWARF2 %s
Alexey Samsonovf50a9ff2012-06-21 08:22:39 +000082//
83// RUN: %clang -### -c -gfoo %s 2>&1 | FileCheck -check-prefix=G_NO %s
84// RUN: %clang -### -c -g -g0 %s 2>&1 | FileCheck -check-prefix=G_NO %s
85// RUN: %clang -### -c -ggdb0 %s 2>&1 | FileCheck -check-prefix=G_NO %s
Paul Robinson0334a042015-12-19 19:41:48 +000086// RUN: %clang -### -c -glldb -g0 %s 2>&1 | FileCheck -check-prefix=G_NO %s
87// RUN: %clang -### -c -glldb -g1 %s 2>&1 \
88// RUN: | FileCheck -check-prefix=GLTO_ONLY -check-prefix=G_LLDB %s
89//
90// PS4 defaults to sce; -ggdb0 changes tuning but turns off debug info,
91// then -g turns it back on without affecting tuning.
92// RUN: %clang -### -c -ggdb0 -g -target x86_64-scei-ps4 %s 2>&1 \
93// RUN: | FileCheck -check-prefix=G -check-prefix=G_GDB %s
Alexey Samsonovf50a9ff2012-06-21 08:22:39 +000094//
Hal Finkel4add5dc2014-10-21 19:20:21 +000095// RUN: %clang -### -c -g1 %s 2>&1 \
96// RUN: | FileCheck -check-prefix=GLTO_ONLY %s
David Blaikie29559b12014-03-11 21:05:26 +000097// RUN: %clang -### -c -gmlt %s 2>&1 \
98// RUN: | FileCheck -check-prefix=GLTO_ONLY %s
Alexey Samsonov74a38682012-05-04 07:39:27 +000099// RUN: %clang -### -c -gline-tables-only %s 2>&1 \
Alexey Samsonovf50a9ff2012-06-21 08:22:39 +0000100// RUN: | FileCheck -check-prefix=GLTO_ONLY %s
Manman Ren17bdb0f2013-11-20 20:22:14 +0000101// RUN: %clang -### -c -gline-tables-only %s -target x86_64-apple-darwin 2>&1 \
Adrian Prantl432d3d22016-09-09 21:10:35 +0000102// RUN: | FileCheck -check-prefix=GLTO_ONLY %s
Brad Smith378e7f9b2014-06-13 03:35:37 +0000103// RUN: %clang -### -c -gline-tables-only %s -target i686-pc-openbsd 2>&1 \
104// RUN: | FileCheck -check-prefix=GLTO_ONLY_DWARF2 %s
105// RUN: %clang -### -c -gline-tables-only %s -target x86_64-pc-freebsd10.0 2>&1 \
106// RUN: | FileCheck -check-prefix=GLTO_ONLY_DWARF2 %s
Manman Ren825e8e412013-07-03 20:45:07 +0000107// RUN: %clang -### -c -gline-tables-only -g %s -target x86_64-linux-gnu 2>&1 \
Alexey Samsonovf50a9ff2012-06-21 08:22:39 +0000108// RUN: | FileCheck -check-prefix=G_ONLY %s
Adrian Prantld50d56c2016-10-17 19:36:18 +0000109// RUN: %clang -### -c -gline-tables-only -g %s -target x86_64-apple-darwin16 2>&1 \
Adrian Prantl3e23c042016-10-17 20:14:23 +0000110// RUN: | FileCheck -check-prefix=G_STANDALONE -check-prefix=G_DWARF4 %s
Brad Smith378e7f9b2014-06-13 03:35:37 +0000111// RUN: %clang -### -c -gline-tables-only -g %s -target i686-pc-openbsd 2>&1 \
112// RUN: | FileCheck -check-prefix=G_ONLY_DWARF2 %s
113// RUN: %clang -### -c -gline-tables-only -g %s -target x86_64-pc-freebsd10.0 2>&1 \
114// RUN: | FileCheck -check-prefix=G_ONLY_DWARF2 %s
Alexander Eremin670c6272014-10-16 05:55:24 +0000115// RUN: %clang -### -c -gline-tables-only -g %s -target i386-pc-solaris 2>&1 \
116// RUN: | FileCheck -check-prefix=G_ONLY_DWARF2 %s
Alexey Samsonovdda3a7f2012-05-29 08:10:34 +0000117// RUN: %clang -### -c -gline-tables-only -g0 %s 2>&1 \
Alexey Samsonovf50a9ff2012-06-21 08:22:39 +0000118// RUN: | FileCheck -check-prefix=GLTO_NO %s
119//
Benjamin Kramer7555b542012-08-03 10:35:06 +0000120// RUN: %clang -### -c -grecord-gcc-switches -gno-record-gcc-switches \
David Blaikied74be702014-01-18 02:02:06 +0000121// RUN: -gstrict-dwarf -gno-strict-dwarf %s 2>&1 \
Eric Christopher2062ec62013-06-18 00:03:46 +0000122// RUN: | FileCheck -check-prefix=GIGNORE %s
Chad Rosierc2bf3382011-11-04 19:28:44 +0000123//
Eric Christopher138c32b2013-09-13 22:37:55 +0000124// RUN: %clang -### -c -ggnu-pubnames %s 2>&1 | FileCheck -check-prefix=GOPT %s
125//
Eric Christopher0d403d22014-02-14 01:27:03 +0000126// RUN: %clang -### -c -gdwarf-aranges %s 2>&1 | FileCheck -check-prefix=GARANGE %s
127//
David Blaikied74be702014-01-18 02:02:06 +0000128// RUN: %clang -### -fdebug-types-section %s 2>&1 \
129// RUN: | FileCheck -check-prefix=FDTS %s
130//
David Blaikief36d9ba2014-01-27 18:52:43 +0000131// RUN: %clang -### -fdebug-types-section -fno-debug-types-section %s 2>&1 \
132// RUN: | FileCheck -check-prefix=NOFDTS %s
133//
Diego Novillo94b276d2014-07-10 23:29:28 +0000134// RUN: %clang -### -g -gno-column-info %s 2>&1 \
135// RUN: | FileCheck -check-prefix=NOCI %s
136//
Filipe Cabecinhasc888e192015-10-14 12:25:43 +0000137// RUN: %clang -### -g -target x86_64-unknown-unknown %s 2>&1 \
138// | FileCheck -check-prefix=CI %s
David Blaikief36d9ba2014-01-27 18:52:43 +0000139//
Adrian Prantl6b21ab22015-08-27 19:46:20 +0000140// RUN: %clang -### -gmodules %s 2>&1 \
141// RUN: | FileCheck -check-prefix=GEXTREFS %s
142//
Adrian Prantle941fc12016-10-10 21:56:20 +0000143// RUN: %clang -### -gmodules -g %s 2>&1 \
144// RUN: | FileCheck -check-prefix=GEXTREFS %s
145//
146// RUN: %clang -### -gline-tables-only -gmodules %s 2>&1 \
147// RUN: | FileCheck -check-prefix=GEXTREFS %s
148//
149// RUN: %clang -### -gmodules -gline-tables-only %s 2>&1 \
150// RUN: | FileCheck -check-prefix=GLTO_ONLY %s
151//
Chad Rosierc2bf3382011-11-04 19:28:44 +0000152// G: "-cc1"
Douglas Katzman3459ce22015-10-08 04:24:12 +0000153// G: "-debug-info-kind=limited"
Manman Ren825e8e412013-07-03 20:45:07 +0000154//
Filipe Cabecinhas2432ff52015-10-14 14:45:36 +0000155// NOG_PS4: "-cc1"
156// NOG_PS4-NOT "-dwarf-version=
157// NOG_PS4: "-generate-arange-section"
158// NOG_PS4-NOT: "-dwarf-version=
159//
Filipe Cabecinhasc888e192015-10-14 12:25:43 +0000160// G_PS4: "-cc1"
Filipe Cabecinhas2432ff52015-10-14 14:45:36 +0000161// G_PS4: "-dwarf-version=
Filipe Cabecinhasc888e192015-10-14 12:25:43 +0000162// G_PS4: "-generate-arange-section"
163//
Alexey Samsonovf50a9ff2012-06-21 08:22:39 +0000164// G_NO: "-cc1"
Douglas Katzman3459ce22015-10-08 04:24:12 +0000165// G_NO-NOT: -debug-info-kind=
Chad Rosier2ad368f2012-02-28 20:49:04 +0000166//
Alexey Samsonovf50a9ff2012-06-21 08:22:39 +0000167// GLTO_ONLY: "-cc1"
Adrian Prantle941fc12016-10-10 21:56:20 +0000168// GLTO_ONLY-NOT: "-dwarf-ext-refs"
Douglas Katzman3459ce22015-10-08 04:24:12 +0000169// GLTO_ONLY: "-debug-info-kind=line-tables-only"
Adrian Prantle941fc12016-10-10 21:56:20 +0000170// GLTO_ONLY-NOT: "-dwarf-ext-refs"
Chad Rosierc2bf3382011-11-04 19:28:44 +0000171//
Brad Smith378e7f9b2014-06-13 03:35:37 +0000172// GLTO_ONLY_DWARF2: "-cc1"
Douglas Katzman3459ce22015-10-08 04:24:12 +0000173// GLTO_ONLY_DWARF2: "-debug-info-kind=line-tables-only"
174// GLTO_ONLY_DWARF2: "-dwarf-version=2"
Adrian Prantl549c5142014-02-17 17:40:52 +0000175//
Alexey Samsonovf50a9ff2012-06-21 08:22:39 +0000176// G_ONLY: "-cc1"
Douglas Katzman3459ce22015-10-08 04:24:12 +0000177// G_ONLY: "-debug-info-kind=limited"
Chad Rosierc2bf3382011-11-04 19:28:44 +0000178//
Douglas Katzman3459ce22015-10-08 04:24:12 +0000179// These tests assert that "-gline-tables-only" "-g" uses the latter,
180// but otherwise not caring about the DebugInfoKind.
Brad Smith378e7f9b2014-06-13 03:35:37 +0000181// G_ONLY_DWARF2: "-cc1"
Douglas Katzman3459ce22015-10-08 04:24:12 +0000182// G_ONLY_DWARF2: "-debug-info-kind={{standalone|limited}}"
183// G_ONLY_DWARF2: "-dwarf-version=2"
Adrian Prantl549c5142014-02-17 17:40:52 +0000184//
Adrian Prantl3e23c042016-10-17 20:14:23 +0000185// G_STANDALONE: "-cc1"
186// G_STANDALONE: "-debug-info-kind=standalone"
187// G_DWARF4: "-dwarf-version=4"
Adrian Prantl432d3d22016-09-09 21:10:35 +0000188//
Adrian Prantld50d56c2016-10-17 19:36:18 +0000189// G_GDB: "-debugger-tuning=gdb"
190// G_LLDB: "-debugger-tuning=lldb"
191// G_SCE: "-debugger-tuning=sce"
192//
Douglas Katzman3459ce22015-10-08 04:24:12 +0000193// This tests asserts that "-gline-tables-only" "-g0" disables debug info.
Alexey Samsonovf50a9ff2012-06-21 08:22:39 +0000194// GLTO_NO: "-cc1"
Douglas Katzman3459ce22015-10-08 04:24:12 +0000195// GLTO_NO-NOT: -debug-info-kind=
Eric Christopher2062ec62013-06-18 00:03:46 +0000196//
197// GIGNORE-NOT: "argument unused during compilation"
Eric Christopher138c32b2013-09-13 22:37:55 +0000198//
199// GOPT: -generate-gnu-dwarf-pub-sections
David Blaikied74be702014-01-18 02:02:06 +0000200//
Eric Christopher0d403d22014-02-14 01:27:03 +0000201// GARANGE: -generate-arange-section
202//
David Blaikied74be702014-01-18 02:02:06 +0000203// FDTS: "-backend-option" "-generate-type-units"
David Blaikief36d9ba2014-01-27 18:52:43 +0000204//
205// NOFDTS-NOT: "-backend-option" "-generate-type-units"
Diego Novillo94b276d2014-07-10 23:29:28 +0000206//
207// CI: "-dwarf-column-info"
208//
209// NOCI-NOT: "-dwarf-column-info"
Adrian Prantl6b21ab22015-08-27 19:46:20 +0000210//
Douglas Katzman6d6a9422015-10-08 05:02:24 +0000211// GEXTREFS: "-dwarf-ext-refs" "-fmodule-format=obj" "-debug-info-kind={{standalone|limited}}"
Douglas Katzmana2ef81f2016-01-06 01:37:57 +0000212
213// RUN: not %clang -cc1 -debug-info-kind=watkind 2>&1 | FileCheck -check-prefix=BADSTRING1 %s
214// BADSTRING1: error: invalid value 'watkind' in '-debug-info-kind=watkind'
215// RUN: not %clang -cc1 -debugger-tuning=gmodal 2>&1 | FileCheck -check-prefix=BADSTRING2 %s
216// BADSTRING2: error: invalid value 'gmodal' in '-debugger-tuning=gmodal'
Amjad Aboud546bc112017-02-09 22:07:24 +0000217
218// RUN: %clang -### -fdebug-macro %s 2>&1 | FileCheck -check-prefix=MACRO %s
219// RUN: %clang -### -fno-debug-macro %s 2>&1 | FileCheck -check-prefix=NOMACRO %s
220// RUN: %clang -### %s 2>&1 | FileCheck -check-prefix=NOMACRO %s
221// MACRO: "-debug-info-macro"
222// NOMACRO-NOT: "-debug-info-macro"