[PATCH] D53792: [DebugInfo] Define base function on DWARFDie reverse iterators

Jonas Devlieghere via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 30 11:27:52 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL345621: [DebugInfo] Define base function on DWARFDie reverse iterators (authored by JDevlieghere, committed by ).

Repository:
  rL LLVM

https://reviews.llvm.org/D53792

Files:
  llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDie.h
  llvm/trunk/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp


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<llvm::DWARFDie::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<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();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53792.171740.patch
Type: text/x-patch
Size: 1205 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181030/8d7d4f0f/attachment.bin>


More information about the llvm-commits mailing list