[llvm-commits] [llvm] r119871 - in /llvm/trunk: include/llvm/ADT/IntervalMap.h unittests/ADT/IntervalMapTest.cpp
Jakob Stoklund Olesen
stoklund at 2pi.dk
Fri Nov 19 15:28:53 PST 2010
Author: stoklund
Date: Fri Nov 19 17:28:53 2010
New Revision: 119871
URL: http://llvm.org/viewvc/llvm-project?rev=119871&view=rev
Log:
Support backwards iteration starting from end().
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=119871&r1=119870&r2=119871&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/IntervalMap.h (original)
+++ llvm/trunk/include/llvm/ADT/IntervalMap.h Fri Nov 19 17:28:53 2010
@@ -1235,7 +1235,7 @@
if (!branched()) {
assert(rootOffset && "Cannot decrement begin()");
--rootOffset;
- } else if (treeLeafOffset())
+ } else if (valid() && treeLeafOffset())
--treeLeafOffset();
else
treeDecrement();
Modified: llvm/trunk/unittests/ADT/IntervalMapTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ADT/IntervalMapTest.cpp?rev=119871&r1=119870&r2=119871&view=diff
==============================================================================
--- llvm/trunk/unittests/ADT/IntervalMapTest.cpp (original)
+++ llvm/trunk/unittests/ADT/IntervalMapTest.cpp Fri Nov 19 17:28:53 2010
@@ -352,6 +352,16 @@
EXPECT_FALSE(I.valid());
EXPECT_TRUE(I == map.end());
+ // Backwards iteration.
+ for (unsigned i = 99; i; --i) {
+ --I;
+ ASSERT_TRUE(I.valid());
+ EXPECT_EQ(10*i, I.start());
+ EXPECT_EQ(10*i+5, I.stop());
+ EXPECT_EQ(i, *I);
+ }
+ EXPECT_TRUE(I == map.begin());
+
}
} // namespace
More information about the llvm-commits
mailing list