summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h4
-rw-r--r--llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp4
2 files changed, 8 insertions, 0 deletions
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h
index c77034f6348..baa47c2bfa5 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h
@@ -404,6 +404,10 @@ public:
Die = Die.getPreviousSibling();
}
+ llvm::DWARFDie::iterator base() const {
+ return llvm::DWARFDie::iterator(AtEnd ? Die : Die.getSibling());
+ }
+
reverse_iterator<llvm::DWARFDie::iterator> &operator++() {
assert(!AtEnd && "Incrementing rend");
llvm::DWARFDie D = Die.getPreviousSibling();
diff --git a/llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp b/llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
index 1be0363adb0..ffbde2df2bc 100644
--- a/llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
+++ b/llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
@@ -1227,6 +1227,10 @@ TEST(DWARFDebugInfo, TestRelations) {
EXPECT_THAT(std::vector<DWARFDie>(A.rbegin(), A.rend()),
testing::ElementsAre(D, C, B));
+ // Make sure conversion from reverse iterator works as expected.
+ EXPECT_EQ(A.rbegin().base(), A.end());
+ EXPECT_EQ(A.rend().base(), A.begin());
+
// Make sure iterator is bidirectional.
{
auto Begin = A.begin();
OpenPOWER on IntegriCloud