/// @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);
/// 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
/// @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.
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;
}
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); }
~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) {
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,
(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))
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());
}
#endif
replaceOperandWith(4, Elements);
}
- void replaceVTableHolder(Metadata *VTableHolder) {
+ void replaceVTableHolder(MDTypeRef VTableHolder) {
replaceOperandWith(5, VTableHolder);
}
void replaceTemplateParams(MDTemplateParameterArray TemplateParams) {
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,
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,
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());
~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,
}
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,
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); }
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());
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 ||
~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);
}
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))
~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,
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),
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); }
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) {
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),
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) {
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,
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 << ")";
}
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 << ")";
}
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,
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
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) {
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,
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,
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) {
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,
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
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
// 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);
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);
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);
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);
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;
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;
}
// 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);
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);
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]);
}
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()?
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
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)
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,
"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);
void DICompositeType::setContainingType(DICompositeType ContainingType) {
TypedTrackingMDRef<MDCompositeTypeBase> N(get());
- N->replaceVTableHolder(ContainingType.getRef());
+ N->replaceVTableHolder(MDTypeRef::get(ContainingType));
DbgNode = N;
}
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); }
};
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); }
};
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(
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",
"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,
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",
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";
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,
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";
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;
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());
typedef MetadataTest MDSubprogramTest;
TEST_F(MDSubprogramTest, get) {
- MDScope *Scope = getCompositeType();
+ MDScopeRef Scope = getCompositeType();
StringRef Name = "name";
StringRef LinkageName = "linkage";
MDFile *File = getFile();
bool IsLocalToUnit = false;
bool IsDefinition = true;
unsigned ScopeLine = 3;
- MDType *ContainingType = getCompositeType();
+ MDTypeRef ContainingType = getCompositeType();
unsigned Virtuality = 4;
unsigned VirtualIndex = 5;
unsigned Flags = 6;
}
TEST_F(MDSubprogramTest, replaceFunction) {
- MDScope *Scope = getCompositeType();
+ MDScopeRef Scope = getCompositeType();
StringRef Name = "name";
StringRef LinkageName = "linkage";
MDFile *File = getFile();
bool IsLocalToUnit = false;
bool IsDefinition = true;
unsigned ScopeLine = 3;
- MDCompositeType *ContainingType = getCompositeType();
+ MDTypeRef ContainingType = getCompositeType();
unsigned Virtuality = 4;
unsigned VirtualIndex = 5;
unsigned Flags = 6;
TEST_F(MDTemplateTypeParameterTest, get) {
StringRef Name = "template";
- MDType *Type = getBasicType("basic");
+ MDTypeRef Type = getBasicType("basic");
auto *N = MDTemplateTypeParameter::get(Context, Name, Type);
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);
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,
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));
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)));
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 =
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,
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);
"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)));
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";