summaryrefslogtreecommitdiff
path: root/unittests
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2015-02-18 20:47:52 +0000
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2015-02-18 20:47:52 +0000
commit668aca9b4a6f2c09c5f798beccdb35485c7005bd (patch)
tree9df391c95ab3f20d096c25b8abf2fa5fec177414 /unittests
parent70ee038129a5a241c339c245bf1e165310baf990 (diff)
downloadllvm-668aca9b4a6f2c09c5f798beccdb35485c7005bd.tar.gz
IR: Add MDCompositeTypeBase::replace*()
Add `replaceElements()`, `replaceVTableHolder()`, and `replaceTemplateParams()` to `MDCompositeTypeBase`. Included an assertion in `replaceElements()` to match the one in `DICompositeType::replaceArrays()`. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229744 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r--unittests/IR/MetadataTest.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/unittests/IR/MetadataTest.cpp b/unittests/IR/MetadataTest.cpp
index a5d64b116c49..fc2ed73d89c0 100644
--- a/unittests/IR/MetadataTest.cpp
+++ b/unittests/IR/MetadataTest.cpp
@@ -897,6 +897,47 @@ TEST_F(MDCompositeTypeTest, get) {
EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp)));
}
+TEST_F(MDCompositeTypeTest, replaceOperands) {
+ unsigned Tag = dwarf::DW_TAG_structure_type;
+ StringRef Name = "some name";
+ Metadata *File = MDTuple::getDistinct(Context, None);
+ unsigned Line = 1;
+ Metadata *Scope = MDTuple::getDistinct(Context, None);
+ Metadata *BaseType = MDTuple::getDistinct(Context, None);
+ unsigned SizeInBits = 2;
+ unsigned AlignInBits = 3;
+ unsigned OffsetInBits = 4;
+ unsigned Flags = 5;
+ unsigned RuntimeLang = 6;
+ StringRef Identifier = "some id";
+
+ auto *N = MDCompositeType::get(Context, Tag, Name, File, Line, Scope,
+ BaseType, SizeInBits, AlignInBits,
+ OffsetInBits, Flags, nullptr, RuntimeLang,
+ nullptr, nullptr, Identifier);
+
+ auto *Elements = MDTuple::getDistinct(Context, None);
+ EXPECT_EQ(nullptr, N->getElements());
+ N->replaceElements(Elements);
+ EXPECT_EQ(Elements, N->getElements());
+ N->replaceElements(nullptr);
+ EXPECT_EQ(nullptr, N->getElements());
+
+ auto *VTableHolder = MDTuple::getDistinct(Context, None);
+ EXPECT_EQ(nullptr, N->getVTableHolder());
+ N->replaceVTableHolder(VTableHolder);
+ EXPECT_EQ(VTableHolder, N->getVTableHolder());
+ N->replaceVTableHolder(nullptr);
+ EXPECT_EQ(nullptr, N->getVTableHolder());
+
+ auto *TemplateParams = MDTuple::getDistinct(Context, None);
+ EXPECT_EQ(nullptr, N->getTemplateParams());
+ N->replaceTemplateParams(TemplateParams);
+ EXPECT_EQ(TemplateParams, N->getTemplateParams());
+ N->replaceTemplateParams(nullptr);
+ EXPECT_EQ(nullptr, N->getTemplateParams());
+}
+
typedef MetadataTest MDSubroutineTypeTest;
TEST_F(MDSubroutineTypeTest, get) {