1 ; RUN: llc %s -o %t -filetype=obj -O0 -mtriple=x86_64-unknown-linux-gnu -dwarf-version=4
2 ; RUN: llvm-dwarfdump -v -debug-info %t | FileCheck %s -check-prefix=PRESENT
3 ; RUN: llvm-dwarfdump -v -debug-info %t | FileCheck %s -check-prefix=ABSENT
4 ; RUN: llc %s -o %t -filetype=obj -O0 -mtriple=x86_64-apple-darwin -dwarf-version=4
5 ; RUN: llvm-dwarfdump -v -debug-info %t | FileCheck %s -check-prefix=DARWINP
6 ; RUN: llvm-dwarfdump -v -debug-info %t | FileCheck %s -check-prefix=DARWINA
7 ; 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.
12 ; LLVM IR generated using: clang -emit-llvm -S -g
13 ; (with the Clang part of this patch applied).
18 ; const static bool const_a = true;
21 ; const static float const_b = 3.14;
24 ; const static int const_c = 18;
39 source_filename = "test/DebugInfo/X86/debug-info-static-member.ll"
41 %class.C = type { i32 }
43 @_ZN1C1aE = global i32 4, align 4, !dbg !0
44 @_ZN1C1bE = global i32 2, align 4, !dbg !18
45 @_ZN1C1cE = global i32 1, align 4, !dbg !20
47 ; Function Attrs: nounwind uwtable
48 define i32 @main() #0 !dbg !26 {
50 %retval = alloca i32, align 4
51 %instance_C = alloca %class.C, align 4
52 store i32 0, ptr %retval
53 call void @llvm.dbg.declare(metadata ptr %instance_C, metadata !29, metadata !30), !dbg !31
54 store i32 8, ptr %instance_C, align 4, !dbg !32
55 %0 = load i32, ptr @_ZN1C1cE, align 4, !dbg !33
59 ; Function Attrs: nounwind readnone
60 declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
62 attributes #0 = { nounwind uwtable }
63 attributes #1 = { nounwind readnone }
66 !llvm.module.flags = !{!25}
68 !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
69 !1 = !DIGlobalVariable(name: "a", linkageName: "_ZN1C1aE", scope: null, file: !2, line: 14, type: !3, isLocal: false, isDefinition: true, declaration: !4)
70 !2 = !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")
71 !3 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
72 !4 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !5, file: !2, line: 3, baseType: !3, flags: DIFlagPrivate | DIFlagStaticMember)
73 !5 = !DICompositeType(tag: DW_TAG_class_type, name: "C", file: !2, line: 1, size: 32, align: 32, elements: !6)
74 !6 = !{!4, !7, !10, !11, !14, !15, !17}
75 !7 = !DIDerivedType(tag: DW_TAG_member, name: "const_a", scope: !5, file: !2, line: 4, baseType: !8, flags: DIFlagPrivate | DIFlagStaticMember, extraData: i1 true)
76 !8 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !9)
77 !9 = !DIBasicType(name: "bool", size: 8, align: 8, encoding: DW_ATE_boolean)
78 !10 = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: !5, file: !2, line: 6, baseType: !3, flags: DIFlagProtected | DIFlagStaticMember)
79 !11 = !DIDerivedType(tag: DW_TAG_member, name: "const_b", scope: !5, file: !2, line: 7, baseType: !12, flags: DIFlagProtected | DIFlagStaticMember, extraData: float 0x40091EB860000000)
80 !12 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !13)
81 !13 = !DIBasicType(name: "float", size: 32, align: 32, encoding: DW_ATE_float)
82 !14 = !DIDerivedType(tag: DW_TAG_member, name: "c", scope: !5, file: !2, line: 9, baseType: !3, flags: DIFlagPublic | DIFlagStaticMember)
83 !15 = !DIDerivedType(tag: DW_TAG_member, name: "const_c", scope: !5, file: !2, line: 10, baseType: !16, flags: DIFlagPublic | DIFlagStaticMember, extraData: i32 18)
84 !16 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !3)
85 !17 = !DIDerivedType(tag: DW_TAG_member, name: "d", scope: !5, file: !2, line: 11, baseType: !3, size: 32, align: 32, flags: DIFlagPublic)
86 !18 = !DIGlobalVariableExpression(var: !19, expr: !DIExpression())
87 !19 = !DIGlobalVariable(name: "b", linkageName: "_ZN1C1bE", scope: null, file: !2, line: 15, type: !3, isLocal: false, isDefinition: true, declaration: !10)
88 !20 = !DIGlobalVariableExpression(var: !21, expr: !DIExpression())
89 !21 = !DIGlobalVariable(name: "c", linkageName: "_ZN1C1cE", scope: null, file: !2, line: 16, type: !3, isLocal: false, isDefinition: true, declaration: !14)
90 !22 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !2, producer: "clang version 3.3 (trunk 171914)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !23, retainedTypes: !23, globals: !24, imports: !23)
93 !25 = !{i32 1, !"Debug Info Version", i32 3}
94 !26 = distinct !DISubprogram(name: "main", scope: !2, file: !2, line: 18, type: !27, isLocal: false, isDefinition: true, scopeLine: 23, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !22, retainedNodes: !23)
95 !27 = !DISubroutineType(types: !28)
97 !29 = !DILocalVariable(name: "instance_C", scope: !26, file: !2, line: 20, type: !5)
99 !31 = !DILocation(line: 20, scope: !26)
100 !32 = !DILocation(line: 21, scope: !26)
101 !33 = !DILocation(line: 22, scope: !26)
103 ; PRESENT verifies that static member declarations have these attributes:
104 ; external, declaration, accessibility, and either DW_AT_linkage_name
105 ; (for variables) or DW_AT_const_value (for constants).
107 ; PRESENT: .debug_info contents:
108 ; PRESENT: DW_TAG_variable
109 ; PRESENT-NEXT: DW_AT_specification {{.*}} "a"
110 ; PRESENT-NEXT: DW_AT_location
111 ; PRESENT-NEXT: DW_AT_linkage_name {{.*}} "_ZN1C1aE"
112 ; PRESENT: DW_TAG_class_type
113 ; PRESENT-NEXT: DW_AT_name {{.*}} "C"
114 ; PRESENT: DW_TAG_member
115 ; PRESENT-NEXT: DW_AT_name {{.*}} "a"
116 ; PRESENT: DW_AT_external
117 ; PRESENT: DW_AT_declaration
118 ; PRESENT: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_private)
119 ; PRESENT: DW_TAG_member
120 ; PRESENT-NEXT: DW_AT_name {{.*}} "const_a"
121 ; PRESENT: DW_AT_external
122 ; PRESENT: DW_AT_declaration
123 ; PRESENT: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_private)
124 ; PRESENT: DW_AT_const_value {{.*}} (1)
125 ; PRESENT: DW_TAG_member
126 ; PRESENT-NEXT: DW_AT_name {{.*}} "b"
127 ; PRESENT: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_protected)
128 ; PRESENT: DW_TAG_member
129 ; PRESENT-NEXT: DW_AT_name {{.*}} "const_b"
130 ; PRESENT: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_protected)
131 ; PRESENT: DW_AT_const_value [DW_FORM_udata] (1078523331)
132 ; PRESENT: DW_TAG_member
133 ; PRESENT-NEXT: DW_AT_name {{.*}} "c"
134 ; PRESENT: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_public)
135 ; PRESENT: DW_TAG_member
136 ; PRESENT-NEXT: DW_AT_name {{.*}} "const_c"
137 ; PRESENT: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_public)
138 ; PRESENT: DW_AT_const_value {{.*}} (18)
139 ; While we're here, a normal member has data_member_location and
140 ; accessibility attributes.
141 ; PRESENT: DW_TAG_member
142 ; PRESENT-NEXT: DW_AT_name {{.*}} "d"
143 ; PRESENT: DW_AT_data_member_location
144 ; PRESENT: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_public)
146 ; Definitions point back to their declarations, and have a location.
147 ; PRESENT: DW_TAG_variable
148 ; PRESENT-NEXT: DW_AT_specification {{.*}} "b"
149 ; PRESENT-NEXT: DW_AT_location
150 ; PRESENT-NEXT: DW_AT_linkage_name {{.*}} "_ZN1C1bE"
151 ; PRESENT: DW_TAG_variable
152 ; PRESENT-NEXT: DW_AT_specification {{.*}} "c"
153 ; PRESENT-NEXT: DW_AT_location
154 ; PRESENT-NEXT: DW_AT_linkage_name {{.*}} "_ZN1C1cE"
157 ; DARWINP: .debug_info contents:
158 ; DARWINP: DW_TAG_variable
159 ; DARWINP-NEXT: DW_AT_specification {{.*}} "a"
160 ; DARWINP-NEXT: DW_AT_location
161 ; DARWINP-NEXT: DW_AT_linkage_name {{.*}} "_ZN1C1aE"
162 ; DARWINP: DW_TAG_class_type
163 ; DARWINP-NEXT: DW_AT_name {{.*}} "C"
164 ; DARWINP: DW_TAG_member
165 ; DARWINP-NEXT: DW_AT_name {{.*}} "a"
166 ; DARWINP: DW_AT_external
167 ; DARWINP: DW_AT_declaration
168 ; DARWINP: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_private)
169 ; DARWINP: DW_TAG_member
170 ; DARWINP-NEXT: DW_AT_name {{.*}} "const_a"
171 ; DARWINP: DW_AT_external
172 ; DARWINP: DW_AT_declaration
173 ; DARWINP: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_private)
174 ; DARWINP: DW_AT_const_value {{.*}} (1)
175 ; DARWINP: DW_TAG_member
176 ; DARWINP-NEXT: DW_AT_name {{.*}} "b"
177 ; DARWINP: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_protected)
178 ; DARWINP: DW_TAG_member
179 ; DARWINP-NEXT: DW_AT_name {{.*}} "const_b"
180 ; DARWINP: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_protected)
181 ; DARWINP: DW_AT_const_value [DW_FORM_udata] (1078523331)
182 ; DARWINP: DW_TAG_member
183 ; DARWINP-NEXT: DW_AT_name {{.*}} "c"
184 ; DARWINP: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_public)
185 ; DARWINP: DW_TAG_member
186 ; DARWINP-NEXT: DW_AT_name {{.*}} "const_c"
187 ; DARWINP: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_public)
188 ; DARWINP: DW_AT_const_value {{.*}} (18)
189 ; While we're here, a normal member has data_member_location and
190 ; accessibility attributes.
191 ; DARWINP: DW_TAG_member
192 ; DARWINP-NEXT: DW_AT_name {{.*}} "d"
193 ; DARWINP: DW_AT_data_member_location
194 ; DARWINP: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_public)
196 ; Definitions point back to their declarations, and have a location.
197 ; DARWINP: DW_TAG_variable
198 ; DARWINP-NEXT: DW_AT_specification {{.*}} "b"
199 ; DARWINP-NEXT: DW_AT_location
200 ; DARWINP-NEXT: DW_AT_linkage_name {{.*}} "_ZN1C1bE"
201 ; DARWINP: DW_TAG_variable
202 ; DARWINP-NEXT: DW_AT_specification {{.*}} "c"
203 ; DARWINP-NEXT: DW_AT_location
204 ; DARWINP-NEXT: DW_AT_linkage_name {{.*}} "_ZN1C1cE"
206 ; ABSENT verifies that static member declarations do not have either
207 ; DW_AT_location or DW_AT_data_member_location; also, variables do not
208 ; have DW_AT_const_value and constants do not have DW_AT_linkage_name.
210 ; ABSENT: .debug_info contents:
211 ; ABSENT: DW_TAG_member
212 ; ABSENT: DW_AT_name {{.*}} "a"
213 ; ABSENT-NOT: DW_AT_const_value
214 ; ABSENT-NOT: location
215 ; ABSENT: DW_AT_name {{.*}} "const_a"
216 ; ABSENT-NOT: DW_AT_linkage_name
217 ; ABSENT-NOT: location
218 ; ABSENT: DW_AT_name {{.*}} "b"
219 ; ABSENT-NOT: DW_AT_const_value
220 ; ABSENT-NOT: location
221 ; ABSENT: DW_AT_name {{.*}} "const_b"
222 ; ABSENT-NOT: DW_AT_linkage_name
223 ; ABSENT-NOT: location
224 ; ABSENT: DW_AT_name {{.*}} "c"
225 ; ABSENT-NOT: DW_AT_const_value
226 ; ABSENT-NOT: location
227 ; ABSENT: DW_AT_name {{.*}} "const_c"
228 ; ABSENT-NOT: DW_AT_linkage_name
229 ; ABSENT-NOT: location
230 ; While we're here, a normal member does not have a linkage name, constant
231 ; value, or DW_AT_location.
232 ; ABSENT: DW_AT_name {{.*}} "d"
233 ; ABSENT-NOT: DW_AT_linkage_name
234 ; ABSENT-NOT: DW_AT_const_value
235 ; ABSENT-NOT: DW_AT_location
239 ; DARWINA: .debug_info contents:
240 ; DARWINA: DW_TAG_member
241 ; DARWINA: DW_AT_name {{.*}} "a"
242 ; DARWINA-NOT: DW_AT_const_value
243 ; DARWINA-NOT: location
244 ; DARWINA: DW_AT_name {{.*}} "const_a"
245 ; DARWINA-NOT: DW_AT_linkage_name
246 ; DARWINA-NOT: location
247 ; DARWINA: DW_AT_name {{.*}} "b"
248 ; DARWINA-NOT: DW_AT_const_value
249 ; DARWINA-NOT: location
250 ; DARWINA: DW_AT_name {{.*}} "const_b"
251 ; DARWINA-NOT: DW_AT_linkage_name
252 ; DARWINA-NOT: location
253 ; DARWINA: DW_AT_name {{.*}} "c"
254 ; DARWINA-NOT: DW_AT_const_value
255 ; DARWINA-NOT: location
256 ; DARWINA: DW_AT_name {{.*}} "const_c"
257 ; DARWINA-NOT: DW_AT_linkage_name
258 ; DARWINA-NOT: location
259 ; While we're here, a normal member does not have a linkage name, constant
260 ; value, or DW_AT_location.
261 ; DARWINA: DW_AT_name {{.*}} "d"
262 ; DARWINA-NOT: DW_AT_linkage_name
263 ; DARWINA-NOT: DW_AT_const_value
264 ; DARWINA-NOT: DW_AT_location