Fix reference to cached end iterator invalidated by an erase operation.

Uncovered by _GLIBCXX_DEBUG.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37795 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
David Greene 2007-06-29 02:49:11 +00:00
parent a4ab2e8c72
commit cfacc8f5d2

View File

@ -1700,7 +1700,9 @@ unsigned SelectionDAGLowering::Clusterify(CaseVector& Cases,
// Merge case into clusters
if (Cases.size()>=2)
for (CaseItr I=Cases.begin(), J=++(Cases.begin()), E=Cases.end(); J!=E; ) {
// Cray [dag]: Must recompute end() each iteration because it may
// be invalidated by erase if we hold on to it
for (CaseItr I=Cases.begin(), J=++(Cases.begin()); J!=Cases.end(); ) {
int64_t nextValue = cast<ConstantInt>(J->Low)->getSExtValue();
int64_t currentValue = cast<ConstantInt>(I->High)->getSExtValue();
MachineBasicBlock* nextBB = J->BB;