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.
DIGlobalVariable createGlobalVariable(DIDescriptor Context, StringRef Name,
StringRef LinkageName, DIFile File,
unsigned LineNo, DITypeRef Ty,
unsigned LineNo, DIType Ty,
bool isLocalToUnit,
llvm::Constant *Val,
MDNode *Decl = nullptr);
@ -473,7 +473,7 @@ namespace llvm {
/// except that the resulting DbgNode is temporary and meant to be RAUWed.
DIGlobalVariable createTempGlobalVariableFwdDecl(
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);
/// 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
/// number. 1 indicates 1st argument.
DIVariable createLocalVariable(unsigned Tag, DIDescriptor Scope,
StringRef Name,
DIFile File, unsigned LineNo,
DITypeRef Ty, bool AlwaysPreserve = false,
unsigned Flags = 0,
unsigned ArgNo = 0);
StringRef Name, DIFile File, unsigned LineNo,
DIType Ty, bool AlwaysPreserve = false,
unsigned Flags = 0, unsigned ArgNo = 0);
/// createExpression - Create a new descriptor for the specified
/// variable which has a complex address expression for its address.

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -653,10 +653,10 @@ template <> struct MDNodeKeyImpl<MDTemplateTypeParameter> {
MDNodeKeyImpl(StringRef Name, Metadata *Type) : Name(Name), Type(Type) {}
MDNodeKeyImpl(const MDTemplateTypeParameter *N)
: Name(N->getName()), Type(N->getType()) {}
: Name(N->getName()), Type(N->getRawType()) {}
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); }
};
@ -670,12 +670,12 @@ template <> struct MDNodeKeyImpl<MDTemplateValueParameter> {
MDNodeKeyImpl(unsigned Tag, StringRef Name, Metadata *Type, Metadata *Value)
: Tag(Tag), Name(Name), Type(Type), Value(Value) {}
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()) {}
bool isKeyOf(const MDTemplateValueParameter *RHS) const {
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); }
};

View File

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