IR: Add missing clone() overloads

Add missing specialized node overloads for `MDNode::clone()` (they were
on most of the node types already, but missing from the others).
`MDNode::clone()` returns `TempMDNode` (`std::unique_ptr<MDNode,...>`),
while `TempMDSubrange::clone()` (for example) returns the more
convenient `TempMDSubrange` (`std::unique_ptr<TempMDSubrange,...>`).

llvm-svn: 229579
This commit is contained in:
Duncan P. N. Exon Smith 2015-02-17 23:10:13 +00:00
parent 09daa881ea
commit 6873feaa2c
2 changed files with 70 additions and 0 deletions

View File

@ -1217,6 +1217,8 @@ public:
Metadata *Type, Metadata *Value),
(Tag, Scope, Name, Type, Value))
TempMDTemplateValueParameter clone() const { return cloneImpl(); }
Metadata *getValue() const { return getOperand(3); }
static bool classof(const Metadata *MD) {
@ -1310,6 +1312,8 @@ public:
(Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit,
IsDefinition, Variable, StaticDataMemberDeclaration))
TempMDGlobalVariable clone() const { return cloneImpl(); }
bool isLocalToUnit() const { return IsLocalToUnit; }
bool isDefinition() const { return IsDefinition; }
StringRef getDisplayName() const { return getStringOperand(4); }
@ -1380,6 +1384,8 @@ public:
Metadata *InlinedAt = nullptr),
(Tag, Scope, Name, File, Line, Type, Arg, Flags, InlinedAt))
TempMDLocalVariable clone() const { return cloneImpl(); }
unsigned getArg() const { return Arg; }
unsigned getFlags() const { return Flags; }
Metadata *getInlinedAt() const { return getOperand(4); }
@ -1417,6 +1423,8 @@ class MDExpression : public DebugNode {
public:
DEFINE_MDNODE_GET(MDExpression, (ArrayRef<uint64_t> Elements), (Elements))
TempMDExpression clone() const { return cloneImpl(); }
ArrayRef<uint64_t> getElements() const { return Elements; }
unsigned getNumElements() const { return Elements.size(); }
@ -1562,6 +1570,8 @@ public:
(Name, File, Line, GetterName, SetterName, Attributes,
Type))
TempMDObjCProperty clone() const { return cloneImpl(); }
unsigned getLine() const { return Line; }
unsigned getAttributes() const { return Attributes; }
StringRef getName() const { return getStringOperand(0); }

View File

