Skip to content

Commit 0e7546f

Browse files
committed
[llvm][DebugInfo][test] Add LLVM tests for Objective-C property debug-info
The IR->DWARF pipeline was not properly tested before. This patch adds a test to generate DWARF for various `DIObjCProperty` constructions. This caught a couple of bugs: 1. The `DW_AT_APPLE_property_getter` and `DW_AT_APPLE_property_setter` properties were emitted the wrong way around. 2. The `DW_TAG_member` ivars were not linking back to the property that they back. These will be fixed in follow-up patches.
1 parent f4e77e9 commit 0e7546f

File tree

1 file changed

+35
-36
lines changed

1 file changed

+35
-36
lines changed

llvm/test/DebugInfo/Generic/objc-property.ll

Lines changed: 35 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -50,40 +50,39 @@
5050
; CHECK: DW_TAG_member
5151
; CHECK-NOT: DW_AT_APPLE_property
5252

53-
!llvm.module.flags = !{!0, !1}
54-
!llvm.dbg.cu = !{!2}
55-
56-
!0 = !{i32 7, !"Dwarf Version", i32 5}
57-
!1 = !{i32 2, !"Debug Info Version", i32 3}
58-
!2 = distinct !DICompileUnit(language: DW_LANG_ObjC, file: !3, producer: "hand written", isOptimized: false, runtimeVersion: 2, emissionKind: FullDebug, retainedTypes: !4, splitDebugInlining: false, debugInfoForProfiling: true, nameTableKind: Apple)
59-
!3 = !DIFile(filename: "main.m", directory: "/tmp")
60-
!4 = !{!5}
61-
!5 = !DICompositeType(tag: DW_TAG_structure_type, name: "Foo", scope: !3, file: !3, line: 1, size: 128, flags: DIFlagObjcClassComplete, elements: !6, runtimeLang: DW_LANG_ObjC)
62-
!6 = !{!7, !9, !10, !11, !12, !13, !14, !15, !16, !17, !24, !27, !28, !29, !30, !31, !32}
63-
!7 = !DIObjCProperty(name: "autoSynthProp", file: !3, line: 5, attributes: 2316, type: !8)
64-
!8 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
65-
!9 = !DIObjCProperty(name: "synthProp", file: !3, line: 6, attributes: 2316, type: !8)
66-
!10 = !DIObjCProperty(name: "customGetterProp", file: !3, line: 7, getter: "customGetter", attributes: 2318, type: !8)
67-
!11 = !DIObjCProperty(name: "customSetterProp", file: !3, line: 8, setter: "customSetter:", attributes: 2444, type: !8)
68-
!12 = !DIObjCProperty(name: "customAccessorsProp", file: !3, line: 9, setter: "customSetter:", getter: "customGetter", attributes: 2446, type: !8)
69-
!13 = !DIDerivedType(tag: DW_TAG_member, name: "someBackingIvar", scope: !3, file: !3, line: 2, baseType: !8, size: 32, flags: DIFlagProtected, extraData: !9)
70-
!14 = !DIDerivedType(tag: DW_TAG_member, name: "_autoSynthProp", scope: !3, file: !3, line: 5, baseType: !8, size: 32, flags: DIFlagPrivate, extraData: !7)
71-
!15 = !DIDerivedType(tag: DW_TAG_member, name: "_customGetterProp", scope: !3, file: !3, line: 7, baseType: !8, size: 32, flags: DIFlagPrivate, extraData: !10)
72-
!16 = !DIDerivedType(tag: DW_TAG_member, name: "_customSetterProp", scope: !3, file: !3, line: 8, baseType: !8, size: 32, flags: DIFlagPrivate, extraData: !11)
73-
!17 = !DISubprogram(name: "-[Foo customGetter]", scope: !5, file: !3, line: 19, type: !18, scopeLine: 19, flags: DIFlagPrototyped, spFlags: DISPFlagLocalToUnit)
74-
!18 = !DISubroutineType(types: !19)
75-
!19 = !{!8, !20, !21}
76-
!20 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !5, size: 64, flags: DIFlagArtificial | DIFlagObjectPointer)
77-
!21 = !DIDerivedType(tag: DW_TAG_typedef, name: "SEL", file: !3, baseType: !22, flags: DIFlagArtificial)
78-
!22 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !23, size: 64)
79-
!23 = !DICompositeType(tag: DW_TAG_structure_type, name: "objc_selector", file: !3, flags: DIFlagFwdDecl)
80-
!24 = !DISubprogram(name: "-[Foo customSetter:]", scope: !5, file: !3, line: 23, type: !25, scopeLine: 23, flags: DIFlagPrototyped, spFlags: DISPFlagLocalToUnit)
81-
!25 = !DISubroutineType(types: !26)
82-
!26 = !{null, !20, !21, !8}
83-
!27 = !DISubprogram(name: "-[Foo synthProp]", scope: !5, file: !3, line: 17, type: !18, scopeLine: 17, flags: DIFlagArtificial | DIFlagPrototyped, spFlags: DISPFlagLocalToUnit)
84-
!28 = !DISubprogram(name: "-[Foo setSynthProp:]", scope: !5, file: !3, line: 17, type: !25, scopeLine: 17, flags: DIFlagArtificial | DIFlagPrototyped, spFlags: DISPFlagLocalToUnit)
85-
!29 = !DISubprogram(name: "-[Foo autoSynthProp]", scope: !5, file: !3, line: 5, type: !18, scopeLine: 5, flags: DIFlagArtificial | DIFlagPrototyped, spFlags: DISPFlagLocalToUnit)
86-
!30 = !DISubprogram(name: "-[Foo setAutoSynthProp:]", scope: !5, file: !3, line: 5, type: !25, scopeLine: 5, flags: DIFlagArtificial | DIFlagPrototyped, spFlags: DISPFlagLocalToUnit)
87-
!31 = !DISubprogram(name: "-[Foo setCustomGetterProp:]", scope: !5, file: !3, line: 7, type: !25, scopeLine: 7, flags: DIFlagArtificial | DIFlagPrototyped, spFlags: DISPFlagLocalToUnit)
88-
!32 = !DISubprogram(name: "-[Foo customSetterProp]", scope: !5, file: !3, line: 8, type: !18, scopeLine: 8, flags: DIFlagArtificial | DIFlagPrototyped, spFlags: DISPFlagLocalToUnit)
53+
!llvm.module.flags = !{!7, !8}
54+
!llvm.dbg.cu = !{!13}
8955

