J-Camilleri created this revision.
J-Camilleri added a reviewer: dexonsmith.
Herald added subscribers: jeroen.dobbelaere, hiraditya.
Herald added a project: All.
J-Camilleri requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.
The accessibility level of a typedef or using declaration in a
struct or class was being lost when producing debug information.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D134339
Files:
clang/lib/CodeGen/CGDebugInfo.cpp
clang/test/CodeGenCXX/debug-info-access.cpp
llvm/include/llvm/IR/DIBuilder.h
llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
llvm/lib/IR/DIBuilder.cpp
llvm/test/DebugInfo/X86/debug-info-access.ll
Index: llvm/test/DebugInfo/X86/debug-info-access.ll
===================================================================
--- llvm/test/DebugInfo/X86/debug-info-access.ll
+++ llvm/test/DebugInfo/X86/debug-info-access.ll
@@ -9,14 +9,30 @@
; struct A {
; void pub_default();
; static int pub_default_static;
+;
+; using pub_default_using = int;
+; pub_default_using a_pub;
; };
;
; class B : public A {
; public:
; void pub();
; static int public_static;
+;
+; typedef int pub_typedef;
+; pub_typedef pub_member;
+;
+; protected:
+; using prot_using = int;
+; prot_using prot_member;
+;
+; private:
+; using priv_using = int;
+; priv_using priv_member;
+;
; protected:
; void prot();
+;
; private:
; void priv_default();
; };
@@ -28,9 +44,13 @@
; protected:
; union E {
; };
+; private:
+; struct J {
+; };
; public:
; D d;
; E e;
+; J j;
; };
;
; struct F {
@@ -57,9 +77,9 @@
;
; void free() {}
;
+; U u;
; A a;
; B b;
-; U u;
; C c;
; F f;
; H h;
@@ -76,7 +96,13 @@
; CHECK: DW_TAG_member
; CHECK: DW_AT_name {{.*}}"pub_default_static")
; CHECK-NOT: DW_AT_accessibility
-; CHECK-NOT: DW_TAG
+
+; CHECK: DW_TAG_member
+; CHECK: DW_AT_name {{.*}}"a_pub")
+
+; CHECK: DW_TAG_typedef
+; CHECK: DW_AT_name {{.*}}"pub_default_using")
+; CHECK-NOT: DW_AT_accessibility
; CHECK: DW_TAG_subprogram
; CHECK: DW_AT_name {{.*}}"pub_default")
@@ -92,6 +118,30 @@
; CHECK-NOT: DW_TAG
; CHECK: DW_AT_accessibility {{.*}}(DW_ACCESS_public)
+; CHECK: DW_TAG_member
+; CHECK: DW_AT_name {{.*}}"pub_member")
+
+; CHECK: DW_TAG_typedef
+; CHECK: DW_AT_name {{.*}}"pub_typedef")
+; CHECK-NOT: DW_TAG
+; CHECK: DW_AT_accessibility {{.*}}(DW_ACCESS_public)
+
+; CHECK: DW_TAG_member
+; CHECK: DW_AT_name {{.*}}"prot_member")
+
+; CHECK: DW_TAG_typedef
+; CHECK: DW_AT_name {{.*}}"prot_using")
+; CHECK-NOT: DW_TAG
+; CHECK: DW_AT_accessibility {{.*}}(DW_ACCESS_protected)
+
+; CHECK: DW_TAG_member
+; CHECK: DW_AT_name {{.*}}"priv_member")
+
+; CHECK: DW_TAG_typedef
+; CHECK: DW_AT_name {{.*}}"priv_using")
+; CHECK-NOT: DW_TAG
+; CHECK-NOT: DW_AT_accessibility
+
; CHECK: DW_TAG_subprogram
; CHECK: DW_AT_name {{.*}}"pub")
; CHECK-NOT: DW_TAG
@@ -129,95 +179,111 @@
; CHECK-NOT: DW_AT_accessibility
%union.U = type { i32 }
-%struct.A = type { i8 }
-%class.B = type { i8 }
-%class.C = type { %"struct.C::D", %"union.C::E" }
+%struct.A = type { i32 }
+%class.B = type { %struct.A, i32, i32, i32 }
+%class.C = type { %"struct.C::D", %"union.C::E", %"struct.C::J" }
%"struct.C::D" = type { i8 }
%"union.C::E" = type { i8 }
+%"struct.C::J" = type { i8 }
%struct.F = type { %"union.F::G" }
%"union.F::G" = type { i8 }
%union.H = type { %"class.H::I" }
%"class.H::I" = type { i8 }
-@u = global %union.U zeroinitializer, align 4, !dbg !0
-@a = global %struct.A zeroinitializer, align 1, !dbg !5
-@b = global %class.B zeroinitializer, align 1, !dbg !16
-@c = global %class.C zeroinitializer, align 1, !dbg !28
-@f = global %struct.F zeroinitializer, align 1, !dbg !37
-@h = global %union.H zeroinitializer, align 1, !dbg !43
+@u = dso_local global %union.U zeroinitializer, align 4, !dbg !0
+@a = dso_local global %struct.A zeroinitializer, align 4, !dbg !5
+@b = dso_local global %class.B zeroinitializer, align 4, !dbg !18
+@c = dso_local global %class.C zeroinitializer, align 1, !dbg !36
+@f = dso_local global %struct.F zeroinitializer, align 1, !dbg !47
+@h = dso_local global %union.H zeroinitializer, align 1, !dbg !53
-; Function Attrs: mustprogress noinline nounwind optnone
-define dso_local void @_Z4freev() #0 !dbg !59 {
+; Function Attrs: mustprogress noinline nounwind optnone uwtable
+define dso_local void @_Z4freev() #0 !dbg !74 {
entry:
- ret void, !dbg !62
+ ret void, !dbg !77
}
-attributes #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" }
+attributes #0 = { mustprogress noinline nounwind optnone uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
!llvm.dbg.cu = !{!2}
-!llvm.module.flags = !{!56, !57}
-!llvm.ident = !{!58}
+!llvm.module.flags = !{!66, !67, !68, !69, !70, !71, !72}
+!llvm.ident = !{!73}
!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
-!1 = distinct !DIGlobalVariable(name: "u", scope: !2, file: !7, line: 73, type: !49, isLocal: false, isDefinition: true)
-!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)
-!3 = !DIFile(filename: "clang/test/CodeGenCXX/<stdin>", directory: "")
-!4 = !{!0, !5, !16, !28, !37, !43}
+!1 = distinct !DIGlobalVariable(name: "u", scope: !2, file: !7, line: 97, type: !59, isLocal: false, isDefinition: true)
+!2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !3, producer: "clang version 16.0.0 (https://github.com/llvm/llvm-project.git de3e34a52a518da7dc0f4eb25cbd490b43523836)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !4, splitDebugInlining: false, nameTableKind: None)
+!3 = !DIFile(filename: "/home/jon/sources/llvm-project/clang/test/CodeGenCXX/debug-info-access.cpp", directory: "/home/jon/sources/llvm-project/build/testing", checksumkind: CSK_MD5, checksum: "ffc7cc9989a6f8eef560c1f7799a826f")
+!4 = !{!0, !5, !18, !36, !47, !53}
!5 = !DIGlobalVariableExpression(var: !6, expr: !DIExpression())
-!6 = distinct !DIGlobalVariable(name: "a", scope: !2, file: !7, line: 74, type: !8, isLocal: false, isDefinition: true)
-!7 = !DIFile(filename: "clang/test/CodeGenCXX/debug-info-access.cpp", directory: "")
-!8 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "A", file: !7, line: 3, size: 8, flags: DIFlagTypePassByValue, elements: !9, identifier: "_ZTS1A")
-!9 = !{!10, !12}
+!6 = distinct !DIGlobalVariable(name: "a", scope: !2, file: !7, line: 98, type: !8, isLocal: false, isDefinition: true)
+!7 = !DIFile(filename: "clang/test/CodeGenCXX/debug-info-access.cpp", directory: "/home/jon/sources/llvm-project", checksumkind: CSK_MD5, checksum: "ffc7cc9989a6f8eef560c1f7799a826f")
+!8 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "A", file: !7, line: 3, size: 32, flags: DIFlagTypePassByValue, elements: !9, identifier: "_ZTS1A")
+!9 = !{!10, !12, !14}
!10 = !DIDerivedType(tag: DW_TAG_member, name: "pub_default_static", scope: !8, file: !7, line: 9, baseType: !11, flags: DIFlagStaticMember)
!11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
-!12 = !DISubprogram(name: "pub_default", linkageName: "_ZN1A11pub_defaultEv", scope: !8, file: !7, line: 7, type: !13, scopeLine: 7, flags: DIFlagPrototyped, spFlags: 0)
-!13 = !DISubroutineType(types: !14)
-!14 = !{null, !15}
-!15 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !8, size: 64, flags: DIFlagArtificial | DIFlagObjectPointer)
-!16 = !DIGlobalVariableExpression(var: !17, expr: !DIExpression())
-!17 = distinct !DIGlobalVariable(name: "b", scope: !2, file: !7, line: 75, type: !18, isLocal: false, isDefinition: true)
-!18 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "B", file: !7, line: 14, size: 8, flags: DIFlagTypePassByValue, elements: !19, identifier: "_ZTS1B")
-!19 = !{!20, !21, !22, !26, !27}
-!20 = !DIDerivedType(tag: DW_TAG_inheritance, scope: !18, baseType: !8, flags: DIFlagPublic, extraData: i32 0)
-!21 = !DIDerivedType(tag: DW_TAG_member, name: "public_static", scope: !18, file: !7, line: 19, baseType: !11, flags: DIFlagPublic | DIFlagStaticMember)
-!22 = !DISubprogram(name: "pub", linkageName: "_ZN1B3pubEv", scope: !18, file: !7, line: 17, type: !23, scopeLine: 17, flags: DIFlagPublic | DIFlagPrototyped, spFlags: 0)
-!23 = !DISubroutineType(types: !24)
-!24 = !{null, !25}
-!25 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !18, size: 64, flags: DIFlagArtificial | DIFlagObjectPointer)
-!26 = !DISubprogram(name: "prot", linkageName: "_ZN1B4protEv", scope: !18, file: !7, line: 22, type: !23, scopeLine: 22, flags: DIFlagProtected | DIFlagPrototyped, spFlags: 0)
-!27 = !DISubprogram(name: "priv_default", linkageName: "_ZN1B12priv_defaultEv", scope: !18, file: !7, line: 25, type: !23, scopeLine: 25, flags: DIFlagPrototyped, spFlags: 0)
-!28 = !DIGlobalVariableExpression(var: !29, expr: !DIExpression())
-!29 = distinct !DIGlobalVariable(name: "c", scope: !2, file: !7, line: 76, type: !30, isLocal: false, isDefinition: true)
-!30 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "C", file: !7, line: 28, size: 16, flags: DIFlagTypePassByValue, elements: !31, identifier: "_ZTS1C")
-!31 = !{!32, !35}
-!32 = !DIDerivedType(tag: DW_TAG_member, name: "d", scope: !30, file: !7, line: 38, baseType: !33, size: 8, flags: DIFlagPublic)
-!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")
-!34 = !{}
-!35 = !DIDerivedType(tag: DW_TAG_member, name: "e", scope: !30, file: !7, line: 39, baseType: !36, size: 8, offset: 8, flags: DIFlagPublic)
-!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")
-!37 = !DIGlobalVariableExpression(var: !38, expr: !DIExpression())
-!38 = distinct !DIGlobalVariable(name: "f", scope: !2, file: !7, line: 77, type: !39, isLocal: false, isDefinition: true)
-!39 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "F", file: !7, line: 42, size: 8, flags: DIFlagTypePassByValue, elements: !40, identifier: "_ZTS1F")
-!40 = !{!41}
-!41 = !DIDerivedType(tag: DW_TAG_member, name: "g", scope: !39, file: !7, line: 48, baseType: !42, size: 8)
-!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")
-!43 = !DIGlobalVariableExpression(var: !44, expr: !DIExpression())
-!44 = distinct !DIGlobalVariable(name: "h", scope: !2, file: !7, line: 78, type: !45, isLocal: false, isDefinition: true)
-!45 = distinct !DICompositeType(tag: DW_TAG_union_type, name: "H", file: !7, line: 51, size: 8, flags: DIFlagTypePassByValue, elements: !46, identifier: "_ZTS1H")
-!46 = !{!47}
-!47 = !DIDerivedType(tag: DW_TAG_member, name: "i", scope: !45, file: !7, line: 57, baseType: !48, size: 8)
-!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")
-!49 = distinct !DICompositeType(tag: DW_TAG_union_type, name: "U", file: !7, line: 60, size: 32, flags: DIFlagTypePassByValue, elements: !50, identifier: "_ZTS1U")
-!50 = !{!51, !52}
-!51 = !DIDerivedType(tag: DW_TAG_member, name: "union_priv", scope: !49, file: !7, line: 65, baseType: !11, size: 32, flags: DIFlagPrivate)
-!52 = !DISubprogram(name: "union_pub_default", linkageName: "_ZN1U17union_pub_defaultEv", scope: !49, file: !7, line: 62, type: !53, scopeLine: 62, flags: DIFlagPrototyped, spFlags: 0)
-!53 = !DISubroutineType(types: !54)
-!54 = !{null, !55}
-!55 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !49, size: 64, flags: DIFlagArtificial | DIFlagObjectPointer)
-!56 = !{i32 2, !"Debug Info Version", i32 3}
-!57 = !{i32 1, !"wchar_size", i32 4}
-!58 = !{!"clang version 14.0.0"}
-!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)
-!60 = !DISubroutineType(types: !61)
-!61 = !{null}
-!62 = !DILocation(line: 71, column: 14, scope: !59)
+!12 = !DIDerivedType(tag: DW_TAG_member, name: "a_pub", scope: !8, file: !7, line: 13, baseType: !13, size: 32)
+!13 = !DIDerivedType(tag: DW_TAG_typedef, name: "pub_default_using", scope: !8, file: !7, line: 12, baseType: !11)
+!14 = !DISubprogram(name: "pub_default", linkageName: "_ZN1A11pub_defaultEv", scope: !8, file: !7, line: 7, type: !15, scopeLine: 7, flags: DIFlagPrototyped, spFlags: 0)
+!15 = !DISubroutineType(types: !16)
+!16 = !{null, !17}
+!17 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !8, size: 64, flags: DIFlagArtificial | DIFlagObjectPointer)
+!18 = !DIGlobalVariableExpression(var: !19, expr: !DIExpression())
+!19 = distinct !DIGlobalVariable(name: "b", scope: !2, file: !7, line: 99, type: !20, isLocal: false, isDefinition: true)
+!20 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "B", file: !7, line: 17, size: 128, flags: DIFlagTypePassByValue, elements: !21, identifier: "_ZTS1B")
+!21 = !{!22, !23, !24, !26, !28, !30, !34, !35}
+!22 = !DIDerivedType(tag: DW_TAG_inheritance, scope: !20, baseType: !8, flags: DIFlagPublic, extraData: i32 0)
+!23 = !DIDerivedType(tag: DW_TAG_member, name: "public_static", scope: !20, file: !7, line: 22, baseType: !11, flags: DIFlagPublic | DIFlagStaticMember)
+!24 = !DIDerivedType(tag: DW_TAG_member, name: "pub_member", scope: !20, file: !7, line: 26, baseType: !25, size: 32, offset: 32, flags: DIFlagPublic)
+!25 = !DIDerivedType(tag: DW_TAG_typedef, name: "pub_typedef", scope: !20, file: !7, line: 25, baseType: !11, flags: DIFlagPublic)
+!26 = !DIDerivedType(tag: DW_TAG_member, name: "prot_member", scope: !20, file: !7, line: 31, baseType: !27, size: 32, offset: 64, flags: DIFlagProtected)
+!27 = !DIDerivedType(tag: DW_TAG_typedef, name: "prot_using", scope: !20, file: !7, line: 30, baseType: !11, flags: DIFlagProtected)
+!28 = !DIDerivedType(tag: DW_TAG_member, name: "priv_member", scope: !20, file: !7, line: 36, baseType: !29, size: 32, offset: 96)
+!29 = !DIDerivedType(tag: DW_TAG_typedef, name: "priv_using", scope: !20, file: !7, line: 35, baseType: !11)
+!30 = !DISubprogram(name: "pub", linkageName: "_ZN1B3pubEv", scope: !20, file: !7, line: 20, type: !31, scopeLine: 20, flags: DIFlagPublic | DIFlagPrototyped, spFlags: 0)
+!31 = !DISubroutineType(types: !32)
+!32 = !{null, !33}
+!33 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !20, size: 64, flags: DIFlagArtificial | DIFlagObjectPointer)
+!34 = !DISubprogram(name: "prot", linkageName: "_ZN1B4protEv", scope: !20, file: !7, line: 40, type: !31, scopeLine: 40, flags: DIFlagProtected | DIFlagPrototyped, spFlags: 0)
+!35 = !DISubprogram(name: "priv_default", linkageName: "_ZN1B12priv_defaultEv", scope: !20, file: !7, line: 44, type: !31, scopeLine: 44, flags: DIFlagPrototyped, spFlags: 0)
+!36 = !DIGlobalVariableExpression(var: !37, expr: !DIExpression())
+!37 = distinct !DIGlobalVariable(name: "c", scope: !2, file: !7, line: 100, type: !38, isLocal: false, isDefinition: true)
+!38 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "C", file: !7, line: 47, size: 24, flags: DIFlagTypePassByValue, elements: !39, identifier: "_ZTS1C")
+!39 = !{!40, !43, !45}
+!40 = !DIDerivedType(tag: DW_TAG_member, name: "d", scope: !38, file: !7, line: 61, baseType: !41, size: 8, flags: DIFlagPublic)
+!41 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "D", scope: !38, file: !7, line: 50, size: 8, flags: DIFlagPublic | DIFlagTypePassByValue, elements: !42, identifier: "_ZTSN1C1DE")
+!42 = !{}
+!43 = !DIDerivedType(tag: DW_TAG_member, name: "e", scope: !38, file: !7, line: 62, baseType: !44, size: 8, offset: 8, flags: DIFlagPublic)
+!44 = distinct !DICompositeType(tag: DW_TAG_union_type, name: "E", scope: !38, file: !7, line: 54, size: 8, flags: DIFlagProtected | DIFlagTypePassByValue, elements: !42, identifier: "_ZTSN1C1EE")
+!45 = !DIDerivedType(tag: DW_TAG_member, name: "j", scope: !38, file: !7, line: 63, baseType: !46, size: 8, offset: 16, flags: DIFlagPublic)
+!46 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "J", scope: !38, file: !7, line: 58, size: 8, flags: DIFlagTypePassByValue, elements: !42, identifier: "_ZTSN1C1JE")
+!47 = !DIGlobalVariableExpression(var: !48, expr: !DIExpression())
+!48 = distinct !DIGlobalVariable(name: "f", scope: !2, file: !7, line: 101, type: !49, isLocal: false, isDefinition: true)
+!49 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "F", file: !7, line: 66, size: 8, flags: DIFlagTypePassByValue, elements: !50, identifier: "_ZTS1F")
+!50 = !{!51}
+!51 = !DIDerivedType(tag: DW_TAG_member, name: "g", scope: !49, file: !7, line: 72, baseType: !52, size: 8)
+!52 = distinct !DICompositeType(tag: DW_TAG_union_type, name: "G", scope: !49, file: !7, line: 69, size: 8, flags: DIFlagPrivate | DIFlagTypePassByValue, elements: !42, identifier: "_ZTSN1F1GE")
+!53 = !DIGlobalVariableExpression(var: !54, expr: !DIExpression())
+!54 = distinct !DIGlobalVariable(name: "h", scope: !2, file: !7, line: 102, type: !55, isLocal: false, isDefinition: true)
+!55 = distinct !DICompositeType(tag: DW_TAG_union_type, name: "H", file: !7, line: 75, size: 8, flags: DIFlagTypePassByValue, elements: !56, identifier: "_ZTS1H")
+!56 = !{!57}
+!57 = !DIDerivedType(tag: DW_TAG_member, name: "i", scope: !55, file: !7, line: 81, baseType: !58, size: 8)
+!58 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "I", scope: !55, file: !7, line: 78, size: 8, flags: DIFlagPrivate | DIFlagTypePassByValue, elements: !42, identifier: "_ZTSN1H1IE")
+!59 = distinct !DICompositeType(tag: DW_TAG_union_type, name: "U", file: !7, line: 84, size: 32, flags: DIFlagTypePassByValue, elements: !60, identifier: "_ZTS1U")
+!60 = !{!61, !62}
+!61 = !DIDerivedType(tag: DW_TAG_member, name: "union_priv", scope: !59, file: !7, line: 89, baseType: !11, size: 32, flags: DIFlagPrivate)
+!62 = !DISubprogram(name: "union_pub_default", linkageName: "_ZN1U17union_pub_defaultEv", scope: !59, file: !7, line: 86, type: !63, scopeLine: 86, flags: DIFlagPrototyped, spFlags: 0)
+!63 = !DISubroutineType(types: !64)
+!64 = !{null, !65}
+!65 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !59, size: 64, flags: DIFlagArtificial | DIFlagObjectPointer)
+!66 = !{i32 7, !"Dwarf Version", i32 5}
+!67 = !{i32 2, !"Debug Info Version", i32 3}
+!68 = !{i32 1, !"wchar_size", i32 4}
+!69 = !{i32 8, !"PIC Level", i32 2}
+!70 = !{i32 7, !"PIE Level", i32 2}
+!71 = !{i32 7, !"uwtable", i32 2}
+!72 = !{i32 7, !"frame-pointer", i32 2}
+!73 = !{!"clang version 16.0.0 (https://github.com/llvm/llvm-project.git de3e34a52a518da7dc0f4eb25cbd490b43523836)"}
+!74 = distinct !DISubprogram(name: "free", linkageName: "_Z4freev", scope: !7, file: !7, line: 95, type: !75, scopeLine: 95, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !42)
+!75 = !DISubroutineType(types: !76)
+!76 = !{null}
+!77 = !DILocation(line: 95, column: 14, scope: !74)
Index: llvm/lib/IR/DIBuilder.cpp
===================================================================
--- llvm/lib/IR/DIBuilder.cpp
+++ llvm/lib/IR/DIBuilder.cpp
@@ -348,11 +348,11 @@
DIDerivedType *DIBuilder::createTypedef(DIType *Ty, StringRef Name,
DIFile *File, unsigned LineNo,
DIScope *Context, uint32_t AlignInBits,
+ DINode::DIFlags Flags,
DINodeArray Annotations) {
return DIDerivedType::get(VMContext, dwarf::DW_TAG_typedef, Name, File,
LineNo, getNonCompileUnitScope(Context), Ty, 0,
- AlignInBits, 0, None, DINode::FlagZero, nullptr,
- Annotations);
+ AlignInBits, 0, None, Flags, nullptr, Annotations);
}
DIDerivedType *DIBuilder::createFriend(DIType *Ty, DIType *FriendTy) {
Index: llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
===================================================================
--- llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
+++ llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
@@ -790,6 +790,9 @@
if (Tag == dwarf::DW_TAG_ptr_to_member_type)
addDIEEntry(Buffer, dwarf::DW_AT_containing_type,
*getOrCreateTypeDIE(cast<DIDerivedType>(DTy)->getClassType()));
+
+ addAccess(Buffer, DTy->getFlags());
+
// Add source line info if available and TyDesc is not a forward declaration.
if (!DTy->isForwardDecl())
addSourceLine(Buffer, DTy);
Index: llvm/include/llvm/IR/DIBuilder.h
===================================================================
--- llvm/include/llvm/IR/DIBuilder.h
+++ llvm/include/llvm/IR/DIBuilder.h
@@ -282,10 +282,12 @@
/// \param LineNo Line number.
/// \param Context The surrounding context for the typedef.
/// \param AlignInBits Alignment. (optional)
+ /// \param Flags Flags to describe inheritance attribute, e.g. private
/// \param Annotations Annotations. (optional)
DIDerivedType *createTypedef(DIType *Ty, StringRef Name, DIFile *File,
unsigned LineNo, DIScope *Context,
uint32_t AlignInBits = 0,
+ DINode::DIFlags Flags = DINode::FlagZero,
DINodeArray Annotations = nullptr);
/// Create debugging information entry for a 'friend'.
Index: clang/test/CodeGenCXX/debug-info-access.cpp
===================================================================
--- clang/test/CodeGenCXX/debug-info-access.cpp
+++ clang/test/CodeGenCXX/debug-info-access.cpp
@@ -7,8 +7,11 @@
void pub_default();
// CHECK-DAG: !DIDerivedType(tag: DW_TAG_member, name: "pub_default_static",{{.*}} line: [[@LINE+1]],{{.*}} flags: DIFlagStaticMember)
static int pub_default_static;
-};
+ // CHECK-DAG: !DIDerivedType(tag: DW_TAG_typedef, name: "pub_default_using",{{.*}} line: [[@LINE+1]]
+ using pub_default_using = int;
+ pub_default_using a_pub;
+};
// CHECK: !DIDerivedType(tag: DW_TAG_inheritance,{{.*}} baseType: ![[A]],{{.*}} flags: DIFlagPublic, extraData: i32 0)
class B : public A {
@@ -17,9 +20,25 @@
void pub();
// CHECK-DAG: !DIDerivedType(tag: DW_TAG_member, name: "public_static",{{.*}} line: [[@LINE+1]],{{.*}} flags: DIFlagPublic | DIFlagStaticMember)
static int public_static;
+
+ // CHECK-DAG: !DIDerivedType(tag: DW_TAG_typedef, name: "pub_typedef",{{.*}} line: [[@LINE+1]],{{.*}} flags: DIFlagPublic)
+ typedef int pub_typedef;
+ pub_typedef pub_member;
+
+protected:
+ // CHECK-DAG: !DIDerivedType(tag: DW_TAG_typedef, name: "prot_using",{{.*}} line: [[@LINE+1]],{{.*}} flags: DIFlagProtected)
+ using prot_using = int;
+ prot_using prot_member;
+
+private:
+ // CHECK-DAG: !DIDerivedType(tag: DW_TAG_typedef, name: "priv_using",{{.*}} line: [[@LINE+1]]
+ using priv_using = int;
+ priv_using priv_member;
+
protected:
// CHECK: !DISubprogram(name: "prot",{{.*}} line: [[@LINE+1]],{{.*}} flags: DIFlagProtected | DIFlagPrototyped,
void prot();
+
private:
// CHECK: !DISubprogram(name: "priv_default",{{.*}} line: [[@LINE+1]],{{.*}} flags: DIFlagPrototyped,
void priv_default();
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===================================================================
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1283,6 +1283,33 @@
getDeclContextDescriptor(AliasDecl));
}
+/// Convert an AccessSpecifier into the corresponding DINode flag.
+/// As an optimization, return 0 if the access specifier equals the
+/// default for the containing type.
+static llvm::DINode::DIFlags getAccessFlag(AccessSpecifier Access,
+ const RecordDecl *RD) {
+ AccessSpecifier Default = clang::AS_none;
+ if (RD && RD->isClass())
+ Default = clang::AS_private;
+ else if (RD && (RD->isStruct() || RD->isUnion()))
+ Default = clang::AS_public;
+
+ if (Access == Default)
+ return llvm::DINode::FlagZero;
+
+ switch (Access) {
+ case clang::AS_private:
+ return llvm::DINode::FlagPrivate;
+ case clang::AS_protected:
+ return llvm::DINode::FlagProtected;
+ case clang::AS_public:
+ return llvm::DINode::FlagPublic;
+ case clang::AS_none:
+ return llvm::DINode::FlagZero;
+ }
+ llvm_unreachable("unexpected access enumerator");
+}
+
llvm::DIType *CGDebugInfo::CreateType(const TypedefType *Ty,
llvm::DIFile *Unit) {
llvm::DIType *Underlying =
@@ -1298,10 +1325,17 @@
uint32_t Align = getDeclAlignIfRequired(Ty->getDecl(), CGM.getContext());
// Typedefs are derived from some other type.
llvm::DINodeArray Annotations = CollectBTFDeclTagAnnotations(Ty->getDecl());
+
+ llvm::DINode::DIFlags Flags = llvm::DINode::FlagZero;
+ const DeclContext *DC = Ty->getDecl()->getDeclContext();
+ if (isa<RecordDecl>(DC)) {
+ Flags = getAccessFlag(Ty->getDecl()->getAccess(), cast<RecordDecl>(DC));
+ }
+
return DBuilder.createTypedef(Underlying, Ty->getDecl()->getName(),
getOrCreateFile(Loc), getLineNumber(Loc),
getDeclContextDescriptor(Ty->getDecl()), Align,
- Annotations);
+ Flags, Annotations);
}
static unsigned getDwarfCC(CallingConv CC) {
@@ -1395,33 +1429,6 @@
return F;
}
-/// Convert an AccessSpecifier into the corresponding DINode flag.
-/// As an optimization, return 0 if the access specifier equals the
-/// default for the containing type.
-static llvm::DINode::DIFlags getAccessFlag(AccessSpecifier Access,
- const RecordDecl *RD) {
- AccessSpecifier Default = clang::AS_none;
- if (RD && RD->isClass())
- Default = clang::AS_private;
- else if (RD && (RD->isStruct() || RD->isUnion()))
- Default = clang::AS_public;
-
- if (Access == Default)
- return llvm::DINode::FlagZero;
-
- switch (Access) {
- case clang::AS_private:
- return llvm::DINode::FlagPrivate;
- case clang::AS_protected:
- return llvm::DINode::FlagProtected;
- case clang::AS_public:
- return llvm::DINode::FlagPublic;
- case clang::AS_none:
- return llvm::DINode::FlagZero;
- }
- llvm_unreachable("unexpected access enumerator");
-}
-
llvm::DIType *CGDebugInfo::createBitFieldType(const FieldDecl *BitFieldDecl,
llvm::DIScope *RecordTy,
const RecordDecl *RD) {
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits