mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 11:42:57 +01:00
IR: Add accessors to MDExpression
Add some accessors to `MDExpression`. llvm-svn: 228648
This commit is contained in:
parent
c23fcf30e5
commit
6c66615baf
@ -1410,6 +1410,12 @@ public:
|
|||||||
|
|
||||||
ArrayRef<uint64_t> getElements() const { return Elements; }
|
ArrayRef<uint64_t> getElements() const { return Elements; }
|
||||||
|
|
||||||
|
unsigned getNumElements() const { return Elements.size(); }
|
||||||
|
uint64_t getElement(unsigned I) const {
|
||||||
|
assert(I < Elements.size() && "Index out of range");
|
||||||
|
return Elements[I];
|
||||||
|
}
|
||||||
|
|
||||||
typedef ArrayRef<uint64_t>::iterator element_iterator;
|
typedef ArrayRef<uint64_t>::iterator element_iterator;
|
||||||
element_iterator elements_begin() const { return getElements().begin(); }
|
element_iterator elements_begin() const { return getElements().begin(); }
|
||||||
element_iterator elements_end() const { return getElements().end(); }
|
element_iterator elements_end() const { return getElements().end(); }
|
||||||
|
@ -1389,6 +1389,13 @@ TEST_F(MDExpressionTest, get) {
|
|||||||
auto *N = MDExpression::get(Context, Elements);
|
auto *N = MDExpression::get(Context, Elements);
|
||||||
EXPECT_EQ(makeArrayRef(Elements), N->getElements());
|
EXPECT_EQ(makeArrayRef(Elements), N->getElements());
|
||||||
EXPECT_EQ(N, MDExpression::get(Context, Elements));
|
EXPECT_EQ(N, MDExpression::get(Context, Elements));
|
||||||
|
|
||||||
|
EXPECT_EQ(5u, N->getNumElements());
|
||||||
|
EXPECT_EQ(2u, N->getElement(0));
|
||||||
|
EXPECT_EQ(6u, N->getElement(1));
|
||||||
|
EXPECT_EQ(9u, N->getElement(2));
|
||||||
|
EXPECT_EQ(78u, N->getElement(3));
|
||||||
|
EXPECT_EQ(0u, N->getElement(4));
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef MetadataTest MDObjCPropertyTest;
|
typedef MetadataTest MDObjCPropertyTest;
|
||||||
|
Loading…
Reference in New Issue
Block a user