diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-05-18 19:21:48 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-05-18 19:21:48 +0000 |
commit | 00ba534163277c871bd74e91b86aa5f079d6d0af (patch) | |
tree | 9783d3250304023eeab0e08253eced8aab96502a /lib/Parse/ParseTentative.cpp | |
parent | 3022dac388832e0bb669821e6677abd5cb8a8784 (diff) | |
download | clang-00ba534163277c871bd74e91b86aa5f079d6d0af.tar.gz |
Fix the location of "missing ';'" suggestions after annotation tokens.
We were incorrectly setting PrevTokLocation to the first token in the
annotation token instead of the last when consuming it. To fix this without
adding a complex switch to the hot path through ConsumeToken, we now have a
ConsumeAnnotationToken function for consuming annotation tokens in addition
to the other Consume*Token special case functions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@303372 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseTentative.cpp')
-rw-r--r-- | lib/Parse/ParseTentative.cpp | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/lib/Parse/ParseTentative.cpp b/lib/Parse/ParseTentative.cpp index 0ea3f8d951..8b076b69fa 100644 --- a/lib/Parse/ParseTentative.cpp +++ b/lib/Parse/ParseTentative.cpp @@ -208,17 +208,20 @@ Parser::TPResult Parser::TryConsumeDeclarationSpecifier() { TryAnnotateCXXScopeToken()) return TPResult::Error; if (Tok.is(tok::annot_cxxscope)) + ConsumeAnnotationToken(); + if (Tok.is(tok::identifier)) ConsumeToken(); - if (Tok.isNot(tok::identifier) && Tok.isNot(tok::annot_template_id)) + else if (Tok.is(tok::annot_template_id)) + ConsumeAnnotationToken(); + else return TPResult::Error; - ConsumeToken(); break; case tok::annot_cxxscope: - ConsumeToken(); + ConsumeAnnotationToken(); // Fall through. default: - ConsumeToken(); + ConsumeAnyToken(); if (getLangOpts().ObjC1 && Tok.is(tok::less)) return TryParseProtocolQualifiers(); @@ -706,7 +709,7 @@ Parser::TPResult Parser::TryParsePtrOperatorSeq() { if (Tok.isOneOf(tok::star, tok::amp, tok::caret, tok::ampamp) || (Tok.is(tok::annot_cxxscope) && NextToken().is(tok::star))) { // ptr-operator - ConsumeToken(); + ConsumeAnyToken(); while (Tok.isOneOf(tok::kw_const, tok::kw_volatile, tok::kw_restrict, tok::kw__Nonnull, tok::kw__Nullable, tok::kw__Null_unspecified)) @@ -883,7 +886,7 @@ Parser::TPResult Parser::TryParseDeclarator(bool mayBeAbstract, mayHaveIdentifier) { // declarator-id if (Tok.is(tok::annot_cxxscope)) - ConsumeToken(); + ConsumeAnnotationToken(); else if (Tok.is(tok::identifier)) TentativelyDeclaredIdentifiers.push_back(Tok.getIdentifierInfo()); if (Tok.is(tok::kw_operator)) { @@ -1399,7 +1402,7 @@ Parser::isCXXDeclarationSpecifier(Parser::TPResult BracedCastResult, SS); if (SS.getScopeRep() && SS.getScopeRep()->isDependent()) { RevertingTentativeParsingAction PA(*this); - ConsumeToken(); + ConsumeAnnotationToken(); ConsumeToken(); bool isIdentifier = Tok.is(tok::identifier); TPResult TPR = TPResult::False; @@ -1471,7 +1474,7 @@ Parser::isCXXDeclarationSpecifier(Parser::TPResult BracedCastResult, if (getLangOpts().ObjC1 && NextToken().is(tok::less)) { // Tentatively parse the protocol qualifiers. RevertingTentativeParsingAction PA(*this); - ConsumeToken(); // The type token + ConsumeAnyToken(); // The type token TPResult TPR = TryParseProtocolQualifiers(); bool isFollowedByParen = Tok.is(tok::l_paren); |