diff --git a/include/llvm/IR/DebugInfoMetadata.h b/include/llvm/IR/DebugInfoMetadata.h index 0125de5d40f5..03dd90159468 100644 --- a/include/llvm/IR/DebugInfoMetadata.h +++ b/include/llvm/IR/DebugInfoMetadata.h @@ -2092,7 +2092,7 @@ class DIObjCProperty : public DINode { static DIObjCProperty * getImpl(LLVMContext &Context, StringRef Name, DIFile *File, unsigned Line, StringRef GetterName, StringRef SetterName, unsigned Attributes, - DIType *Type, StorageType Storage, bool ShouldCreate = true) { + DITypeRef Type, StorageType Storage, bool ShouldCreate = true) { return getImpl(Context, getCanonicalMDString(Context, Name), File, Line, getCanonicalMDString(Context, GetterName), getCanonicalMDString(Context, SetterName), Attributes, Type, @@ -2114,7 +2114,7 @@ class DIObjCProperty : public DINode { DEFINE_MDNODE_GET(DIObjCProperty, (StringRef Name, DIFile *File, unsigned Line, StringRef GetterName, StringRef SetterName, - unsigned Attributes, DIType *Type), + unsigned Attributes, DITypeRef Type), (Name, File, Line, GetterName, SetterName, Attributes, Type)) DEFINE_MDNODE_GET(DIObjCProperty, @@ -2132,12 +2132,7 @@ class DIObjCProperty : public DINode { DIFile *getFile() const { return cast_or_null(getRawFile()); } StringRef getGetterName() const { return getStringOperand(2); } StringRef getSetterName() const { return getStringOperand(3); } - - /// \brief Get the type. - /// - /// \note Objective-C doesn't have an ODR, so there is no benefit in storing - /// a type ref here. - DIType *getType() const { return cast_or_null(getRawType()); } + DITypeRef getType() const { return DITypeRef(getRawType()); } StringRef getFilename() const { if (auto *F = getFile()) diff --git a/lib/CodeGen/AsmPrinter/DwarfUnit.cpp b/lib/CodeGen/AsmPrinter/DwarfUnit.cpp index 907f6706bc6a..5c6dc3d38ad7 100644 --- a/lib/CodeGen/AsmPrinter/DwarfUnit.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfUnit.cpp @@ -931,7 +931,7 @@ void DwarfUnit::constructTypeDIE(DIE &Buffer, const DICompositeType *CTy) { StringRef PropertyName = Property->getName(); addString(ElemDie, dwarf::DW_AT_APPLE_property_name, PropertyName); if (Property->getType()) - addType(ElemDie, Property->getType()); + addType(ElemDie, resolve(Property->getType())); addSourceLine(ElemDie, Property); StringRef GetterName = Property->getGetterName(); if (!GetterName.empty()) diff --git a/lib/IR/DIBuilder.cpp b/lib/IR/DIBuilder.cpp index b1925ea5c48f..f23f280c978a 100644 --- a/lib/IR/DIBuilder.cpp +++ b/lib/IR/DIBuilder.cpp @@ -327,7 +327,8 @@ DIBuilder::createObjCProperty(StringRef Name, DIFile *File, unsigned LineNumber, StringRef GetterName, StringRef SetterName, unsigned PropertyAttributes, DIType *Ty) { return DIObjCProperty::get(VMContext, Name, File, LineNumber, GetterName, - SetterName, PropertyAttributes, Ty); + SetterName, PropertyAttributes, + DITypeRef::get(Ty)); } DITemplateTypeParameter * diff --git a/lib/IR/Verifier.cpp b/lib/IR/Verifier.cpp index c0a8eec6c187..5fac05527bbf 100644 --- a/lib/IR/Verifier.cpp +++ b/lib/IR/Verifier.cpp @@ -1086,7 +1086,7 @@ void Verifier::visitDIExpression(const DIExpression &N) { void Verifier::visitDIObjCProperty(const DIObjCProperty &N) { Assert(N.getTag() == dwarf::DW_TAG_APPLE_property, "invalid tag", &N); if (auto *T = N.getRawType()) - Assert(isa(T), "invalid type ref", &N, T); + Assert(isTypeRef(N, T), "invalid type ref", &N, T); if (auto *F = N.getRawFile()) Assert(isa(F), "invalid file", &N, F); } diff --git a/unittests/IR/MetadataTest.cpp b/unittests/IR/MetadataTest.cpp index 6994e2133f6f..b255ba8e0348 100644 --- a/unittests/IR/MetadataTest.cpp +++ b/unittests/IR/MetadataTest.cpp @@ -1945,7 +1945,7 @@ TEST_F(DIObjCPropertyTest, get) { StringRef GetterName = "getter"; StringRef SetterName = "setter"; unsigned Attributes = 7; - DIType *Type = cast(getBasicType("basic")); + DITypeRef Type = getBasicType("basic"); auto *N = DIObjCProperty::get(Context, Name, File, Line, GetterName, SetterName, Attributes, Type); @@ -1975,7 +1975,7 @@ TEST_F(DIObjCPropertyTest, get) { SetterName, Attributes + 1, Type)); EXPECT_NE(N, DIObjCProperty::get(Context, Name, File, Line, GetterName, SetterName, Attributes, - cast(getBasicType("other")))); + getBasicType("other"))); TempDIObjCProperty Temp = N->clone(); EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp)));