blob: 55d6588f2e7e0377b1165b4262daa8f48bbc1c53 [file] [log] [blame]
Eric Christopheraf7eca22014-03-13 23:26:25 +00001; RUN: llc %s -o %t -filetype=obj -O0 -mtriple=x86_64-unknown-linux-gnu -dwarf-version=4
David Blaikie49cfc8c2014-10-23 19:12:43 +00002; RUN: llvm-dwarfdump -debug-dump=info %t | FileCheck %s -check-prefix=PRESENT
Eli Benderskye6abe832013-01-25 21:44:53 +00003; RUN: llvm-dwarfdump -debug-dump=info %t | FileCheck %s -check-prefix=ABSENT
Eric Christopheraf7eca22014-03-13 23:26:25 +00004; RUN: llc %s -o %t -filetype=obj -O0 -mtriple=x86_64-apple-darwin -dwarf-version=4
Manman Ren584e4c02013-02-27 23:21:02 +00005; RUN: llvm-dwarfdump -debug-dump=info %t | FileCheck %s -check-prefix=DARWINP
6; RUN: llvm-dwarfdump -debug-dump=info %t | FileCheck %s -check-prefix=DARWINA
Eric Christopherce26df82013-01-16 19:53:47 +00007; Verify that attributes we do want are PRESENT;
8; verify that attributes we don't want are ABSENT.
9; It's a lot easier to do this in two passes than in one.
10; PR14471
11
David Blaikie9f4b70d2013-01-26 21:55:23 +000012; LLVM IR generated using: clang -emit-llvm -S -g
Eric Christopherce26df82013-01-16 19:53:47 +000013; (with the Clang part of this patch applied).
14;
15; class C
16; {
17; static int a;
David Blaikieb0859312013-01-19 23:00:25 +000018; const static bool const_a = true;
Eric Christopherce26df82013-01-16 19:53:47 +000019; protected:
20; static int b;
David Blaikiea39a76e2013-01-20 01:18:01 +000021; const static float const_b = 3.14;
Eric Christopherce26df82013-01-16 19:53:47 +000022; public:
23; static int c;
24; const static int const_c = 18;
25; int d;
26; };
27;
28; int C::a = 4;
29; int C::b = 2;
30; int C::c = 1;
31;
32; int main()
33; {
34; C instance_C;
35; instance_C.d = 8;
36; return C::c;
37; }
38
39%class.C = type { i32 }
40
Peter Collingbourned4135bb2016-09-13 01:12:59 +000041@_ZN1C1aE = global i32 4, align 4, !dbg !12
42@_ZN1C1bE = global i32 2, align 4, !dbg !27
43@_ZN1C1cE = global i32 1, align 4, !dbg !28
Eric Christopherce26df82013-01-16 19:53:47 +000044
Peter Collingbourned4bff302015-11-05 22:03:56 +000045define i32 @main() nounwind uwtable !dbg !5 {
Eric Christopherce26df82013-01-16 19:53:47 +000046entry:
47 %retval = alloca i32, align 4
48 %instance_C = alloca %class.C, align 4
49 store i32 0, i32* %retval
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000050 call void @llvm.dbg.declare(metadata %class.C* %instance_C, metadata !29, metadata !DIExpression()), !dbg !30
David Blaikie79e6c742015-02-27 19:29:02 +000051 %d = getelementptr inbounds %class.C, %class.C* %instance_C, i32 0, i32 0, !dbg !31
David Blaikie9f4b70d2013-01-26 21:55:23 +000052 store i32 8, i32* %d, align 4, !dbg !31
David Blaikiea79ac142015-02-27 21:17:42 +000053 %0 = load i32, i32* @_ZN1C1cE, align 4, !dbg !32
David Blaikie9f4b70d2013-01-26 21:55:23 +000054 ret i32 %0, !dbg !32
Eric Christopherce26df82013-01-16 19:53:47 +000055}
56
Adrian Prantl87b7eb92014-10-01 18:55:02 +000057declare void @llvm.dbg.declare(metadata, metadata, metadata) nounwind readnone
Eric Christopherce26df82013-01-16 19:53:47 +000058
59!llvm.dbg.cu = !{!0}
Manman Ren409558f2013-11-22 21:49:45 +000060!llvm.module.flags = !{!34}
Eric Christopherce26df82013-01-16 19:53:47 +000061
Adrian Prantl75819ae2016-04-15 15:57:41 +000062!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.3 (trunk 171914)", isOptimized: false, emissionKind: FullDebug, file: !33, enums: !1, retainedTypes: !1, globals: !10, imports: !1)
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +000063!1 = !{}
Adrian Prantl75819ae2016-04-15 15:57:41 +000064!5 = distinct !DISubprogram(name: "main", line: 18, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 23, file: !33, scope: !6, type: !7, variables: !1)
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000065!6 = !DIFile(filename: "/usr/local/google/home/blaikie/Development/llvm/src/tools/clang/test/CodeGenCXX/debug-info-static-member.cpp", directory: "/home/blaikie/local/Development/llvm/build/clang/x86-64/Debug/llvm")
66!7 = !DISubroutineType(types: !8)
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +000067!8 = !{!9}
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000068!9 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +000069!10 = !{!12, !27, !28}
Adrian Prantlbceaaa92016-12-20 02:09:43 +000070!12 = !DIGlobalVariableExpression(var: !DIGlobalVariable(name: "a", linkageName: "_ZN1C1aE", line: 14, isLocal: false, isDefinition: true, scope: null, file: !6, type: !9, declaration: !15))
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000071!13 = !DICompositeType(tag: DW_TAG_class_type, name: "C", line: 1, size: 32, align: 32, file: !33, elements: !14)
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +000072!14 = !{!15, !16, !19, !20, !23, !24, !26}
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000073!15 = !DIDerivedType(tag: DW_TAG_member, name: "a", line: 3, flags: DIFlagPrivate | DIFlagStaticMember, file: !33, scope: !13, baseType: !9)
74!16 = !DIDerivedType(tag: DW_TAG_member, name: "const_a", line: 4, flags: DIFlagPrivate | DIFlagStaticMember, file: !33, scope: !13, baseType: !17, extraData: i1 true)
75!17 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !18)
76!18 = !DIBasicType(tag: DW_TAG_base_type, name: "bool", size: 8, align: 8, encoding: DW_ATE_boolean)
77!19 = !DIDerivedType(tag: DW_TAG_member, name: "b", line: 6, flags: DIFlagProtected | DIFlagStaticMember, file: !33, scope: !13, baseType: !9)
78!20 = !DIDerivedType(tag: DW_TAG_member, name: "const_b", line: 7, flags: DIFlagProtected | DIFlagStaticMember, file: !33, scope: !13, baseType: !21, extraData: float 0x40091EB860000000)
79!21 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !22)
80!22 = !DIBasicType(tag: DW_TAG_base_type, name: "float", size: 32, align: 32, encoding: DW_ATE_float)
81!23 = !DIDerivedType(tag: DW_TAG_member, name: "c", line: 9, flags: DIFlagPublic | DIFlagStaticMember, file: !33, scope: !13, baseType: !9)
82!24 = !DIDerivedType(tag: DW_TAG_member, name: "const_c", line: 10, flags: DIFlagPublic | DIFlagStaticMember, file: !33, scope: !13, baseType: !25, extraData: i32 18)
83!25 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !9)
84!26 = !DIDerivedType(tag: DW_TAG_member, name: "d", line: 11, size: 32, align: 32, flags: DIFlagPublic, file: !33, scope: !13, baseType: !9)
Adrian Prantlbceaaa92016-12-20 02:09:43 +000085!27 = !DIGlobalVariableExpression(var: !DIGlobalVariable(name: "b", linkageName: "_ZN1C1bE", line: 15, isLocal: false, isDefinition: true, scope: null, file: !6, type: !9, declaration: !19))
86!28 = !DIGlobalVariableExpression(var: !DIGlobalVariable(name: "c", linkageName: "_ZN1C1cE", line: 16, isLocal: false, isDefinition: true, scope: null, file: !6, type: !9, declaration: !23))
Duncan P. N. Exon Smithed013cd2015-07-31 18:58:39 +000087!29 = !DILocalVariable(name: "instance_C", line: 20, scope: !5, file: !6, type: !13)
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000088!30 = !DILocation(line: 20, scope: !5)
89!31 = !DILocation(line: 21, scope: !5)
90!32 = !DILocation(line: 22, scope: !5)
91!33 = !DIFile(filename: "/usr/local/google/home/blaikie/Development/llvm/src/tools/clang/test/CodeGenCXX/debug-info-static-member.cpp", directory: "/home/blaikie/local/Development/llvm/build/clang/x86-64/Debug/llvm")
Eric Christopherce26df82013-01-16 19:53:47 +000092; PRESENT verifies that static member declarations have these attributes:
Paul Robinson857b4432015-03-10 22:44:45 +000093; external, declaration, accessibility, and either DW_AT_linkage_name
Eric Christopherce26df82013-01-16 19:53:47 +000094; (for variables) or DW_AT_const_value (for constants).
95;
96; PRESENT: .debug_info contents:
David Blaikie49cfc8c2014-10-23 19:12:43 +000097; PRESENT: DW_TAG_variable
98; PRESENT-NEXT: DW_AT_specification {{.*}} "a"
99; PRESENT-NEXT: DW_AT_location
100; PRESENT-NEXT: DW_AT_linkage_name {{.*}} "_ZN1C1aE"
Eric Christopherce26df82013-01-16 19:53:47 +0000101; PRESENT: DW_TAG_class_type
102; PRESENT-NEXT: DW_AT_name {{.*}} "C"
Frederic Rissd4de1802014-10-10 15:51:02 +0000103; PRESENT: DW_TAG_member
Eric Christopherce26df82013-01-16 19:53:47 +0000104; PRESENT-NEXT: DW_AT_name {{.*}} "a"
105; PRESENT: DW_AT_external
106; PRESENT: DW_AT_declaration
Frederic Riss878065b2014-09-04 19:39:20 +0000107; PRESENT: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_private)
Eric Christopherce26df82013-01-16 19:53:47 +0000108; PRESENT: DW_TAG_member
109; PRESENT-NEXT: DW_AT_name {{.*}} "const_a"
110; PRESENT: DW_AT_external
111; PRESENT: DW_AT_declaration
Frederic Riss878065b2014-09-04 19:39:20 +0000112; PRESENT: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_private)
David Blaikieb0859312013-01-19 23:00:25 +0000113; PRESENT: DW_AT_const_value {{.*}} (1)
Frederic Rissd4de1802014-10-10 15:51:02 +0000114; PRESENT: DW_TAG_member
Eric Christopherce26df82013-01-16 19:53:47 +0000115; PRESENT-NEXT: DW_AT_name {{.*}} "b"
Frederic Riss878065b2014-09-04 19:39:20 +0000116; PRESENT: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_protected)
Eric Christopherce26df82013-01-16 19:53:47 +0000117; PRESENT: DW_TAG_member
118; PRESENT-NEXT: DW_AT_name {{.*}} "const_b"
Frederic Riss878065b2014-09-04 19:39:20 +0000119; PRESENT: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_protected)
David Blaikiec05c8f42014-05-11 15:47:39 +0000120; PRESENT: DW_AT_const_value [DW_FORM_udata] (1078523331)
Frederic Rissd4de1802014-10-10 15:51:02 +0000121; PRESENT: DW_TAG_member
Eric Christopherce26df82013-01-16 19:53:47 +0000122; PRESENT-NEXT: DW_AT_name {{.*}} "c"
Frederic Riss878065b2014-09-04 19:39:20 +0000123; PRESENT: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_public)
Eric Christopherce26df82013-01-16 19:53:47 +0000124; PRESENT: DW_TAG_member
125; PRESENT-NEXT: DW_AT_name {{.*}} "const_c"
Frederic Riss878065b2014-09-04 19:39:20 +0000126; PRESENT: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_public)
Eric Christopher9d1daa82013-08-27 23:49:04 +0000127; PRESENT: DW_AT_const_value {{.*}} (18)
Eric Christopherce26df82013-01-16 19:53:47 +0000128; While we're here, a normal member has data_member_location and
129; accessibility attributes.
130; PRESENT: DW_TAG_member
131; PRESENT-NEXT: DW_AT_name {{.*}} "d"
132; PRESENT: DW_AT_data_member_location
Frederic Riss878065b2014-09-04 19:39:20 +0000133; PRESENT: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_public)
Eric Christopherce26df82013-01-16 19:53:47 +0000134; PRESENT: NULL
135; Definitions point back to their declarations, and have a location.
136; PRESENT: DW_TAG_variable
Frederic Rissd4de1802014-10-10 15:51:02 +0000137; PRESENT-NEXT: DW_AT_specification {{.*}} "b"
Eric Christopherce26df82013-01-16 19:53:47 +0000138; PRESENT-NEXT: DW_AT_location
Eric Christopheraf7eca22014-03-13 23:26:25 +0000139; PRESENT-NEXT: DW_AT_linkage_name {{.*}} "_ZN1C1bE"
Eric Christopherce26df82013-01-16 19:53:47 +0000140; PRESENT: DW_TAG_variable
Frederic Rissd4de1802014-10-10 15:51:02 +0000141; PRESENT-NEXT: DW_AT_specification {{.*}} "c"
Eric Christopherce26df82013-01-16 19:53:47 +0000142; PRESENT-NEXT: DW_AT_location
Eric Christopheraf7eca22014-03-13 23:26:25 +0000143; PRESENT-NEXT: DW_AT_linkage_name {{.*}} "_ZN1C1cE"
Eric Christopherce26df82013-01-16 19:53:47 +0000144
Manman Ren584e4c02013-02-27 23:21:02 +0000145; For Darwin gdb:
146; DARWINP: .debug_info contents:
David Blaikie49cfc8c2014-10-23 19:12:43 +0000147; DARWINP: DW_TAG_variable
148; DARWINP-NEXT: DW_AT_specification {{.*}} "a"
149; DARWINP-NEXT: DW_AT_location
150; DARWINP-NEXT: DW_AT_linkage_name {{.*}} "_ZN1C1aE"
Manman Ren584e4c02013-02-27 23:21:02 +0000151; DARWINP: DW_TAG_class_type
152; DARWINP-NEXT: DW_AT_name {{.*}} "C"
Frederic Rissd4de1802014-10-10 15:51:02 +0000153; DARWINP: DW_TAG_member
Manman Ren584e4c02013-02-27 23:21:02 +0000154; DARWINP-NEXT: DW_AT_name {{.*}} "a"
155; DARWINP: DW_AT_external
156; DARWINP: DW_AT_declaration
Frederic Riss878065b2014-09-04 19:39:20 +0000157; DARWINP: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_private)
Manman Ren584e4c02013-02-27 23:21:02 +0000158; DARWINP: DW_TAG_member
159; DARWINP-NEXT: DW_AT_name {{.*}} "const_a"
160; DARWINP: DW_AT_external
161; DARWINP: DW_AT_declaration
Frederic Riss878065b2014-09-04 19:39:20 +0000162; DARWINP: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_private)
Manman Ren584e4c02013-02-27 23:21:02 +0000163; DARWINP: DW_AT_const_value {{.*}} (1)
Frederic Rissd4de1802014-10-10 15:51:02 +0000164; DARWINP: DW_TAG_member
Manman Ren584e4c02013-02-27 23:21:02 +0000165; DARWINP-NEXT: DW_AT_name {{.*}} "b"
Frederic Riss878065b2014-09-04 19:39:20 +0000166; DARWINP: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_protected)
Manman Ren584e4c02013-02-27 23:21:02 +0000167; DARWINP: DW_TAG_member
168; DARWINP-NEXT: DW_AT_name {{.*}} "const_b"
Frederic Riss878065b2014-09-04 19:39:20 +0000169; DARWINP: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_protected)
David Blaikiec05c8f42014-05-11 15:47:39 +0000170; DARWINP: DW_AT_const_value [DW_FORM_udata] (1078523331)
Frederic Rissd4de1802014-10-10 15:51:02 +0000171; DARWINP: DW_TAG_member
Manman Ren584e4c02013-02-27 23:21:02 +0000172; DARWINP-NEXT: DW_AT_name {{.*}} "c"
Frederic Riss878065b2014-09-04 19:39:20 +0000173; DARWINP: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_public)
Manman Ren584e4c02013-02-27 23:21:02 +0000174; DARWINP: DW_TAG_member
175; DARWINP-NEXT: DW_AT_name {{.*}} "const_c"
Frederic Riss878065b2014-09-04 19:39:20 +0000176; DARWINP: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_public)
Eric Christopher9d1daa82013-08-27 23:49:04 +0000177; DARWINP: DW_AT_const_value {{.*}} (18)
Manman Ren584e4c02013-02-27 23:21:02 +0000178; While we're here, a normal member has data_member_location and
179; accessibility attributes.
180; DARWINP: DW_TAG_member
181; DARWINP-NEXT: DW_AT_name {{.*}} "d"
182; DARWINP: DW_AT_data_member_location
Frederic Riss878065b2014-09-04 19:39:20 +0000183; DARWINP: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_public)
Manman Ren584e4c02013-02-27 23:21:02 +0000184; DARWINP: NULL
185; Definitions point back to their declarations, and have a location.
186; DARWINP: DW_TAG_variable
Frederic Rissd4de1802014-10-10 15:51:02 +0000187; DARWINP-NEXT: DW_AT_specification {{.*}} "b"
Manman Ren584e4c02013-02-27 23:21:02 +0000188; DARWINP-NEXT: DW_AT_location
Eric Christopheraf7eca22014-03-13 23:26:25 +0000189; DARWINP-NEXT: DW_AT_linkage_name {{.*}} "_ZN1C1bE"
Manman Ren584e4c02013-02-27 23:21:02 +0000190; DARWINP: DW_TAG_variable
Frederic Rissd4de1802014-10-10 15:51:02 +0000191; DARWINP-NEXT: DW_AT_specification {{.*}} "c"
Manman Ren584e4c02013-02-27 23:21:02 +0000192; DARWINP-NEXT: DW_AT_location
Eric Christopheraf7eca22014-03-13 23:26:25 +0000193; DARWINP-NEXT: DW_AT_linkage_name {{.*}} "_ZN1C1cE"
Manman Ren584e4c02013-02-27 23:21:02 +0000194
Eric Christopherce26df82013-01-16 19:53:47 +0000195; ABSENT verifies that static member declarations do not have either
196; DW_AT_location or DW_AT_data_member_location; also, variables do not
Eric Christopheraf7eca22014-03-13 23:26:25 +0000197; have DW_AT_const_value and constants do not have DW_AT_linkage_name.
Eric Christopherce26df82013-01-16 19:53:47 +0000198;
199; ABSENT: .debug_info contents:
200; ABSENT: DW_TAG_member
201; ABSENT: DW_AT_name {{.*}} "a"
202; ABSENT-NOT: DW_AT_const_value
203; ABSENT-NOT: location
204; ABSENT: DW_AT_name {{.*}} "const_a"
Eric Christopheraf7eca22014-03-13 23:26:25 +0000205; ABSENT-NOT: DW_AT_linkage_name
Eric Christopherce26df82013-01-16 19:53:47 +0000206; ABSENT-NOT: location
207; ABSENT: DW_AT_name {{.*}} "b"
208; ABSENT-NOT: DW_AT_const_value
209; ABSENT-NOT: location
210; ABSENT: DW_AT_name {{.*}} "const_b"
Eric Christopheraf7eca22014-03-13 23:26:25 +0000211; ABSENT-NOT: DW_AT_linkage_name
Eric Christopherce26df82013-01-16 19:53:47 +0000212; ABSENT-NOT: location
213; ABSENT: DW_AT_name {{.*}} "c"
214; ABSENT-NOT: DW_AT_const_value
215; ABSENT-NOT: location
216; ABSENT: DW_AT_name {{.*}} "const_c"
Eric Christopheraf7eca22014-03-13 23:26:25 +0000217; ABSENT-NOT: DW_AT_linkage_name
Eric Christopherce26df82013-01-16 19:53:47 +0000218; ABSENT-NOT: location
219; While we're here, a normal member does not have a linkage name, constant
220; value, or DW_AT_location.
221; ABSENT: DW_AT_name {{.*}} "d"
Eric Christopheraf7eca22014-03-13 23:26:25 +0000222; ABSENT-NOT: DW_AT_linkage_name
Eric Christopherce26df82013-01-16 19:53:47 +0000223; ABSENT-NOT: DW_AT_const_value
224; ABSENT-NOT: DW_AT_location
225; ABSENT: NULL
Manman Ren584e4c02013-02-27 23:21:02 +0000226
227; For Darwin gdb:
228; DARWINA: .debug_info contents:
229; DARWINA: DW_TAG_member
230; DARWINA: DW_AT_name {{.*}} "a"
231; DARWINA-NOT: DW_AT_const_value
232; DARWINA-NOT: location
233; DARWINA: DW_AT_name {{.*}} "const_a"
Eric Christopheraf7eca22014-03-13 23:26:25 +0000234; DARWINA-NOT: DW_AT_linkage_name
Manman Ren584e4c02013-02-27 23:21:02 +0000235; DARWINA-NOT: location
236; DARWINA: DW_AT_name {{.*}} "b"
237; DARWINA-NOT: DW_AT_const_value
238; DARWINA-NOT: location
239; DARWINA: DW_AT_name {{.*}} "const_b"
Eric Christopheraf7eca22014-03-13 23:26:25 +0000240; DARWINA-NOT: DW_AT_linkage_name
Manman Ren584e4c02013-02-27 23:21:02 +0000241; DARWINA-NOT: location
242; DARWINA: DW_AT_name {{.*}} "c"
243; DARWINA-NOT: DW_AT_const_value
244; DARWINA-NOT: location
245; DARWINA: DW_AT_name {{.*}} "const_c"
Eric Christopheraf7eca22014-03-13 23:26:25 +0000246; DARWINA-NOT: DW_AT_linkage_name
Manman Ren584e4c02013-02-27 23:21:02 +0000247; DARWINA-NOT: location
248; While we're here, a normal member does not have a linkage name, constant
249; value, or DW_AT_location.
250; DARWINA: DW_AT_name {{.*}} "d"
Eric Christopheraf7eca22014-03-13 23:26:25 +0000251; DARWINA-NOT: DW_AT_linkage_name
Manman Ren584e4c02013-02-27 23:21:02 +0000252; DARWINA-NOT: DW_AT_const_value
253; DARWINA-NOT: DW_AT_location
254; DARWINA: NULL
Duncan P. N. Exon Smithe2741802015-03-03 17:24:31 +0000255!34 = !{i32 1, !"Debug Info Version", i32 3}