aboutsummaryrefslogtreecommitdiff
path: root/lib/Parse/Parser.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Parse/Parser.cpp')
-rw-r--r--lib/Parse/Parser.cpp25
1 files changed, 14 insertions, 11 deletions
diff --git a/lib/Parse/Parser.cpp b/lib/Parse/Parser.cpp
index 501e50c1e7..6342b10568 100644
--- a/lib/Parse/Parser.cpp
+++ b/lib/Parse/Parser.cpp
@@ -1401,18 +1401,21 @@ bool Parser::TryAnnotateCXXScopeToken(bool EnteringContext) {
return false;
}
-bool Parser::isTokenEqualOrMistypedEqualEqual(unsigned DiagID) {
- if (Tok.is(tok::equalequal)) {
- // We have '==' in a context that we would expect a '='.
- // The user probably made a typo, intending to type '='. Emit diagnostic,
- // fixit hint to turn '==' -> '=' and continue as if the user typed '='.
- Diag(Tok, DiagID)
- << FixItHint::CreateReplacement(SourceRange(Tok.getLocation()),
- getTokenSimpleSpelling(tok::equal));
- return true;
- }
+bool Parser::CreateTokenReplacement(tok::TokenKind ExpectedToken,
+ tok::TokenKind FoundToken,
+ unsigned DiagID) {
+ if (Tok.isNot(FoundToken))
+ return false;
- return Tok.is(tok::equal);
+ // We have FoundToken in a context that we would expect an ExpectedToken.
+ // The user probably made a typo, intending to type ExpectedToken.
+ // Emit diagnostic, fixit hint to turn ReplaceToken -> ExpectedToken
+ // and continue as if the user typed ExpectedToken.
+ Tok.setKind(ExpectedToken);
+ Diag(Tok, DiagID)
+ << FixItHint::CreateReplacement(SourceRange(Tok.getLocation()),
+ getTokenSimpleSpelling(ExpectedToken));
+ return true;
}
SourceLocation Parser::handleUnexpectedCodeCompletionToken() {