diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2013-11-15 21:56:44 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2013-11-15 21:56:44 +0000 |
commit | 4303b091d0b0c4982efde6f575f4dfd72ff14c42 (patch) | |
tree | 89276cf819699754ed1f3c171c3968b2ee8b62f0 | |
parent | d515e98ebf711d7e80589e4029f27c206573b400 (diff) | |
download | external_llvm-4303b091d0b0c4982efde6f575f4dfd72ff14c42.zip external_llvm-4303b091d0b0c4982efde6f575f4dfd72ff14c42.tar.gz external_llvm-4303b091d0b0c4982efde6f575f4dfd72ff14c42.tar.bz2 |
[PM] Fix an iterator problem spotted by the MSVC debug iterators and
AaronBallman. Thanks for the excellent review.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194857 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/IR/PassManager.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/lib/IR/PassManager.cpp b/lib/IR/PassManager.cpp index f706a0d..966af7d 100644 --- a/lib/IR/PassManager.cpp +++ b/lib/IR/PassManager.cpp @@ -47,11 +47,12 @@ void AnalysisManager::invalidateAll(Function *F) { FunctionAnalysisResultListT &ResultsList = FunctionAnalysisResultLists[F]; for (FunctionAnalysisResultListT::iterator I = ResultsList.begin(), E = ResultsList.end(); - I != E; ++I) + I != E;) if (I->second->invalidate(F)) { - FunctionAnalysisResultListT::iterator Old = I--; - InvalidatedPassIDs.push_back(Old->first); - ResultsList.erase(Old); + InvalidatedPassIDs.push_back(I->first); + I = ResultsList.erase(I); + } else { + ++I; } while (!InvalidatedPassIDs.empty()) FunctionAnalysisResults.erase( @@ -80,11 +81,12 @@ void AnalysisManager::invalidateAll(Module *M) { FunctionAnalysisResultListT &ResultsList = FI->second; for (FunctionAnalysisResultListT::iterator I = ResultsList.begin(), E = ResultsList.end(); - I != E; ++I) + I != E;) if (I->second->invalidate(F)) { - FunctionAnalysisResultListT::iterator Old = I--; - InvalidatedPassIDs.push_back(Old->first); - ResultsList.erase(Old); + InvalidatedPassIDs.push_back(I->first); + I = ResultsList.erase(I); + } else { + ++I; } while (!InvalidatedPassIDs.empty()) FunctionAnalysisResults.erase( |