1; RUN: llc -mtriple=x86_64-apple-darwin %s -o %t -filetype=obj
2; RUN: llvm-dwarfdump -v -debug-info %t | FileCheck %s
3
4; Check that the friend tag is there and is followed by a DW_AT_friend that has a reference back.
5
6; CHECK: [[BACK:0x[0-9a-f]*]]:   DW_TAG_class_type
7; CHECK-NEXT: DW_AT_name [DW_FORM_strp]       ( .debug_str[{{.*}}] = "A")
8; CHECK: DW_TAG_friend
9; CHECK-NEXT: DW_AT_friend [DW_FORM_ref4]   (cu + 0x{{[0-9a-f]*}} => {[[BACK]]})
10
11source_filename = "test/DebugInfo/X86/DW_TAG_friend.ll"
12
13%class.A = type { i32 }
14%class.B = type { i32 }
15
16@a = global %class.A zeroinitializer, align 4, !dbg !0
17@b = global %class.B zeroinitializer, align 4, !dbg !11
18
19!llvm.dbg.cu = !{!21}
20!llvm.module.flags = !{!24}
21
22!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
23!1 = !DIGlobalVariable(name: "a", scope: null, file: !2, line: 10, type: !3, isLocal: false, isDefinition: true)
24!2 = !DIFile(filename: "foo.cpp", directory: "/Users/echristo/tmp")
25!3 = !DICompositeType(tag: DW_TAG_class_type, name: "A", file: !2, line: 1, size: 32, align: 32, elements: !4)
26!4 = !{!5, !7}
27!5 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !3, file: !2, line: 2, baseType: !6, size: 32, align: 32, flags: DIFlagPrivate)
28!6 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
29!7 = !DISubprogram(name: "A", scope: !3, file: !2, line: 1, type: !8, isLocal: false, isDefinition: false, scopeLine: 1, virtualIndex: 6, flags: DIFlagArtificial | DIFlagPrototyped, isOptimized: false)
30!8 = !DISubroutineType(types: !9)
31!9 = !{null, !10}
32!10 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !3, size: 64, align: 64, flags: DIFlagArtificial)
33!11 = !DIGlobalVariableExpression(var: !12, expr: !DIExpression())
34!12 = !DIGlobalVariable(name: "b", scope: null, file: !2, line: 11, type: !13, isLocal: false, isDefinition: true)
35!13 = !DICompositeType(tag: DW_TAG_class_type, name: "B", file: !2, line: 5, size: 32, align: 32, elements: !14)
36!14 = !{!15, !16, !20}
37!15 = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: !13, file: !2, line: 7, baseType: !6, size: 32, align: 32, flags: DIFlagPrivate)
38!16 = !DISubprogram(name: "B", scope: !13, file: !2, line: 5, type: !17, isLocal: false, isDefinition: false, scopeLine: 5, virtualIndex: 6, flags: DIFlagArtificial | DIFlagPrototyped, isOptimized: false)
39!17 = !DISubroutineType(types: !18)
40!18 = !{null, !19}
41!19 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !13, size: 64, align: 64, flags: DIFlagArtificial)
42!20 = !DIDerivedType(tag: DW_TAG_friend, file: !2, baseType: !3)
43!21 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !2, producer: "clang version 3.1 (trunk 153413) (llvm/trunk 153428)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !22, retainedTypes: !22, globals: !23, imports: !22)
44!22 = !{}
45!23 = !{!0, !11}
46!24 = !{i32 1, !"Debug Info Version", i32 3}
47
48