56+
!7 = !{i32 7, !"Dwarf Version", i32 5}
57+
!8 = !{i32 2, !"Debug Info Version", i32 3}
58+
!13 = distinct !DICompileUnit(language: DW_LANG_ObjC, file: !14, producer: "hand written", isOptimized: false, runtimeVersion: 2, emissionKind: FullDebug, retainedTypes: !15, splitDebugInlining: false, debugInfoForProfiling: true, nameTableKind: Apple)
59+
!14 = !DIFile(filename: "main.m", directory: "/tmp")
60+
!15 = !{!16}
61+
!16 = !DICompositeType(tag: DW_TAG_structure_type, name: "Foo", scope: !14, file: !14, line: 1, size: 128, flags: DIFlagObjcClassComplete, elements: !17, runtimeLang: DW_LANG_ObjC)
62+
!17 = !{!18, !20, !21, !22, !23, !24, !25, !26, !27, !28, !35, !38, !39, !40, !41, !42, !43}
63+
!18 = !DIObjCProperty(name: "autoSynthProp", file: !14, line: 5, attributes: 2316, type: !19)
64+
!19 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
65+
!20 = !DIObjCProperty(name: "synthProp", file: !14, line: 6, attributes: 2316, type: !19)
66+
!21 = !DIObjCProperty(name: "customGetterProp", file: !14, line: 7, getter: "customGetter", attributes: 2318, type: !19)
67+
!22 = !DIObjCProperty(name: "customSetterProp", file: !14, line: 8, setter: "customSetter:", attributes: 2444, type: !19)
68+
!23 = !DIObjCProperty(name: "customAccessorsProp", file: !14, line: 9, setter: "customSetter:", getter: "customGetter", attributes: 2446, type: !19)
69+
!24 = !DIDerivedType(tag: DW_TAG_member, name: "someBackingIvar", scope: !14, file: !14, line: 2, baseType: !19, size: 32, flags: DIFlagProtected, extraData: !20)
70+
!25 = !DIDerivedType(tag: DW_TAG_member, name: "_autoSynthProp", scope: !14, file: !14, line: 5, baseType: !19, size: 32, flags: DIFlagPrivate, extraData: !18)
71+
!26 = !DIDerivedType(tag: DW_TAG_member, name: "_customGetterProp", scope: !14, file: !14, line: 7, baseType: !19, size: 32, flags: DIFlagPrivate, extraData: !21)
72+
!27 = !DIDerivedType(tag: DW_TAG_member, name: "_customSetterProp", scope: !14, file: !14, line: 8, baseType: !19, size: 32, flags: DIFlagPrivate, extraData: !22)
73+
!28 = !DISubprogram(name: "-[Foo customGetter]", scope: !16, file: !14, line: 19, type: !29, scopeLine: 19, flags: DIFlagPrototyped, spFlags: DISPFlagLocalToUnit)
74+
!29 = !DISubroutineType(types: !30)
75+
!30 = !{!19, !31, !32}
76+
!31 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !16, size: 64, flags: DIFlagArtificial | DIFlagObjectPointer)
77+
!32 = !DIDerivedType(tag: DW_TAG_typedef, name: "SEL", file: !14, baseType: !33, flags: DIFlagArtificial)
78+
!33 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !34, size: 64)
79+
!34 = !DICompositeType(tag: DW_TAG_structure_type, name: "objc_selector", file: !14, flags: DIFlagFwdDecl)
80+
!35 = !DISubprogram(name: "-[Foo customSetter:]", scope: !16, file: !14, line: 23, type: !36, scopeLine: 23, flags: DIFlagPrototyped, spFlags: DISPFlagLocalToUnit)
81+
!36 = !DISubroutineType(types: !37)
82+
!37 = !{null, !31, !32, !19}
83+
!38 = !DISubprogram(name: "-[Foo synthProp]", scope: !16, file: !14, line: 17, type: !29, scopeLine: 17, flags: DIFlagArtificial | DIFlagPrototyped, spFlags: DISPFlagLocalToUnit)
84+
!39 = !DISubprogram(name: "-[Foo setSynthProp:]", scope: !16, file: !14, line: 17, type: !36, scopeLine: 17, flags: DIFlagArtificial | DIFlagPrototyped, spFlags: DISPFlagLocalToUnit)
85+
!40 = !DISubprogram(name: "-[Foo autoSynthProp]", scope: !16, file: !14, line: 5, type: !29, scopeLine: 5, flags: DIFlagArtificial | DIFlagPrototyped, spFlags: DISPFlagLocalToUnit)
86+
!41 = !DISubprogram(name: "-[Foo setAutoSynthProp:]", scope: !16, file: !14, line: 5, type: !36, scopeLine: 5, flags: DIFlagArtificial | DIFlagPrototyped, spFlags: DISPFlagLocalToUnit)
87+
!42 = !DISubprogram(name: "-[Foo setCustomGetterProp:]", scope: !16, file: !14, line: 7, type: !36, scopeLine: 7, flags: DIFlagArtificial | DIFlagPrototyped, spFlags: DISPFlagLocalToUnit)
88+
!43 = !DISubprogram(name: "-[Foo customSetterProp]", scope: !16, file: !14, line: 8, type: !29, scopeLine: 8, flags: DIFlagArtificial | DIFlagPrototyped, spFlags: DISPFlagLocalToUnit)

0 commit comments

Comments
 (0)