diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2013-04-01 21:12:30 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2013-04-01 21:12:30 +0000 |
commit | e40e496fcec9381d75c0f72a15207902b08838e1 (patch) | |
tree | c6d6aeae9b2d6397684b48572e5544b848c7f2b3 | |
parent | e25d2f6c5b164b6e2ce1f0cacd62cf3cf59f5c37 (diff) |
[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
-rw-r--r-- | lib/ARCMigrate/TransProtectedScope.cpp | 12 |
1 files 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<StoredDiagnostic, 16> StoredDiags; + StoredDiags.append(DiagList.begin(), DiagList.end()); + SmallVectorImpl<StoredDiagnostic>::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<StoredDiagnostic>::iterator &DiagI, + SmallVectorImpl<StoredDiagnostic>::iterator DiagE){ Transaction Trans(Pass.TA); assert(DiagI->getID() == diag::err_switch_into_protected_scope); SourceLocation ErrLoc = DiagI->getLocation(); |