DebugInfo: Use MDTypeRef throughout the hierarchy

Use `MDTypeRef` (etc.) in the new debug info hierarchy rather than raw
`Metadata *` pointers.

I rolled in a change to `DIBuilder` that looks unrelated: take `DIType`
instead of `DITypeRef` as type arguments when creating variables.
However, this was the simplest way to use `MDTypeRef` within the
functions, and didn't require any cleanups from callers in clang (since
they were all passing in `DIType`s anyway, relying on their implicit
conversions to `DITypeRef`).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234197 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Duncan P. N. Exon Smith 2015-04-06 19:03:45 +00:00
parent ebb3c53316
commit e009b6fd92
8 changed files with 206 additions and 186 deletions

View File

@ -464,7 +464,7 @@ namespace llvm {
/// @param Decl Reference to the corresponding declaration. /// @param Decl Reference to the corresponding declaration.
DIGlobalVariable createGlobalVariable(DIDescriptor Context, StringRef Name, DIGlobalVariable createGlobalVariable(DIDescriptor Context, StringRef Name,
StringRef LinkageName, DIFile File, StringRef LinkageName, DIFile File,
unsigned LineNo, DITypeRef Ty, unsigned LineNo, DIType Ty,
bool isLocalToUnit, bool isLocalToUnit,
llvm::Constant *Val, llvm::Constant *Val,
MDNode *Decl = nullptr); MDNode *Decl = nullptr);
@ -473,7 +473,7 @@ namespace llvm {
/// except that the resulting DbgNode is temporary and meant to be RAUWed. /// except that the resulting DbgNode is temporary and meant to be RAUWed.
DIGlobalVariable createTempGlobalVariableFwdDecl( DIGlobalVariable createTempGlobalVariableFwdDecl(
DIDescriptor Context, StringRef Name, StringRef LinkageName, DIDescriptor Context, StringRef Name, StringRef LinkageName,
DIFile File, unsigned LineNo, DITypeRef Ty, bool isLocalToUnit, DIFile File, unsigned LineNo, DIType Ty, bool isLocalToUnit,
llvm::Constant *Val, MDNode *Decl = nullptr); llvm::Constant *Val, MDNode *Decl = nullptr);
/// createLocalVariable - Create a new descriptor for the specified /// createLocalVariable - Create a new descriptor for the specified
@ -491,11 +491,9 @@ namespace llvm {
/// @param ArgNo If this variable is an argument then this argument's /// @param ArgNo If this variable is an argument then this argument's
/// number. 1 indicates 1st argument. /// number. 1 indicates 1st argument.
DIVariable createLocalVariable(unsigned Tag, DIDescriptor Scope, DIVariable createLocalVariable(unsigned Tag, DIDescriptor Scope,
StringRef Name, StringRef Name, DIFile File, unsigned LineNo,
DIFile File, unsigned LineNo, DIType Ty, bool AlwaysPreserve = false,
DITypeRef Ty, bool AlwaysPreserve = false, unsigned Flags = 0, unsigned ArgNo = 0);
unsigned Flags = 0,
unsigned ArgNo = 0);
/// createExpression - Create a new descriptor for the specified /// createExpression - Create a new descriptor for the specified
/// variable which has a complex address expression for its address. /// variable which has a complex address expression for its address.

View File

@ -195,6 +195,9 @@ public:
template <typename T> class DITypedArray : public DIDescriptor { template <typename T> class DITypedArray : public DIDescriptor {
public: public:
explicit DITypedArray(const MDNode *N = nullptr) : DIDescriptor(N) {} explicit DITypedArray(const MDNode *N = nullptr) : DIDescriptor(N) {}
operator MDTuple *() const {
return const_cast<MDTuple *>(cast_or_null<MDTuple>(DbgNode));
}
unsigned getNumElements() const { unsigned getNumElements() const {
return DbgNode ? DbgNode->getNumOperands() : 0; return DbgNode ? DbgNode->getNumOperands() : 0;
} }

View File

@ -466,7 +466,7 @@ public:
uint64_t getOffsetInBits() const { return OffsetInBits; } uint64_t getOffsetInBits() const { return OffsetInBits; }
unsigned getFlags() const { return Flags; } unsigned getFlags() const { return Flags; }
Metadata *getScope() const { return getRawScope(); } MDScopeRef getScope() const { return MDScopeRef(getRawScope()); }
StringRef getName() const { return getStringOperand(2); } StringRef getName() const { return getStringOperand(2); }
@ -563,7 +563,7 @@ protected:
~MDDerivedTypeBase() {} ~MDDerivedTypeBase() {}
public: public:
Metadata *getBaseType() const { return getRawBaseType(); } MDTypeRef getBaseType() const { return MDTypeRef(getRawBaseType()); }
Metadata *getRawBaseType() const { return getOperand(3); } Metadata *getRawBaseType() const { return getOperand(3); }
static bool classof(const Metadata *MD) { static bool classof(const Metadata *MD) {
@ -592,7 +592,7 @@ class MDDerivedType : public MDDerivedTypeBase {
static MDDerivedType *getImpl(LLVMContext &Context, unsigned Tag, static MDDerivedType *getImpl(LLVMContext &Context, unsigned Tag,
StringRef Name, MDFile *File, unsigned Line, StringRef Name, MDFile *File, unsigned Line,
Metadata *Scope, Metadata *BaseType, MDScopeRef Scope, MDTypeRef BaseType,
uint64_t SizeInBits, uint64_t AlignInBits, uint64_t SizeInBits, uint64_t AlignInBits,
uint64_t OffsetInBits, unsigned Flags, uint64_t OffsetInBits, unsigned Flags,
Metadata *ExtraData, StorageType Storage, Metadata *ExtraData, StorageType Storage,
@ -626,11 +626,10 @@ public:
(Tag, Name, File, Line, Scope, BaseType, SizeInBits, (Tag, Name, File, Line, Scope, BaseType, SizeInBits,
AlignInBits, OffsetInBits, Flags, ExtraData)) AlignInBits, OffsetInBits, Flags, ExtraData))
DEFINE_MDNODE_GET(MDDerivedType, DEFINE_MDNODE_GET(MDDerivedType,
(unsigned Tag, StringRef Name, MDFile *File, (unsigned Tag, StringRef Name, MDFile *File, unsigned Line,
unsigned Line, Metadata *Scope, Metadata *BaseType, MDScopeRef Scope, MDTypeRef BaseType, uint64_t SizeInBits,
uint64_t SizeInBits, uint64_t AlignInBits, uint64_t AlignInBits, uint64_t OffsetInBits,
uint64_t OffsetInBits, unsigned Flags, unsigned Flags, Metadata *ExtraData = nullptr),
Metadata *ExtraData = nullptr),
(Tag, Name, File, Line, Scope, BaseType, SizeInBits, (Tag, Name, File, Line, Scope, BaseType, SizeInBits,
AlignInBits, OffsetInBits, Flags, ExtraData)) AlignInBits, OffsetInBits, Flags, ExtraData))
@ -672,7 +671,7 @@ public:
MDTuple *getElements() const { MDTuple *getElements() const {
return cast_or_null<MDTuple>(getRawElements()); return cast_or_null<MDTuple>(getRawElements());
} }
Metadata *getVTableHolder() const { return getRawVTableHolder(); } MDTypeRef getVTableHolder() const { return MDTypeRef(getRawVTableHolder()); }
MDTemplateParameterArray getTemplateParams() const { MDTemplateParameterArray getTemplateParams() const {
return cast_or_null<MDTuple>(getRawTemplateParams()); return cast_or_null<MDTuple>(getRawTemplateParams());
} }
@ -699,7 +698,7 @@ public:
#endif #endif
replaceOperandWith(4, Elements); replaceOperandWith(4, Elements);
} }
void replaceVTableHolder(Metadata *VTableHolder) { void replaceVTableHolder(MDTypeRef VTableHolder) {
replaceOperandWith(5, VTableHolder); replaceOperandWith(5, VTableHolder);
} }
void replaceTemplateParams(MDTemplateParameterArray TemplateParams) { void replaceTemplateParams(MDTemplateParameterArray TemplateParams) {
@ -732,10 +731,10 @@ class MDCompositeType : public MDCompositeTypeBase {
static MDCompositeType * static MDCompositeType *
getImpl(LLVMContext &Context, unsigned Tag, StringRef Name, Metadata *File, getImpl(LLVMContext &Context, unsigned Tag, StringRef Name, Metadata *File,
unsigned Line, Metadata *Scope, Metadata *BaseType, unsigned Line, MDScopeRef Scope, MDTypeRef BaseType,
uint64_t SizeInBits, uint64_t AlignInBits, uint64_t OffsetInBits, uint64_t SizeInBits, uint64_t AlignInBits, uint64_t OffsetInBits,
uint64_t Flags, Metadata *Elements, unsigned RuntimeLang, uint64_t Flags, MDTuple *Elements, unsigned RuntimeLang,
Metadata *VTableHolder, Metadata *TemplateParams, MDTypeRef VTableHolder, MDTemplateParameterArray TemplateParams,
StringRef Identifier, StorageType Storage, bool ShouldCreate = true) { StringRef Identifier, StorageType Storage, bool ShouldCreate = true) {
return getImpl(Context, Tag, getCanonicalMDString(Context, Name), File, return getImpl(Context, Tag, getCanonicalMDString(Context, Name), File,
Line, Scope, BaseType, SizeInBits, AlignInBits, OffsetInBits, Line, Scope, BaseType, SizeInBits, AlignInBits, OffsetInBits,
@ -761,12 +760,12 @@ class MDCompositeType : public MDCompositeTypeBase {
public: public:
DEFINE_MDNODE_GET(MDCompositeType, DEFINE_MDNODE_GET(MDCompositeType,
(unsigned Tag, StringRef Name, Metadata *File, (unsigned Tag, StringRef Name, MDFile *File, unsigned Line,
unsigned Line, Metadata *Scope, Metadata *BaseType, MDScopeRef Scope, MDTypeRef BaseType, uint64_t SizeInBits,
uint64_t SizeInBits, uint64_t AlignInBits, uint64_t AlignInBits, uint64_t OffsetInBits,
uint64_t OffsetInBits, unsigned Flags, Metadata *Elements, unsigned Flags, MDTuple *Elements, unsigned RuntimeLang,
unsigned RuntimeLang, Metadata *VTableHolder, MDTypeRef VTableHolder,
Metadata *TemplateParams = nullptr, MDTemplateParameterArray TemplateParams = nullptr,
StringRef Identifier = ""), StringRef Identifier = ""),
(Tag, Name, File, Line, Scope, BaseType, SizeInBits, (Tag, Name, File, Line, Scope, BaseType, SizeInBits,
AlignInBits, OffsetInBits, Flags, Elements, RuntimeLang, AlignInBits, OffsetInBits, Flags, Elements, RuntimeLang,
@ -1033,7 +1032,7 @@ public:
unsigned getLine() const { return SubclassData32; } unsigned getLine() const { return SubclassData32; }
unsigned getColumn() const { return SubclassData16; } unsigned getColumn() const { return SubclassData16; }
MDLocalScope *getScope() const { MDLocalScope *getScope() const {
return cast_or_null<MDLocalScope>(getRawScope()); return cast<MDLocalScope>(getRawScope());
} }
MDLocation *getInlinedAt() const { MDLocation *getInlinedAt() const {
return cast_or_null<MDLocation>(getRawInlinedAt()); return cast_or_null<MDLocation>(getRawInlinedAt());
@ -1090,14 +1089,14 @@ class MDSubprogram : public MDLocalScope {
~MDSubprogram() {} ~MDSubprogram() {}
static MDSubprogram * static MDSubprogram *
getImpl(LLVMContext &Context, Metadata *Scope, StringRef Name, getImpl(LLVMContext &Context, MDScopeRef Scope, StringRef Name,
StringRef LinkageName, MDFile *File, unsigned Line, StringRef LinkageName, MDFile *File, unsigned Line,
MDSubroutineType *Type, bool IsLocalToUnit, bool IsDefinition, MDSubroutineType *Type, bool IsLocalToUnit, bool IsDefinition,
unsigned ScopeLine, Metadata *ContainingType, unsigned Virtuality, unsigned ScopeLine, MDTypeRef ContainingType, unsigned Virtuality,
unsigned VirtualIndex, unsigned Flags, bool IsOptimized, unsigned VirtualIndex, unsigned Flags, bool IsOptimized,
ConstantAsMetadata *Function, MDTuple *TemplateParams, ConstantAsMetadata *Function, MDTemplateParameterArray TemplateParams,
MDSubprogram *Declaration, MDTuple *Variables, StorageType Storage, MDSubprogram *Declaration, MDLocalVariableArray Variables,
bool ShouldCreate = true) { StorageType Storage, bool ShouldCreate = true) {
return getImpl(Context, Scope, getCanonicalMDString(Context, Name), return getImpl(Context, Scope, getCanonicalMDString(Context, Name),
getCanonicalMDString(Context, LinkageName), File, Line, Type, getCanonicalMDString(Context, LinkageName), File, Line, Type,
IsLocalToUnit, IsDefinition, ScopeLine, ContainingType, IsLocalToUnit, IsDefinition, ScopeLine, ContainingType,
@ -1124,18 +1123,20 @@ class MDSubprogram : public MDLocalScope {
} }
public: public:
DEFINE_MDNODE_GET( DEFINE_MDNODE_GET(MDSubprogram,
MDSubprogram, (MDScopeRef Scope, StringRef Name, StringRef LinkageName,
(Metadata * Scope, StringRef Name, StringRef LinkageName, MDFile *File, MDFile *File, unsigned Line, MDSubroutineType *Type,
unsigned Line, MDSubroutineType *Type, bool IsLocalToUnit, bool IsLocalToUnit, bool IsDefinition, unsigned ScopeLine,
bool IsDefinition, unsigned ScopeLine, Metadata *ContainingType, MDTypeRef ContainingType, unsigned Virtuality,
unsigned Virtuality, unsigned VirtualIndex, unsigned Flags, unsigned VirtualIndex, unsigned Flags, bool IsOptimized,
bool IsOptimized, ConstantAsMetadata *Function = nullptr, ConstantAsMetadata *Function = nullptr,
MDTuple *TemplateParams = nullptr, MDSubprogram *Declaration = nullptr, MDTemplateParameterArray TemplateParams = nullptr,
MDTuple *Variables = nullptr), MDSubprogram *Declaration = nullptr,
(Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit, IsDefinition, MDLocalVariableArray Variables = nullptr),
ScopeLine, ContainingType, Virtuality, VirtualIndex, Flags, IsOptimized, (Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit,
Function, TemplateParams, Declaration, Variables)) IsDefinition, ScopeLine, ContainingType, Virtuality,
VirtualIndex, Flags, IsOptimized, Function, TemplateParams,
Declaration, Variables))
DEFINE_MDNODE_GET( DEFINE_MDNODE_GET(
MDSubprogram, MDSubprogram,
(Metadata * Scope, MDString *Name, MDString *LinkageName, Metadata *File, (Metadata * Scope, MDString *Name, MDString *LinkageName, Metadata *File,
@ -1160,7 +1161,7 @@ public:
bool isDefinition() const { return IsDefinition; } bool isDefinition() const { return IsDefinition; }
bool isOptimized() const { return IsOptimized; } bool isOptimized() const { return IsOptimized; }
Metadata *getScope() const { return getRawScope(); } MDScopeRef getScope() const { return MDScopeRef(getRawScope()); }
StringRef getName() const { return getStringOperand(2); } StringRef getName() const { return getStringOperand(2); }
StringRef getDisplayName() const { return getStringOperand(3); } StringRef getDisplayName() const { return getStringOperand(3); }
@ -1172,7 +1173,9 @@ public:
MDSubroutineType *getType() const { MDSubroutineType *getType() const {
return cast_or_null<MDSubroutineType>(getRawType()); return cast_or_null<MDSubroutineType>(getRawType());
} }
Metadata *getContainingType() const { return getRawContainingType(); } MDTypeRef getContainingType() const {
return MDTypeRef(getRawContainingType());
}
ConstantAsMetadata *getFunction() const { ConstantAsMetadata *getFunction() const {
return cast_or_null<ConstantAsMetadata>(getRawFunction()); return cast_or_null<ConstantAsMetadata>(getRawFunction());
@ -1386,9 +1389,10 @@ protected:
public: public:
StringRef getName() const { return getStringOperand(0); } StringRef getName() const { return getStringOperand(0); }
Metadata *getType() const { return getOperand(1); } MDTypeRef getType() const { return MDTypeRef(getRawType()); }
MDString *getRawName() const { return getOperandAs<MDString>(0); } MDString *getRawName() const { return getOperandAs<MDString>(0); }
Metadata *getRawType() const { return getOperand(1); }
static bool classof(const Metadata *MD) { static bool classof(const Metadata *MD) {
return MD->getMetadataID() == MDTemplateTypeParameterKind || return MD->getMetadataID() == MDTemplateTypeParameterKind ||
@ -1407,7 +1411,7 @@ class MDTemplateTypeParameter : public MDTemplateParameter {
~MDTemplateTypeParameter() {} ~MDTemplateTypeParameter() {}
static MDTemplateTypeParameter *getImpl(LLVMContext &Context, StringRef Name, static MDTemplateTypeParameter *getImpl(LLVMContext &Context, StringRef Name,
Metadata *Type, StorageType Storage, MDTypeRef Type, StorageType Storage,
bool ShouldCreate = true) { bool ShouldCreate = true) {
return getImpl(Context, getCanonicalMDString(Context, Name), Type, Storage, return getImpl(Context, getCanonicalMDString(Context, Name), Type, Storage,
ShouldCreate); ShouldCreate);
@ -1421,7 +1425,7 @@ class MDTemplateTypeParameter : public MDTemplateParameter {
} }
public: public:
DEFINE_MDNODE_GET(MDTemplateTypeParameter, (StringRef Name, Metadata *Type), DEFINE_MDNODE_GET(MDTemplateTypeParameter, (StringRef Name, MDTypeRef Type),
(Name, Type)) (Name, Type))
DEFINE_MDNODE_GET(MDTemplateTypeParameter, (MDString * Name, Metadata *Type), DEFINE_MDNODE_GET(MDTemplateTypeParameter, (MDString * Name, Metadata *Type),
(Name, Type)) (Name, Type))
@ -1444,7 +1448,7 @@ class MDTemplateValueParameter : public MDTemplateParameter {
~MDTemplateValueParameter() {} ~MDTemplateValueParameter() {}
static MDTemplateValueParameter *getImpl(LLVMContext &Context, unsigned Tag, static MDTemplateValueParameter *getImpl(LLVMContext &Context, unsigned Tag,
StringRef Name, Metadata *Type, StringRef Name, MDTypeRef Type,
Metadata *Value, StorageType Storage, Metadata *Value, StorageType Storage,
bool ShouldCreate = true) { bool ShouldCreate = true) {
return getImpl(Context, Tag, getCanonicalMDString(Context, Name), Type, return getImpl(Context, Tag, getCanonicalMDString(Context, Name), Type,
@ -1462,7 +1466,7 @@ class MDTemplateValueParameter : public MDTemplateParameter {
public: public:
DEFINE_MDNODE_GET(MDTemplateValueParameter, (unsigned Tag, StringRef Name, DEFINE_MDNODE_GET(MDTemplateValueParameter, (unsigned Tag, StringRef Name,
Metadata *Type, Metadata *Value), MDTypeRef Type, Metadata *Value),
(Tag, Name, Type, Value)) (Tag, Name, Type, Value))
DEFINE_MDNODE_GET(MDTemplateValueParameter, (unsigned Tag, MDString *Name, DEFINE_MDNODE_GET(MDTemplateValueParameter, (unsigned Tag, MDString *Name,
Metadata *Type, Metadata *Value), Metadata *Type, Metadata *Value),
@ -1494,7 +1498,7 @@ public:
MDScope *getScope() const { return cast_or_null<MDScope>(getRawScope()); } MDScope *getScope() const { return cast_or_null<MDScope>(getRawScope()); }
StringRef getName() const { return getStringOperand(1); } StringRef getName() const { return getStringOperand(1); }
MDFile *getFile() const { return cast_or_null<MDFile>(getRawFile()); } MDFile *getFile() const { return cast_or_null<MDFile>(getRawFile()); }
Metadata *getType() const { return getRawType(); } MDTypeRef getType() const { return MDTypeRef(getRawType()); }
Metadata *getRawScope() const { return getOperand(0); } Metadata *getRawScope() const { return getOperand(0); }
MDString *getRawName() const { return getOperandAs<MDString>(1); } MDString *getRawName() const { return getOperandAs<MDString>(1); }
@ -1527,7 +1531,7 @@ class MDGlobalVariable : public MDVariable {
static MDGlobalVariable * static MDGlobalVariable *
getImpl(LLVMContext &Context, MDScope *Scope, StringRef Name, getImpl(LLVMContext &Context, MDScope *Scope, StringRef Name,
StringRef LinkageName, MDFile *File, unsigned Line, Metadata *Type, StringRef LinkageName, MDFile *File, unsigned Line, MDTypeRef Type,
bool IsLocalToUnit, bool IsDefinition, ConstantAsMetadata *Variable, bool IsLocalToUnit, bool IsDefinition, ConstantAsMetadata *Variable,
MDDerivedType *StaticDataMemberDeclaration, StorageType Storage, MDDerivedType *StaticDataMemberDeclaration, StorageType Storage,
bool ShouldCreate = true) { bool ShouldCreate = true) {
@ -1553,7 +1557,7 @@ class MDGlobalVariable : public MDVariable {
public: public:
DEFINE_MDNODE_GET(MDGlobalVariable, DEFINE_MDNODE_GET(MDGlobalVariable,
(MDScope * Scope, StringRef Name, StringRef LinkageName, (MDScope * Scope, StringRef Name, StringRef LinkageName,
MDFile *File, unsigned Line, Metadata *Type, MDFile *File, unsigned Line, MDTypeRef Type,
bool IsLocalToUnit, bool IsDefinition, bool IsLocalToUnit, bool IsDefinition,
ConstantAsMetadata *Variable, ConstantAsMetadata *Variable,
MDDerivedType *StaticDataMemberDeclaration), MDDerivedType *StaticDataMemberDeclaration),
@ -1610,7 +1614,7 @@ class MDLocalVariable : public MDVariable {
static MDLocalVariable *getImpl(LLVMContext &Context, unsigned Tag, static MDLocalVariable *getImpl(LLVMContext &Context, unsigned Tag,
MDScope *Scope, StringRef Name, MDFile *File, MDScope *Scope, StringRef Name, MDFile *File,
unsigned Line, Metadata *Type, unsigned Arg, unsigned Line, MDTypeRef Type, unsigned Arg,
unsigned Flags, MDLocation *InlinedAt, unsigned Flags, MDLocation *InlinedAt,
StorageType Storage, StorageType Storage,
bool ShouldCreate = true) { bool ShouldCreate = true) {
@ -1634,7 +1638,7 @@ class MDLocalVariable : public MDVariable {
public: public:
DEFINE_MDNODE_GET(MDLocalVariable, DEFINE_MDNODE_GET(MDLocalVariable,
(unsigned Tag, MDLocalScope *Scope, StringRef Name, (unsigned Tag, MDLocalScope *Scope, StringRef Name,
MDFile *File, unsigned Line, Metadata *Type, unsigned Arg, MDFile *File, unsigned Line, MDTypeRef Type, unsigned Arg,
unsigned Flags, MDLocation *InlinedAt = nullptr), unsigned Flags, MDLocation *InlinedAt = nullptr),
(Tag, Scope, Name, File, Line, Type, Arg, Flags, InlinedAt)) (Tag, Scope, Name, File, Line, Type, Arg, Flags, InlinedAt))
DEFINE_MDNODE_GET(MDLocalVariable, DEFINE_MDNODE_GET(MDLocalVariable,

View File

@ -1695,7 +1695,7 @@ static void writeMDTemplateTypeParameter(raw_ostream &Out,
Out << "!MDTemplateTypeParameter("; Out << "!MDTemplateTypeParameter(";
MDFieldPrinter Printer(Out, TypePrinter, Machine, Context); MDFieldPrinter Printer(Out, TypePrinter, Machine, Context);
Printer.printString("name", N->getName()); Printer.printString("name", N->getName());
Printer.printMetadata("type", N->getType(), /* ShouldSkipNull */ false); Printer.printMetadata("type", N->getRawType(), /* ShouldSkipNull */ false);
Out << ")"; Out << ")";
} }
@ -1709,7 +1709,7 @@ static void writeMDTemplateValueParameter(raw_ostream &Out,
if (N->getTag() != dwarf::DW_TAG_template_value_parameter) if (N->getTag() != dwarf::DW_TAG_template_value_parameter)
Printer.printTag(N); Printer.printTag(N);
Printer.printString("name", N->getName()); Printer.printString("name", N->getName());
Printer.printMetadata("type", N->getType()); Printer.printMetadata("type", N->getRawType());
Printer.printMetadata("value", N->getValue(), /* ShouldSkipNull */ false); Printer.printMetadata("value", N->getValue(), /* ShouldSkipNull */ false);
Out << ")"; Out << ")";
} }

View File

@ -196,14 +196,14 @@ DIImportedEntity DIBuilder::createImportedModule(DIScope Context,
DIImportedEntity DIBuilder::createImportedDeclaration(DIScope Context, DIImportedEntity DIBuilder::createImportedDeclaration(DIScope Context,
DIDescriptor Decl, DIDescriptor Decl,
unsigned Line, StringRef Name) { unsigned Line,
StringRef Name) {
// Make sure to use the unique identifier based metadata reference for // Make sure to use the unique identifier based metadata reference for
// types that have one. // types that have one.
Metadata *V = return ::createImportedModule(
Decl.isType() ? static_cast<Metadata *>(DIType(Decl).getRef()) : Decl; VMContext, dwarf::DW_TAG_imported_declaration, Context,
return ::createImportedModule(VMContext, dwarf::DW_TAG_imported_declaration, DebugNodeRef::get(cast_or_null<DebugNode>(Decl.get())), Line, Name,
Context, V, Line, Name, AllImportedModules);
AllImportedModules);
} }
DIImportedEntity DIBuilder::createImportedDeclaration(DIScope Context, DIImportedEntity DIBuilder::createImportedDeclaration(DIScope Context,
@ -241,7 +241,7 @@ DIBuilder::createBasicType(StringRef Name, uint64_t SizeInBits,
DIDerivedType DIBuilder::createQualifiedType(unsigned Tag, DIType FromTy) { DIDerivedType DIBuilder::createQualifiedType(unsigned Tag, DIType FromTy) {
return MDDerivedType::get(VMContext, Tag, "", nullptr, 0, nullptr, return MDDerivedType::get(VMContext, Tag, "", nullptr, 0, nullptr,
FromTy.getRef(), 0, 0, 0, 0); MDTypeRef::get(FromTy), 0, 0, 0, 0);
} }
DIDerivedType DIDerivedType
@ -249,30 +249,30 @@ DIBuilder::createPointerType(DIType PointeeTy, uint64_t SizeInBits,
uint64_t AlignInBits, StringRef Name) { uint64_t AlignInBits, StringRef Name) {
// FIXME: Why is there a name here? // FIXME: Why is there a name here?
return MDDerivedType::get(VMContext, dwarf::DW_TAG_pointer_type, Name, return MDDerivedType::get(VMContext, dwarf::DW_TAG_pointer_type, Name,
nullptr, 0, nullptr, PointeeTy.getRef(), SizeInBits, nullptr, 0, nullptr, MDTypeRef::get(PointeeTy),
AlignInBits, 0, 0); SizeInBits, AlignInBits, 0, 0);
} }
DIDerivedType DIDerivedType
DIBuilder::createMemberPointerType(DIType PointeeTy, DIType Base, DIBuilder::createMemberPointerType(DIType PointeeTy, DIType Base,
uint64_t SizeInBits, uint64_t AlignInBits) { uint64_t SizeInBits, uint64_t AlignInBits) {
return MDDerivedType::get(VMContext, dwarf::DW_TAG_ptr_to_member_type, "", return MDDerivedType::get(VMContext, dwarf::DW_TAG_ptr_to_member_type, "",
nullptr, 0, nullptr, PointeeTy.getRef(), SizeInBits, nullptr, 0, nullptr, MDTypeRef::get(PointeeTy),
AlignInBits, 0, 0, Base.getRef()); SizeInBits, AlignInBits, 0, 0, MDTypeRef::get(Base));
} }
DIDerivedType DIBuilder::createReferenceType(unsigned Tag, DIType RTy) { DIDerivedType DIBuilder::createReferenceType(unsigned Tag, DIType RTy) {
assert(RTy.isType() && "Unable to create reference type"); assert(RTy.isType() && "Unable to create reference type");
return MDDerivedType::get(VMContext, Tag, "", nullptr, 0, nullptr, return MDDerivedType::get(VMContext, Tag, "", nullptr, 0, nullptr,
RTy.getRef(), 0, 0, 0, 0); MDTypeRef::get(RTy), 0, 0, 0, 0);
} }
DIDerivedType DIBuilder::createTypedef(DIType Ty, StringRef Name, DIFile File, DIDerivedType DIBuilder::createTypedef(DIType Ty, StringRef Name, DIFile File,
unsigned LineNo, DIDescriptor Context) { unsigned LineNo, DIDescriptor Context) {
return MDDerivedType::get(VMContext, dwarf::DW_TAG_typedef, Name, File, return MDDerivedType::get(
LineNo, VMContext, dwarf::DW_TAG_typedef, Name, File, LineNo,
DIScope(getNonCompileUnitScope(Context)).getRef(), MDScopeRef::get(DIScope(getNonCompileUnitScope(Context))),
Ty.getRef(), 0, 0, 0, 0); MDTypeRef::get(Ty), 0, 0, 0, 0);
} }
DIDerivedType DIBuilder::createFriend(DIType Ty, DIType FriendTy) { DIDerivedType DIBuilder::createFriend(DIType Ty, DIType FriendTy) {
@ -280,7 +280,8 @@ DIDerivedType DIBuilder::createFriend(DIType Ty, DIType FriendTy) {
assert(Ty.isType() && "Invalid type!"); assert(Ty.isType() && "Invalid type!");
assert(FriendTy.isType() && "Invalid friend type!"); assert(FriendTy.isType() && "Invalid friend type!");
return MDDerivedType::get(VMContext, dwarf::DW_TAG_friend, "", nullptr, 0, return MDDerivedType::get(VMContext, dwarf::DW_TAG_friend, "", nullptr, 0,
Ty.getRef(), FriendTy.getRef(), 0, 0, 0, 0); MDTypeRef::get(Ty), MDTypeRef::get(FriendTy), 0, 0,
0, 0);
} }
DIDerivedType DIBuilder::createInheritance(DIType Ty, DIType BaseTy, DIDerivedType DIBuilder::createInheritance(DIType Ty, DIType BaseTy,
@ -288,8 +289,8 @@ DIDerivedType DIBuilder::createInheritance(DIType Ty, DIType BaseTy,
unsigned Flags) { unsigned Flags) {
assert(Ty.isType() && "Unable to create inheritance"); assert(Ty.isType() && "Unable to create inheritance");
return MDDerivedType::get(VMContext, dwarf::DW_TAG_inheritance, "", nullptr, return MDDerivedType::get(VMContext, dwarf::DW_TAG_inheritance, "", nullptr,
0, Ty.getRef(), BaseTy.getRef(), 0, 0, BaseOffset, 0, MDTypeRef::get(Ty), MDTypeRef::get(BaseTy), 0, 0,
Flags); BaseOffset, Flags);
} }
DIDerivedType DIBuilder::createMemberType(DIDescriptor Scope, StringRef Name, DIDerivedType DIBuilder::createMemberType(DIDescriptor Scope, StringRef Name,
@ -300,8 +301,8 @@ DIDerivedType DIBuilder::createMemberType(DIDescriptor Scope, StringRef Name,
DIType Ty) { DIType Ty) {
return MDDerivedType::get( return MDDerivedType::get(
VMContext, dwarf::DW_TAG_member, Name, File, LineNumber, VMContext, dwarf::DW_TAG_member, Name, File, LineNumber,
DIScope(getNonCompileUnitScope(Scope)).getRef(), Ty.getRef(), SizeInBits, MDScopeRef::get(DIScope(getNonCompileUnitScope(Scope))),
AlignInBits, OffsetInBits, Flags); MDTypeRef::get(Ty), SizeInBits, AlignInBits, OffsetInBits, Flags);
} }
static ConstantAsMetadata *getConstantOrNull(Constant *C) { static ConstantAsMetadata *getConstantOrNull(Constant *C) {
@ -319,8 +320,8 @@ DIDerivedType DIBuilder::createStaticMemberType(DIDescriptor Scope,
Flags |= DIDescriptor::FlagStaticMember; Flags |= DIDescriptor::FlagStaticMember;
return MDDerivedType::get( return MDDerivedType::get(
VMContext, dwarf::DW_TAG_member, Name, File, LineNumber, VMContext, dwarf::DW_TAG_member, Name, File, LineNumber,
DIScope(getNonCompileUnitScope(Scope)).getRef(), Ty.getRef(), 0, 0, 0, MDScopeRef::get(DIScope(getNonCompileUnitScope(Scope))),
Flags, getConstantOrNull(Val)); MDTypeRef::get(Ty), 0, 0, 0, Flags, getConstantOrNull(Val));
} }
DIDerivedType DIBuilder::createObjCIVar(StringRef Name, DIFile File, DIDerivedType DIBuilder::createObjCIVar(StringRef Name, DIFile File,
@ -329,10 +330,10 @@ DIDerivedType DIBuilder::createObjCIVar(StringRef Name, DIFile File,
uint64_t AlignInBits, uint64_t AlignInBits,
uint64_t OffsetInBits, unsigned Flags, uint64_t OffsetInBits, unsigned Flags,
DIType Ty, MDNode *PropertyNode) { DIType Ty, MDNode *PropertyNode) {
return MDDerivedType::get(VMContext, dwarf::DW_TAG_member, Name, File, return MDDerivedType::get(
LineNumber, getNonCompileUnitScope(File), VMContext, dwarf::DW_TAG_member, Name, File, LineNumber,
Ty.getRef(), SizeInBits, AlignInBits, OffsetInBits, MDScopeRef::get(getNonCompileUnitScope(File)), MDTypeRef::get(Ty),
Flags, PropertyNode); SizeInBits, AlignInBits, OffsetInBits, Flags, PropertyNode);
} }
DIObjCProperty DIObjCProperty
@ -346,18 +347,19 @@ DIBuilder::createObjCProperty(StringRef Name, DIFile File, unsigned LineNumber,
DITemplateTypeParameter DITemplateTypeParameter
DIBuilder::createTemplateTypeParameter(DIDescriptor Context, StringRef Name, DIBuilder::createTemplateTypeParameter(DIDescriptor Context, StringRef Name,
DIType Ty) { DIType Ty) {
assert(!DIScope(getNonCompileUnitScope(Context)).getRef() && assert((!Context || isa<MDCompileUnit>(Context.get())) &&
"Expected compile unit"); "Expected compile unit");
return MDTemplateTypeParameter::get(VMContext, Name, Ty.getRef()); return MDTemplateTypeParameter::get(VMContext, Name, MDTypeRef::get(Ty));
} }
static DITemplateValueParameter static DITemplateValueParameter
createTemplateValueParameterHelper(LLVMContext &VMContext, unsigned Tag, createTemplateValueParameterHelper(LLVMContext &VMContext, unsigned Tag,
DIDescriptor Context, StringRef Name, DIDescriptor Context, StringRef Name,
DIType Ty, Metadata *MD) { DIType Ty, Metadata *MD) {
assert(!DIScope(getNonCompileUnitScope(Context)).getRef() && assert((!Context || isa<MDCompileUnit>(Context.get())) &&
"Expected compile unit"); "Expected compile unit");
return MDTemplateValueParameter::get(VMContext, Tag, Name, Ty.getRef(), MD); return MDTemplateValueParameter::get(VMContext, Tag, Name, MDTypeRef::get(Ty),
MD);
} }
DITemplateValueParameter DITemplateValueParameter
@ -399,9 +401,10 @@ DICompositeType DIBuilder::createClassType(DIDescriptor Context, StringRef Name,
// TAG_class_type is encoded in DICompositeType format. // TAG_class_type is encoded in DICompositeType format.
DICompositeType R = MDCompositeType::get( DICompositeType R = MDCompositeType::get(
VMContext, dwarf::DW_TAG_structure_type, Name, File, LineNumber, VMContext, dwarf::DW_TAG_structure_type, Name, File, LineNumber,
DIScope(getNonCompileUnitScope(Context)).getRef(), DerivedFrom.getRef(), MDScopeRef::get(DIScope(getNonCompileUnitScope(Context))),
SizeInBits, AlignInBits, OffsetInBits, Flags, Elements, 0, MDTypeRef::get(DerivedFrom), SizeInBits, AlignInBits, OffsetInBits, Flags,
VTableHolder.getRef(), TemplateParams, UniqueIdentifier); Elements, 0, MDTypeRef::get(VTableHolder),
cast_or_null<MDTuple>(TemplateParams), UniqueIdentifier);
if (!UniqueIdentifier.empty()) if (!UniqueIdentifier.empty())
retainType(R); retainType(R);
trackIfUnresolved(R); trackIfUnresolved(R);
@ -420,9 +423,9 @@ DICompositeType DIBuilder::createStructType(DIDescriptor Context,
StringRef UniqueIdentifier) { StringRef UniqueIdentifier) {
DICompositeType R = MDCompositeType::get( DICompositeType R = MDCompositeType::get(
VMContext, dwarf::DW_TAG_structure_type, Name, File, LineNumber, VMContext, dwarf::DW_TAG_structure_type, Name, File, LineNumber,
DIScope(getNonCompileUnitScope(Context)).getRef(), DerivedFrom.getRef(), MDScopeRef::get(DIScope(getNonCompileUnitScope(Context))),
SizeInBits, AlignInBits, 0, Flags, Elements, RunTimeLang, MDTypeRef::get(DerivedFrom), SizeInBits, AlignInBits, 0, Flags, Elements,
VTableHolder.getRef(), nullptr, UniqueIdentifier); RunTimeLang, MDTypeRef::get(VTableHolder), nullptr, UniqueIdentifier);
if (!UniqueIdentifier.empty()) if (!UniqueIdentifier.empty())
retainType(R); retainType(R);
trackIfUnresolved(R); trackIfUnresolved(R);
@ -438,9 +441,9 @@ DICompositeType DIBuilder::createUnionType(DIDescriptor Scope, StringRef Name,
StringRef UniqueIdentifier) { StringRef UniqueIdentifier) {
DICompositeType R = MDCompositeType::get( DICompositeType R = MDCompositeType::get(
VMContext, dwarf::DW_TAG_union_type, Name, File, LineNumber, VMContext, dwarf::DW_TAG_union_type, Name, File, LineNumber,
DIScope(getNonCompileUnitScope(Scope)).getRef(), nullptr, SizeInBits, MDScopeRef::get(DIScope(getNonCompileUnitScope(Scope))), nullptr,
AlignInBits, 0, Flags, Elements, RunTimeLang, nullptr, nullptr, SizeInBits, AlignInBits, 0, Flags, Elements, RunTimeLang, nullptr,
UniqueIdentifier); nullptr, UniqueIdentifier);
if (!UniqueIdentifier.empty()) if (!UniqueIdentifier.empty())
retainType(R); retainType(R);
trackIfUnresolved(R); trackIfUnresolved(R);
@ -459,9 +462,9 @@ DICompositeType DIBuilder::createEnumerationType(
DIType UnderlyingType, StringRef UniqueIdentifier) { DIType UnderlyingType, StringRef UniqueIdentifier) {
DICompositeType CTy = MDCompositeType::get( DICompositeType CTy = MDCompositeType::get(
VMContext, dwarf::DW_TAG_enumeration_type, Name, File, LineNumber, VMContext, dwarf::DW_TAG_enumeration_type, Name, File, LineNumber,
DIScope(getNonCompileUnitScope(Scope)).getRef(), UnderlyingType.getRef(), MDScopeRef::get(DIScope(getNonCompileUnitScope(Scope))),
SizeInBits, AlignInBits, 0, 0, Elements, 0, nullptr, nullptr, MDTypeRef::get(UnderlyingType), SizeInBits, AlignInBits, 0, 0, Elements,
UniqueIdentifier); 0, nullptr, nullptr, UniqueIdentifier);
AllEnumTypes.push_back(CTy); AllEnumTypes.push_back(CTy);
if (!UniqueIdentifier.empty()) if (!UniqueIdentifier.empty())
retainType(CTy); retainType(CTy);
@ -472,7 +475,7 @@ DICompositeType DIBuilder::createEnumerationType(
DICompositeType DIBuilder::createArrayType(uint64_t Size, uint64_t AlignInBits, DICompositeType DIBuilder::createArrayType(uint64_t Size, uint64_t AlignInBits,
DIType Ty, DIArray Subscripts) { DIType Ty, DIArray Subscripts) {
auto *R = MDCompositeType::get(VMContext, dwarf::DW_TAG_array_type, "", auto *R = MDCompositeType::get(VMContext, dwarf::DW_TAG_array_type, "",
nullptr, 0, nullptr, Ty.getRef(), Size, nullptr, 0, nullptr, MDTypeRef::get(Ty), Size,
AlignInBits, 0, 0, Subscripts, 0, nullptr); AlignInBits, 0, 0, Subscripts, 0, nullptr);
trackIfUnresolved(R); trackIfUnresolved(R);
return R; return R;
@ -480,9 +483,10 @@ DICompositeType DIBuilder::createArrayType(uint64_t Size, uint64_t AlignInBits,
DICompositeType DIBuilder::createVectorType(uint64_t Size, uint64_t AlignInBits, DICompositeType DIBuilder::createVectorType(uint64_t Size, uint64_t AlignInBits,
DIType Ty, DIArray Subscripts) { DIType Ty, DIArray Subscripts) {
auto *R = MDCompositeType::get( auto *R =
VMContext, dwarf::DW_TAG_array_type, "", nullptr, 0, nullptr, Ty.getRef(), MDCompositeType::get(VMContext, dwarf::DW_TAG_array_type, "", nullptr, 0,
Size, AlignInBits, 0, DIType::FlagVector, Subscripts, 0, nullptr); nullptr, MDTypeRef::get(Ty), Size, AlignInBits, 0,
DIType::FlagVector, Subscripts, 0, nullptr);
trackIfUnresolved(R); trackIfUnresolved(R);
return R; return R;
} }
@ -526,10 +530,10 @@ DIBuilder::createForwardDecl(unsigned Tag, StringRef Name, DIDescriptor Scope,
// FIXME: Define in terms of createReplaceableForwardDecl() by calling // FIXME: Define in terms of createReplaceableForwardDecl() by calling
// replaceWithUniqued(). // replaceWithUniqued().
DICompositeType RetTy = MDCompositeType::get( DICompositeType RetTy = MDCompositeType::get(
VMContext, Tag, Name, F.getFileNode(), Line, VMContext, Tag, Name, F, Line,
DIScope(getNonCompileUnitScope(Scope)).getRef(), nullptr, SizeInBits, MDScopeRef::get(DIScope(getNonCompileUnitScope(Scope))), nullptr,
AlignInBits, 0, DIDescriptor::FlagFwdDecl, nullptr, RuntimeLang, nullptr, SizeInBits, AlignInBits, 0, DIDescriptor::FlagFwdDecl, nullptr,
nullptr, UniqueIdentifier); RuntimeLang, nullptr, nullptr, UniqueIdentifier);
if (!UniqueIdentifier.empty()) if (!UniqueIdentifier.empty())
retainType(RetTy); retainType(RetTy);
trackIfUnresolved(RetTy); trackIfUnresolved(RetTy);
@ -542,10 +546,11 @@ DICompositeType DIBuilder::createReplaceableCompositeType(
unsigned Flags, StringRef UniqueIdentifier) { unsigned Flags, StringRef UniqueIdentifier) {
DICompositeType RetTy = DICompositeType RetTy =
MDCompositeType::getTemporary( MDCompositeType::getTemporary(
VMContext, Tag, Name, F.getFileNode(), Line, VMContext, Tag, Name, F, Line,
DIScope(getNonCompileUnitScope(Scope)).getRef(), nullptr, SizeInBits, MDScopeRef::get(DIScope(getNonCompileUnitScope(Scope))), nullptr,
AlignInBits, 0, Flags, nullptr, RuntimeLang, SizeInBits, AlignInBits, 0, Flags, nullptr, RuntimeLang, nullptr,
nullptr, nullptr, UniqueIdentifier).release(); nullptr, UniqueIdentifier)
.release();
if (!UniqueIdentifier.empty()) if (!UniqueIdentifier.empty())
retainType(RetTy); retainType(RetTy);
trackIfUnresolved(RetTy); trackIfUnresolved(RetTy);
@ -560,7 +565,7 @@ DITypeArray DIBuilder::getOrCreateTypeArray(ArrayRef<Metadata *> Elements) {
SmallVector<llvm::Metadata *, 16> Elts; SmallVector<llvm::Metadata *, 16> Elts;
for (unsigned i = 0, e = Elements.size(); i != e; ++i) { for (unsigned i = 0, e = Elements.size(); i != e; ++i) {
if (Elements[i] && isa<MDNode>(Elements[i])) if (Elements[i] && isa<MDNode>(Elements[i]))
Elts.push_back(DIType(cast<MDNode>(Elements[i])).getRef()); Elts.push_back(MDTypeRef::get(DIType(cast<MDNode>(Elements[i]))));
else else
Elts.push_back(Elements[i]); Elts.push_back(Elements[i]);
} }
@ -581,33 +586,33 @@ static void checkGlobalVariableScope(DIDescriptor Context) {
DIGlobalVariable DIBuilder::createGlobalVariable( DIGlobalVariable DIBuilder::createGlobalVariable(
DIDescriptor Context, StringRef Name, StringRef LinkageName, DIFile F, DIDescriptor Context, StringRef Name, StringRef LinkageName, DIFile F,
unsigned LineNumber, DITypeRef Ty, bool isLocalToUnit, Constant *Val, unsigned LineNumber, DIType Ty, bool isLocalToUnit, Constant *Val,
MDNode *Decl) { MDNode *Decl) {
checkGlobalVariableScope(Context); checkGlobalVariableScope(Context);
auto *N = MDGlobalVariable::get( auto *N = MDGlobalVariable::get(
VMContext, cast_or_null<MDScope>(Context.get()), Name, LinkageName, F, VMContext, cast_or_null<MDScope>(Context.get()), Name, LinkageName, F,
LineNumber, Ty, isLocalToUnit, true, getConstantOrNull(Val), LineNumber, MDTypeRef::get(Ty), isLocalToUnit, true,
cast_or_null<MDDerivedType>(Decl)); getConstantOrNull(Val), cast_or_null<MDDerivedType>(Decl));
AllGVs.push_back(N); AllGVs.push_back(N);
return N; return N;
} }
DIGlobalVariable DIBuilder::createTempGlobalVariableFwdDecl( DIGlobalVariable DIBuilder::createTempGlobalVariableFwdDecl(
DIDescriptor Context, StringRef Name, StringRef LinkageName, DIFile F, DIDescriptor Context, StringRef Name, StringRef LinkageName, DIFile F,
unsigned LineNumber, DITypeRef Ty, bool isLocalToUnit, Constant *Val, unsigned LineNumber, DIType Ty, bool isLocalToUnit, Constant *Val,
MDNode *Decl) { MDNode *Decl) {
checkGlobalVariableScope(Context); checkGlobalVariableScope(Context);
return MDGlobalVariable::getTemporary( return MDGlobalVariable::getTemporary(
VMContext, cast_or_null<MDScope>(Context.get()), Name, LinkageName, VMContext, cast_or_null<MDScope>(Context.get()), Name, LinkageName,
F, LineNumber, Ty, isLocalToUnit, false, getConstantOrNull(Val), F, LineNumber, MDTypeRef::get(Ty), isLocalToUnit, false, getConstantOrNull(Val),
cast_or_null<MDDerivedType>(Decl)).release(); cast_or_null<MDDerivedType>(Decl)).release();
} }
DIVariable DIBuilder::createLocalVariable(unsigned Tag, DIDescriptor Scope, DIVariable DIBuilder::createLocalVariable(unsigned Tag, DIDescriptor Scope,
StringRef Name, DIFile File, StringRef Name, DIFile File,
unsigned LineNo, DITypeRef Ty, unsigned LineNo, DIType Ty,
bool AlwaysPreserve, unsigned Flags, bool AlwaysPreserve, unsigned Flags,
unsigned ArgNo) { unsigned ArgNo) {
// FIXME: Why getNonCompileUnitScope()? // FIXME: Why getNonCompileUnitScope()?
@ -618,9 +623,9 @@ DIVariable DIBuilder::createLocalVariable(unsigned Tag, DIDescriptor Scope,
assert((!Context || Context.isScope()) && assert((!Context || Context.isScope()) &&
"createLocalVariable should be called with a valid Context"); "createLocalVariable should be called with a valid Context");
auto *Node = MDLocalVariable::get(VMContext, Tag, auto *Node = MDLocalVariable::get(
cast_or_null<MDLocalScope>(Context.get()), VMContext, Tag, cast_or_null<MDLocalScope>(Context.get()), Name, File,
Name, File, LineNo, Ty, ArgNo, Flags); LineNo, MDTypeRef::get(Ty), ArgNo, Flags);
if (AlwaysPreserve) { if (AlwaysPreserve) {
// The optimizer may remove local variable. If there is an interest // The optimizer may remove local variable. If there is an interest
// to preserve variable info in such situation then stash it in a // to preserve variable info in such situation then stash it in a
@ -673,11 +678,11 @@ DISubprogram DIBuilder::createFunction(DIDescriptor Context, StringRef Name,
assert(Ty.getTag() == dwarf::DW_TAG_subroutine_type && assert(Ty.getTag() == dwarf::DW_TAG_subroutine_type &&
"function types should be subroutines"); "function types should be subroutines");
auto *Node = MDSubprogram::get( auto *Node = MDSubprogram::get(
VMContext, DIScope(getNonCompileUnitScope(Context)).getRef(), Name, VMContext, MDScopeRef::get(DIScope(getNonCompileUnitScope(Context))),
LinkageName, File.get(), LineNo, cast_or_null<MDSubroutineType>(Ty.get()), Name, LinkageName, File.get(), LineNo,
isLocalToUnit, isDefinition, ScopeLine, nullptr, 0, 0, Flags, isOptimized, cast_or_null<MDSubroutineType>(Ty.get()), isLocalToUnit, isDefinition,
getConstantOrNull(Fn), cast_or_null<MDTuple>(TParams), ScopeLine, nullptr, 0, 0, Flags, isOptimized, getConstantOrNull(Fn),
cast_or_null<MDSubprogram>(Decl), cast_or_null<MDTuple>(TParams), cast_or_null<MDSubprogram>(Decl),
MDTuple::getTemporary(VMContext, None).release()); MDTuple::getTemporary(VMContext, None).release());
if (isDefinition) if (isDefinition)
@ -695,12 +700,14 @@ DIBuilder::createTempFunctionFwdDecl(DIDescriptor Context, StringRef Name,
bool isOptimized, Function *Fn, bool isOptimized, Function *Fn,
MDNode *TParams, MDNode *Decl) { MDNode *TParams, MDNode *Decl) {
return MDSubprogram::getTemporary( return MDSubprogram::getTemporary(
VMContext, DIScope(getNonCompileUnitScope(Context)).getRef(), Name, VMContext,
MDScopeRef::get(DIScope(getNonCompileUnitScope(Context))), Name,
LinkageName, File.get(), LineNo, LinkageName, File.get(), LineNo,
cast_or_null<MDSubroutineType>(Ty.get()), isLocalToUnit, cast_or_null<MDSubroutineType>(Ty.get()), isLocalToUnit,
isDefinition, ScopeLine, nullptr, 0, 0, Flags, isOptimized, isDefinition, ScopeLine, nullptr, 0, 0, Flags, isOptimized,
getConstantOrNull(Fn), cast_or_null<MDTuple>(TParams), getConstantOrNull(Fn), cast_or_null<MDTuple>(TParams),
cast_or_null<MDSubprogram>(Decl), nullptr).release(); cast_or_null<MDSubprogram>(Decl), nullptr)
.release();
} }
DISubprogram DIBuilder::createMethod(DIDescriptor Context, StringRef Name, DISubprogram DIBuilder::createMethod(DIDescriptor Context, StringRef Name,
@ -718,10 +725,11 @@ DISubprogram DIBuilder::createMethod(DIDescriptor Context, StringRef Name,
"the compile unit."); "the compile unit.");
// FIXME: Do we want to use different scope/lines? // FIXME: Do we want to use different scope/lines?
auto *Node = MDSubprogram::get( auto *Node = MDSubprogram::get(
VMContext, DIScope(Context).getRef(), Name, LinkageName, F.get(), LineNo, VMContext, MDScopeRef::get(DIScope(Context)), Name, LinkageName, F.get(),
cast_or_null<MDSubroutineType>(Ty.get()), isLocalToUnit, isDefinition, LineNo, cast_or_null<MDSubroutineType>(Ty.get()), isLocalToUnit,
LineNo, VTableHolder.getRef(), VK, VIndex, Flags, isOptimized, isDefinition, LineNo, MDTypeRef::get(VTableHolder), VK, VIndex, Flags,
getConstantOrNull(Fn), cast_or_null<MDTuple>(TParam), nullptr, nullptr); isOptimized, getConstantOrNull(Fn), cast_or_null<MDTuple>(TParam),
nullptr, nullptr);
if (isDefinition) if (isDefinition)
AllSubprograms.push_back(Node); AllSubprograms.push_back(Node);

View File

@ -257,7 +257,7 @@ DIScopeRef DIScope::getRef() const { return MDScopeRef::get(get()); }
void DICompositeType::setContainingType(DICompositeType ContainingType) { void DICompositeType::setContainingType(DICompositeType ContainingType) {
TypedTrackingMDRef<MDCompositeTypeBase> N(get()); TypedTrackingMDRef<MDCompositeTypeBase> N(get());
N->replaceVTableHolder(ContainingType.getRef()); N->replaceVTableHolder(MDTypeRef::get(ContainingType));
DbgNode = N; DbgNode = N;
} }

View File

@ -653,10 +653,10 @@ template <> struct MDNodeKeyImpl<MDTemplateTypeParameter> {
MDNodeKeyImpl(StringRef Name, Metadata *Type) : Name(Name), Type(Type) {} MDNodeKeyImpl(StringRef Name, Metadata *Type) : Name(Name), Type(Type) {}
MDNodeKeyImpl(const MDTemplateTypeParameter *N) MDNodeKeyImpl(const MDTemplateTypeParameter *N)
: Name(N->getName()), Type(N->getType()) {} : Name(N->getName()), Type(N->getRawType()) {}
bool isKeyOf(const MDTemplateTypeParameter *RHS) const { bool isKeyOf(const MDTemplateTypeParameter *RHS) const {
return Name == RHS->getName() && Type == RHS->getType(); return Name == RHS->getName() && Type == RHS->getRawType();
} }
unsigned getHashValue() const { return hash_combine(Name, Type); } unsigned getHashValue() const { return hash_combine(Name, Type); }
}; };
@ -670,12 +670,12 @@ template <> struct MDNodeKeyImpl<MDTemplateValueParameter> {
MDNodeKeyImpl(unsigned Tag, StringRef Name, Metadata *Type, Metadata *Value) MDNodeKeyImpl(unsigned Tag, StringRef Name, Metadata *Type, Metadata *Value)
: Tag(Tag), Name(Name), Type(Type), Value(Value) {} : Tag(Tag), Name(Name), Type(Type), Value(Value) {}
MDNodeKeyImpl(const MDTemplateValueParameter *N) MDNodeKeyImpl(const MDTemplateValueParameter *N)
: Tag(N->getTag()), Name(N->getName()), Type(N->getType()), : Tag(N->getTag()), Name(N->getName()), Type(N->getRawType()),
Value(N->getValue()) {} Value(N->getValue()) {}
bool isKeyOf(const MDTemplateValueParameter *RHS) const { bool isKeyOf(const MDTemplateValueParameter *RHS) const {
return Tag == RHS->getTag() && Name == RHS->getName() && return Tag == RHS->getTag() && Name == RHS->getName() &&
Type == RHS->getType() && Value == RHS->getValue(); Type == RHS->getRawType() && Value == RHS->getValue();
} }
unsigned getHashValue() const { return hash_combine(Tag, Name, Type, Value); } unsigned getHashValue() const { return hash_combine(Tag, Name, Type, Value); }
}; };

View File

@ -85,25 +85,29 @@ protected:
nullptr, false, false, 0, nullptr, 0, 0, 0, nullptr, false, false, 0, nullptr, 0, 0, 0,
0); 0);
} }
MDScopeRef getSubprogramRef() { return getSubprogram()->getRef(); }
MDFile *getFile() { MDFile *getFile() {
return MDFile::getDistinct(Context, "file.c", "/path/to/dir"); return MDFile::getDistinct(Context, "file.c", "/path/to/dir");
} }
MDBasicType *getBasicType(StringRef Name) { MDTypeRef getBasicType(StringRef Name) {
return MDBasicType::get(Context, dwarf::DW_TAG_unspecified_type, Name); return MDBasicType::get(Context, dwarf::DW_TAG_unspecified_type, Name)
->getRef();
} }
MDDerivedType *getDerivedType() { MDTypeRef getDerivedType() {
return MDDerivedType::getDistinct(Context, dwarf::DW_TAG_pointer_type, "", return MDDerivedType::getDistinct(Context, dwarf::DW_TAG_pointer_type, "",
nullptr, 0, nullptr, nullptr, 0, nullptr,
getBasicType("basictype"), 1, 2, 0, 0); getBasicType("basictype"), 1, 2, 0, 0)
->getRef();
} }
ConstantAsMetadata *getConstantAsMetadata() { ConstantAsMetadata *getConstantAsMetadata() {
return ConstantAsMetadata::get( return ConstantAsMetadata::get(
ConstantInt::get(Type::getInt32Ty(Context), Counter++)); ConstantInt::get(Type::getInt32Ty(Context), Counter++));
} }
MDCompositeType *getCompositeType() { MDTypeRef getCompositeType() {
return MDCompositeType::getDistinct( return MDCompositeType::getDistinct(
Context, dwarf::DW_TAG_structure_type, "", nullptr, 0, nullptr, nullptr, Context, dwarf::DW_TAG_structure_type, "", nullptr, 0, nullptr,
32, 32, 0, 0, nullptr, 0, nullptr, nullptr, ""); nullptr, 32, 32, 0, 0, nullptr, 0, nullptr, nullptr, "")
->getRef();
} }
ConstantAsMetadata *getFunctionAsMetadata(StringRef Name) { ConstantAsMetadata *getFunctionAsMetadata(StringRef Name) {
return ConstantAsMetadata::get(M.getOrInsertFunction( return ConstantAsMetadata::get(M.getOrInsertFunction(
@ -958,8 +962,8 @@ typedef MetadataTest MDDerivedTypeTest;
TEST_F(MDDerivedTypeTest, get) { TEST_F(MDDerivedTypeTest, get) {
MDFile *File = getFile(); MDFile *File = getFile();
MDScope *Scope = getSubprogram(); MDScopeRef Scope = getSubprogramRef();
MDType *BaseType = getBasicType("basic"); MDTypeRef BaseType = getBasicType("basic");
MDTuple *ExtraData = getTuple(); MDTuple *ExtraData = getTuple();
auto *N = MDDerivedType::get(Context, dwarf::DW_TAG_pointer_type, "something", auto *N = MDDerivedType::get(Context, dwarf::DW_TAG_pointer_type, "something",
@ -992,7 +996,7 @@ TEST_F(MDDerivedTypeTest, get) {
"something", File, 2, Scope, BaseType, 2, 3, "something", File, 2, Scope, BaseType, 2, 3,
4, 5, ExtraData)); 4, 5, ExtraData));
EXPECT_NE(N, MDDerivedType::get(Context, dwarf::DW_TAG_pointer_type, EXPECT_NE(N, MDDerivedType::get(Context, dwarf::DW_TAG_pointer_type,
"something", File, 1, getSubprogram(), "something", File, 1, getSubprogramRef(),
BaseType, 2, 3, 4, 5, ExtraData)); BaseType, 2, 3, 4, 5, ExtraData));
EXPECT_NE(N, MDDerivedType::get( EXPECT_NE(N, MDDerivedType::get(
Context, dwarf::DW_TAG_pointer_type, "something", File, 1, Context, dwarf::DW_TAG_pointer_type, "something", File, 1,
@ -1019,8 +1023,8 @@ TEST_F(MDDerivedTypeTest, get) {
TEST_F(MDDerivedTypeTest, getWithLargeValues) { TEST_F(MDDerivedTypeTest, getWithLargeValues) {
MDFile *File = getFile(); MDFile *File = getFile();
MDScope *Scope = getSubprogram(); MDScopeRef Scope = getSubprogramRef();
MDType *BaseType = getBasicType("basic"); MDTypeRef BaseType = getBasicType("basic");
MDTuple *ExtraData = getTuple(); MDTuple *ExtraData = getTuple();
auto *N = MDDerivedType::get(Context, dwarf::DW_TAG_pointer_type, "something", auto *N = MDDerivedType::get(Context, dwarf::DW_TAG_pointer_type, "something",
@ -1038,15 +1042,15 @@ TEST_F(MDCompositeTypeTest, get) {
StringRef Name = "some name"; StringRef Name = "some name";
MDFile *File = getFile(); MDFile *File = getFile();
unsigned Line = 1; unsigned Line = 1;
MDScope *Scope = getSubprogram(); MDScopeRef Scope = getSubprogramRef();
MDType *BaseType = getCompositeType(); MDTypeRef BaseType = getCompositeType();
uint64_t SizeInBits = 2; uint64_t SizeInBits = 2;
uint64_t AlignInBits = 3; uint64_t AlignInBits = 3;
uint64_t OffsetInBits = 4; uint64_t OffsetInBits = 4;
unsigned Flags = 5; unsigned Flags = 5;
MDTuple *Elements = getTuple(); MDTuple *Elements = getTuple();
unsigned RuntimeLang = 6; unsigned RuntimeLang = 6;
MDType *VTableHolder = getCompositeType(); MDTypeRef VTableHolder = getCompositeType();
MDTuple *TemplateParams = getTuple(); MDTuple *TemplateParams = getTuple();
StringRef Identifier = "some id"; StringRef Identifier = "some id";
@ -1092,13 +1096,13 @@ TEST_F(MDCompositeTypeTest, get) {
OffsetInBits, Flags, Elements, RuntimeLang, OffsetInBits, Flags, Elements, RuntimeLang,
VTableHolder, TemplateParams, Identifier)); VTableHolder, TemplateParams, Identifier));
EXPECT_NE(N, MDCompositeType::get( EXPECT_NE(N, MDCompositeType::get(
Context, Tag, Name, File, Line, getSubprogram(), BaseType, Context, Tag, Name, File, Line, getSubprogramRef(), BaseType,
SizeInBits, AlignInBits, OffsetInBits, Flags, Elements,
RuntimeLang, VTableHolder, TemplateParams, Identifier));
EXPECT_NE(N, MDCompositeType::get(
Context, Tag, Name, File, Line, Scope, getBasicType("other"),
SizeInBits, AlignInBits, OffsetInBits, Flags, Elements, SizeInBits, AlignInBits, OffsetInBits, Flags, Elements,
RuntimeLang, VTableHolder, TemplateParams, Identifier)); RuntimeLang, VTableHolder, TemplateParams, Identifier));
EXPECT_NE(N, MDCompositeType::get(Context, Tag, Name, File, Line, Scope, File,
SizeInBits, AlignInBits, OffsetInBits,
Flags, Elements, RuntimeLang, VTableHolder,
TemplateParams, Identifier));
EXPECT_NE(N, MDCompositeType::get(Context, Tag, Name, File, Line, Scope, EXPECT_NE(N, MDCompositeType::get(Context, Tag, Name, File, Line, Scope,
BaseType, SizeInBits + 1, AlignInBits, BaseType, SizeInBits + 1, AlignInBits,
OffsetInBits, Flags, Elements, RuntimeLang, OffsetInBits, Flags, Elements, RuntimeLang,
@ -1155,15 +1159,15 @@ TEST_F(MDCompositeTypeTest, getWithLargeValues) {
StringRef Name = "some name"; StringRef Name = "some name";
MDFile *File = getFile(); MDFile *File = getFile();
unsigned Line = 1; unsigned Line = 1;
MDScope *Scope = getSubprogram(); MDScopeRef Scope = getSubprogramRef();
MDType *BaseType = getCompositeType(); MDTypeRef BaseType = getCompositeType();
uint64_t SizeInBits = UINT64_MAX; uint64_t SizeInBits = UINT64_MAX;
uint64_t AlignInBits = UINT64_MAX - 1; uint64_t AlignInBits = UINT64_MAX - 1;
uint64_t OffsetInBits = UINT64_MAX - 2; uint64_t OffsetInBits = UINT64_MAX - 2;
unsigned Flags = 5; unsigned Flags = 5;
MDTuple *Elements = getTuple(); MDTuple *Elements = getTuple();
unsigned RuntimeLang = 6; unsigned RuntimeLang = 6;
MDType *VTableHolder = getCompositeType(); MDTypeRef VTableHolder = getCompositeType();
MDTuple *TemplateParams = getTuple(); MDTuple *TemplateParams = getTuple();
StringRef Identifier = "some id"; StringRef Identifier = "some id";
@ -1181,8 +1185,8 @@ TEST_F(MDCompositeTypeTest, replaceOperands) {
StringRef Name = "some name"; StringRef Name = "some name";
MDFile *File = getFile(); MDFile *File = getFile();
unsigned Line = 1; unsigned Line = 1;
MDScope *Scope = getSubprogram(); MDScopeRef Scope = getSubprogramRef();
MDType *BaseType = getCompositeType(); MDTypeRef BaseType = getCompositeType();
uint64_t SizeInBits = 2; uint64_t SizeInBits = 2;
uint64_t AlignInBits = 3; uint64_t AlignInBits = 3;
uint64_t OffsetInBits = 4; uint64_t OffsetInBits = 4;
@ -1202,7 +1206,7 @@ TEST_F(MDCompositeTypeTest, replaceOperands) {
N->replaceElements(nullptr); N->replaceElements(nullptr);
EXPECT_EQ(nullptr, N->getElements()); EXPECT_EQ(nullptr, N->getElements());
auto *VTableHolder = MDTuple::getDistinct(Context, None); MDTypeRef VTableHolder = getCompositeType();
EXPECT_EQ(nullptr, N->getVTableHolder()); EXPECT_EQ(nullptr, N->getVTableHolder());
N->replaceVTableHolder(VTableHolder); N->replaceVTableHolder(VTableHolder);
EXPECT_EQ(VTableHolder, N->getVTableHolder()); EXPECT_EQ(VTableHolder, N->getVTableHolder());
@ -1413,7 +1417,7 @@ TEST_F(MDCompileUnitTest, replaceArrays) {
typedef MetadataTest MDSubprogramTest; typedef MetadataTest MDSubprogramTest;
TEST_F(MDSubprogramTest, get) { TEST_F(MDSubprogramTest, get) {
MDScope *Scope = getCompositeType(); MDScopeRef Scope = getCompositeType();
StringRef Name = "name"; StringRef Name = "name";
StringRef LinkageName = "linkage"; StringRef LinkageName = "linkage";
MDFile *File = getFile(); MDFile *File = getFile();
@ -1422,7 +1426,7 @@ TEST_F(MDSubprogramTest, get) {
bool IsLocalToUnit = false; bool IsLocalToUnit = false;
bool IsDefinition = true; bool IsDefinition = true;
unsigned ScopeLine = 3; unsigned ScopeLine = 3;
MDType *ContainingType = getCompositeType(); MDTypeRef ContainingType = getCompositeType();
unsigned Virtuality = 4; unsigned Virtuality = 4;
unsigned VirtualIndex = 5; unsigned VirtualIndex = 5;
unsigned Flags = 6; unsigned Flags = 6;
@ -1559,7 +1563,7 @@ TEST_F(MDSubprogramTest, get) {
} }
TEST_F(MDSubprogramTest, replaceFunction) { TEST_F(MDSubprogramTest, replaceFunction) {
MDScope *Scope = getCompositeType(); MDScopeRef Scope = getCompositeType();
StringRef Name = "name"; StringRef Name = "name";
StringRef LinkageName = "linkage"; StringRef LinkageName = "linkage";
MDFile *File = getFile(); MDFile *File = getFile();
@ -1568,7 +1572,7 @@ TEST_F(MDSubprogramTest, replaceFunction) {
bool IsLocalToUnit = false; bool IsLocalToUnit = false;
bool IsDefinition = true; bool IsDefinition = true;
unsigned ScopeLine = 3; unsigned ScopeLine = 3;
MDCompositeType *ContainingType = getCompositeType(); MDTypeRef ContainingType = getCompositeType();
unsigned Virtuality = 4; unsigned Virtuality = 4;
unsigned VirtualIndex = 5; unsigned VirtualIndex = 5;
unsigned Flags = 6; unsigned Flags = 6;
@ -1677,7 +1681,7 @@ typedef MetadataTest MDTemplateTypeParameterTest;
TEST_F(MDTemplateTypeParameterTest, get) { TEST_F(MDTemplateTypeParameterTest, get) {
StringRef Name = "template"; StringRef Name = "template";
MDType *Type = getBasicType("basic"); MDTypeRef Type = getBasicType("basic");
auto *N = MDTemplateTypeParameter::get(Context, Name, Type); auto *N = MDTemplateTypeParameter::get(Context, Name, Type);
@ -1699,7 +1703,7 @@ typedef MetadataTest MDTemplateValueParameterTest;
TEST_F(MDTemplateValueParameterTest, get) { TEST_F(MDTemplateValueParameterTest, get) {
unsigned Tag = dwarf::DW_TAG_template_value_parameter; unsigned Tag = dwarf::DW_TAG_template_value_parameter;
StringRef Name = "template"; StringRef Name = "template";
MDType *Type = getBasicType("basic"); MDTypeRef Type = getBasicType("basic");
Metadata *Value = getConstantAsMetadata(); Metadata *Value = getConstantAsMetadata();
auto *N = MDTemplateValueParameter::get(Context, Tag, Name, Type, Value); auto *N = MDTemplateValueParameter::get(Context, Tag, Name, Type, Value);
@ -1731,11 +1735,12 @@ TEST_F(MDGlobalVariableTest, get) {
StringRef LinkageName = "linkage"; StringRef LinkageName = "linkage";
MDFile *File = getFile(); MDFile *File = getFile();
unsigned Line = 5; unsigned Line = 5;
Metadata *Type = MDTuple::getDistinct(Context, None); MDTypeRef Type = getDerivedType();
bool IsLocalToUnit = false; bool IsLocalToUnit = false;
bool IsDefinition = true; bool IsDefinition = true;
ConstantAsMetadata *Variable = getConstantAsMetadata(); ConstantAsMetadata *Variable = getConstantAsMetadata();
MDDerivedType *StaticDataMemberDeclaration = getDerivedType(); MDDerivedType *StaticDataMemberDeclaration =
cast<MDDerivedType>(getDerivedType());
auto *N = MDGlobalVariable::get(Context, Scope, Name, LinkageName, File, Line, auto *N = MDGlobalVariable::get(Context, Scope, Name, LinkageName, File, Line,
Type, IsLocalToUnit, IsDefinition, Variable, Type, IsLocalToUnit, IsDefinition, Variable,
@ -1773,9 +1778,10 @@ TEST_F(MDGlobalVariableTest, get) {
MDGlobalVariable::get(Context, Scope, Name, LinkageName, File, MDGlobalVariable::get(Context, Scope, Name, LinkageName, File,
Line + 1, Type, IsLocalToUnit, IsDefinition, Line + 1, Type, IsLocalToUnit, IsDefinition,
Variable, StaticDataMemberDeclaration)); Variable, StaticDataMemberDeclaration));
EXPECT_NE(N, MDGlobalVariable::get(Context, Scope, Name, LinkageName, File, EXPECT_NE(N,
Line, Scope, IsLocalToUnit, IsDefinition, MDGlobalVariable::get(Context, Scope, Name, LinkageName, File, Line,
Variable, StaticDataMemberDeclaration)); getDerivedType(), IsLocalToUnit, IsDefinition,
Variable, StaticDataMemberDeclaration));
EXPECT_NE(N, MDGlobalVariable::get(Context, Scope, Name, LinkageName, File, EXPECT_NE(N, MDGlobalVariable::get(Context, Scope, Name, LinkageName, File,
Line, Type, !IsLocalToUnit, IsDefinition, Line, Type, !IsLocalToUnit, IsDefinition,
Variable, StaticDataMemberDeclaration)); Variable, StaticDataMemberDeclaration));
@ -1786,9 +1792,10 @@ TEST_F(MDGlobalVariableTest, get) {
Line, Type, IsLocalToUnit, IsDefinition, Line, Type, IsLocalToUnit, IsDefinition,
getConstantAsMetadata(), getConstantAsMetadata(),
StaticDataMemberDeclaration)); StaticDataMemberDeclaration));
EXPECT_NE(N, MDGlobalVariable::get(Context, Scope, Name, LinkageName, File, EXPECT_NE(N,
Line, Type, IsLocalToUnit, IsDefinition, MDGlobalVariable::get(Context, Scope, Name, LinkageName, File, Line,
Variable, getDerivedType())); Type, IsLocalToUnit, IsDefinition, Variable,
cast<MDDerivedType>(getDerivedType())));
TempMDGlobalVariable Temp = N->clone(); TempMDGlobalVariable Temp = N->clone();
EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp))); EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp)));
@ -1802,7 +1809,7 @@ TEST_F(MDLocalVariableTest, get) {
StringRef Name = "name"; StringRef Name = "name";
MDFile *File = getFile(); MDFile *File = getFile();
unsigned Line = 5; unsigned Line = 5;
Metadata *Type = MDTuple::getDistinct(Context, None); MDTypeRef Type = getDerivedType();
unsigned Arg = 6; unsigned Arg = 6;
unsigned Flags = 7; unsigned Flags = 7;
MDLocation *InlinedAt = MDLocation *InlinedAt =
@ -1834,7 +1841,7 @@ TEST_F(MDLocalVariableTest, get) {
EXPECT_NE(N, MDLocalVariable::get(Context, Tag, Scope, Name, File, Line + 1, EXPECT_NE(N, MDLocalVariable::get(Context, Tag, Scope, Name, File, Line + 1,
Type, Arg, Flags, InlinedAt)); Type, Arg, Flags, InlinedAt));
EXPECT_NE(N, MDLocalVariable::get(Context, Tag, Scope, Name, File, Line, EXPECT_NE(N, MDLocalVariable::get(Context, Tag, Scope, Name, File, Line,
Scope, Arg, Flags, InlinedAt)); getDerivedType(), Arg, Flags, InlinedAt));
EXPECT_NE(N, MDLocalVariable::get(Context, Tag, Scope, Name, File, Line, Type, EXPECT_NE(N, MDLocalVariable::get(Context, Tag, Scope, Name, File, Line, Type,
Arg + 1, Flags, InlinedAt)); Arg + 1, Flags, InlinedAt));
EXPECT_NE(N, MDLocalVariable::get(Context, Tag, Scope, Name, File, Line, Type, EXPECT_NE(N, MDLocalVariable::get(Context, Tag, Scope, Name, File, Line, Type,
@ -1924,7 +1931,7 @@ TEST_F(MDObjCPropertyTest, get) {
StringRef GetterName = "getter"; StringRef GetterName = "getter";
StringRef SetterName = "setter"; StringRef SetterName = "setter";
unsigned Attributes = 7; unsigned Attributes = 7;
MDType *Type = getBasicType("basic"); MDType *Type = cast<MDBasicType>(getBasicType("basic"));
auto *N = MDObjCProperty::get(Context, Name, File, Line, GetterName, auto *N = MDObjCProperty::get(Context, Name, File, Line, GetterName,
SetterName, Attributes, Type); SetterName, Attributes, Type);
@ -1952,9 +1959,9 @@ TEST_F(MDObjCPropertyTest, get) {
"other", Attributes, Type)); "other", Attributes, Type));
EXPECT_NE(N, MDObjCProperty::get(Context, Name, File, Line, GetterName, EXPECT_NE(N, MDObjCProperty::get(Context, Name, File, Line, GetterName,
SetterName, Attributes + 1, Type)); SetterName, Attributes + 1, Type));
EXPECT_NE(N, EXPECT_NE(N, MDObjCProperty::get(Context, Name, File, Line, GetterName,
MDObjCProperty::get(Context, Name, File, Line, GetterName, SetterName, Attributes,
SetterName, Attributes, getBasicType("other"))); cast<MDBasicType>(getBasicType("other"))));
TempMDObjCProperty Temp = N->clone(); TempMDObjCProperty Temp = N->clone();
EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp))); EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp)));
@ -1965,7 +1972,7 @@ typedef MetadataTest MDImportedEntityTest;
TEST_F(MDImportedEntityTest, get) { TEST_F(MDImportedEntityTest, get) {
unsigned Tag = dwarf::DW_TAG_imported_module; unsigned Tag = dwarf::DW_TAG_imported_module;
MDScope *Scope = getSubprogram(); MDScope *Scope = getSubprogram();
DebugNode *Entity = getCompositeType(); DebugNodeRef Entity = getCompositeType();
unsigned Line = 5; unsigned Line = 5;
StringRef Name = "name"; StringRef Name = "name";