[llvm-commits] [llvm] r121995 - in /llvm/trunk: include/llvm/ADT/IntervalMap.h unittests/ADT/IntervalMapTest.cpp

Jakob Stoklund Olesen stoklund at 2pi.dk
Thu Dec 16 11:46:09 PST 2010


Author: stoklund
Date: Thu Dec 16 13:46:09 2010
New Revision: 121995

URL: http://llvm.org/viewvc/llvm-project?rev=121995&view=rev
Log:
Add basic test exposing many bugs.

Modified:
    llvm/trunk/include/llvm/ADT/IntervalMap.h
    llvm/trunk/unittests/ADT/IntervalMapTest.cpp

Modified: llvm/trunk/include/llvm/ADT/IntervalMap.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/IntervalMap.h?rev=121995&r1=121994&r2=121995&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/IntervalMap.h (original)
+++ llvm/trunk/include/llvm/ADT/IntervalMap.h Thu Dec 16 13:46:09 2010
@@ -2036,11 +2036,11 @@
     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 @@
   /// 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 @@
   /// 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 @@
   /// 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();

Modified: llvm/trunk/unittests/ADT/IntervalMapTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ADT/IntervalMapTest.cpp?rev=121995&r1=121994&r2=121995&view=diff
==============================================================================
--- llvm/trunk/unittests/ADT/IntervalMapTest.cpp (original)
+++ llvm/trunk/unittests/ADT/IntervalMapTest.cpp Thu Dec 16 13:46:09 2010
@@ -550,4 +550,19 @@
 
 }
 
+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





More information about the llvm-commits mailing list