diff options
Diffstat (limited to 'contrib/llvm/tools/clang/lib/Parse/ParseTentative.cpp')
-rw-r--r-- | contrib/llvm/tools/clang/lib/Parse/ParseTentative.cpp | 37 |
1 files changed, 32 insertions, 5 deletions
diff --git a/contrib/llvm/tools/clang/lib/Parse/ParseTentative.cpp b/contrib/llvm/tools/clang/lib/Parse/ParseTentative.cpp index 8514af2..abf16fa 100644 --- a/contrib/llvm/tools/clang/lib/Parse/ParseTentative.cpp +++ b/contrib/llvm/tools/clang/lib/Parse/ParseTentative.cpp @@ -195,7 +195,9 @@ Parser::TPResult Parser::TryConsumeDeclarationSpecifier() { } } - if (TryAnnotateCXXScopeToken()) + if ((Tok.is(tok::identifier) || Tok.is(tok::coloncolon) || + Tok.is(tok::kw_decltype) || Tok.is(tok::annot_template_id)) && + TryAnnotateCXXScopeToken()) return TPResult::Error; if (Tok.is(tok::annot_cxxscope)) ConsumeToken(); @@ -837,6 +839,7 @@ Parser::TPResult Parser::TryParseDeclarator(bool mayBeAbstract, Tok.is(tok::kw___stdcall) || Tok.is(tok::kw___fastcall) || Tok.is(tok::kw___thiscall) || + Tok.is(tok::kw___vectorcall) || Tok.is(tok::kw___unaligned)) return TPResult::True; // attributes indicate declaration TPResult TPR = TryParseDeclarator(mayBeAbstract, mayHaveIdentifier); @@ -891,6 +894,7 @@ Parser::isExpressionOrTypeSpecifierSimple(tok::TokenKind Kind) { case tok::numeric_constant: case tok::char_constant: case tok::wide_char_constant: + case tok::utf8_char_constant: case tok::utf16_char_constant: case tok::utf32_char_constant: case tok::string_literal: @@ -984,9 +988,11 @@ Parser::isExpressionOrTypeSpecifierSimple(tok::TokenKind Kind) { case tok::kw___stdcall: case tok::kw___fastcall: case tok::kw___thiscall: + case tok::kw___vectorcall: case tok::kw___unaligned: case tok::kw___vector: case tok::kw___pixel: + case tok::kw___bool: case tok::kw__Atomic: case tok::kw___unknown_anytype: return TPResult::False; @@ -1004,6 +1010,28 @@ bool Parser::isTentativelyDeclared(IdentifierInfo *II) { != TentativelyDeclaredIdentifiers.end(); } +namespace { +class TentativeParseCCC : public CorrectionCandidateCallback { +public: + TentativeParseCCC(const Token &Next) { + WantRemainingKeywords = false; + WantTypeSpecifiers = Next.is(tok::l_paren) || Next.is(tok::r_paren) || + Next.is(tok::greater) || Next.is(tok::l_brace) || + Next.is(tok::identifier); + } + + bool ValidateCandidate(const TypoCorrection &Candidate) override { + // Reject any candidate that only resolves to instance members since they + // aren't viable as standalone identifiers instead of member references. + if (Candidate.isResolved() && !Candidate.isKeyword() && + std::all_of(Candidate.begin(), Candidate.end(), + [](NamedDecl *ND) { return ND->isCXXInstanceMember(); })) + return false; + + return CorrectionCandidateCallback::ValidateCandidate(Candidate); + } +}; +} /// isCXXDeclarationSpecifier - Returns TPResult::True if it is a declaration /// specifier, TPResult::False if it is not, TPResult::Ambiguous if it could /// be either a decl-specifier or a function-style cast, and TPResult::Error @@ -1129,11 +1157,8 @@ Parser::isCXXDeclarationSpecifier(Parser::TPResult BracedCastResult, // a parse error one way or another. In that case, tell the caller that // this is ambiguous. Typo-correct to type and expression keywords and // to types and identifiers, in order to try to recover from errors. - CorrectionCandidateCallback TypoCorrection; - TypoCorrection.WantRemainingKeywords = false; - TypoCorrection.WantTypeSpecifiers = Next.isNot(tok::arrow); switch (TryAnnotateName(false /* no nested name specifier */, - &TypoCorrection)) { + llvm::make_unique<TentativeParseCCC>(Next))) { case ANK_Error: return TPResult::Error; case ANK_TentativeDecl: @@ -1181,6 +1206,7 @@ Parser::isCXXDeclarationSpecifier(Parser::TPResult BracedCastResult, return TPResult::False; } // Fall through. + case tok::kw___super: case tok::kw_decltype: // Annotate typenames and C++ scope specifiers. If we get one, just // recurse to handle whatever we get. @@ -1250,6 +1276,7 @@ Parser::isCXXDeclarationSpecifier(Parser::TPResult BracedCastResult, case tok::kw___stdcall: case tok::kw___fastcall: case tok::kw___thiscall: + case tok::kw___vectorcall: case tok::kw___w64: case tok::kw___sptr: case tok::kw___uptr: |