Teach parseMatchingToken() to set a matched location even when it wasn't matched.

We were working around this in several different places, which was
error-prone (see <rdar://problem/17479771>). This way, we always have
usable left/right delimiter locations.

Swift SVN r19292
This commit is contained in:
Doug Gregor
2014-06-27 15:17:05 +00:00
parent 8ab00858e5
commit 461cde049a
6 changed files with 26 additions and 47 deletions

View File

@@ -520,6 +520,8 @@ bool Parser::parseMatchingToken(tok K, SourceLoc &TokLoc, Diag<> ErrorDiag,
}
if (parseToken(K, TokLoc, ErrorDiag)) {
diagnose(OtherLoc, OtherNote);
TokLoc = Tok.getLoc();
return true;
}
@@ -588,7 +590,6 @@ Parser::parseList(tok RightK, SourceLoc LeftLoc, SourceLoc &RightLoc,
if (parseMatchingToken(RightK, RightLoc, ErrorDiag, LeftLoc)) {
Status.setIsParseError();
RightLoc = PreviousLoc.isValid()? PreviousLoc : Tok.getLoc();
}
return Status;