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; Regenerate me: 7; clang++ -g tools/clang/test/CodeGenCXX/debug-info-access.cpp -S -emit-llvm -o - 8; 9; struct A { 10; void pub_default(); 11; static int pub_default_static; 12; }; 13; 14; class B : public A { 15; public: 16; void pub(); 17; static int public_static; 18; protected: 19; void prot(); 20; private: 21; void priv_default(); 22; }; 23; 24; class C { 25; public: 26; struct D { 27; }; 28; protected: 29; union E { 30; }; 31; public: 32; D d; 33; E e; 34; }; 35; 36; struct F { 37; private: 38; union G { 39; }; 40; public: 41; G g; 42; }; 43; 44; union H { 45; private: 46; class I { 47; }; 48; public: 49; I i; 50; }; 51; 52; union U { 53; void union_pub_default(); 54; private: 55; int union_priv; 56; }; 57; 58; void free() {} 59; 60; A a; 61; B b; 62; U u; 63; C c; 64; F f; 65; H h; 66 67; CHECK: DW_TAG_member 68; CHECK: DW_AT_name {{.*}}"union_priv") 69; CHECK-NOT: DW_TAG 70; CHECK: DW_AT_accessibility {{.*}}(DW_ACCESS_private) 71 72; CHECK: DW_TAG_subprogram 73; CHECK: DW_AT_name {{.*}}"union_pub_default") 74; CHECK-NOT: DW_AT_accessibility 75 76; CHECK: DW_TAG_member 77; CHECK: DW_AT_name {{.*}}"pub_default_static") 78; CHECK-NOT: DW_AT_accessibility 79; CHECK-NOT: DW_TAG 80 81; CHECK: DW_TAG_subprogram 82; CHECK: DW_AT_name {{.*}}"pub_default") 83; CHECK-NOT: DW_AT_accessibility 84; CHECK: DW_TAG 85 86; CHECK: DW_TAG_inheritance 87; CHECK-NOT: DW_TAG 88; CHECK: DW_AT_accessibility {{.*}}(DW_ACCESS_public) 89 90; CHECK: DW_TAG_member 91; CHECK: DW_AT_name {{.*}}"public_static") 92; CHECK-NOT: DW_TAG 93; CHECK: DW_AT_accessibility {{.*}}(DW_ACCESS_public) 94 95; CHECK: DW_TAG_subprogram 96; CHECK: DW_AT_name {{.*}}"pub") 97; CHECK-NOT: DW_TAG 98; CHECK: DW_AT_accessibility {{.*}}(DW_ACCESS_public) 99 100; CHECK: DW_TAG_subprogram 101; CHECK: DW_AT_name {{.*}}"prot") 102; CHECK-NOT: DW_TAG 103; CHECK: DW_AT_accessibility {{.*}}(DW_ACCESS_protected) 104 105; CHECK: DW_TAG_subprogram 106; CHECK: DW_AT_name {{.*}}"priv_default") 107; CHECK-NOT: DW_AT_accessibility 108; CHECK: DW_TAG 109 110; CHECK: DW_TAG_structure_type 111; CHECK: DW_AT_name ("D") 112; CHECK: DW_AT_accessibility (DW_ACCESS_public) 113 114; CHECK: DW_TAG_union_type 115; CHECK: DW_AT_name ("E") 116; CHECK: DW_AT_byte_size (0x01) 117; CHECK: DW_AT_accessibility (DW_ACCESS_protected) 118 119; CHECK: DW_TAG_union_type 120; CHECK: DW_AT_name ("G") 121; CHECK: DW_AT_accessibility (DW_ACCESS_private) 122 123; CHECK: DW_TAG_class_type 124; CHECK: DW_AT_name ("I") 125; CHECK: DW_AT_accessibility (DW_ACCESS_private) 126 127; CHECK: DW_TAG_subprogram 128; CHECK: DW_AT_name {{.*}}"free") 129; CHECK-NOT: DW_AT_accessibility 130 131%union.U = type { i32 } 132%struct.A = type { i8 } 133%class.B = type { i8 } 134%class.C = type { %"struct.C::D", %"union.C::E" } 135%"struct.C::D" = type { i8 } 136%"union.C::E" = type { i8 } 137%struct.F = type { %"union.F::G" } 138%"union.F::G" = type { i8 } 139%union.H = type { %"class.H::I" } 140%"class.H::I" = type { i8 } 141 142@u = global %union.U zeroinitializer, align 4, !dbg !0 143@a = global %struct.A zeroinitializer, align 1, !dbg !5 144@b = global %class.B zeroinitializer, align 1, !dbg !16 145@c = global %class.C zeroinitializer, align 1, !dbg !28 146@f = global %struct.F zeroinitializer, align 1, !dbg !37 147@h = global %union.H zeroinitializer, align 1, !dbg !43 148 149; Function Attrs: mustprogress noinline nounwind optnone 150define dso_local void @_Z4freev() #0 !dbg !59 { 151entry: 152 ret void, !dbg !62 153} 154 155attributes #0 = { mustprogress noinline nounwind optnone "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+cx8,+mmx,+sse,+sse2,+x87" } 156 157!llvm.dbg.cu = !{!2} 158!llvm.module.flags = !{!56, !57} 159!llvm.ident = !{!58} 160 161!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) 162!1 = distinct !DIGlobalVariable(name: "u", scope: !2, file: !7, line: 73, type: !49, isLocal: false, isDefinition: true) 163!2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !3, producer: "clang version 14.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !4, splitDebugInlining: false, nameTableKind: None) 164!3 = !DIFile(filename: "clang/test/CodeGenCXX/<stdin>", directory: "") 165!4 = !{!0, !5, !16, !28, !37, !43} 166!5 = !DIGlobalVariableExpression(var: !6, expr: !DIExpression()) 167!6 = distinct !DIGlobalVariable(name: "a", scope: !2, file: !7, line: 74, type: !8, isLocal: false, isDefinition: true) 168!7 = !DIFile(filename: "clang/test/CodeGenCXX/debug-info-access.cpp", directory: "") 169!8 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "A", file: !7, line: 3, size: 8, flags: DIFlagTypePassByValue, elements: !9, identifier: "_ZTS1A") 170!9 = !{!10, !12} 171!10 = !DIDerivedType(tag: DW_TAG_member, name: "pub_default_static", scope: !8, file: !7, line: 9, baseType: !11, flags: DIFlagStaticMember) 172!11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) 173!12 = !DISubprogram(name: "pub_default", linkageName: "_ZN1A11pub_defaultEv", scope: !8, file: !7, line: 7, type: !13, scopeLine: 7, flags: DIFlagPrototyped, spFlags: 0) 174!13 = !DISubroutineType(types: !14) 175!14 = !{null, !15} 176!15 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !8, size: 64, flags: DIFlagArtificial | DIFlagObjectPointer) 177!16 = !DIGlobalVariableExpression(var: !17, expr: !DIExpression()) 178!17 = distinct !DIGlobalVariable(name: "b", scope: !2, file: !7, line: 75, type: !18, isLocal: false, isDefinition: true) 179!18 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "B", file: !7, line: 14, size: 8, flags: DIFlagTypePassByValue, elements: !19, identifier: "_ZTS1B") 180!19 = !{!20, !21, !22, !26, !27} 181!20 = !DIDerivedType(tag: DW_TAG_inheritance, scope: !18, baseType: !8, flags: DIFlagPublic, extraData: i32 0) 182!21 = !DIDerivedType(tag: DW_TAG_member, name: "public_static", scope: !18, file: !7, line: 19, baseType: !11, flags: DIFlagPublic | DIFlagStaticMember) 183!22 = !DISubprogram(name: "pub", linkageName: "_ZN1B3pubEv", scope: !18, file: !7, line: 17, type: !23, scopeLine: 17, flags: DIFlagPublic | DIFlagPrototyped, spFlags: 0) 184!23 = !DISubroutineType(types: !24) 185!24 = !{null, !25} 186!25 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !18, size: 64, flags: DIFlagArtificial | DIFlagObjectPointer) 187!26 = !DISubprogram(name: "prot", linkageName: "_ZN1B4protEv", scope: !18, file: !7, line: 22, type: !23, scopeLine: 22, flags: DIFlagProtected | DIFlagPrototyped, spFlags: 0) 188!27 = !DISubprogram(name: "priv_default", linkageName: "_ZN1B12priv_defaultEv", scope: !18, file: !7, line: 25, type: !23, scopeLine: 25, flags: DIFlagPrototyped, spFlags: 0) 189!28 = !DIGlobalVariableExpression(var: !29, expr: !DIExpression()) 190!29 = distinct !DIGlobalVariable(name: "c", scope: !2, file: !7, line: 76, type: !30, isLocal: false, isDefinition: true) 191!30 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "C", file: !7, line: 28, size: 16, flags: DIFlagTypePassByValue, elements: !31, identifier: "_ZTS1C") 192!31 = !{!32, !35} 193!32 = !DIDerivedType(tag: DW_TAG_member, name: "d", scope: !30, file: !7, line: 38, baseType: !33, size: 8, flags: DIFlagPublic) 194!33 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "D", scope: !30, file: !7, line: 31, size: 8, flags: DIFlagPublic | DIFlagTypePassByValue, elements: !34, identifier: "_ZTSN1C1DE") 195!34 = !{} 196!35 = !DIDerivedType(tag: DW_TAG_member, name: "e", scope: !30, file: !7, line: 39, baseType: !36, size: 8, offset: 8, flags: DIFlagPublic) 197!36 = distinct !DICompositeType(tag: DW_TAG_union_type, name: "E", scope: !30, file: !7, line: 35, size: 8, flags: DIFlagProtected | DIFlagTypePassByValue, elements: !34, identifier: "_ZTSN1C1EE") 198!37 = !DIGlobalVariableExpression(var: !38, expr: !DIExpression()) 199!38 = distinct !DIGlobalVariable(name: "f", scope: !2, file: !7, line: 77, type: !39, isLocal: false, isDefinition: true) 200!39 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "F", file: !7, line: 42, size: 8, flags: DIFlagTypePassByValue, elements: !40, identifier: "_ZTS1F") 201!40 = !{!41} 202!41 = !DIDerivedType(tag: DW_TAG_member, name: "g", scope: !39, file: !7, line: 48, baseType: !42, size: 8) 203!42 = distinct !DICompositeType(tag: DW_TAG_union_type, name: "G", scope: !39, file: !7, line: 45, size: 8, flags: DIFlagPrivate | DIFlagTypePassByValue, elements: !34, identifier: "_ZTSN1F1GE") 204!43 = !DIGlobalVariableExpression(var: !44, expr: !DIExpression()) 205!44 = distinct !DIGlobalVariable(name: "h", scope: !2, file: !7, line: 78, type: !45, isLocal: false, isDefinition: true) 206!45 = distinct !DICompositeType(tag: DW_TAG_union_type, name: "H", file: !7, line: 51, size: 8, flags: DIFlagTypePassByValue, elements: !46, identifier: "_ZTS1H") 207!46 = !{!47} 208!47 = !DIDerivedType(tag: DW_TAG_member, name: "i", scope: !45, file: !7, line: 57, baseType: !48, size: 8) 209!48 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "I", scope: !45, file: !7, line: 54, size: 8, flags: DIFlagPrivate | DIFlagTypePassByValue, elements: !34, identifier: "_ZTSN1H1IE") 210!49 = distinct !DICompositeType(tag: DW_TAG_union_type, name: "U", file: !7, line: 60, size: 32, flags: DIFlagTypePassByValue, elements: !50, identifier: "_ZTS1U") 211!50 = !{!51, !52} 212!51 = !DIDerivedType(tag: DW_TAG_member, name: "union_priv", scope: !49, file: !7, line: 65, baseType: !11, size: 32, flags: DIFlagPrivate) 213!52 = !DISubprogram(name: "union_pub_default", linkageName: "_ZN1U17union_pub_defaultEv", scope: !49, file: !7, line: 62, type: !53, scopeLine: 62, flags: DIFlagPrototyped, spFlags: 0) 214!53 = !DISubroutineType(types: !54) 215!54 = !{null, !55} 216!55 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !49, size: 64, flags: DIFlagArtificial | DIFlagObjectPointer) 217!56 = !{i32 2, !"Debug Info Version", i32 3} 218!57 = !{i32 1, !"wchar_size", i32 4} 219!58 = !{!"clang version 14.0.0"} 220!59 = distinct !DISubprogram(name: "free", linkageName: "_Z4freev", scope: !7, file: !7, line: 71, type: !60, scopeLine: 71, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !34) 221!60 = !DISubroutineType(types: !61) 222!61 = !{null} 223!62 = !DILocation(line: 71, column: 14, scope: !59) 224