Index: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDie.h =================================================================== --- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDie.h +++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDie.h @@ -404,6 +404,10 @@ Die = Die.getPreviousSibling(); } + llvm::DWARFDie::iterator base() const { + return llvm::DWARFDie::iterator(AtEnd ? Die : Die.getSibling()); + } + reverse_iterator &operator++() { assert(!AtEnd && "Incrementing rend"); llvm::DWARFDie D = Die.getPreviousSibling(); Index: llvm/trunk/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp =================================================================== --- llvm/trunk/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp +++ llvm/trunk/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp @@ -1227,6 +1227,10 @@ EXPECT_THAT(std::vector(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();