Avoid creating a SlotIndex from the end() iterator.

No test case, spotted by inspection.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176705 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Jakob Stoklund Olesen 2013-03-08 18:08:54 +00:00
parent 7a58099f0a
commit e77b6ceb02

View File

@ -396,12 +396,16 @@ namespace llvm {
return index.isValid() ? index.listEntry()->getInstr() : 0; return index.isValid() ? index.listEntry()->getInstr() : 0;
} }
/// Returns the next non-null index. /// Returns the next non-null index, if one exists.
SlotIndex getNextNonNullIndex(SlotIndex index) { /// Otherwise returns getLastIndex().
IndexList::iterator itr(index.listEntry()); SlotIndex getNextNonNullIndex(SlotIndex Index) {
++itr; IndexList::iterator I = Index.listEntry();
while (itr != indexList.end() && itr->getInstr() == 0) { ++itr; } IndexList::iterator E = indexList.end();
return SlotIndex(itr, index.getSlot()); while (I != E)
if ((++I)->getInstr())
return SlotIndex(I, Index.getSlot());
// We reached the end of the function.
return getLastIndex();
} }
/// getIndexBefore - Returns the index of the last indexed instruction /// getIndexBefore - Returns the index of the last indexed instruction