[llvm] r228648 - IR: Add accessors to MDExpression
Duncan P. N. Exon Smith
dexonsmith at apple.com
Mon Feb 9 17:36:47 PST 2015
Author: dexonsmith
Date: Mon Feb 9 19:36:46 2015
New Revision: 228648
URL: http://llvm.org/viewvc/llvm-project?rev=228648&view=rev
Log:
IR: Add accessors to MDExpression
Add some accessors to `MDExpression`.
Modified:
llvm/trunk/include/llvm/IR/DebugInfoMetadata.h
llvm/trunk/unittests/IR/MetadataTest.cpp
Modified: llvm/trunk/include/llvm/IR/DebugInfoMetadata.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/DebugInfoMetadata.h?rev=228648&r1=228647&r2=228648&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/DebugInfoMetadata.h (original)
+++ llvm/trunk/include/llvm/IR/DebugInfoMetadata.h Mon Feb 9 19:36:46 2015
@@ -1410,6 +1410,12 @@ public:
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;
element_iterator elements_begin() const { return getElements().begin(); }
element_iterator elements_end() const { return getElements().end(); }
Modified: llvm/trunk/unittests/IR/MetadataTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/IR/MetadataTest.cpp?rev=228648&r1=228647&r2=228648&view=diff
==============================================================================
--- llvm/trunk/unittests/IR/MetadataTest.cpp (original)
+++ llvm/trunk/unittests/IR/MetadataTest.cpp Mon Feb 9 19:36:46 2015
@@ -1389,6 +1389,13 @@ TEST_F(MDExpressionTest, get) {
auto *N = MDExpression::get(Context, Elements);
EXPECT_EQ(makeArrayRef(Elements), N->getElements());
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;
More information about the llvm-commits
mailing list