blob: 72d0136a8c403c0a6987ed0b501f96356c22a09e [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
Manman Ren825e8e412013-07-03 20:45:07 +00004// RUN: %clang -### -c -g %s -target x86_64-linux-gnu 2>&1 \
Paul Robinson0334a042015-12-19 19:41:48 +00005// RUN: | FileCheck -check-prefix=G -check-prefix=G_GDB %s
Manman Ren825e8e412013-07-03 20:45:07 +00006// RUN: %clang -### -c -g2 %s -target x86_64-linux-gnu 2>&1 \
Filipe Cabecinhascc2f70b2015-07-16 05:22:17 +00007// RUN: | FileCheck -check-prefix=G %s
Manman Ren825e8e412013-07-03 20:45:07 +00008// RUN: %clang -### -c -g3 %s -target x86_64-linux-gnu 2>&1 \
Filipe Cabecinhascc2f70b2015-07-16 05:22:17 +00009// RUN: | FileCheck -check-prefix=G %s
Manman Ren825e8e412013-07-03 20:45:07 +000010// RUN: %clang -### -c -ggdb %s -target x86_64-linux-gnu 2>&1 \
Paul Robinson0334a042015-12-19 19:41:48 +000011// RUN: | FileCheck -check-prefix=G -check-prefix=G_GDB %s
Manman Ren825e8e412013-07-03 20:45:07 +000012// RUN: %clang -### -c -ggdb1 %s -target x86_64-linux-gnu 2>&1 \
Paul Robinson0334a042015-12-19 19:41:48 +000013// RUN: | FileCheck -check-prefix=GLTO_ONLY -check-prefix=G_GDB %s
Manman Ren825e8e412013-07-03 20:45:07 +000014// RUN: %clang -### -c -ggdb3 %s -target x86_64-linux-gnu 2>&1 \
Filipe Cabecinhascc2f70b2015-07-16 05:22:17 +000015// RUN: | FileCheck -check-prefix=G %s
Paul Robinson0334a042015-12-19 19:41:48 +000016// RUN: %clang -### -c -glldb %s -target x86_64-linux-gnu 2>&1 \
17// RUN: | FileCheck -check-prefix=G -check-prefix=G_LLDB %s
18// RUN: %clang -### -c -gsce %s -target x86_64-linux-gnu 2>&1 \
19// RUN: | FileCheck -check-prefix=G -check-prefix=G_SCE %s
Manman Ren825e8e412013-07-03 20:45:07 +000020
21// RUN: %clang -### -c -g %s -target x86_64-apple-darwin 2>&1 \
Paul Robinson0334a042015-12-19 19:41:48 +000022// RUN: | FileCheck -check-prefix=G_DARWIN -check-prefix=G_LLDB %s
Manman Ren825e8e412013-07-03 20:45:07 +000023// RUN: %clang -### -c -g2 %s -target x86_64-apple-darwin 2>&1 \
Filipe Cabecinhascc2f70b2015-07-16 05:22:17 +000024// RUN: | FileCheck -check-prefix=G_DARWIN %s
Manman Ren825e8e412013-07-03 20:45:07 +000025// RUN: %clang -### -c -g3 %s -target x86_64-apple-darwin 2>&1 \
Filipe Cabecinhascc2f70b2015-07-16 05:22:17 +000026// RUN: | FileCheck -check-prefix=G_DARWIN %s
Manman Ren825e8e412013-07-03 20:45:07 +000027// RUN: %clang -### -c -ggdb %s -target x86_64-apple-darwin 2>&1 \
Paul Robinson0334a042015-12-19 19:41:48 +000028// RUN: | FileCheck -check-prefix=G_DARWIN -check-prefix=G_GDB %s
Manman Ren825e8e412013-07-03 20:45:07 +000029// RUN: %clang -### -c -ggdb1 %s -target x86_64-apple-darwin 2>&1 \
Douglas Katzman9a2ef282015-09-30 15:55:59 +000030// RUN: | FileCheck -check-prefix=GLTO_ONLY_DWARF2 %s
Manman Ren825e8e412013-07-03 20:45:07 +000031// RUN: %clang -### -c -ggdb3 %s -target x86_64-apple-darwin 2>&1 \
Filipe Cabecinhascc2f70b2015-07-16 05:22:17 +000032// RUN: | FileCheck -check-prefix=G_DARWIN %s
Manman Ren825e8e412013-07-03 20:45:07 +000033
Paul Robinson0334a042015-12-19 19:41:48 +000034// RUN: %clang -### -c -g %s -target x86_64-pc-freebsd10.0 2>&1 \
35// RUN: | FileCheck -check-prefix=G_LLDB %s
36
Filipe Cabecinhasc888e192015-10-14 12:25:43 +000037// On the PS4, -g defaults to -gno-column-info, and we always generate the
38// arange section.
39// RUN: %clang -### -c %s -target x86_64-scei-ps4 2>&1 \
Filipe Cabecinhas2432ff52015-10-14 14:45:36 +000040// RUN: | FileCheck -check-prefix=NOG_PS4 %s
Filipe Cabecinhasc888e192015-10-14 12:25:43 +000041// RUN: %clang -### -c %s -g -target x86_64-scei-ps4 2>&1 \
42// RUN: | FileCheck -check-prefix=G_PS4 %s
43// RUN: %clang -### -c %s -g -target x86_64-scei-ps4 2>&1 \
Paul Robinson0334a042015-12-19 19:41:48 +000044// RUN: | FileCheck -check-prefix=G_SCE %s
45// RUN: %clang -### -c %s -g -target x86_64-scei-ps4 2>&1 \
Filipe Cabecinhasc888e192015-10-14 12:25:43 +000046// RUN: | FileCheck -check-prefix=NOCI %s
47// RUN: %clang -### -c %s -g -gcolumn-info -target x86_64-scei-ps4 2>&1 \
48// RUN: | FileCheck -check-prefix=CI %s
49
Manman Ren9691f7f2013-06-19 01:46:49 +000050// RUN: %clang -### -c -gdwarf-2 %s 2>&1 | FileCheck -check-prefix=G_D2 %s
Alexey Samsonovf50a9ff2012-06-21 08:22:39 +000051//
52// RUN: %clang -### -c -gfoo %s 2>&1 | FileCheck -check-prefix=G_NO %s
53// RUN: %clang -### -c -g -g0 %s 2>&1 | FileCheck -check-prefix=G_NO %s
54// RUN: %clang -### -c -ggdb0 %s 2>&1 | FileCheck -check-prefix=G_NO %s
Paul Robinson0334a042015-12-19 19:41:48 +000055// RUN: %clang -### -c -glldb -g0 %s 2>&1 | FileCheck -check-prefix=G_NO %s
56// RUN: %clang -### -c -glldb -g1 %s 2>&1 \
57// RUN: | FileCheck -check-prefix=GLTO_ONLY -check-prefix=G_LLDB %s
58//
59// PS4 defaults to sce; -ggdb0 changes tuning but turns off debug info,
60// then -g turns it back on without affecting tuning.
61// RUN: %clang -### -c -ggdb0 -g -target x86_64-scei-ps4 %s 2>&1 \
62// RUN: | FileCheck -check-prefix=G -check-prefix=G_GDB %s
Alexey Samsonovf50a9ff2012-06-21 08:22:39 +000063//
Hal Finkel4add5dc2014-10-21 19:20:21 +000064// RUN: %clang -### -c -g1 %s 2>&1 \
65// RUN: | FileCheck -check-prefix=GLTO_ONLY %s
David Blaikie29559b12014-03-11 21:05:26 +000066// RUN: %clang -### -c -gmlt %s 2>&1 \
67// RUN: | FileCheck -check-prefix=GLTO_ONLY %s
Alexey Samsonov74a38682012-05-04 07:39:27 +000068// RUN: %clang -### -c -gline-tables-only %s 2>&1 \
Alexey Samsonovf50a9ff2012-06-21 08:22:39 +000069// RUN: | FileCheck -check-prefix=GLTO_ONLY %s
Manman Ren17bdb0f2013-11-20 20:22:14 +000070// RUN: %clang -### -c -gline-tables-only %s -target x86_64-apple-darwin 2>&1 \
Brad Smith378e7f9b2014-06-13 03:35:37 +000071// RUN: | FileCheck -check-prefix=GLTO_ONLY_DWARF2 %s
72// RUN: %clang -### -c -gline-tables-only %s -target i686-pc-openbsd 2>&1 \
73// RUN: | FileCheck -check-prefix=GLTO_ONLY_DWARF2 %s
74// RUN: %clang -### -c -gline-tables-only %s -target x86_64-pc-freebsd10.0 2>&1 \
75// RUN: | FileCheck -check-prefix=GLTO_ONLY_DWARF2 %s
Manman Ren825e8e412013-07-03 20:45:07 +000076// RUN: %clang -### -c -gline-tables-only -g %s -target x86_64-linux-gnu 2>&1 \
Alexey Samsonovf50a9ff2012-06-21 08:22:39 +000077// RUN: | FileCheck -check-prefix=G_ONLY %s
Manman Ren825e8e412013-07-03 20:45:07 +000078// RUN: %clang -### -c -gline-tables-only -g %s -target x86_64-apple-darwin 2>&1 \
Brad Smith378e7f9b2014-06-13 03:35:37 +000079// RUN: | FileCheck -check-prefix=G_ONLY_DWARF2 %s
80// RUN: %clang -### -c -gline-tables-only -g %s -target i686-pc-openbsd 2>&1 \
81// RUN: | FileCheck -check-prefix=G_ONLY_DWARF2 %s
82// RUN: %clang -### -c -gline-tables-only -g %s -target x86_64-pc-freebsd10.0 2>&1 \
83// RUN: | FileCheck -check-prefix=G_ONLY_DWARF2 %s
Alexander Eremin670c6272014-10-16 05:55:24 +000084// RUN: %clang -### -c -gline-tables-only -g %s -target i386-pc-solaris 2>&1 \
85// RUN: | FileCheck -check-prefix=G_ONLY_DWARF2 %s
Alexey Samsonovdda3a7f2012-05-29 08:10:34 +000086// RUN: %clang -### -c -gline-tables-only -g0 %s 2>&1 \
Alexey Samsonovf50a9ff2012-06-21 08:22:39 +000087// RUN: | FileCheck -check-prefix=GLTO_NO %s
88//
Benjamin Kramer7555b542012-08-03 10:35:06 +000089// RUN: %clang -### -c -grecord-gcc-switches -gno-record-gcc-switches \
David Blaikied74be702014-01-18 02:02:06 +000090// RUN: -gstrict-dwarf -gno-strict-dwarf %s 2>&1 \
Eric Christopher2062ec62013-06-18 00:03:46 +000091// RUN: | FileCheck -check-prefix=GIGNORE %s
Chad Rosierc2bf3382011-11-04 19:28:44 +000092//
Eric Christopher138c32b2013-09-13 22:37:55 +000093// RUN: %clang -### -c -ggnu-pubnames %s 2>&1 | FileCheck -check-prefix=GOPT %s
94//
Eric Christopher0d403d22014-02-14 01:27:03 +000095// RUN: %clang -### -c -gdwarf-aranges %s 2>&1 | FileCheck -check-prefix=GARANGE %s
96//
David Blaikied74be702014-01-18 02:02:06 +000097// RUN: %clang -### -fdebug-types-section %s 2>&1 \
98// RUN: | FileCheck -check-prefix=FDTS %s
99//
David Blaikief36d9ba2014-01-27 18:52:43 +0000100// RUN: %clang -### -fdebug-types-section -fno-debug-types-section %s 2>&1 \
101// RUN: | FileCheck -check-prefix=NOFDTS %s
102//
Diego Novillo94b276d2014-07-10 23:29:28 +0000103// RUN: %clang -### -g -gno-column-info %s 2>&1 \
104// RUN: | FileCheck -check-prefix=NOCI %s
105//
Filipe Cabecinhasc888e192015-10-14 12:25:43 +0000106// RUN: %clang -### -g -target x86_64-unknown-unknown %s 2>&1 \
107// | FileCheck -check-prefix=CI %s
David Blaikief36d9ba2014-01-27 18:52:43 +0000108//
Adrian Prantl6b21ab22015-08-27 19:46:20 +0000109// RUN: %clang -### -gmodules %s 2>&1 \
110// RUN: | FileCheck -check-prefix=GEXTREFS %s
111//
Chad Rosierc2bf3382011-11-04 19:28:44 +0000112// G: "-cc1"
Douglas Katzman3459ce22015-10-08 04:24:12 +0000113// G: "-debug-info-kind=limited"
Manman Ren825e8e412013-07-03 20:45:07 +0000114//
115// G_DARWIN: "-cc1"
Douglas Katzman3459ce22015-10-08 04:24:12 +0000116// G_DARWIN: "-dwarf-version=2"
Eric Christopher0d403d22014-02-14 01:27:03 +0000117//
Filipe Cabecinhas2432ff52015-10-14 14:45:36 +0000118// NOG_PS4: "-cc1"
119// NOG_PS4-NOT "-dwarf-version=
120// NOG_PS4: "-generate-arange-section"
121// NOG_PS4-NOT: "-dwarf-version=
122//
Filipe Cabecinhasc888e192015-10-14 12:25:43 +0000123// G_PS4: "-cc1"
Filipe Cabecinhas2432ff52015-10-14 14:45:36 +0000124// G_PS4: "-dwarf-version=
Filipe Cabecinhasc888e192015-10-14 12:25:43 +0000125// G_PS4: "-generate-arange-section"
126//
Manman Ren9691f7f2013-06-19 01:46:49 +0000127// G_D2: "-cc1"
Douglas Katzman3459ce22015-10-08 04:24:12 +0000128// G_D2: "-dwarf-version=2"
Chad Rosierc2bf3382011-11-04 19:28:44 +0000129//
Alexey Samsonovf50a9ff2012-06-21 08:22:39 +0000130// G_NO: "-cc1"
Douglas Katzman3459ce22015-10-08 04:24:12 +0000131// G_NO-NOT: -debug-info-kind=
Chad Rosier2ad368f2012-02-28 20:49:04 +0000132//
Alexey Samsonovf50a9ff2012-06-21 08:22:39 +0000133// GLTO_ONLY: "-cc1"
Douglas Katzman3459ce22015-10-08 04:24:12 +0000134// GLTO_ONLY: "-debug-info-kind=line-tables-only"
Chad Rosierc2bf3382011-11-04 19:28:44 +0000135//
Brad Smith378e7f9b2014-06-13 03:35:37 +0000136// GLTO_ONLY_DWARF2: "-cc1"
Douglas Katzman3459ce22015-10-08 04:24:12 +0000137// GLTO_ONLY_DWARF2: "-debug-info-kind=line-tables-only"
138// GLTO_ONLY_DWARF2: "-dwarf-version=2"
Adrian Prantl549c5142014-02-17 17:40:52 +0000139//
Alexey Samsonovf50a9ff2012-06-21 08:22:39 +0000140// G_ONLY: "-cc1"
Douglas Katzman3459ce22015-10-08 04:24:12 +0000141// G_ONLY: "-debug-info-kind=limited"
Chad Rosierc2bf3382011-11-04 19:28:44 +0000142//
Paul Robinson0334a042015-12-19 19:41:48 +0000143// G_GDB: "-debugger-tuning=gdb"
144// G_LLDB: "-debugger-tuning=lldb"
145// G_SCE: "-debugger-tuning=sce"
146//
Douglas Katzman3459ce22015-10-08 04:24:12 +0000147// These tests assert that "-gline-tables-only" "-g" uses the latter,
148// but otherwise not caring about the DebugInfoKind.
Brad Smith378e7f9b2014-06-13 03:35:37 +0000149// G_ONLY_DWARF2: "-cc1"
Douglas Katzman3459ce22015-10-08 04:24:12 +0000150// G_ONLY_DWARF2: "-debug-info-kind={{standalone|limited}}"
151// G_ONLY_DWARF2: "-dwarf-version=2"
Adrian Prantl549c5142014-02-17 17:40:52 +0000152//
Douglas Katzman3459ce22015-10-08 04:24:12 +0000153// This tests asserts that "-gline-tables-only" "-g0" disables debug info.
Alexey Samsonovf50a9ff2012-06-21 08:22:39 +0000154// GLTO_NO: "-cc1"
Douglas Katzman3459ce22015-10-08 04:24:12 +0000155// GLTO_NO-NOT: -debug-info-kind=
Eric Christopher2062ec62013-06-18 00:03:46 +0000156//
157// GIGNORE-NOT: "argument unused during compilation"
Eric Christopher138c32b2013-09-13 22:37:55 +0000158//
159// GOPT: -generate-gnu-dwarf-pub-sections
David Blaikied74be702014-01-18 02:02:06 +0000160//
Eric Christopher0d403d22014-02-14 01:27:03 +0000161// GARANGE: -generate-arange-section
162//
David Blaikied74be702014-01-18 02:02:06 +0000163// FDTS: "-backend-option" "-generate-type-units"
David Blaikief36d9ba2014-01-27 18:52:43 +0000164//
165// NOFDTS-NOT: "-backend-option" "-generate-type-units"
Diego Novillo94b276d2014-07-10 23:29:28 +0000166//
167// CI: "-dwarf-column-info"
168//
169// NOCI-NOT: "-dwarf-column-info"
Adrian Prantl6b21ab22015-08-27 19:46:20 +0000170//
Douglas Katzman6d6a9422015-10-08 05:02:24 +0000171// GEXTREFS: "-dwarf-ext-refs" "-fmodule-format=obj" "-debug-info-kind={{standalone|limited}}"
Douglas Katzmana2ef81f2016-01-06 01:37:57 +0000172
173// RUN: not %clang -cc1 -debug-info-kind=watkind 2>&1 | FileCheck -check-prefix=BADSTRING1 %s
174// BADSTRING1: error: invalid value 'watkind' in '-debug-info-kind=watkind'
175// RUN: not %clang -cc1 -debugger-tuning=gmodal 2>&1 | FileCheck -check-prefix=BADSTRING2 %s
176// BADSTRING2: error: invalid value 'gmodal' in '-debugger-tuning=gmodal'