From 8a46d342d8cbca7c9c7be6c66007d41329babad0 Mon Sep 17 00:00:00 2001 From: David Greene Date: Fri, 29 Jun 2007 02:45:24 +0000 Subject: Fix misue of iterator pointing to erased object. Uncovered by _GLIBCXX_DEBUG. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37793 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/MachineBasicBlock.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/CodeGen/MachineBasicBlock.cpp') diff --git a/lib/CodeGen/MachineBasicBlock.cpp b/lib/CodeGen/MachineBasicBlock.cpp index da062b1559..ba428c5bdb 100644 --- a/lib/CodeGen/MachineBasicBlock.cpp +++ b/lib/CodeGen/MachineBasicBlock.cpp @@ -176,10 +176,10 @@ void MachineBasicBlock::removeSuccessor(MachineBasicBlock *succ) { Successors.erase(I); } -void MachineBasicBlock::removeSuccessor(succ_iterator I) { +MachineBasicBlock::succ_iterator MachineBasicBlock::removeSuccessor(succ_iterator I) { assert(I != Successors.end() && "Not a current successor!"); (*I)->removePredecessor(this); - Successors.erase(I); + return(Successors.erase(I)); } void MachineBasicBlock::addPredecessor(MachineBasicBlock *pred) { @@ -273,7 +273,7 @@ bool MachineBasicBlock::CorrectExtraCFGEdges(MachineBasicBlock *DestA, ++SI; } else { // Otherwise, this is a superfluous edge, remove it. - removeSuccessor(SI); + SI = removeSuccessor(SI); MadeChange = true; } } -- cgit v1.2.3-18-g5258