[PATCH] D29619: ADT: Add explicit conversions for reverse ilist iterators

Duncan P. N. Exon Smith via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 6 22:46:59 PST 2017


dexonsmith created this revision.

Add explicit conversions between forward and reverse ilist iterators.
These follow the conversion conventions of std::reverse_iterator, which
are off-by-one: the newly-constructed "reverse" iterator dereferences to
the previous node of the one sent in.  This has the benefit of
converting reverse ranges in place:

- If [I, E) is a valid range,
- then [reverse(E), reverse(I)) gives the same range in reverse order.

ilist_iterator::getReverse() is unchanged: it returns a reverse iterator
to the *same* node.

Note: we should probably add some release notes for LLVM 4.0 around the
ilist changes, and I think it makes sense to have these conversions in
(and described there).  There's been some debate about whether to keep,
delete, or rename getReverse(), but for now I'd just like to get the
explicit conversions in and we can decide later whether to make
getReverse() harder to access.


https://reviews.llvm.org/D29619

Files:
  llvm/include/llvm/ADT/ilist_iterator.h
  llvm/include/llvm/CodeGen/MachineInstrBundleIterator.h
  llvm/unittests/ADT/IListIteratorTest.cpp
  llvm/unittests/CodeGen/MachineInstrBundleIteratorTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D29619.87364.patch
Type: text/x-patch
Size: 8670 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170207/96c32f66/attachment.bin>


More information about the llvm-commits mailing list