1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 18:54:02 +01:00

Verifier: Add operand checks for remaining debug info

llvm-svn: 233565
This commit is contained in:
Duncan P. N. Exon Smith 2015-03-30 17:21:38 +00:00
parent 552256692c
commit 2772e933dc
10 changed files with 98 additions and 77 deletions

View File

@ -282,8 +282,7 @@ protected:
~MDScope() {} ~MDScope() {}
public: public:
// FIXME: Downcast to MDFile once we've verified all subclasses. MDFile *getFile() const { return cast_or_null<MDFile>(getRawFile()); }
Metadata *getFile() const { return getRawFile(); }
/// \brief Return the raw underlying file. /// \brief Return the raw underlying file.
/// ///
@ -393,9 +392,6 @@ public:
uint64_t getOffsetInBits() const { return OffsetInBits; } uint64_t getOffsetInBits() const { return OffsetInBits; }
unsigned getFlags() const { return Flags; } unsigned getFlags() const { return Flags; }
// FIXME: Remove this once MDScope::getFile() does the same.
MDFile *getFile() const { return cast_or_null<MDFile>(getRawFile()); }
Metadata *getScope() const { return getRawScope(); } Metadata *getScope() const { return getRawScope(); }
StringRef getName() const { return getStringOperand(2); } StringRef getName() const { return getStringOperand(2); }
@ -831,9 +827,6 @@ public:
TempMDCompileUnit clone() const { return cloneImpl(); } TempMDCompileUnit clone() const { return cloneImpl(); }
// FIXME: Remove this once MDScope::getFile() does the same.
MDFile *getFile() const { return cast_or_null<MDFile>(getRawFile()); }
unsigned getSourceLanguage() const { return SourceLanguage; } unsigned getSourceLanguage() const { return SourceLanguage; }
bool isOptimized() const { return IsOptimized; } bool isOptimized() const { return IsOptimized; }
unsigned getRuntimeVersion() const { return RuntimeVersion; } unsigned getRuntimeVersion() const { return RuntimeVersion; }
@ -1067,9 +1060,6 @@ public:
bool isDefinition() const { return IsDefinition; } bool isDefinition() const { return IsDefinition; }
bool isOptimized() const { return IsOptimized; } bool isOptimized() const { return IsOptimized; }
// FIXME: Remove this once MDScope::getFile() does the same.
MDFile *getFile() const { return cast_or_null<MDFile>(getRawFile()); }
Metadata *getScope() const { return getRawScope(); } Metadata *getScope() const { return getRawScope(); }
StringRef getName() const { return getStringOperand(2); } StringRef getName() const { return getStringOperand(2); }
@ -1129,9 +1119,6 @@ protected:
~MDLexicalBlockBase() {} ~MDLexicalBlockBase() {}
public: public:
// FIXME: Remove this once MDScope::getFile() does the same.
MDFile *getFile() const { return cast_or_null<MDFile>(getRawFile()); }
MDLocalScope *getScope() const { return cast<MDLocalScope>(getRawScope()); } MDLocalScope *getScope() const { return cast<MDLocalScope>(getRawScope()); }
Metadata *getRawScope() const { return getOperand(1); } Metadata *getRawScope() const { return getOperand(1); }
@ -1252,8 +1239,8 @@ class MDNamespace : public MDScope {
Line(Line) {} Line(Line) {}
~MDNamespace() {} ~MDNamespace() {}
static MDNamespace *getImpl(LLVMContext &Context, Metadata *Scope, static MDNamespace *getImpl(LLVMContext &Context, MDScope *Scope,
Metadata *File, StringRef Name, unsigned Line, MDFile *File, StringRef Name, unsigned Line,
StorageType Storage, bool ShouldCreate = true) { StorageType Storage, bool ShouldCreate = true) {
return getImpl(Context, Scope, File, getCanonicalMDString(Context, Name), return getImpl(Context, Scope, File, getCanonicalMDString(Context, Name),
Line, Storage, ShouldCreate); Line, Storage, ShouldCreate);
@ -1268,8 +1255,8 @@ class MDNamespace : public MDScope {
} }
public: public:
DEFINE_MDNODE_GET(MDNamespace, (Metadata * Scope, Metadata *File, DEFINE_MDNODE_GET(MDNamespace, (MDScope * Scope, MDFile *File, StringRef Name,
StringRef Name, unsigned Line), unsigned Line),
(Scope, File, Name, Line)) (Scope, File, Name, Line))
DEFINE_MDNODE_GET(MDNamespace, (Metadata * Scope, Metadata *File, DEFINE_MDNODE_GET(MDNamespace, (Metadata * Scope, Metadata *File,
MDString *Name, unsigned Line), MDString *Name, unsigned Line),
@ -1278,9 +1265,10 @@ public:
TempMDNamespace clone() const { return cloneImpl(); } TempMDNamespace clone() const { return cloneImpl(); }
unsigned getLine() const { return Line; } unsigned getLine() const { return Line; }
Metadata *getScope() const { return getOperand(1); } MDScope *getScope() const { return cast_or_null<MDScope>(getRawScope()); }
StringRef getName() const { return getStringOperand(2); } StringRef getName() const { return getStringOperand(2); }
Metadata *getRawScope() const { return getOperand(1); }
MDString *getRawName() const { return getOperandAs<MDString>(2); } MDString *getRawName() const { return getOperandAs<MDString>(2); }
static bool classof(const Metadata *MD) { static bool classof(const Metadata *MD) {
@ -1730,9 +1718,9 @@ class MDObjCProperty : public DebugNode {
~MDObjCProperty() {} ~MDObjCProperty() {}
static MDObjCProperty * static MDObjCProperty *
getImpl(LLVMContext &Context, StringRef Name, Metadata *File, unsigned Line, getImpl(LLVMContext &Context, StringRef Name, MDFile *File, unsigned Line,
StringRef GetterName, StringRef SetterName, unsigned Attributes, StringRef GetterName, StringRef SetterName, unsigned Attributes,
Metadata *Type, StorageType Storage, bool ShouldCreate = true) { MDType *Type, StorageType Storage, bool ShouldCreate = true) {
return getImpl(Context, getCanonicalMDString(Context, Name), File, Line, return getImpl(Context, getCanonicalMDString(Context, Name), File, Line,
getCanonicalMDString(Context, GetterName), getCanonicalMDString(Context, GetterName),
getCanonicalMDString(Context, SetterName), Attributes, Type, getCanonicalMDString(Context, SetterName), Attributes, Type,
@ -1752,9 +1740,9 @@ class MDObjCProperty : public DebugNode {
public: public:
DEFINE_MDNODE_GET(MDObjCProperty, DEFINE_MDNODE_GET(MDObjCProperty,
(StringRef Name, Metadata *File, unsigned Line, (StringRef Name, MDFile *File, unsigned Line,
StringRef GetterName, StringRef SetterName, StringRef GetterName, StringRef SetterName,
unsigned Attributes, Metadata *Type), unsigned Attributes, MDType *Type),
(Name, File, Line, GetterName, SetterName, Attributes, (Name, File, Line, GetterName, SetterName, Attributes,
Type)) Type))
DEFINE_MDNODE_GET(MDObjCProperty, DEFINE_MDNODE_GET(MDObjCProperty,
@ -1769,14 +1757,16 @@ public:
unsigned getLine() const { return Line; } unsigned getLine() const { return Line; }
unsigned getAttributes() const { return Attributes; } unsigned getAttributes() const { return Attributes; }
StringRef getName() const { return getStringOperand(0); } StringRef getName() const { return getStringOperand(0); }
Metadata *getFile() const { return getOperand(1); } MDFile *getFile() const { return cast_or_null<MDFile>(getRawFile()); }
StringRef getGetterName() const { return getStringOperand(2); } StringRef getGetterName() const { return getStringOperand(2); }
StringRef getSetterName() const { return getStringOperand(3); } StringRef getSetterName() const { return getStringOperand(3); }
Metadata *getType() const { return getOperand(4); } MDType *getType() const { return cast_or_null<MDType>(getRawType()); }
MDString *getRawName() const { return getOperandAs<MDString>(0); } MDString *getRawName() const { return getOperandAs<MDString>(0); }
Metadata *getRawFile() const { return getOperand(1); }
MDString *getRawGetterName() const { return getOperandAs<MDString>(2); } MDString *getRawGetterName() const { return getOperandAs<MDString>(2); }
MDString *getRawSetterName() const { return getOperandAs<MDString>(3); } MDString *getRawSetterName() const { return getOperandAs<MDString>(3); }
Metadata *getRawType() const { return getOperand(4); }
static bool classof(const Metadata *MD) { static bool classof(const Metadata *MD) {
return MD->getMetadataID() == MDObjCPropertyKind; return MD->getMetadataID() == MDObjCPropertyKind;
@ -1795,7 +1785,7 @@ class MDImportedEntity : public DebugNode {
~MDImportedEntity() {} ~MDImportedEntity() {}
static MDImportedEntity *getImpl(LLVMContext &Context, unsigned Tag, static MDImportedEntity *getImpl(LLVMContext &Context, unsigned Tag,
Metadata *Scope, Metadata *Entity, MDScope *Scope, Metadata *Entity,
unsigned Line, StringRef Name, unsigned Line, StringRef Name,
StorageType Storage, StorageType Storage,
bool ShouldCreate = true) { bool ShouldCreate = true) {
@ -1815,7 +1805,7 @@ class MDImportedEntity : public DebugNode {
public: public:
DEFINE_MDNODE_GET(MDImportedEntity, DEFINE_MDNODE_GET(MDImportedEntity,
(unsigned Tag, Metadata *Scope, Metadata *Entity, (unsigned Tag, MDScope *Scope, Metadata *Entity,
unsigned Line, StringRef Name = ""), unsigned Line, StringRef Name = ""),
(Tag, Scope, Entity, Line, Name)) (Tag, Scope, Entity, Line, Name))
DEFINE_MDNODE_GET(MDImportedEntity, DEFINE_MDNODE_GET(MDImportedEntity,
@ -1826,10 +1816,12 @@ public:
TempMDImportedEntity clone() const { return cloneImpl(); } TempMDImportedEntity clone() const { return cloneImpl(); }
unsigned getLine() const { return Line; } unsigned getLine() const { return Line; }
Metadata *getScope() const { return getOperand(0); } MDScope *getScope() const { return cast_or_null<MDScope>(getRawScope()); }
Metadata *getEntity() const { return getOperand(1); } Metadata *getEntity() const { return getRawEntity(); }
StringRef getName() const { return getStringOperand(2); } StringRef getName() const { return getStringOperand(2); }
Metadata *getRawScope() const { return getOperand(0); }
Metadata *getRawEntity() const { return getOperand(1); }
MDString *getRawName() const { return getOperandAs<MDString>(2); } MDString *getRawName() const { return getOperandAs<MDString>(2); }
static bool classof(const Metadata *MD) { static bool classof(const Metadata *MD) {

View File

@ -1681,8 +1681,8 @@ static void writeMDNamespace(raw_ostream &Out, const MDNamespace *N,
Out << "!MDNamespace("; Out << "!MDNamespace(";
MDFieldPrinter Printer(Out, TypePrinter, Machine, Context); MDFieldPrinter Printer(Out, TypePrinter, Machine, Context);
Printer.printString("name", N->getName()); Printer.printString("name", N->getName());
Printer.printMetadata("scope", N->getScope(), /* ShouldSkipNull */ false); Printer.printMetadata("scope", N->getRawScope(), /* ShouldSkipNull */ false);
Printer.printMetadata("file", N->getFile()); Printer.printMetadata("file", N->getRawFile());
Printer.printInt("line", N->getLine()); Printer.printInt("line", N->getLine());
Out << ")"; Out << ")";
} }
@ -1778,12 +1778,12 @@ static void writeMDObjCProperty(raw_ostream &Out, const MDObjCProperty *N,
Out << "!MDObjCProperty("; Out << "!MDObjCProperty(";
MDFieldPrinter Printer(Out, TypePrinter, Machine, Context); MDFieldPrinter Printer(Out, TypePrinter, Machine, Context);
Printer.printString("name", N->getName()); Printer.printString("name", N->getName());
Printer.printMetadata("file", N->getFile()); Printer.printMetadata("file", N->getRawFile());
Printer.printInt("line", N->getLine()); Printer.printInt("line", N->getLine());
Printer.printString("setter", N->getSetterName()); Printer.printString("setter", N->getSetterName());
Printer.printString("getter", N->getGetterName()); Printer.printString("getter", N->getGetterName());
Printer.printInt("attributes", N->getAttributes()); Printer.printInt("attributes", N->getAttributes());
Printer.printMetadata("type", N->getType()); Printer.printMetadata("type", N->getRawType());
Out << ")"; Out << ")";
} }
@ -1794,8 +1794,8 @@ static void writeMDImportedEntity(raw_ostream &Out, const MDImportedEntity *N,
MDFieldPrinter Printer(Out, TypePrinter, Machine, Context); MDFieldPrinter Printer(Out, TypePrinter, Machine, Context);
Printer.printTag(N); Printer.printTag(N);
Printer.printString("name", N->getName()); Printer.printString("name", N->getName());
Printer.printMetadata("scope", N->getScope(), /* ShouldSkipNull */ false); Printer.printMetadata("scope", N->getRawScope(), /* ShouldSkipNull */ false);
Printer.printMetadata("entity", N->getEntity()); Printer.printMetadata("entity", N->getRawEntity());
Printer.printInt("line", N->getLine()); Printer.printInt("line", N->getLine());
Out << ")"; Out << ")";
} }

View File

@ -734,7 +734,7 @@ DISubprogram DIBuilder::createMethod(DIDescriptor Context, StringRef Name,
DINameSpace DIBuilder::createNameSpace(DIDescriptor Scope, StringRef Name, DINameSpace DIBuilder::createNameSpace(DIDescriptor Scope, StringRef Name,
DIFile File, unsigned LineNo) { DIFile File, unsigned LineNo) {
DINameSpace R = MDNamespace::get(VMContext, getNonCompileUnitScope(Scope), DINameSpace R = MDNamespace::get(VMContext, getNonCompileUnitScope(Scope),
File.getFileNode(), Name, LineNo); File, Name, LineNo);
assert(R.Verify() && assert(R.Verify() &&
"createNameSpace should return a verifiable DINameSpace"); "createNameSpace should return a verifiable DINameSpace");
return R; return R;

View File

@ -635,11 +635,11 @@ template <> struct MDNodeKeyImpl<MDNamespace> {
MDNodeKeyImpl(Metadata *Scope, Metadata *File, StringRef Name, unsigned Line) MDNodeKeyImpl(Metadata *Scope, Metadata *File, StringRef Name, unsigned Line)
: Scope(Scope), File(File), Name(Name), Line(Line) {} : Scope(Scope), File(File), Name(Name), Line(Line) {}
MDNodeKeyImpl(const MDNamespace *N) MDNodeKeyImpl(const MDNamespace *N)
: Scope(N->getScope()), File(N->getFile()), Name(N->getName()), : Scope(N->getRawScope()), File(N->getRawFile()), Name(N->getName()),
Line(N->getLine()) {} Line(N->getLine()) {}
bool isKeyOf(const MDNamespace *RHS) const { bool isKeyOf(const MDNamespace *RHS) const {
return Scope == RHS->getScope() && File == RHS->getFile() && return Scope == RHS->getRawScope() && File == RHS->getRawFile() &&
Name == RHS->getName() && Line == RHS->getLine(); Name == RHS->getName() && Line == RHS->getLine();
} }
unsigned getHashValue() const { unsigned getHashValue() const {
@ -789,15 +789,15 @@ template <> struct MDNodeKeyImpl<MDObjCProperty> {
: Name(Name), File(File), Line(Line), GetterName(GetterName), : Name(Name), File(File), Line(Line), GetterName(GetterName),
SetterName(SetterName), Attributes(Attributes), Type(Type) {} SetterName(SetterName), Attributes(Attributes), Type(Type) {}
MDNodeKeyImpl(const MDObjCProperty *N) MDNodeKeyImpl(const MDObjCProperty *N)
: Name(N->getName()), File(N->getFile()), Line(N->getLine()), : Name(N->getName()), File(N->getRawFile()), Line(N->getLine()),
GetterName(N->getGetterName()), SetterName(N->getSetterName()), GetterName(N->getGetterName()), SetterName(N->getSetterName()),
Attributes(N->getAttributes()), Type(N->getType()) {} Attributes(N->getAttributes()), Type(N->getRawType()) {}
bool isKeyOf(const MDObjCProperty *RHS) const { bool isKeyOf(const MDObjCProperty *RHS) const {
return Name == RHS->getName() && File == RHS->getFile() && return Name == RHS->getName() && File == RHS->getRawFile() &&
Line == RHS->getLine() && GetterName == RHS->getGetterName() && Line == RHS->getLine() && GetterName == RHS->getGetterName() &&
SetterName == RHS->getSetterName() && SetterName == RHS->getSetterName() &&
Attributes == RHS->getAttributes() && Type == RHS->getType(); Attributes == RHS->getAttributes() && Type == RHS->getRawType();
} }
unsigned getHashValue() const { unsigned getHashValue() const {
return hash_combine(Name, File, Line, GetterName, SetterName, Attributes, return hash_combine(Name, File, Line, GetterName, SetterName, Attributes,
@ -816,12 +816,12 @@ template <> struct MDNodeKeyImpl<MDImportedEntity> {
StringRef Name) StringRef Name)
: Tag(Tag), Scope(Scope), Entity(Entity), Line(Line), Name(Name) {} : Tag(Tag), Scope(Scope), Entity(Entity), Line(Line), Name(Name) {}
MDNodeKeyImpl(const MDImportedEntity *N) MDNodeKeyImpl(const MDImportedEntity *N)
: Tag(N->getTag()), Scope(N->getScope()), Entity(N->getEntity()), : Tag(N->getTag()), Scope(N->getRawScope()), Entity(N->getRawEntity()),
Line(N->getLine()), Name(N->getName()) {} Line(N->getLine()), Name(N->getName()) {}
bool isKeyOf(const MDImportedEntity *RHS) const { bool isKeyOf(const MDImportedEntity *RHS) const {
return Tag == RHS->getTag() && Scope == RHS->getScope() && return Tag == RHS->getTag() && Scope == RHS->getRawScope() &&
Entity == RHS->getEntity() && Line == RHS->getLine() && Entity == RHS->getRawEntity() && Line == RHS->getLine() &&
Name == RHS->getName(); Name == RHS->getName();
} }
unsigned getHashValue() const { unsigned getHashValue() const {

View File

@ -303,6 +303,7 @@ private:
void visitMDDerivedTypeBase(const MDDerivedTypeBase &N); void visitMDDerivedTypeBase(const MDDerivedTypeBase &N);
void visitMDVariable(const MDVariable &N); void visitMDVariable(const MDVariable &N);
void visitMDLexicalBlockBase(const MDLexicalBlockBase &N); void visitMDLexicalBlockBase(const MDLexicalBlockBase &N);
void visitMDTemplateParameter(const MDTemplateParameter &N);
// InstVisitor overrides... // InstVisitor overrides...
using InstVisitor<Verifier>::visit; using InstVisitor<Verifier>::visit;
@ -681,6 +682,15 @@ static bool isScopeRef(const Metadata *MD) {
return isa<MDScope>(MD); return isa<MDScope>(MD);
} }
/// \brief Check if a value can be a debug info ref.
static bool isDIRef(const Metadata *MD) {
if (!MD)
return true;
if (auto *S = dyn_cast<MDString>(MD))
return !S->getString().empty();
return isa<DebugNode>(MD);
}
template <class Ty> template <class Ty>
bool isValidMetadataArrayImpl(const MDTuple &N, bool AllowNull) { bool isValidMetadataArrayImpl(const MDTuple &N, bool AllowNull) {
for (Metadata *MD : N.operands()) { for (Metadata *MD : N.operands()) {
@ -890,15 +900,25 @@ void Verifier::visitMDLexicalBlockFile(const MDLexicalBlockFile &N) {
void Verifier::visitMDNamespace(const MDNamespace &N) { void Verifier::visitMDNamespace(const MDNamespace &N) {
Assert(N.getTag() == dwarf::DW_TAG_namespace, "invalid tag", &N); Assert(N.getTag() == dwarf::DW_TAG_namespace, "invalid tag", &N);
if (auto *S = N.getRawScope())
Assert(isa<MDScope>(S), "invalid scope ref", &N, S);
}
void Verifier::visitMDTemplateParameter(const MDTemplateParameter &N) {
Assert(isTypeRef(N.getType()), "invalid type ref", &N, N.getType());
} }
void Verifier::visitMDTemplateTypeParameter(const MDTemplateTypeParameter &N) { void Verifier::visitMDTemplateTypeParameter(const MDTemplateTypeParameter &N) {
visitMDTemplateParameter(N);
Assert(N.getTag() == dwarf::DW_TAG_template_type_parameter, "invalid tag", Assert(N.getTag() == dwarf::DW_TAG_template_type_parameter, "invalid tag",
&N); &N);
} }
void Verifier::visitMDTemplateValueParameter( void Verifier::visitMDTemplateValueParameter(
const MDTemplateValueParameter &N) { const MDTemplateValueParameter &N) {
visitMDTemplateParameter(N);
Assert(N.getTag() == dwarf::DW_TAG_template_value_parameter || Assert(N.getTag() == dwarf::DW_TAG_template_value_parameter ||
N.getTag() == dwarf::DW_TAG_GNU_template_template_param || N.getTag() == dwarf::DW_TAG_GNU_template_template_param ||
N.getTag() == dwarf::DW_TAG_GNU_template_parameter_pack, N.getTag() == dwarf::DW_TAG_GNU_template_parameter_pack,
@ -949,12 +969,19 @@ void Verifier::visitMDExpression(const MDExpression &N) {
void Verifier::visitMDObjCProperty(const MDObjCProperty &N) { void Verifier::visitMDObjCProperty(const MDObjCProperty &N) {
Assert(N.getTag() == dwarf::DW_TAG_APPLE_property, "invalid tag", &N); Assert(N.getTag() == dwarf::DW_TAG_APPLE_property, "invalid tag", &N);
if (auto *T = N.getRawType())
Assert(isa<MDType>(T), "invalid type ref", &N, T);
if (auto *F = N.getRawFile())
Assert(isa<MDFile>(F), "invalid file", &N, F);
} }
void Verifier::visitMDImportedEntity(const MDImportedEntity &N) { void Verifier::visitMDImportedEntity(const MDImportedEntity &N) {
Assert(N.getTag() == dwarf::DW_TAG_imported_module || Assert(N.getTag() == dwarf::DW_TAG_imported_module ||
N.getTag() == dwarf::DW_TAG_imported_declaration, N.getTag() == dwarf::DW_TAG_imported_declaration,
"invalid tag", &N); "invalid tag", &N);
if (auto *S = N.getRawScope())
Assert(isa<MDScope>(S), "invalid scope for imported entity", &N, S);
Assert(isDIRef(N.getEntity()), "invalid imported entity", &N, N.getEntity());
} }
void Verifier::visitComdat(const Comdat &C) { void Verifier::visitComdat(const Comdat &C) {

View File

@ -4,10 +4,10 @@
; CHECK: !named = !{!0, !1, !2, !3, !3} ; CHECK: !named = !{!0, !1, !2, !3, !3}
!named = !{!0, !1, !2, !3, !4} !named = !{!0, !1, !2, !3, !4}
; CHECK: !0 = distinct !{} ; CHECK: !0 = !MDSubprogram({{.*}})
; CHECK-NEXT: !1 = distinct !{} ; CHECK-NEXT: !1 = !MDCompositeType({{.*}})
!0 = distinct !{} !0 = !MDSubprogram(name: "foo")
!1 = distinct !{} !1 = !MDCompositeType(tag: DW_TAG_structure_type, name: "Class", size: 32, align: 32)
; CHECK-NEXT: !2 = !MDImportedEntity(tag: DW_TAG_imported_module, name: "foo", scope: !0, entity: !1, line: 7) ; CHECK-NEXT: !2 = !MDImportedEntity(tag: DW_TAG_imported_module, name: "foo", scope: !0, entity: !1, line: 7)
!2 = !MDImportedEntity(tag: DW_TAG_imported_module, name: "foo", scope: !0, !2 = !MDImportedEntity(tag: DW_TAG_imported_module, name: "foo", scope: !0,

View File

@ -4,7 +4,7 @@
; CHECK: !named = !{!0, !1, !2, !3, !4, !4} ; CHECK: !named = !{!0, !1, !2, !3, !4, !4}
!named = !{!0, !1, !2, !3, !4, !5} !named = !{!0, !1, !2, !3, !4, !5}
!0 = distinct !{} !0 = !MDFile(filename: "file.cpp", directory: "/path/to/dir")
!1 = distinct !{} !1 = distinct !{}
!2 = !MDFile(filename: "path/to/file", directory: "/path/to/dir") !2 = !MDFile(filename: "path/to/file", directory: "/path/to/dir")

View File

@ -6,10 +6,9 @@
!0 = distinct !{} !0 = distinct !{}
!1 = !MDFile(filename: "path/to/file", directory: "/path/to/dir") !1 = !MDFile(filename: "path/to/file", directory: "/path/to/dir")
!2 = distinct !{} !2 = !MDCompositeType(tag: DW_TAG_structure_type, name: "Object")
; CHECK: !2 = !MDCompositeType({{.*}})
; CHECK: !2 = distinct !{}
; CHECK-NEXT: !3 = !MDObjCProperty(name: "foo", file: !1, line: 7, setter: "setFoo", getter: "getFoo", attributes: 7, type: !2) ; CHECK-NEXT: !3 = !MDObjCProperty(name: "foo", file: !1, line: 7, setter: "setFoo", getter: "getFoo", attributes: 7, type: !2)
!3 = !MDObjCProperty(name: "foo", file: !1, line: 7, setter: "setFoo", !3 = !MDObjCProperty(name: "foo", file: !1, line: 7, setter: "setFoo",
getter: "getFoo", attributes: 7, type: !2) getter: "getFoo", attributes: 7, type: !2)

View File

@ -5,8 +5,8 @@
!named = !{!0, !1, !2, !3, !4, !5, !6, !7, !8} !named = !{!0, !1, !2, !3, !4, !5, !6, !7, !8}
!0 = distinct !{} !0 = distinct !{}
!1 = distinct !{} !1 = !MDBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
; CHECK: !1 = distinct !{} ; CHECK: !1 = !MDBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
; CHECK-NEXT: !2 = !MDTemplateTypeParameter(name: "Ty", type: !1) ; CHECK-NEXT: !2 = !MDTemplateTypeParameter(name: "Ty", type: !1)
; CHECK-NEXT: !3 = !MDTemplateTypeParameter(type: !1) ; CHECK-NEXT: !3 = !MDTemplateTypeParameter(type: !1)

View File

@ -1608,8 +1608,8 @@ TEST_F(MDLexicalBlockFileTest, get) {
typedef MetadataTest MDNamespaceTest; typedef MetadataTest MDNamespaceTest;
TEST_F(MDNamespaceTest, get) { TEST_F(MDNamespaceTest, get) {
Metadata *Scope = MDTuple::getDistinct(Context, None); MDScope *Scope = getFile();
Metadata *File = MDTuple::getDistinct(Context, None); MDFile *File = getFile();
StringRef Name = "namespace"; StringRef Name = "namespace";
unsigned Line = 5; unsigned Line = 5;
@ -1622,8 +1622,8 @@ TEST_F(MDNamespaceTest, get) {
EXPECT_EQ(Line, N->getLine()); EXPECT_EQ(Line, N->getLine());
EXPECT_EQ(N, MDNamespace::get(Context, Scope, File, Name, Line)); EXPECT_EQ(N, MDNamespace::get(Context, Scope, File, Name, Line));
EXPECT_NE(N, MDNamespace::get(Context, File, File, Name, Line)); EXPECT_NE(N, MDNamespace::get(Context, getFile(), File, Name, Line));
EXPECT_NE(N, MDNamespace::get(Context, Scope, Scope, Name, Line)); EXPECT_NE(N, MDNamespace::get(Context, Scope, getFile(), Name, Line));
EXPECT_NE(N, MDNamespace::get(Context, Scope, File, "other", Line)); EXPECT_NE(N, MDNamespace::get(Context, Scope, File, "other", Line));
EXPECT_NE(N, MDNamespace::get(Context, Scope, File, Name, Line + 1)); EXPECT_NE(N, MDNamespace::get(Context, Scope, File, Name, Line + 1));
@ -1635,8 +1635,7 @@ typedef MetadataTest MDTemplateTypeParameterTest;
TEST_F(MDTemplateTypeParameterTest, get) { TEST_F(MDTemplateTypeParameterTest, get) {
StringRef Name = "template"; StringRef Name = "template";
Metadata *Type = MDTuple::getDistinct(Context, None); MDType *Type = getBasicType("basic");
Metadata *Other = MDTuple::getDistinct(Context, None);
auto *N = MDTemplateTypeParameter::get(Context, Name, Type); auto *N = MDTemplateTypeParameter::get(Context, Name, Type);
@ -1646,7 +1645,8 @@ TEST_F(MDTemplateTypeParameterTest, get) {
EXPECT_EQ(N, MDTemplateTypeParameter::get(Context, Name, Type)); EXPECT_EQ(N, MDTemplateTypeParameter::get(Context, Name, Type));
EXPECT_NE(N, MDTemplateTypeParameter::get(Context, "other", Type)); EXPECT_NE(N, MDTemplateTypeParameter::get(Context, "other", Type));
EXPECT_NE(N, MDTemplateTypeParameter::get(Context, Name, Other)); EXPECT_NE(N,
MDTemplateTypeParameter::get(Context, Name, getBasicType("other")));
TempMDTemplateTypeParameter Temp = N->clone(); TempMDTemplateTypeParameter Temp = N->clone();
EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp))); EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp)));
@ -1657,9 +1657,8 @@ 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";
Metadata *Type = MDTuple::getDistinct(Context, None); MDType *Type = getBasicType("basic");
Metadata *Value = MDTuple::getDistinct(Context, None); Metadata *Value = getConstantAsMetadata();
Metadata *Other = MDTuple::getDistinct(Context, None);
auto *N = MDTemplateValueParameter::get(Context, Tag, Name, Type, Value); auto *N = MDTemplateValueParameter::get(Context, Tag, Name, Type, Value);
EXPECT_EQ(Tag, N->getTag()); EXPECT_EQ(Tag, N->getTag());
@ -1673,9 +1672,10 @@ TEST_F(MDTemplateValueParameterTest, get) {
Type, Value)); Type, Value));
EXPECT_NE(N, MDTemplateValueParameter::get(Context, Tag, "other", Type, EXPECT_NE(N, MDTemplateValueParameter::get(Context, Tag, "other", Type,
Value)); Value));
EXPECT_NE(N, MDTemplateValueParameter::get(Context, Tag, Name, Other, EXPECT_NE(N, MDTemplateValueParameter::get(Context, Tag, Name,
Value)); getBasicType("other"), Value));
EXPECT_NE(N, MDTemplateValueParameter::get(Context, Tag, Name, Type, Other)); EXPECT_NE(N, MDTemplateValueParameter::get(Context, Tag, Name, Type,
getConstantAsMetadata()));
TempMDTemplateValueParameter Temp = N->clone(); TempMDTemplateValueParameter Temp = N->clone();
EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp))); EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp)));
@ -1877,12 +1877,12 @@ typedef MetadataTest MDObjCPropertyTest;
TEST_F(MDObjCPropertyTest, get) { TEST_F(MDObjCPropertyTest, get) {
StringRef Name = "name"; StringRef Name = "name";
Metadata *File = MDTuple::getDistinct(Context, None); MDFile *File = getFile();
unsigned Line = 5; unsigned Line = 5;
StringRef GetterName = "getter"; StringRef GetterName = "getter";
StringRef SetterName = "setter"; StringRef SetterName = "setter";
unsigned Attributes = 7; unsigned Attributes = 7;
Metadata *Type = MDTuple::getDistinct(Context, None); MDType *Type = 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);
@ -1900,7 +1900,7 @@ TEST_F(MDObjCPropertyTest, get) {
EXPECT_NE(N, MDObjCProperty::get(Context, "other", File, Line, GetterName, EXPECT_NE(N, MDObjCProperty::get(Context, "other", File, Line, GetterName,
SetterName, Attributes, Type)); SetterName, Attributes, Type));
EXPECT_NE(N, MDObjCProperty::get(Context, Name, Type, Line, GetterName, EXPECT_NE(N, MDObjCProperty::get(Context, Name, getFile(), Line, GetterName,
SetterName, Attributes, Type)); SetterName, Attributes, Type));
EXPECT_NE(N, MDObjCProperty::get(Context, Name, File, Line + 1, GetterName, EXPECT_NE(N, MDObjCProperty::get(Context, Name, File, Line + 1, GetterName,
SetterName, Attributes, Type)); SetterName, Attributes, Type));
@ -1910,8 +1910,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, MDObjCProperty::get(Context, Name, File, Line, GetterName, EXPECT_NE(N,
SetterName, Attributes, File)); MDObjCProperty::get(Context, Name, File, Line, GetterName,
SetterName, Attributes, 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)));
@ -1921,8 +1922,8 @@ 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;
Metadata *Scope = MDTuple::getDistinct(Context, None); MDScope *Scope = getSubprogram();
Metadata *Entity = MDTuple::getDistinct(Context, None); DebugNode *Entity = getCompositeType();
unsigned Line = 5; unsigned Line = 5;
StringRef Name = "name"; StringRef Name = "name";
@ -1938,8 +1939,10 @@ TEST_F(MDImportedEntityTest, get) {
EXPECT_NE(N, EXPECT_NE(N,
MDImportedEntity::get(Context, dwarf::DW_TAG_imported_declaration, MDImportedEntity::get(Context, dwarf::DW_TAG_imported_declaration,
Scope, Entity, Line, Name)); Scope, Entity, Line, Name));
EXPECT_NE(N, MDImportedEntity::get(Context, Tag, Entity, Entity, Line, Name)); EXPECT_NE(N, MDImportedEntity::get(Context, Tag, getSubprogram(), Entity,
EXPECT_NE(N, MDImportedEntity::get(Context, Tag, Scope, Scope, Line, Name)); Line, Name));
EXPECT_NE(N, MDImportedEntity::get(Context, Tag, Scope, getCompositeType(),
Line, Name));
EXPECT_NE(N, EXPECT_NE(N,
MDImportedEntity::get(Context, Tag, Scope, Entity, Line + 1, Name)); MDImportedEntity::get(Context, Tag, Scope, Entity, Line + 1, Name));
EXPECT_NE(N, EXPECT_NE(N,