aboutsummaryrefslogtreecommitdiff
path: root/lib/Parse/Parser.cpp
diff options
context:
space:
mode:
authorRichard Trieu <rtrieu@google.com>2012-01-19 22:01:51 +0000
committerRichard Trieu <rtrieu@google.com>2012-01-19 22:01:51 +0000
commitfcaf27e185695bdf755e202aeba9632e0a8ef3c6 (patch)
tree92e589aff6c75dcedfa1385163d787e7fc0749cf /lib/Parse/Parser.cpp
parent65eccf007d1275f571f596ca68c9ad6abc906c46 (diff)
Extend the error of invalid token after declarations to include fixits for
!=, %=, ^=, &=, *=, -=, |=, /=, <<=, <=, >=, and >>= to =. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148499 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/Parser.cpp')
-rw-r--r--lib/Parse/Parser.cpp38
1 files changed, 24 insertions, 14 deletions
diff --git a/lib/Parse/Parser.cpp b/lib/Parse/Parser.cpp
index 6342b10568..45b4a74583 100644
--- a/lib/Parse/Parser.cpp
+++ b/lib/Parse/Parser.cpp
@@ -1401,21 +1401,31 @@ bool Parser::TryAnnotateCXXScopeToken(bool EnteringContext) {
return false;
}
-bool Parser::CreateTokenReplacement(tok::TokenKind ExpectedToken,
- tok::TokenKind FoundToken,
- unsigned DiagID) {
- if (Tok.isNot(FoundToken))
+bool Parser::isTokenEqualOrEqualTypo() {
+ tok::TokenKind Kind = Tok.getKind();
+ switch (Kind) {
+ default:
return false;
-
- // 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;
+ case tok::ampequal: // &=
+ case tok::starequal: // *=
+ case tok::plusequal: // +=
+ case tok::minusequal: // -=
+ case tok::exclaimequal: // !=
+ case tok::slashequal: // /=
+ case tok::percentequal: // %=
+ case tok::lessequal: // <=
+ case tok::lesslessequal: // <<=
+ case tok::greaterequal: // >=
+ case tok::greatergreaterequal: // >>=
+ case tok::caretequal: // ^=
+ case tok::pipeequal: // |=
+ case tok::equalequal: // ==
+ Diag(Tok, diag::err_invalid_token_after_declarator_suggest_equal)
+ << getTokenSimpleSpelling(Kind)
+ << FixItHint::CreateReplacement(SourceRange(Tok.getLocation()), "=");
+ case tok::equal:
+ return true;
+ }
}
SourceLocation Parser::handleUnexpectedCodeCompletionToken() {