Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions clang/test/DebugInfo/ObjC/property-2.m

This file was deleted.

13 changes: 13 additions & 0 deletions clang/test/DebugInfo/ObjC/property-auto-synth.m
Original file line number Diff line number Diff line change
@@ -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) {}
20 changes: 20 additions & 0 deletions clang/test/DebugInfo/ObjC/property-basic.m
Original file line number Diff line number Diff line change
@@ -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
34 changes: 34 additions & 0 deletions clang/test/DebugInfo/ObjC/property-explicit-accessors.m
Original file line number Diff line number Diff line change
@@ -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) {}
22 changes: 22 additions & 0 deletions clang/test/DebugInfo/ObjC/property-explicit-ivar.m
Original file line number Diff line number Diff line change
@@ -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) {}
15 changes: 0 additions & 15 deletions clang/test/DebugInfo/ObjC/property.m

This file was deleted.

15 changes: 0 additions & 15 deletions clang/test/DebugInfo/ObjC/property2.m

This file was deleted.

18 changes: 0 additions & 18 deletions clang/test/DebugInfo/ObjC/property4.m

This file was deleted.

33 changes: 0 additions & 33 deletions clang/test/DebugInfo/ObjC/property5.m

This file was deleted.

4 changes: 2 additions & 2 deletions llvm/lib/AsmParser/LLParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
5 changes: 3 additions & 2 deletions llvm/lib/Bitcode/Reader/MetadataLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1097,7 +1097,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())
Expand Down
28 changes: 28 additions & 0 deletions llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,25 @@ static DWARFDie resolveReferencedType(DWARFDie D, DWARFFormValue F) {
return D.getAttributeValueAsReferencedDie(F).resolveTypeUnitReference();
}

static llvm::Expected<llvm::StringRef>
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) {
Expand Down Expand Up @@ -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()) {
Expand Down
46 changes: 46 additions & 0 deletions llvm/test/Bitcode/dwarf-objc-property.ll
Original file line number Diff line number Diff line change
@@ -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)

Loading