diff --git a/clang/test/DebugInfo/ObjC/property-2.m b/clang/test/DebugInfo/ObjC/property-2.m deleted file mode 100644 index f15213131ccc0..0000000000000 --- a/clang/test/DebugInfo/ObjC/property-2.m +++ /dev/null @@ -1,18 +0,0 @@ -// FIXME: Check IR rather than asm, then triple is not needed. -// RUN: %clang_cc1 -triple %itanium_abi_triple -S -debug-info-kind=limited -x objective-c < %s | grep DW_AT_name -@interface Foo { - int i; -} -@property int i; -@end - -@implementation Foo -@synthesize i; -@end - -int bar(Foo *f) { - int i = 1; - f.i = 2; - i = f.i; - return i; -} diff --git a/clang/test/DebugInfo/ObjC/property-auto-synth.m b/clang/test/DebugInfo/ObjC/property-auto-synth.m new file mode 100644 index 0000000000000..5e961d424e532 --- /dev/null +++ b/clang/test/DebugInfo/ObjC/property-auto-synth.m @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited %s -o - | FileCheck %s + +// CHECK-NOT: setter +// CHECK-NOT: getter + +@interface I1 +@property int p1; +@end + +@implementation I1 +@end + +void foo(I1 *ptr) {} diff --git a/clang/test/DebugInfo/ObjC/property-basic.m b/clang/test/DebugInfo/ObjC/property-basic.m new file mode 100644 index 0000000000000..65e1d7a6a9b1f --- /dev/null +++ b/clang/test/DebugInfo/ObjC/property-basic.m @@ -0,0 +1,20 @@ +// Checks basic debug-info generation for property. Makes sure we +// create a DIObjCProperty for the synthesized property. + +// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited %s -o - | FileCheck %s + +// CHECK: !DIObjCProperty(name: "p1" +// CHECK-SAME: attributes: 2316 +// CHECK-SAME: type: ![[P1_TYPE:[0-9]+]] +// +// CHECK: ![[P1_TYPE]] = !DIBasicType(name: "int" + +@interface I1 { +int p1; +} +@property int p1; +@end + +@implementation I1 +@synthesize p1; +@end diff --git a/clang/test/DebugInfo/ObjC/property-explicit-accessors.m b/clang/test/DebugInfo/ObjC/property-explicit-accessors.m new file mode 100644 index 0000000000000..86eade6998afe --- /dev/null +++ b/clang/test/DebugInfo/ObjC/property-explicit-accessors.m @@ -0,0 +1,34 @@ +// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited %s -o - | FileCheck %s + +// CHECK: !DIObjCProperty(name: "baseInt" +// CHECK-SAME: setter: "mySetBaseInt:" +// CHECK-SAME: getter: "myGetBaseInt" +// CHECK-SAME: attributes: 2446 +// CHECK-SAME: type: ![[P1_TYPE:[0-9]+]] +// +// CHECK: ![[P1_TYPE]] = !DIBasicType(name: "int" + +@interface BaseClass2 +{ + int _baseInt; +} +- (int) myGetBaseInt; +- (void) mySetBaseInt: (int) in_int; +@property(getter=myGetBaseInt,setter=mySetBaseInt:) int baseInt; +@end + +@implementation BaseClass2 + +- (int) myGetBaseInt +{ + return _baseInt; +} + +- (void) mySetBaseInt: (int) in_int +{ + _baseInt = 2 * in_int; +} +@end + + +void foo(BaseClass2 *ptr) {} diff --git a/clang/test/DebugInfo/ObjC/property-explicit-ivar.m b/clang/test/DebugInfo/ObjC/property-explicit-ivar.m new file mode 100644 index 0000000000000..5092e23e195f8 --- /dev/null +++ b/clang/test/DebugInfo/ObjC/property-explicit-ivar.m @@ -0,0 +1,22 @@ +// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited %s -o - | FileCheck %s + +// CHECK: ![[BASE_PROP:[0-9]+]] = !DIObjCProperty(name: "base" +// CHECK-SAME: attributes: 2316 +// CHECK-SAME: type: ![[P1_TYPE:[0-9]+]] +// +// CHECK: ![[P1_TYPE]] = !DIBasicType(name: "int" +// +// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "_customIvar" +// CHECK-SAME: extraData: ![[BASE_PROP]] + +@interface C { + int _customIvar; +} +@property int base; +@end + +@implementation C +@synthesize base = _customIvar; +@end + +void foo(C *cptr) {} diff --git a/clang/test/DebugInfo/ObjC/property.m b/clang/test/DebugInfo/ObjC/property.m deleted file mode 100644 index ca013b24be421..0000000000000 --- a/clang/test/DebugInfo/ObjC/property.m +++ /dev/null @@ -1,15 +0,0 @@ -// FIXME: Check IR rather than asm, then triple is not needed. -// RUN: %clang_cc1 -triple %itanium_abi_triple -S -debug-info-kind=limited %s -o - | FileCheck %s - -// CHECK: AT_APPLE_property_name -// CHECK: AT_APPLE_property_attribute -// CHECK: AT_APPLE_property -@interface I1 { -int p1; -} -@property int p1; -@end - -@implementation I1 -@synthesize p1; -@end diff --git a/clang/test/DebugInfo/ObjC/property2.m b/clang/test/DebugInfo/ObjC/property2.m deleted file mode 100644 index 7e0a5e9f954ba..0000000000000 --- a/clang/test/DebugInfo/ObjC/property2.m +++ /dev/null @@ -1,15 +0,0 @@ -// FIXME: Check IR rather than asm, then triple is not needed. -// RUN: %clang_cc1 -triple %itanium_abi_triple -S -debug-info-kind=limited %s -o - | FileCheck %s - -// CHECK: AT_APPLE_property_name -@interface C { - int _base; -} -@property int base; -@end - -@implementation C -@synthesize base = _base; -@end - -void foo(C *cptr) {} diff --git a/clang/test/DebugInfo/ObjC/property4.m b/clang/test/DebugInfo/ObjC/property4.m deleted file mode 100644 index 1f489f2f6b637..0000000000000 --- a/clang/test/DebugInfo/ObjC/property4.m +++ /dev/null @@ -1,18 +0,0 @@ -// FIXME: Check IR rather than asm, then triple is not needed. -// RUN: %clang_cc1 -triple %itanium_abi_triple -S -debug-info-kind=limited %s -o - | FileCheck %s - -// CHECK: AT_APPLE_property_name -// CHECK-NOT: AT_APPLE_property_getter -// CHECK-NOT: AT_APPLE_property_setter -// CHECK: AT_APPLE_property_attribute -// CHECK: AT_APPLE_property - - -@interface I1 -@property int p1; -@end - -@implementation I1 -@end - -void foo(I1 *ptr) {} diff --git a/clang/test/DebugInfo/ObjC/property5.m b/clang/test/DebugInfo/ObjC/property5.m deleted file mode 100644 index 8b70f1ff20824..0000000000000 --- a/clang/test/DebugInfo/ObjC/property5.m +++ /dev/null @@ -1,33 +0,0 @@ -// FIXME: Check IR rather than asm, then triple is not needed. -// RUN: %clang_cc1 -triple %itanium_abi_triple -S -debug-info-kind=limited %s -o - | FileCheck %s - -// CHECK: AT_APPLE_property_name -// CHECK: AT_APPLE_property_getter -// CHECK: AT_APPLE_property_setter -// CHECK: AT_APPLE_property_attribute -// CHECK: AT_APPLE_property - -@interface BaseClass2 -{ - int _baseInt; -} -- (int) myGetBaseInt; -- (void) mySetBaseInt: (int) in_int; -@property(getter=myGetBaseInt,setter=mySetBaseInt:) int baseInt; -@end - -@implementation BaseClass2 - -- (int) myGetBaseInt -{ - return _baseInt; -} - -- (void) mySetBaseInt: (int) in_int -{ - _baseInt = 2 * in_int; -} -@end - - -void foo(BaseClass2 *ptr) {} diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp index b1bde668d5cc8..4bc4e728596d8 100644 --- a/llvm/lib/AsmParser/LLParser.cpp +++ b/llvm/lib/AsmParser/LLParser.cpp @@ -6256,8 +6256,8 @@ bool LLParser::parseDIObjCProperty(MDNode *&Result, bool IsDistinct) { #undef VISIT_MD_FIELDS Result = GET_OR_DISTINCT(DIObjCProperty, - (Context, name.Val, file.Val, line.Val, setter.Val, - getter.Val, attributes.Val, type.Val)); + (Context, name.Val, file.Val, line.Val, getter.Val, + setter.Val, attributes.Val, type.Val)); return false; } diff --git a/llvm/lib/Bitcode/Reader/MetadataLoader.cpp b/llvm/lib/Bitcode/Reader/MetadataLoader.cpp index c1e1a0fb1bc09..7062fe90ed8cf 100644 --- a/llvm/lib/Bitcode/Reader/MetadataLoader.cpp +++ b/llvm/lib/Bitcode/Reader/MetadataLoader.cpp @@ -2318,8 +2318,9 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata( GET_OR_DISTINCT(DIObjCProperty, (Context, getMDString(Record[1]), getMDOrNull(Record[2]), Record[3], - getMDString(Record[4]), getMDString(Record[5]), - Record[6], getDITypeRefOrNull(Record[7]))), + /*GetterName=*/getMDString(Record[5]), + /*SetterName=*/getMDString(Record[4]), Record[6], + getDITypeRefOrNull(Record[7]))), NextMetadataNo); NextMetadataNo++; break; diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp index 4c99a4d623450..c85bd066ad7ac 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp @@ -1097,7 +1097,7 @@ void DwarfUnit::constructTypeDIE(DIE &Buffer, const DICompositeType *CTy) { constructMemberDIE(Buffer, DDTy); } } else if (auto *Property = dyn_cast(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()) diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp index edc69a36cdff2..8fa8dd9f5debc 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp @@ -107,6 +107,25 @@ static DWARFDie resolveReferencedType(DWARFDie D, DWARFFormValue F) { return D.getAttributeValueAsReferencedDie(F).resolveTypeUnitReference(); } +static llvm::Expected +getApplePropertyName(const DWARFDie &PropDIE) { + if (!PropDIE) + return llvm::createStringError("invalid DIE"); + + if (PropDIE.getTag() != DW_TAG_APPLE_property) + return llvm::createStringError("not referencing a DW_TAG_APPLE_property"); + + auto PropNameForm = PropDIE.find(DW_AT_APPLE_property_name); + if (!PropNameForm) + return ""; + + auto NameOrErr = PropNameForm->getAsCString(); + if (!NameOrErr) + return NameOrErr.takeError(); + + return *NameOrErr; +} + static void dumpAttribute(raw_ostream &OS, const DWARFDie &Die, const DWARFAttribute &AttrValue, unsigned Indent, DIDumpOptions DumpOpts) { @@ -197,6 +216,15 @@ static void dumpAttribute(raw_ostream &OS, const DWARFDie &Die, Die.getAttributeValueAsReferencedDie(FormValue).getName( DINameKind::LinkageName)) OS << Space << "\"" << Name << '\"'; + } else if (Attr == DW_AT_APPLE_property) { + auto PropDIE = Die.getAttributeValueAsReferencedDie(FormValue); + if (auto PropNameOrErr = getApplePropertyName(PropDIE)) + OS << Space << "\"" << *PropNameOrErr << '\"'; + else + DumpOpts.RecoverableErrorHandler(createStringError( + errc::invalid_argument, + llvm::formatv("decoding DW_AT_APPLE_property_name: {}", + toString(PropNameOrErr.takeError())))); } else if (Attr == DW_AT_type || Attr == DW_AT_containing_type) { DWARFDie D = resolveReferencedType(Die, FormValue); if (D && !D.isNULL()) { diff --git a/llvm/test/Bitcode/dwarf-objc-property.ll b/llvm/test/Bitcode/dwarf-objc-property.ll new file mode 100644 index 0000000000000..f054f572feffa --- /dev/null +++ b/llvm/test/Bitcode/dwarf-objc-property.ll @@ -0,0 +1,46 @@ +; RUN: llvm-as < %s | llvm-dis | FileCheck %s +; RUN: llvm-as < %s | llvm-dis | llvm-as | llvm-dis | FileCheck %s + +; CHECK: !DIObjCProperty(name: "autoSynthProp", file: !3, line: 5, attributes: 2316, type: !8) +; CHECK: !DIObjCProperty(name: "synthProp", file: !3, line: 6, attributes: 2316, type: !8) +; CHECK: !DIObjCProperty(name: "customGetterProp", file: !3, line: 7, getter: "customGetter", attributes: 2318, type: !8) +; CHECK: !DIObjCProperty(name: "customSetterProp", file: !3, line: 8, setter: "customSetter:", attributes: 2444, type: !8) +; CHECK: !DIObjCProperty(name: "customAccessorsProp", file: !3, line: 9, setter: "customSetter:", getter: "customGetter", attributes: 2446, type: !8) + +!llvm.module.flags = !{!0, !1} +!llvm.dbg.cu = !{!2} + +!0 = !{i32 7, !"Dwarf Version", i32 5} +!1 = !{i32 2, !"Debug Info Version", i32 3} +!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) +!3 = !DIFile(filename: "main.m", directory: "/tmp") +!4 = !{!5} +!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) +!6 = !{!7, !9, !10, !11, !12, !13, !14, !15, !16, !17, !24, !27, !28, !29, !30, !31, !32} +!7 = !DIObjCProperty(name: "autoSynthProp", file: !3, line: 5, attributes: 2316, type: !8) +!8 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) +!9 = !DIObjCProperty(name: "synthProp", file: !3, line: 6, attributes: 2316, type: !8) +!10 = !DIObjCProperty(name: "customGetterProp", file: !3, line: 7, getter: "customGetter", attributes: 2318, type: !8) +!11 = !DIObjCProperty(name: "customSetterProp", file: !3, line: 8, setter: "customSetter:", attributes: 2444, type: !8) +!12 = !DIObjCProperty(name: "customAccessorsProp", file: !3, line: 9, setter: "customSetter:", getter: "customGetter", attributes: 2446, type: !8) +!13 = !DIDerivedType(tag: DW_TAG_member, name: "someBackingIvar", scope: !3, file: !3, line: 2, baseType: !8, size: 32, flags: DIFlagProtected, extraData: !9) +!14 = !DIDerivedType(tag: DW_TAG_member, name: "_autoSynthProp", scope: !3, file: !3, line: 5, baseType: !8, size: 32, flags: DIFlagPrivate, extraData: !7) +!15 = !DIDerivedType(tag: DW_TAG_member, name: "_customGetterProp", scope: !3, file: !3, line: 7, baseType: !8, size: 32, flags: DIFlagPrivate, extraData: !10) +!16 = !DIDerivedType(tag: DW_TAG_member, name: "_customSetterProp", scope: !3, file: !3, line: 8, baseType: !8, size: 32, flags: DIFlagPrivate, extraData: !11) +!17 = !DISubprogram(name: "-[Foo customGetter]", scope: !5, file: !3, line: 19, type: !18, scopeLine: 19, flags: DIFlagPrototyped, spFlags: DISPFlagLocalToUnit) +!18 = !DISubroutineType(types: !19) +!19 = !{!8, !20, !21} +!20 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !5, size: 64, flags: DIFlagArtificial | DIFlagObjectPointer) +!21 = !DIDerivedType(tag: DW_TAG_typedef, name: "SEL", file: !3, baseType: !22, flags: DIFlagArtificial) +!22 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !23, size: 64) +!23 = !DICompositeType(tag: DW_TAG_structure_type, name: "objc_selector", file: !3, flags: DIFlagFwdDecl) +!24 = !DISubprogram(name: "-[Foo customSetter:]", scope: !5, file: !3, line: 23, type: !25, scopeLine: 23, flags: DIFlagPrototyped, spFlags: DISPFlagLocalToUnit) +!25 = !DISubroutineType(types: !26) +!26 = !{null, !20, !21, !8} +!27 = !DISubprogram(name: "-[Foo synthProp]", scope: !5, file: !3, line: 17, type: !18, scopeLine: 17, flags: DIFlagArtificial | DIFlagPrototyped, spFlags: DISPFlagLocalToUnit) +!28 = !DISubprogram(name: "-[Foo setSynthProp:]", scope: !5, file: !3, line: 17, type: !25, scopeLine: 17, flags: DIFlagArtificial | DIFlagPrototyped, spFlags: DISPFlagLocalToUnit) +!29 = !DISubprogram(name: "-[Foo autoSynthProp]", scope: !5, file: !3, line: 5, type: !18, scopeLine: 5, flags: DIFlagArtificial | DIFlagPrototyped, spFlags: DISPFlagLocalToUnit) +!30 = !DISubprogram(name: "-[Foo setAutoSynthProp:]", scope: !5, file: !3, line: 5, type: !25, scopeLine: 5, flags: DIFlagArtificial | DIFlagPrototyped, spFlags: DISPFlagLocalToUnit) +!31 = !DISubprogram(name: "-[Foo setCustomGetterProp:]", scope: !5, file: !3, line: 7, type: !25, scopeLine: 7, flags: DIFlagArtificial | DIFlagPrototyped, spFlags: DISPFlagLocalToUnit) +!32 = !DISubprogram(name: "-[Foo customSetterProp]", scope: !5, file: !3, line: 8, type: !18, scopeLine: 8, flags: DIFlagArtificial | DIFlagPrototyped, spFlags: DISPFlagLocalToUnit) + diff --git a/llvm/test/DebugInfo/Generic/objc-property.ll b/llvm/test/DebugInfo/Generic/objc-property.ll new file mode 100644 index 0000000000000..1ee792941bcbb --- /dev/null +++ b/llvm/test/DebugInfo/Generic/objc-property.ll @@ -0,0 +1,94 @@ +; UNSUPPORTED: target={{.*}}-aix{{.*}} +; +; RUN: llc -filetype=obj -o - %s | llvm-dwarfdump --debug-info - | FileCheck %s + +; CHECK: DW_TAG_structure_type +; CHECK: DW_AT_name ("Foo") +; +; 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: 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: 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: 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: 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:") +; 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_setter, DW_APPLE_PROPERTY_atomic, DW_APPLE_PROPERTY_unsafe_unretained +; +; CHECK: DW_TAG_member +; CHECK: DW_AT_name ("someBackingIvar") +; CHECK: DW_AT_APPLE_property (0x[[SYNTH]] "synthProp") +; +; CHECK: DW_TAG_member +; CHECK: DW_AT_name ("_autoSynthProp") +; CHECK: DW_AT_APPLE_property (0x[[AUTO_SYNTH]] "autoSynthProp") +; +; CHECK: DW_TAG_member +; CHECK: DW_AT_name ("_customGetterProp") +; CHECK: DW_AT_APPLE_property (0x[[GET]] "customGetterProp") +; +; CHECK: DW_TAG_member +; CHECK: DW_AT_name ("_customSetterProp") +; CHECK: DW_AT_APPLE_property (0x[[SET]] "customSetterProp") + +!llvm.module.flags = !{!0, !1} +!llvm.dbg.cu = !{!2} + +!0 = !{i32 7, !"Dwarf Version", i32 5} +!1 = !{i32 2, !"Debug Info Version", i32 3} +!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) +!3 = !DIFile(filename: "main.m", directory: "/tmp") +!4 = !{!5} +!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) +!6 = !{!7, !9, !10, !11, !12, !13, !14, !15, !16, !17, !24, !27, !28, !29, !30, !31, !32} +!7 = !DIObjCProperty(name: "autoSynthProp", file: !3, line: 5, attributes: 2316, type: !8) +!8 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) +!9 = !DIObjCProperty(name: "synthProp", file: !3, line: 6, attributes: 2316, type: !8) +!10 = !DIObjCProperty(name: "customGetterProp", file: !3, line: 7, getter: "customGetter", attributes: 2318, type: !8) +!11 = !DIObjCProperty(name: "customSetterProp", file: !3, line: 8, setter: "customSetter:", attributes: 2444, type: !8) +!12 = !DIObjCProperty(name: "customAccessorsProp", file: !3, line: 9, setter: "customSetter:", getter: "customGetter", attributes: 2446, type: !8) +!13 = !DIDerivedType(tag: DW_TAG_member, name: "someBackingIvar", scope: !3, file: !3, line: 2, baseType: !8, size: 32, flags: DIFlagProtected, extraData: !9) +!14 = !DIDerivedType(tag: DW_TAG_member, name: "_autoSynthProp", scope: !3, file: !3, line: 5, baseType: !8, size: 32, flags: DIFlagPrivate, extraData: !7) +!15 = !DIDerivedType(tag: DW_TAG_member, name: "_customGetterProp", scope: !3, file: !3, line: 7, baseType: !8, size: 32, flags: DIFlagPrivate, extraData: !10) +!16 = !DIDerivedType(tag: DW_TAG_member, name: "_customSetterProp", scope: !3, file: !3, line: 8, baseType: !8, size: 32, flags: DIFlagPrivate, extraData: !11) +!17 = !DISubprogram(name: "-[Foo customGetter]", scope: !5, file: !3, line: 19, type: !18, scopeLine: 19, flags: DIFlagPrototyped, spFlags: DISPFlagLocalToUnit) +!18 = !DISubroutineType(types: !19) +!19 = !{!8, !20, !21} +!20 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !5, size: 64, flags: DIFlagArtificial | DIFlagObjectPointer) +!21 = !DIDerivedType(tag: DW_TAG_typedef, name: "SEL", file: !3, baseType: !22, flags: DIFlagArtificial) +!22 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !23, size: 64) +!23 = !DICompositeType(tag: DW_TAG_structure_type, name: "objc_selector", file: !3, flags: DIFlagFwdDecl) +!24 = !DISubprogram(name: "-[Foo customSetter:]", scope: !5, file: !3, line: 23, type: !25, scopeLine: 23, flags: DIFlagPrototyped, spFlags: DISPFlagLocalToUnit) +!25 = !DISubroutineType(types: !26) +!26 = !{null, !20, !21, !8} +!27 = !DISubprogram(name: "-[Foo synthProp]", scope: !5, file: !3, line: 17, type: !18, scopeLine: 17, flags: DIFlagArtificial | DIFlagPrototyped, spFlags: DISPFlagLocalToUnit) +!28 = !DISubprogram(name: "-[Foo setSynthProp:]", scope: !5, file: !3, line: 17, type: !25, scopeLine: 17, flags: DIFlagArtificial | DIFlagPrototyped, spFlags: DISPFlagLocalToUnit) +!29 = !DISubprogram(name: "-[Foo autoSynthProp]", scope: !5, file: !3, line: 5, type: !18, scopeLine: 5, flags: DIFlagArtificial | DIFlagPrototyped, spFlags: DISPFlagLocalToUnit) +!30 = !DISubprogram(name: "-[Foo setAutoSynthProp:]", scope: !5, file: !3, line: 5, type: !25, scopeLine: 5, flags: DIFlagArtificial | DIFlagPrototyped, spFlags: DISPFlagLocalToUnit) +!31 = !DISubprogram(name: "-[Foo setCustomGetterProp:]", scope: !5, file: !3, line: 7, type: !25, scopeLine: 7, flags: DIFlagArtificial | DIFlagPrototyped, spFlags: DISPFlagLocalToUnit) +!32 = !DISubprogram(name: "-[Foo customSetterProp]", scope: !5, file: !3, line: 8, type: !18, scopeLine: 8, flags: DIFlagArtificial | DIFlagPrototyped, spFlags: DISPFlagLocalToUnit) + diff --git a/llvm/test/tools/llvm-dwarfdump/AArch64/DW_AT_APPLE_property.s b/llvm/test/tools/llvm-dwarfdump/AArch64/DW_AT_APPLE_property.s new file mode 100644 index 0000000000000..6c38791b0a083 --- /dev/null +++ b/llvm/test/tools/llvm-dwarfdump/AArch64/DW_AT_APPLE_property.s @@ -0,0 +1,126 @@ +# Checks that we correctly display the DW_AT_APPLE_property_name of a +# referenced DW_TAG_APPLE_property. +# +# RUN: llvm-mc -triple=aarch64--darwin -filetype=obj -o %t.o < %s +# RUN: not llvm-dwarfdump %t.o 2> %t.errs.txt | FileCheck %s +# RUN: FileCheck %s --check-prefix=ERRORS < %t.errs.txt + +# CHECK: 0x[[PROP_REF:[0-9a-f]+]]: DW_TAG_APPLE_property +# CHECK-NEXT: DW_AT_APPLE_property_name ("autoSynthProp") +# +# CHECK: 0x[[NO_NAME_PROP:[0-9a-f]+]]: DW_TAG_APPLE_property +# CHECK-NOT: DW_AT_APPLE_property_name +# +# CHECK: 0x[[INVALID_STRP:[0-9a-f]+]]: DW_TAG_APPLE_property +# CHECK-NEXT: DW_AT_APPLE_property_name +# +# CHECK: DW_TAG_member +# CHECK: DW_AT_APPLE_property (0x[[PROP_REF]] "autoSynthProp") +# CHECK: DW_AT_APPLE_property (0x[[NO_NAME_PROP]] "") +# CHECK: DW_AT_APPLE_property (0x{{.*}}) +# CHECK: DW_AT_APPLE_property (0x{{.*}}) +# CHECK: DW_AT_APPLE_property (0x[[INVALID_STRP]]) + +# ERRORS: error: decoding DW_AT_APPLE_property_name: not referencing a DW_TAG_APPLE_property +# ERRORS: error: decoding DW_AT_APPLE_property_name: invalid DIE +# ERRORS: error: decoding DW_AT_APPLE_property_name: DW_FORM_strp offset 102 is beyond .debug_str bounds + + .section __DWARF,__debug_abbrev,regular,debug +Lsection_abbrev: + .byte 1 ; Abbreviation Code + .byte 17 ; DW_TAG_compile_unit + .byte 1 ; DW_CHILDREN_yes + .byte 114 ; DW_AT_str_offsets_base + .byte 23 ; DW_FORM_sec_offset + .byte 0 ; EOM(1) + .byte 0 ; EOM(2) + .byte 2 ; Abbreviation Code + .byte 19 ; DW_TAG_structure_type + .byte 1 ; DW_CHILDREN_yes + .byte 3 ; DW_AT_name + .byte 37 ; DW_FORM_strx1 + .byte 0 ; EOM(1) + .byte 0 ; EOM(2) + .byte 3 ; Abbreviation Code + .ascii "\200\204\001" ; DW_TAG_APPLE_property + .byte 0 ; DW_CHILDREN_no + .ascii "\350\177" ; DW_AT_APPLE_property_name + .byte 37 ; DW_FORM_strx1 + .byte 0 ; EOM(1) + .byte 0 ; EOM(2) + .byte 4 ; Abbreviation Code + .ascii "\200\204\001" ; DW_TAG_APPLE_property + .byte 0 ; DW_CHILDREN_no + .byte 0 ; EOM(1) + .byte 0 ; EOM(2) + .byte 5 ; Abbreviation Code + .ascii "\200\204\001" ; DW_TAG_APPLE_property + .byte 0 ; DW_CHILDREN_no + .ascii "\350\177" ; DW_AT_APPLE_property_name + .byte 14 ; DW_FORM_strp + .byte 0 ; EOM(1) + .byte 0 ; EOM(2) + .byte 6 ; Abbreviation Code + .byte 13 ; DW_TAG_member + .byte 0 ; DW_CHILDREN_no + .byte 3 ; DW_AT_name + .byte 37 ; DW_FORM_strx1 + .ascii "\355\177" ; DW_AT_APPLE_property + .byte 19 ; DW_FORM_ref4 + .ascii "\355\177" ; DW_AT_APPLE_property + .byte 19 ; DW_FORM_ref4 + .ascii "\355\177" ; DW_AT_APPLE_property + .byte 19 ; DW_FORM_ref4 + .ascii "\355\177" ; DW_AT_APPLE_property + .byte 19 ; DW_FORM_ref4 + .ascii "\355\177" ; DW_AT_APPLE_property + .byte 19 ; DW_FORM_ref4 + .byte 0 ; EOM(1) + .byte 0 ; EOM(2) + .byte 0 ; EOM(3) + .section __DWARF,__debug_info,regular,debug +Lsection_info: +Lcu_begin0: +Lset0 = Ldebug_info_end0-Ldebug_info_start0 ; Length of Unit + .long Lset0 +Ldebug_info_start0: + .short 5 ; DWARF version number + .byte 1 ; DWARF Unit Type + .byte 8 ; Address Size (in bytes) +Lset1 = Lsection_abbrev-Lsection_abbrev ; Offset Into Abbrev. Section + .long Lset1 + .byte 1 ; Abbrev [1] DW_TAG_compile_unit +Lset2 = Lstr_offsets_base0-Lsection_str_off ; DW_AT_str_offsets_base + .long Lset2 + .byte 2 ; Abbrev [2] DW_TAG_structure_type + .byte 2 ; DW_AT_name + .byte 3 ; Abbrev [3] DW_TAG_APPLE_property + .byte 0 ; DW_AT_APPLE_property_name + .byte 4 ; Abbrev [4] DW_TAG_APPLE_property + .byte 5 ; Abbrev [5] DW_TAG_APPLE_property + .long 102 ; DW_AT_APPLE_property_name + .byte 6 ; Abbrev [6] DW_TAG_member + .byte 1 ; DW_AT_name + .long 19 ; DW_AT_APPLE_property + .long 21 ; DW_AT_APPLE_property + .long 17 ; DW_AT_APPLE_property + .long 0 ; DW_AT_APPLE_property + .long 22 ; DW_AT_APPLE_property + .byte 0 ; End Of Children Mark + .byte 0 ; End Of Children Mark +Ldebug_info_end0: + .section __DWARF,__debug_str_offs,regular,debug +Lsection_str_off: + .long 16 ; Length of String Offsets Set + .short 5 + .short 0 +Lstr_offsets_base0: + .section __DWARF,__debug_str,regular,debug +Linfo_string: + .asciz "autoSynthProp" ; string offset=0 + .asciz "_var" ; string offset=14 + .asciz "Foo" ; string offset=19 + .section __DWARF,__debug_str_offs,regular,debug + .long 0 + .long 14 + .long 19