From e40e496fcec9381d75c0f72a15207902b08838e1 Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Mon, 1 Apr 2013 21:12:30 +0000 Subject: [PATCH] [arcmt] Copy the diagnostics so we don't have to worry about invaliding iterators from the diagnostic list. Should fix http://llvm.org/PR15500 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178500 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/ARCMigrate/TransProtectedScope.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/ARCMigrate/TransProtectedScope.cpp b/lib/ARCMigrate/TransProtectedScope.cpp index b8b25f2594..237aa42877 100644 --- a/lib/ARCMigrate/TransProtectedScope.cpp +++ b/lib/ARCMigrate/TransProtectedScope.cpp @@ -109,7 +109,12 @@ public: SourceRange BodyRange = BodyCtx.getTopStmt()->getSourceRange(); const CapturedDiagList &DiagList = Pass.getDiags(); - CapturedDiagList::iterator I = DiagList.begin(), E = DiagList.end(); + // Copy the diagnostics so we don't have to worry about invaliding iterators + // from the diagnostic list. + SmallVector StoredDiags; + StoredDiags.append(DiagList.begin(), DiagList.end()); + SmallVectorImpl::iterator + I = StoredDiags.begin(), E = StoredDiags.end(); while (I != E) { if (I->getID() == diag::err_switch_into_protected_scope && isInRange(I->getLocation(), BodyRange)) { @@ -120,8 +125,9 @@ public: } } - void handleProtectedScopeError(CapturedDiagList::iterator &DiagI, - CapturedDiagList::iterator DiagE) { + void handleProtectedScopeError( + SmallVectorImpl::iterator &DiagI, + SmallVectorImpl::iterator DiagE){ Transaction Trans(Pass.TA); assert(DiagI->getID() == diag::err_switch_into_protected_scope); SourceLocation ErrLoc = DiagI->getLocation(); -- 2.40.0