summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorJakob Stoklund Olesen <stoklund@2pi.dk>2013-03-08 18:08:54 +0000
committerJakob Stoklund Olesen <stoklund@2pi.dk>2013-03-08 18:08:54 +0000
commite77b6ceb02b07659092b969fb4a96b56c52375ad (patch)
tree13cc73ec3b7549a54e3c28e53de627b8660e0c38 /include
parent7a58099f0a4c9503f400f6b81590a5f6b73d4b97 (diff)
downloadllvm-e77b6ceb02b07659092b969fb4a96b56c52375ad.tar.gz
llvm-e77b6ceb02b07659092b969fb4a96b56c52375ad.tar.bz2
llvm-e77b6ceb02b07659092b969fb4a96b56c52375ad.tar.xz
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
Diffstat (limited to 'include')
-rw-r--r--include/llvm/CodeGen/SlotIndexes.h16
1 files changed, 10 insertions, 6 deletions
diff --git a/include/llvm/CodeGen/SlotIndexes.h b/include/llvm/CodeGen/SlotIndexes.h
index 78fb233e5f..0f85c994a2 100644
--- a/include/llvm/CodeGen/SlotIndexes.h
+++ b/include/llvm/CodeGen/SlotIndexes.h
@@ -396,12 +396,16 @@ namespace llvm {
return index.isValid() ? index.listEntry()->getInstr() : 0;
}
- /// Returns the next non-null index.
- SlotIndex getNextNonNullIndex(SlotIndex index) {
- IndexList::iterator itr(index.listEntry());
- ++itr;
- while (itr != indexList.end() && itr->getInstr() == 0) { ++itr; }
- return SlotIndex(itr, index.getSlot());
+ /// Returns the next non-null index, if one exists.
+ /// Otherwise returns getLastIndex().
+ SlotIndex getNextNonNullIndex(SlotIndex Index) {
+ IndexList::iterator I = Index.listEntry();
+ IndexList::iterator E = indexList.end();
+ 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