Add reverse(ContainerTy) range adapter.
authorPete Cooper <peter_cooper@apple.com>
Wed, 29 Jul 2015 20:00:39 +0000 (20:00 +0000)
committerPete Cooper <peter_cooper@apple.com>
Wed, 29 Jul 2015 20:00:39 +0000 (20:00 +0000)
commita53ce4e0be51725468c589b1d0a070b30fffacde
tree7d52c3c1b90477030e7c0a46221ca163afbc4384
parent67e53da671b698a89864d2b6df8904456eb1a8ee
Add reverse(ContainerTy) range adapter.

For cases where we needed a foreach loop in reverse over a container,
we had to do something like

  for (const GlobalValue *GV : make_range(TypeInfos.rbegin(),
                                          TypeInfos.rend())) {

This provides a convenience method which shortens this to

  for (const GlobalValue *GV : reverse(TypeInfos)) {

There are 2 versions of this, with a preference to the rbegin() version.

The first uses rbegin() and rend() to construct an iterator_range.

The second constructs an iterator_range from the begin() and end() methods
wrapped in std::reverse_iterator's.

Reviewed by David Blaikie.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243563 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/ADT/STLExtras.h
lib/CodeGen/AsmPrinter/ARMException.cpp
unittests/ADT/CMakeLists.txt
unittests/ADT/RangeAdapterTest.cpp [new file with mode: 0644]