summaryrefslogtreecommitdiff
path: root/unittests/IR
diff options
context:
space:
mode:
authorVedant Kumar <vsk@apple.com>2018-05-10 23:01:54 +0000
committerVedant Kumar <vsk@apple.com>2018-05-10 23:01:54 +0000
commit48fd38c57346ad9ccc63cea271c9b9a1cbeb38fe (patch)
tree0942a87911f4d653a9f8402c11612ffc6998acc9 /unittests/IR
parentfd0a9c3d8a037210f68b960b663d97ec9506b300 (diff)
[STLExtras] Add distance() for ranges, pred_size(), and succ_size()
This commit adds a wrapper for std::distance() which works with ranges. As it would be a common case to write `distance(predecessors(BB))`, this also introduces `pred_size()` and `succ_size()` helpers to make that easier to write. Differential Revision: https://reviews.llvm.org/D46668 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332057 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/IR')
-rw-r--r--unittests/IR/BasicBlockTest.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/unittests/IR/BasicBlockTest.cpp b/unittests/IR/BasicBlockTest.cpp
index 07ed997f638..bdb2b8751ee 100644
--- a/unittests/IR/BasicBlockTest.cpp
+++ b/unittests/IR/BasicBlockTest.cpp
@@ -73,9 +73,9 @@ TEST(BasicBlockTest, PhiRange) {
auto isPhi = [](Instruction &I) { return isa<PHINode>(&I); };
auto Phis = make_filter_range(*BB, isPhi);
auto ReversedPhis = reverse(make_filter_range(*BB, isPhi));
- EXPECT_EQ(std::distance(Phis.begin(), Phis.end()), 3);
+ EXPECT_EQ(distance(Phis), 3);
EXPECT_EQ(&*Phis.begin(), P1);
- EXPECT_EQ(std::distance(ReversedPhis.begin(), ReversedPhis.end()), 3);
+ EXPECT_EQ(distance(ReversedPhis), 3);
EXPECT_EQ(&*ReversedPhis.begin(), P3);
// And iterate a const range.
@@ -87,8 +87,7 @@ TEST(BasicBlockTest, PhiRange) {
}
#define CHECK_ITERATORS(Range1, Range2) \
- EXPECT_EQ(std::distance(Range1.begin(), Range1.end()), \
- std::distance(Range2.begin(), Range2.end())); \
+ EXPECT_EQ(distance(Range1), distance(Range2)); \
for (auto Pair : zip(Range1, Range2)) \
EXPECT_EQ(&std::get<0>(Pair), std::get<1>(Pair));