[llvm][DebugInfo][ObjC] Make sure we link backing ivars to their DW_TAG_APPLE_property (#165409)

Depends on:
* https://github.com/llvm/llvm-project/pull/165373

When an Objective-C property has a backing ivar, we would previously not
add a `DW_AT_APPLE_property` to the ivar's `DW_TAG_member`. This is what
was intended based on the [Objective-C DebugInfo
docs](https://github.com/llvm/llvm-project/blob/main/llvm/docs/SourceLevelDebugging.rst#proposal)
but is not what LLVM currently generates.

LLDB currently doesn't ever try linking the `ObjCPropertyDecl`s to their
`ObjCIvarDecl`s, but if we wanted to, this debug-info patch is a
pre-requisite.
This commit is contained in:
Michael Buch 2025-10-31 10:25:58 +00:00 committed by GitHub
parent 31a0ebb840
commit 10fbbb62ce
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 17 additions and 11 deletions

View File

@ -1120,7 +1120,7 @@ void DwarfUnit::constructTypeDIE(DIE &Buffer, const DICompositeType *CTy) {
constructMemberDIE(Buffer, DDTy);
}
} else if (auto *Property = dyn_cast<DIObjCProperty>(Element)) {
DIE &ElemDie = createAndAddDIE(Property->getTag(), Buffer);
DIE &ElemDie = createAndAddDIE(Property->getTag(), Buffer, Property);
StringRef PropertyName = Property->getName();
addString(ElemDie, dwarf::DW_AT_APPLE_property_name, PropertyName);
if (Property->getType())

View File

@ -5,33 +5,33 @@
; CHECK: DW_TAG_structure_type
; CHECK: DW_AT_name ("Foo")
;
; CHECK: DW_TAG_APPLE_property
; CHECK: 0x[[AUTO_SYNTH:[0-9a-f]+]]: DW_TAG_APPLE_property
; CHECK: DW_AT_APPLE_property_name ("autoSynthProp")
; CHECK: DW_AT_APPLE_property_attribute
; CHECK-SAME: DW_APPLE_PROPERTY_assign, DW_APPLE_PROPERTY_readwrite,
; CHECK-SAME: DW_APPLE_PROPERTY_atomic, DW_APPLE_PROPERTY_unsafe_unretained
;
; CHECK: DW_TAG_APPLE_property
; CHECK: 0x[[SYNTH:[0-9a-f]+]]: DW_TAG_APPLE_property
; CHECK: DW_AT_APPLE_property_name ("synthProp")
; CHECK: DW_AT_APPLE_property_attribute
; CHECK-SAME: DW_APPLE_PROPERTY_assign, DW_APPLE_PROPERTY_readwrite,
; CHECK-SAME: DW_APPLE_PROPERTY_atomic, DW_APPLE_PROPERTY_unsafe_unretained
;
; CHECK: DW_TAG_APPLE_property
; CHECK: 0x[[GET:[0-9a-f]+]]: DW_TAG_APPLE_property
; CHECK: DW_AT_APPLE_property_name ("customGetterProp")
; CHECK: DW_AT_APPLE_property_getter ("customGetter")
; CHECK: DW_AT_APPLE_property_attribute
; CHECK-SAME: DW_APPLE_PROPERTY_getter, DW_APPLE_PROPERTY_assign, DW_APPLE_PROPERTY_readwrite,
; CHECK-SAME: DW_APPLE_PROPERTY_atomic, DW_APPLE_PROPERTY_unsafe_unretained
;
; CHECK: DW_TAG_APPLE_property
; CHECK: 0x[[SET:[0-9a-f]+]]: DW_TAG_APPLE_property
; CHECK: DW_AT_APPLE_property_name ("customSetterProp")
; CHECK: DW_AT_APPLE_property_setter ("customSetter:")
; CHECK: DW_AT_APPLE_property_attribute
; CHECK-SAME: DW_APPLE_PROPERTY_assign, DW_APPLE_PROPERTY_readwrite,
; CHECK-SAME: DW_APPLE_PROPERTY_setter, DW_APPLE_PROPERTY_atomic, DW_APPLE_PROPERTY_unsafe_unretained
;
; CHECK: DW_TAG_APPLE_property
; CHECK: 0x[[ACCESSORS:[0-9a-f]+]]: DW_TAG_APPLE_property
; CHECK: DW_AT_APPLE_property_name ("customAccessorsProp")
; CHECK: DW_AT_APPLE_property_getter ("customGetter")
; CHECK: DW_AT_APPLE_property_setter ("customSetter:")
@ -39,15 +39,21 @@
; CHECK-SAME: DW_APPLE_PROPERTY_getter, DW_APPLE_PROPERTY_assign, DW_APPLE_PROPERTY_readwrite,
; CHECK-SAME: DW_APPLE_PROPERTY_setter, DW_APPLE_PROPERTY_atomic, DW_APPLE_PROPERTY_unsafe_unretained
;
; FIXME: missing link between DW_TAG_member and the associated DW_TAG_APPLE_property
; CHECK: DW_TAG_member
; CHECK-NOT: DW_AT_APPLE_property
; CHECK: DW_AT_name ("someBackingIvar")
; CHECK: DW_AT_APPLE_property (0x[[SYNTH]] "synthProp")
;
; CHECK: DW_TAG_member
; CHECK-NOT: DW_AT_APPLE_property
; CHECK: DW_AT_name ("_autoSynthProp")
; CHECK: DW_AT_APPLE_property (0x[[AUTO_SYNTH]] "autoSynthProp")
;
; CHECK: DW_TAG_member
; CHECK-NOT: DW_AT_APPLE_property
; CHECK: DW_AT_name ("_customGetterProp")
; CHECK: DW_AT_APPLE_property (0x[[GET]] "customGetterProp")
;
; CHECK: DW_TAG_member
; CHECK-NOT: DW_AT_APPLE_property
; CHECK: DW_AT_name ("_customSetterProp")
; CHECK: DW_AT_APPLE_property (0x[[SET]] "customSetterProp")
!llvm.module.flags = !{!0, !1}
!llvm.dbg.cu = !{!2}