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

Uncovered by _GLIBCXX_DEBUG.

llvm-svn: 37795
This commit is contained in:
David Greene 2007-06-29 02:49:11 +00:00
parent 5b6f755575
commit 9468bfd932
1 changed files with 3 additions and 1 deletions

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;