summaryrefslogtreecommitdiffstats
path: root/llvm/unittests
diff options
context:
space:
mode:
authorVedant Kumar <vsk@apple.com>2018-05-16 23:20:42 +0000
committerVedant Kumar <vsk@apple.com>2018-05-16 23:20:42 +0000
commit5a0872c2b751fd339e10c1b9d29ed4a9e62a323d (patch)
tree60578e1838b47b5da4279a36a8c17be782946192 /llvm/unittests
parentae83159530f2657d35bc2543065e23256489d7ea (diff)
downloadbcm5719-llvm-5a0872c2b751fd339e10c1b9d29ed4a9e62a323d.tar.gz
bcm5719-llvm-5a0872c2b751fd339e10c1b9d29ed4a9e62a323d.zip
[STLExtras] Add size() for ranges, and remove distance()
r332057 introduced distance() for ranges. Based on post-commit feedback, this renames distance() to size(). The new size() is also only enabled when the operation is O(1). Differential Revision: https://reviews.llvm.org/D46976 llvm-svn: 332551
Diffstat (limited to 'llvm/unittests')
-rw-r--r--llvm/unittests/ADT/IteratorTest.cpp4
-rw-r--r--llvm/unittests/IR/BasicBlockTest.cpp7
2 files changed, 6 insertions, 5 deletions
diff --git a/llvm/unittests/ADT/IteratorTest.cpp b/llvm/unittests/ADT/IteratorTest.cpp
index 69033bbf593..341049a6847 100644
--- a/llvm/unittests/ADT/IteratorTest.cpp
+++ b/llvm/unittests/ADT/IteratorTest.cpp
@@ -369,8 +369,8 @@ TEST(RangeTest, Distance) {
std::vector<int> v1;
std::vector<int> v2{1, 2, 3};
- EXPECT_EQ(std::distance(v1.begin(), v1.end()), distance(v1));
- EXPECT_EQ(std::distance(v2.begin(), v2.end()), distance(v2));
+ EXPECT_EQ(std::distance(v1.begin(), v1.end()), size(v1));
+ EXPECT_EQ(std::distance(v2.begin(), v2.end()), size(v2));
}
} // anonymous namespace
diff --git a/llvm/unittests/IR/BasicBlockTest.cpp b/llvm/unittests/IR/BasicBlockTest.cpp
index bdb2b8751ee..07ed997f638 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(distance(Phis), 3);
+ EXPECT_EQ(std::distance(Phis.begin(), Phis.end()), 3);
EXPECT_EQ(&*Phis.begin(), P1);
- EXPECT_EQ(distance(ReversedPhis), 3);
+ EXPECT_EQ(std::distance(ReversedPhis.begin(), ReversedPhis.end()), 3);
EXPECT_EQ(&*ReversedPhis.begin(), P3);
// And iterate a const range.
@@ -87,7 +87,8 @@ TEST(BasicBlockTest, PhiRange) {
}
#define CHECK_ITERATORS(Range1, Range2) \
- EXPECT_EQ(distance(Range1), distance(Range2)); \
+ EXPECT_EQ(std::distance(Range1.begin(), Range1.end()), \
+ std::distance(Range2.begin(), Range2.end())); \
for (auto Pair : zip(Range1, Range2)) \
EXPECT_EQ(&std::get<0>(Pair), std::get<1>(Pair));
OpenPOWER on IntegriCloud