diff options
author | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2010-12-17 19:18:38 +0000 |
---|---|---|
committer | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2010-12-17 19:18:38 +0000 |
commit | 4aec85ae01188f87e45e5e91baab4f303cbcd336 (patch) | |
tree | 70c1d2c1852f26f6476fd10f789c98122988de6f /include/llvm/ADT/IntervalMap.h | |
parent | a3dbd3a2444f2531763ba05b64a30932542a631f (diff) | |
download | external_llvm-4aec85ae01188f87e45e5e91baab4f303cbcd336.zip external_llvm-4aec85ae01188f87e45e5e91baab4f303cbcd336.tar.gz external_llvm-4aec85ae01188f87e45e5e91baab4f303cbcd336.tar.bz2 |
Fix crash when IntervalMapOverlaps::advanceTo moves past the last overlap.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122081 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/ADT/IntervalMap.h')
-rw-r--r-- | include/llvm/ADT/IntervalMap.h | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/include/llvm/ADT/IntervalMap.h b/include/llvm/ADT/IntervalMap.h index 3f7a4c7..25be574 100644 --- a/include/llvm/ADT/IntervalMap.h +++ b/include/llvm/ADT/IntervalMap.h @@ -2036,6 +2036,8 @@ class IntervalMapOverlaps { /// either meets end. /// Don't move the iterators if they are already overlapping. void advance() { + if (!valid()) + return; for (;;) { // Make a.end > b.start. posA.advanceTo(posB.start()); @@ -2052,10 +2054,7 @@ public: /// IntervalMapOverlaps - Create an iterator for the overlaps of a and b. IntervalMapOverlaps(const MapA &a, const MapB &b) : posA(b.empty() ? a.end() : a.find(b.start())), - posB(posA.valid() ? b.find(posA.start()) : b.end()) { - if (valid()) - advance(); - } + posB(posA.valid() ? b.find(posA.start()) : b.end()) { advance(); } /// valid - Return true if iterator is at an overlap. bool valid() const { @@ -2090,7 +2089,7 @@ public: // Second half-loop of advance(). posB.advanceTo(posA.start()); if (!posB.valid() || !Traits::stopLess(posA.stop(), posB.start())) - return ; + return; advance(); } @@ -2098,7 +2097,7 @@ public: void skipB() { ++posB; if (!posB.valid() || !Traits::stopLess(posA.stop(), posB.start())) - return; + return; advance(); } |