@ -643,6 +643,9 @@ TEST_F(GenericDebugNodeTest, get) {
EXPECT_EQ(Empty, N->getDwarfOperand(0));
ASSERT_TRUE(N->isUniqued());
EXPECT_EQ(N, GenericDebugNode::get(Context, 15, Header, Ops1));
TempGenericDebugNode Temp = N->clone();
EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp)));
}
TEST_F(GenericDebugNodeTest, getEmptyHeader) {
@ -661,6 +664,9 @@ TEST_F(MDSubrangeTest, get) {
EXPECT_EQ(7, N->getLo());
EXPECT_EQ(N, MDSubrange::get(Context, 5, 7));
EXPECT_EQ(MDSubrange::get(Context, 5, 0), MDSubrange::get(Context, 5));
TempMDSubrange Temp = N->clone();
EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp)));
}
typedef MetadataTest MDEnumeratorTest;
@ -674,6 +680,9 @@ TEST_F(MDEnumeratorTest, get) {
EXPECT_NE(N, MDEnumerator::get(Context, 8, "name"));
EXPECT_NE(N, MDEnumerator::get(Context, 7, "nam"));
TempMDEnumerator Temp = N->clone();
EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp)));
}
typedef MetadataTest MDBasicTypeTest;
@ -700,6 +709,9 @@ TEST_F(MDBasicTypeTest, get) {
25, 7));
EXPECT_NE(N, MDBasicType::get(Context, dwarf::DW_TAG_base_type, "special", 33,
26, 6));
TempMDBasicType Temp = N->clone();
EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp)));
}
typedef MetadataTest MDDerivedTypeTest;
@ -760,6 +772,9 @@ TEST_F(MDDerivedTypeTest, get) {
EXPECT_NE(N,
MDDerivedType::get(Context, dwarf::DW_TAG_pointer_type, "something",
File, 1, Scope, BaseType, 2, 3, 4, 5, File));
TempMDDerivedType Temp = N->clone();
EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp)));
}
typedef MetadataTest MDCompositeTypeTest;
@ -876,6 +891,9 @@ TEST_F(MDCompositeTypeTest, get) {
Context, Tag, Name, File, Line, Scope, BaseType, SizeInBits,
AlignInBits, OffsetInBits, Flags, Elements, RuntimeLang,
VTableHolder, TemplateParams)->getRawIdentifier());
TempMDCompositeType Temp = N->clone();
EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp)));
}
typedef MetadataTest MDSubroutineTypeTest;
@ -893,6 +911,9 @@ TEST_F(MDSubroutineTypeTest, get) {
EXPECT_NE(N, MDSubroutineType::get(Context, Flags + 1, TypeArray));
EXPECT_NE(N, MDSubroutineType::get(Context, Flags,
MDTuple::getDistinct(Context, None)));
TempMDSubroutineType Temp = N->clone();
EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp)));
}
typedef MetadataTest MDFileTest;
@ -909,6 +930,9 @@ TEST_F(MDFileTest, get) {
EXPECT_NE(N, MDFile::get(Context, "other", Directory));
EXPECT_NE(N, MDFile::get(Context, Filename, "other"));
TempMDFile Temp = N->clone();
EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp)));
}
typedef MetadataTest MDCompileUnitTest;
@ -1013,6 +1037,9 @@ TEST_F(MDCompileUnitTest, get) {
Context, SourceLanguage, File, Producer, IsOptimized, Flags,
RuntimeVersion, SplitDebugFilename, EmissionKind, EnumTypes,
RetainedTypes, Subprograms, GlobalVariables, File));
TempMDCompileUnit Temp = N->clone();
EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp)));
}
typedef MetadataTest MDSubprogramTest;
@ -1157,6 +1184,9 @@ TEST_F(MDSubprogramTest, get) {
ContainingType, Virtuality, VirtualIndex,
Flags, IsOptimized, Function, TemplateParams,
Declaration, Type));
TempMDSubprogram Temp = N->clone();
EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp)));
}
typedef MetadataTest MDLexicalBlockTest;
@ -1180,6 +1210,9 @@ TEST_F(MDLexicalBlockTest, get) {
EXPECT_NE(N, MDLexicalBlock::get(Context, Scope, Scope, Line, Column));
EXPECT_NE(N, MDLexicalBlock::get(Context, Scope, File, Line + 1, Column));
EXPECT_NE(N, MDLexicalBlock::get(Context, Scope, File, Line, Column + 1));
TempMDLexicalBlock Temp = N->clone();
EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp)));
}
typedef MetadataTest MDLexicalBlockFileTest;
@ -1201,6 +1234,9 @@ TEST_F(MDLexicalBlockFileTest, get) {
EXPECT_NE(N, MDLexicalBlockFile::get(Context, Scope, Scope, Discriminator));
EXPECT_NE(N,
MDLexicalBlockFile::get(Context, Scope, File, Discriminator + 1));
TempMDLexicalBlockFile Temp = N->clone();
EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp)));
}
typedef MetadataTest MDNamespaceTest;
@ -1224,6 +1260,9 @@ TEST_F(MDNamespaceTest, get) {
EXPECT_NE(N, MDNamespace::get(Context, Scope, Scope, Name, Line));
EXPECT_NE(N, MDNamespace::get(Context, Scope, File, "other", Line));
EXPECT_NE(N, MDNamespace::get(Context, Scope, File, Name, Line + 1));
TempMDNamespace Temp = N->clone();
EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp)));
}
typedef MetadataTest MDTemplateTypeParameterTest;
@ -1244,6 +1283,9 @@ TEST_F(MDTemplateTypeParameterTest, get) {
EXPECT_NE(N, MDTemplateTypeParameter::get(Context, Type, Name, Type));
EXPECT_NE(N, MDTemplateTypeParameter::get(Context, Scope, "other", Type));
EXPECT_NE(N, MDTemplateTypeParameter::get(Context, Scope, Name, Scope));
TempMDTemplateTypeParameter Temp = N->clone();
EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp)));
}
typedef MetadataTest MDTemplateValueParameterTest;
@ -1276,6 +1318,9 @@ TEST_F(MDTemplateValueParameterTest, get) {
Value));
EXPECT_NE(
N, MDTemplateValueParameter::get(Context, Tag, Scope, Name, Type, Scope));
TempMDTemplateValueParameter Temp = N->clone();
EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp)));
}
typedef MetadataTest MDGlobalVariableTest;
@ -1341,6 +1386,9 @@ TEST_F(MDGlobalVariableTest, get) {
EXPECT_NE(N, MDGlobalVariable::get(Context, Scope, Name, LinkageName, File,
Line, Type, IsLocalToUnit, IsDefinition,
Variable, Type));
TempMDGlobalVariable Temp = N->clone();
EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp)));
}
typedef MetadataTest MDLocalVariableTest;
@ -1389,6 +1437,9 @@ TEST_F(MDLocalVariableTest, get) {
Arg, ~Flags, InlinedAt));
EXPECT_NE(N, MDLocalVariable::get(Context, Tag, Scope, Name, File, Line, Type,
Arg, Flags, Scope));
TempMDLocalVariable Temp = N->clone();
EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp)));
}
typedef MetadataTest MDExpressionTest;
@ -1405,6 +1456,9 @@ TEST_F(MDExpressionTest, get) {
EXPECT_EQ(9u, N->getElement(2));
EXPECT_EQ(78u, N->getElement(3));
EXPECT_EQ(0u, N->getElement(4));
TempMDExpression Temp = N->clone();
EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp)));
}
TEST_F(MDExpressionTest, isValid) {
@ -1482,6 +1536,9 @@ TEST_F(MDObjCPropertyTest, get) {
SetterName, Attributes + 1, Type));
EXPECT_NE(N, MDObjCProperty::get(Context, Name, File, Line, GetterName,
SetterName, Attributes, File));
TempMDObjCProperty Temp = N->clone();
EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp)));
}
typedef MetadataTest MDImportedEntityTest;
@ -1511,6 +1568,9 @@ TEST_F(MDImportedEntityTest, get) {
MDImportedEntity::get(Context, Tag, Scope, Entity, Line + 1, Name));
EXPECT_NE(N,
MDImportedEntity::get(Context, Tag, Scope, Entity, Line, "other"));
TempMDImportedEntity Temp = N->clone();
EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp)));
}
typedef MetadataTest MetadataAsValueTest;