r178500 - [arcmt] Copy the diagnostics so we don't have to worry about invaliding iterators from the diagnostic list.
Argyrios Kyrtzidis
akyrtzi at gmail.com
Mon Apr 1 14:12:30 PDT 2013
Author: akirtzidis
Date: Mon Apr 1 16:12:30 2013
New Revision: 178500
URL: http://llvm.org/viewvc/llvm-project?rev=178500&view=rev
Log:
[arcmt] Copy the diagnostics so we don't have to worry about invaliding iterators from the diagnostic list.
Should fix http://llvm.org/PR15500
Modified:
cfe/trunk/lib/ARCMigrate/TransProtectedScope.cpp
Modified: cfe/trunk/lib/ARCMigrate/TransProtectedScope.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/TransProtectedScope.cpp?rev=178500&r1=178499&r2=178500&view=diff
==============================================================================
--- cfe/trunk/lib/ARCMigrate/TransProtectedScope.cpp (original)
+++ cfe/trunk/lib/ARCMigrate/TransProtectedScope.cpp Mon Apr 1 16:12:30 2013
@@ -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();
More information about the cfe-commits
mailing list