summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJakob Stoklund Olesen <stoklund@2pi.dk>2010-12-16 19:46:09 +0000
committerJakob Stoklund Olesen <stoklund@2pi.dk>2010-12-16 19:46:09 +0000
commitaf49e9774ac9ebb5f169196e6dd8dd70861d80e0 (patch)
tree08bd1b7ee0fc699afd5c0b6f6a8239d8cc94fa3d
parent266f4092d75c7a451d6f21de111c603720d83333 (diff)
downloadbcm5719-llvm-af49e9774ac9ebb5f169196e6dd8dd70861d80e0.tar.gz
bcm5719-llvm-af49e9774ac9ebb5f169196e6dd8dd70861d80e0.zip
Add basic test exposing many bugs.
llvm-svn: 121995
-rw-r--r--llvm/include/llvm/ADT/IntervalMap.h12
-rw-r--r--llvm/unittests/ADT/IntervalMapTest.cpp15
2 files changed, 21 insertions, 6 deletions
diff --git a/llvm/include/llvm/ADT/IntervalMap.h b/llvm/include/llvm/ADT/IntervalMap.h
index ae79e845088..86652f5673a 100644
--- a/llvm/include/llvm/ADT/IntervalMap.h
+++ b/llvm/include/llvm/ADT/IntervalMap.h
@@ -2036,11 +2036,11 @@ class IntervalMapOverlaps {
for (;;) {
// Make a.end > b.start.
posA.advanceTo(posB.start());
- if (!posA.valid() || !Traits::stopLess(posB.end(), posA.start()))
+ if (!posA.valid() || !Traits::stopLess(posB.stop(), posA.start()))
return;
// Make b.end > a.start.
posB.advanceTo(posA.start());
- if (!posB.valid() || !Traits::stopLess(posA.end(), posB.start()))
+ if (!posB.valid() || !Traits::stopLess(posA.stop(), posB.start()))
return;
}
}
@@ -2068,11 +2068,11 @@ public:
/// skipA - Move to the next overlap that doesn't involve a().
void skipA() {
++posA;
- if (!posA.valid() || !Traits::stopLess(posB.end(), posA.start()))
+ if (!posA.valid() || !Traits::stopLess(posB.stop(), posA.start()))
return;
// Second half-loop of advance().
posB.advanceTo(posA.start());
- if (!posB.valid() || !Traits::stopLess(posA.end(), posB.start()))
+ if (!posB.valid() || !Traits::stopLess(posA.stop(), posB.start()))
return ;
advance();
}
@@ -2080,7 +2080,7 @@ public:
/// skipB - Move to the next overlap that doesn't involve b().
void skipB() {
++posB;
- if (!posB.valid() || !Traits::stopLess(posA.end(), posB.start()))
+ if (!posB.valid() || !Traits::stopLess(posA.stop(), posB.start()))
return;
advance();
}
@@ -2088,7 +2088,7 @@ public:
/// Preincrement - Move to the next overlap.
IntervalMapOverlaps &operator++() {
// Bump the iterator that ends first. The other one may have more overlaps.
- if (Traits::startLess(posB.end(), posA.end()))
+ if (Traits::startLess(posB.stop(), posA.stop()))
skipB();
else
skipA();
diff --git a/llvm/unittests/ADT/IntervalMapTest.cpp b/llvm/unittests/ADT/IntervalMapTest.cpp
index fc16a327982..a84cca8dd76 100644
--- a/llvm/unittests/ADT/IntervalMapTest.cpp
+++ b/llvm/unittests/ADT/IntervalMapTest.cpp
@@ -550,4 +550,19 @@ TEST(IntervalMapTest, RandomCoalescing) {
}
+TEST(IntervalMapOverlapsTest, EmptyMaps) {
+ typedef IntervalMapOverlaps<UUMap,UUMap> UUOverlaps;
+ UUMap::Allocator allocator;
+ UUMap mapA(allocator);
+ UUMap mapB(allocator);
+
+ // empty, empty.
+ EXPECT_FALSE(UUOverlaps(mapA, mapB).valid());
+
+ mapA.insert(1, 2, 3);
+ // full, empty
+ EXPECT_FALSE(UUOverlaps(mapA, mapB).valid());
+ // empty, full
+ EXPECT_FALSE(UUOverlaps(mapB, mapA).valid());
+}
} // namespace
OpenPOWER on IntegriCloud