summaryrefslogtreecommitdiffstats
path: root/llvm/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
commite0b5f86b3083747beaf5d7639333af0109c9e6ef (patch)
treef76486dec408880ad53ce624064ccb10f2b9faea /llvm/unittests/IR
parent4855c5f717fde5207033e97989b20b273298a57b (diff)
downloadbcm5719-llvm-e0b5f86b3083747beaf5d7639333af0109c9e6ef.tar.gz
bcm5719-llvm-e0b5f86b3083747beaf5d7639333af0109c9e6ef.zip
[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 llvm-svn: 332057
Diffstat (limited to 'llvm/unittests/IR')
-rw-r--r--llvm/unittests/IR/BasicBlockTest.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/llvm/unittests/IR/BasicBlockTest.cpp b/llvm/unittests/IR/BasicBlockTest.cpp
index 07ed997f638..bdb2b8751ee 100644
--- a/llvm/unittests/IR/BasicBlockTest.cpp
+++ b/llvm/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));
OpenPOWER on IntegriCloud