1; RUN: llc -mtriple=x86_64-apple-darwin %s -o %t -filetype=obj
2; RUN: llvm-dwarfdump -debug-info %t | FileCheck %s
3;
4; Test the DW_AT_accessibility DWARF attribute.
5;
6;
7; Regenerate me:
8; clang++ -g tools/clang/test/CodeGenCXX/debug-info-access.cpp -S -emit-llvm -o -
9;
10;   struct A {
11;     void pub_default();
12;     static int pub_default_static;
13;   };
14;
15;   class B : public A {
16;   public:
17;     void pub();
18;     static int public_static;
19;   protected:
20;     void prot();
21;   private:
22;     void priv_default();
23;   };
24;
25;   union U {
26;     void union_pub_default();
27;   private:
28;     int union_priv;
29;   };
30;
31;   void free() {}
32;
33;   A a;
34;   B b;
35;   U u;
36
37; CHECK: DW_TAG_member
38; CHECK:     DW_AT_name {{.*}}"pub_default_static")
39; CHECK-NOT: DW_AT_accessibility
40; CHECK-NOT: DW_TAG
41;
42; CHECK: DW_TAG_subprogram
43; CHECK:     DW_AT_name {{.*}}"pub_default")
44; CHECK-NOT: DW_AT_accessibility
45; CHECK: DW_TAG
46;
47; CHECK: DW_TAG_inheritance
48; CHECK-NOT: DW_TAG
49; CHECK:     DW_AT_accessibility {{.*}}(DW_ACCESS_public)
50;
51; CHECK: DW_TAG_member
52; CHECK:     DW_AT_name {{.*}}"public_static")
53; CHECK-NOT: DW_TAG
54; CHECK:     DW_AT_accessibility {{.*}}(DW_ACCESS_public)
55;
56; CHECK: DW_TAG_subprogram
57; CHECK:     DW_AT_name {{.*}}"pub")
58; CHECK-NOT: DW_TAG
59; CHECK:     DW_AT_accessibility {{.*}}(DW_ACCESS_public)
60;
61; CHECK: DW_TAG_subprogram
62; CHECK:     DW_AT_name {{.*}}"prot")
63; CHECK-NOT: DW_TAG
64; CHECK:     DW_AT_accessibility {{.*}}(DW_ACCESS_protected)
65;
66; CHECK: DW_TAG_subprogram
67; CHECK:     DW_AT_name {{.*}}"priv_default")
68; CHECK-NOT: DW_AT_accessibility
69; CHECK: DW_TAG
70;
71; CHECK: DW_TAG_member
72; CHECK:     DW_AT_name {{.*}}"union_priv")
73; CHECK-NOT: DW_TAG
74; CHECK:     DW_AT_accessibility {{.*}}(DW_ACCESS_private)
75;
76; CHECK: DW_TAG_subprogram
77; CHECK:     DW_AT_name {{.*}}"union_pub_default")
78; CHECK-NOT: DW_AT_accessibility
79; CHECK: DW_TAG
80;
81; CHECK: DW_TAG_subprogram
82; CHECK:     DW_AT_name {{.*}}"free")
83; CHECK-NOT: DW_AT_accessibility
84; CHECK-NOT: DW_TAG
85;
86; ModuleID = '/llvm/tools/clang/test/CodeGenCXX/debug-info-access.cpp'
87source_filename = "test/DebugInfo/X86/debug-info-access.ll"
88target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
89target triple = "x86_64-apple-macosx10.10.0"
90
91%struct.A = type { i8 }
92%class.B = type { i8 }
93%union.U = type { i32 }
94
95@a = global %struct.A zeroinitializer, align 1, !dbg !0
96@b = global %class.B zeroinitializer, align 1, !dbg !11
97@u = global %union.U zeroinitializer, align 4, !dbg !23
98
99; Function Attrs: nounwind ssp uwtable
100define void @_Z4freev() #0 !dbg !39 {
101  ret void, !dbg !42
102}
103
104attributes #0 = { nounwind ssp uwtable }
105
106!llvm.dbg.cu = !{!32}
107!llvm.module.flags = !{!36, !37}
108!llvm.ident = !{!38}
109
110!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
111!1 = !DIGlobalVariable(name: "a", scope: null, file: !2, line: 37, type: !3, isLocal: false, isDefinition: true)
112!2 = !DIFile(filename: "/llvm/tools/clang/test/CodeGenCXX/debug-info-access.cpp", directory: "")
113!3 = !DICompositeType(tag: DW_TAG_structure_type, name: "A", file: !2, line: 3, size: 8, align: 8, elements: !4, identifier: "_ZTS1A")
114!4 = !{!5, !7}
115!5 = !DIDerivedType(tag: DW_TAG_member, name: "pub_default_static", scope: !3, file: !2, line: 7, baseType: !6, flags: DIFlagStaticMember)
116!6 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
117!7 = !DISubprogram(name: "pub_default", linkageName: "_ZN1A11pub_defaultEv", scope: !3, file: !2, line: 5, type: !8, isLocal: false, isDefinition: false, scopeLine: 5, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false)
118!8 = !DISubroutineType(types: !9)
119!9 = !{null, !10}
120!10 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !3, size: 64, align: 64, flags: DIFlagArtificial | DIFlagObjectPointer)
121!11 = !DIGlobalVariableExpression(var: !12, expr: !DIExpression())
122!12 = !DIGlobalVariable(name: "b", scope: null, file: !2, line: 38, type: !13, isLocal: false, isDefinition: true)
123!13 = !DICompositeType(tag: DW_TAG_class_type, name: "B", file: !2, line: 11, size: 8, align: 8, elements: !14, identifier: "_ZTS1B")
124!14 = !{!15, !16, !17, !21, !22}
125!15 = !DIDerivedType(tag: DW_TAG_inheritance, scope: !13, baseType: !3, flags: DIFlagPublic)
126!16 = !DIDerivedType(tag: DW_TAG_member, name: "public_static", scope: !13, file: !2, line: 16, baseType: !6, flags: DIFlagPublic | DIFlagStaticMember)
127!17 = !DISubprogram(name: "pub", linkageName: "_ZN1B3pubEv", scope: !13, file: !2, line: 14, type: !18, isLocal: false, isDefinition: false, scopeLine: 14, virtualIndex: 6, flags: DIFlagPublic | DIFlagPrototyped, isOptimized: false)
128!18 = !DISubroutineType(types: !19)
129!19 = !{null, !20}
130!20 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !13, size: 64, align: 64, flags: DIFlagArtificial | DIFlagObjectPointer)
131!21 = !DISubprogram(name: "prot", linkageName: "_ZN1B4protEv", scope: !13, file: !2, line: 19, type: !18, isLocal: false, isDefinition: false, scopeLine: 19, virtualIndex: 6, flags: DIFlagProtected | DIFlagPrototyped, isOptimized: false)
132!22 = !DISubprogram(name: "priv_default", linkageName: "_ZN1B12priv_defaultEv", scope: !13, file: !2, line: 22, type: !18, isLocal: false, isDefinition: false, scopeLine: 22, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false)
133!23 = !DIGlobalVariableExpression(var: !24, expr: !DIExpression())
134!24 = !DIGlobalVariable(name: "u", scope: null, file: !2, line: 39, type: !25, isLocal: false, isDefinition: true)
135!25 = !DICompositeType(tag: DW_TAG_union_type, name: "U", file: !2, line: 25, size: 32, align: 32, elements: !26, identifier: "_ZTS1U")
136!26 = !{!27, !28}
137!27 = !DIDerivedType(tag: DW_TAG_member, name: "union_priv", scope: !25, file: !2, line: 30, baseType: !6, size: 32, align: 32, flags: DIFlagPrivate)
138!28 = !DISubprogram(name: "union_pub_default", linkageName: "_ZN1U17union_pub_defaultEv", scope: !25, file: !2, line: 27, type: !29, isLocal: false, isDefinition: false, scopeLine: 27, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false)
139!29 = !DISubroutineType(types: !30)
140!30 = !{null, !31}
141!31 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !25, size: 64, align: 64, flags: DIFlagArtificial | DIFlagObjectPointer)
142!32 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !2, producer: "clang version 3.6.0 ", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !33, retainedTypes: !34, globals: !35, imports: !33)
143!33 = !{}
144!34 = !{!3, !13, !25}
145!35 = !{!0, !11, !23}
146!36 = !{i32 2, !"Dwarf Version", i32 2}
147!37 = !{i32 2, !"Debug Info Version", i32 3}
148!38 = !{!"clang version 3.6.0 "}
149!39 = distinct !DISubprogram(name: "free", linkageName: "_Z4freev", scope: !2, file: !2, line: 35, type: !40, isLocal: false, isDefinition: true, scopeLine: 35, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !32, retainedNodes: !33)
150!40 = !DISubroutineType(types: !41)
151!41 = !{null}
152!42 = !DILocation(line: 35, column: 14, scope: !39)
153
154