summaryrefslogtreecommitdiff
path: root/unittests/ADT/RangeAdapterTest.cpp
AgeCommit message (Collapse)Author
2017-06-06Re-sort #include lines for unittests. This uses a slightly modifiedChandler Carruth
clang-format (https://reviews.llvm.org/D33932) to keep primary headers at the top and handle new utility headers like 'gmock' consistently with other utility headers. No other change was made. I did no manual edits, all of this is clang-format. This should allow other changes to have more clear and focused diffs, and is especially motivated by moving some headers into more focused libraries. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@304786 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-18Reapply "ADT: Remove references in has_rbegin for reverse()"Duncan P. N. Exon Smith
This reverts commit r279086, reapplying r279084. I'm not sure what I ran before, because the compile failure for ADTTests reproduced locally. The problem is that TestRev is calling BidirectionalVector::rbegin() when the BidirectionalVector is const, but rbegin() is always non-const. I've updated BidirectionalVector::rbegin() to be callable from const. Original commit message follows. -- As a follow-up to r278991, add some tests that check that decltype(reverse(R).begin()) == decltype(R.rbegin()), and get them passing by adding std::remove_reference to has_rbegin. I'm using static_assert instead of EXPECT_TRUE (and updated the other has_rbegin check from r278991 in the same way) since I figure that's more helpful. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279091 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-18Revert "ADT: Remove references in has_rbegin for reverse()"Duncan P. N. Exon Smith
This reverts commit r279084, since it failed on a bot: http://bb.pgr.jp/builders/cmake-llvm-x86_64-linux/builds/41733 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279086 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-18ADT: Remove references in has_rbegin for reverse()Duncan P. N. Exon Smith
As a follow-up to r278991, add some tests that check that decltype(reverse(R).begin()) == decltype(R.rbegin()), and get them passing by adding std::remove_reference to has_rbegin. I'm using static_assert instead of EXPECT_TRUE (and updated the other has_rbegin check from r278991 in the same way) since I figure that's more helpful. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279084 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-17Actually enable new test for const RangeAdapter. Missing from r278991Pete Cooper
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279000 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-17Fix reverse to work on const rbegin()/rend().Pete Cooper
Duncan found that reverse worked on mutable rbegin(), but the has_rbegin trait didn't work with a const method. See http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20160815/382890.html for more details. Turns out this was already solved in clang with has_getDecl. Copied that and made it work for rbegin. This includes the tests Duncan attached to that thread, including the traits test. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278991 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-29Reapply "Add reverse(ContainerTy) range adapter."Pete Cooper
This reverts commit r243567, which ultimately reapplies r243563. The fix here was to use std::enable_if for overload resolution. Thanks to David Blaikie for lots of help on this, and for the extra tests! Original commit message follows: 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@243581 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-29Revert "Add reverse(ContainerTy) range adapter."Pete Cooper
This reverts commit r243563. The GCC buildbots were extremely unhappy about this. Reverting while we discuss a better way of doing overload resolution. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243567 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-29Add reverse(ContainerTy) range adapter.Pete Cooper
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