Home | History | Annotate | Download | only in Parse

Lines Matching refs:Tok

28 static int SelectDigraphErrorMessage(tok::TokenKind Kind) {
31 case tok::unknown: return 0;
33 case tok::kw_const_cast: return 1;
34 case tok::kw_dynamic_cast: return 2;
35 case tok::kw_reinterpret_cast: return 3;
36 case tok::kw_static_cast: return 4;
52 Token &ColonToken, tok::TokenKind Kind, bool AtDigraph) {
66 ColonToken.setKind(tok::coloncolon);
69 DigraphToken.setKind(tok::less);
83 if (!Next.is(tok::l_square) || Next.getLength() != 2)
87 if (!SecondToken.is(tok::colon) || !areTokensAdjacent(Next, SecondToken))
92 TemplateName.setIdentifier(&II, Tok.getLocation());
99 FixDigraph(*this, PP, Next, SecondToken, tok::unknown,
108 if (!Tok.is(tok::l_paren))
111 Token LParen = Tok;
115 Token IdentifierTok = StarTok.is(tok::star) ? GetLookAheadToken(2) : StarTok;
116 if (IdentifierTok.isNot(tok::identifier))
123 NextTok = StarTok.is(tok::star) ? GetLookAheadToken(2) : GetLookAheadToken(1);
124 if (NextTok.is(tok::r_paren)) {
127 if (StarTok.is(tok::star))
134 if (StarTok.is(tok::star))
196 if (Tok.is(tok::annot_cxxscope)) {
199 Actions.RestoreNestedNameSpecifierAnnotation(Tok.getAnnotationValue(),
200 Tok.getAnnotationRange(),
206 if (Tok.is(tok::annot_template_id)) {
209 TemplateIdAnnotation *TemplateId = takeTemplateIdAnnotation(Tok);
225 if (Tok.is(tok::coloncolon)) {
227 tok::TokenKind NextKind = NextToken().getKind();
228 if (NextKind == tok::kw_new || NextKind == tok::kw_delete)
231 if (NextKind == tok::l_brace) {
234 Diag(ConsumeToken(), diag::err_expected) << tok::identifier;
246 if (Tok.is(tok::kw___super)) {
248 if (!Tok.is(tok::coloncolon)) {
249 Diag(Tok.getLocation(), diag::err_expected_coloncolon_after_super);
257 Tok.isOneOf(tok::kw_decltype, tok::annot_decltype)) {
259 SourceLocation DeclLoc = Tok.getLocation();
263 if (!TryConsumeToken(tok::coloncolon, CCLoc)) {
288 if (Tok.is(tok::code_completion)) {
296 SS.setEndLoc(Tok.getLocation());
307 if (Tok.is(tok::kw_template)) {
318 if (Tok.is(tok::identifier)) {
320 TemplateName.setIdentifier(Tok.getIdentifierInfo(), Tok.getLocation());
322 } else if (Tok.is(tok::kw_operator)) {
349 if (Tok.isNot(tok::less)) {
371 if (Tok.is(tok::annot_template_id) && NextToken().is(tok::coloncolon)) {
379 TemplateIdAnnotation *TemplateId = takeTemplateIdAnnotation(Tok);
380 if (CheckForDestructor && GetLookAheadToken(2).is(tok::tilde)) {
391 assert(Tok.is(tok::coloncolon) && "NextToken() not working properly!");
419 // tok::identifier.
420 if (Tok.isNot(tok::identifier))
423 IdentifierInfo &II = *Tok.getIdentifierInfo();
433 if (Next.is(tok::colon) && !ColonIsSacred) {
435 Tok.getLocation(),
441 PP.LookAhead(1).is(tok::identifier)) {
445 Next.setKind(tok::coloncolon);
449 if (Next.is(tok::coloncolon) && GetLookAheadToken(2).is(tok::l_brace)) {
452 Token Identifier = Tok; // Stash away the identifier.
455 << tok::identifier;
460 if (Next.is(tok::coloncolon)) {
461 if (CheckForDestructor && GetLookAheadToken(2).is(tok::tilde) &&
463 getCurScope(), SS, Tok.getLocation(), II, ObjectType)) {
470 if (Next2.is(tok::kw_private) || Next2.is(tok::kw_protected) ||
471 Next2.is(tok::kw_public) || Next2.is(tok::kw_virtual)) {
477 ColonColon.setKind(tok::colon);
488 Token Identifier = Tok;
490 assert(Tok.isOneOf(tok::coloncolon, tok::colon) &&
492 Token ColonColon = Tok;
505 ColonColon.setKind(tok::colon);
506 PP.EnterToken(Tok);
508 Tok = Identifier;
521 if (Next.is(tok::less)) {
524 TemplateName.setIdentifier(&II, Tok.getLocation());
556 Diag(Tok.getLocation(), DiagID)
558 << FixItHint::CreateInsertion(Tok.getLocation(), "template ");
586 if (CheckForDestructor && Tok.is(tok::tilde))
609 Tok.is(tok::l_paren), isAddressOfOperand,
722 Diag(Tok, DiagID.getValue());
723 SkipUntil(tok::r_square, StopAtSemi);
724 SkipUntil(tok::l_brace, StopAtSemi);
725 SkipUntil(tok::r_brace, StopAtSemi);
739 && Tok.is(tok::l_square)
745 if (Next.is(tok::r_square) || // []
746 Next.is(tok::equal) || // [=
747 (Next.is(tok::amp) && // [&] or [&,
748 (After.is(tok::r_square) ||
749 After.is(tok::comma))) ||
750 (Next.is(tok::identifier) && // [identifier]
751 After.is(tok::r_square))) {
757 if (Next.is(tok::identifier) && After.is(tok::identifier)) {
787 assert(Tok.is(tok::l_square) && "Lambda expressions begin with '['.");
788 BalancedDelimiterTracker T(*this, tok::l_square);
796 if (Tok.is(tok::amp) &&
797 (NextToken().is(tok::comma) || NextToken().is(tok::r_square))) {
801 } else if (Tok.is(tok::equal)) {
807 while (Tok.isNot(tok::r_square)) {
809 if (Tok.isNot(tok::comma)) {
814 if (Tok.is(tok::code_completion) &&
828 if (Tok.is(tok::code_completion)) {
850 if (Tok.is(tok::kw_this)) {
854 if (Tok.is(tok::amp)) {
858 if (Tok.is(tok::code_completion)) {
866 if (Tok.is(tok::identifier)) {
867 Id = Tok.getIdentifierInfo();
869 } else if (Tok.is(tok::kw_this)) {
878 if (Tok.is(tok::l_paren)) {
879 tok::l_paren);
898 } else if (Tok.isOneOf(tok::l_brace, tok::equal)) {
905 if (TryConsumeToken(tok::equal))
912 } else if (Tok.is(tok::l_brace)) {
913 BalancedDelimiterTracker Braces(*this, tok::l_brace);
938 SourceLocation StartLoc = Tok.getLocation();
942 if (Tok.getLocation() != StartLoc) {
947 Tok.setLocation(StartLoc);
948 Tok.setKind(tok::annot_primary_expr);
949 setExprAnnotation(Tok, Init);
950 Tok.setAnnotationEndLoc(PP.getLastCachedTokenLocation());
951 PP.AnnotateCachedTokens(Tok);
958 TryConsumeToken(tok::ellipsis, EllipsisLoc);
1067 if (Tok.is(tok::l_paren)) {
1074 BalancedDelimiterTracker T(*this, tok::l_paren);
1083 if (Tok.isNot(tok::r_paren)) {
1105 if (TryConsumeToken(tok::kw_mutable, MutableLoc))
1131 if (Tok.is(tok::arrow)) {
1132 FunLocalRangeEnd = Tok.getLocation();
1164 } else if (Tok.isOneOf(tok::kw_mutable, tok::arrow, tok::kw___attribute) ||
1165 (Tok.is(tok::l_square) && NextToken().is(tok::l_square))) {
1169 switch (Tok.getKind()) {
1170 case tok::kw_mutable: TokKind = 0; break;
1171 case tok::arrow: TokKind = 1; break;
1172 case tok::kw___attribute:
1173 case tok::l_square: TokKind = 2; break;
1177 Diag(Tok, diag::err_lambda_missing_parens)
1179 << FixItHint::CreateInsertion(Tok.getLocation(), "() ");
1180 SourceLocation DeclLoc = Tok.getLocation();
1190 if (Tok.is(tok::kw_mutable)) {
1199 if (Tok.is(tok::arrow)) {
1242 if (!Tok.is(tok::l_brace)) {
1243 Diag(Tok, diag::err_expected_lambda_body);
1268 tok::TokenKind Kind = Tok.getKind();
1273 tok::kw_const_cast: CastName = "const_cast"; break;
1274 case tok::kw_dynamic_cast: CastName = "dynamic_cast"; break;
1275 case tok::kw_reinterpret_cast: CastName = "reinterpret_cast"; break;
1276 case tok::kw_static_cast: CastName = "static_cast"; break;
1280 SourceLocation LAngleBracketLoc = Tok.getLocation();
1284 if (Tok.is(tok::l_square) && Tok.getLength() == 2) {
1286 if (Next.is(tok::colon) && areTokensAdjacent(Tok, Next))
1287 FixDigraph(*this, PP, Tok, Next, Kind, /*AtDigraph*/true);
1290 if (ExpectAndConsume(tok::less, diag::err_expected_less_after, CastName))
1301 SourceLocation RAngleBracketLoc = Tok.getLocation();
1303 if (ExpectAndConsume(tok::greater))
1304 return ExprError(Diag(LAngleBracketLoc, diag::note_matching) << tok::less);
1307 BalancedDelimiterTracker T(*this, tok::l_paren);
1334 assert(Tok.is(tok::kw_typeid) && "Not 'typeid'!");
1338 BalancedDelimiterTracker T(*this, tok::l_paren);
1379 SkipUntil(tok::r_paren, StopAtSemi);
1400 assert(Tok.is(tok::kw___uuidof) && "Not '__uuidof'!");
1403 BalancedDelimiterTracker T(*this, tok::l_paren);
1429 SkipUntil(tok::r_paren, StopAtSemi);
1458 tok::TokenKind OpKind,
1471 if (Tok.is(tok::identifier)) {
1472 FirstTypeName.setIdentifier(Tok.getIdentifierInfo(), Tok.getLocation());
1474 assert(Tok.is(tok::coloncolon) &&"ParseOptionalCXXScopeSpecifier fail");
1476 } else if (Tok.is(tok::annot_template_id)) {
1480 (TemplateIdAnnotation *)Tok.getAnnotationValue());
1482 assert(Tok.is(tok::coloncolon) &&"ParseOptionalCXXScopeSpecifier fail");
1489 assert(Tok.is(tok::tilde) && "ParseOptionalCXXScopeSpecifier fail");
1492 if (Tok.is(tok::kw_decltype) && !FirstTypeName.isValid() && SS.isEmpty()) {
1501 if (!Tok.is(tok::identifier)) {
1502 Diag(Tok, diag::err_destructor_tilde_identifier);
1508 IdentifierInfo *Name = Tok.getIdentifierInfo();
1514 if (Tok.is(tok::less) &&
1532 tok::TokenKind Kind = Tok.getKind();
1541 assert(Tok.is(tok::kw_throw) && "Not throw!");
1547 switch (Tok.getKind()) { // FIXME: move this predicate somewhere common.
1548 case tok::semi:
1549 case tok::r_paren:
1550 case tok::r_square:
1551 case tok::r_brace:
1552 case tok::colon:
1553 case tok::comma:
1568 assert(Tok.is(tok::kw_co_yield) && "Not co_yield!");
1571 ExprResult Expr = Tok.is(tok::l_brace) ? ParseBraceInitializer()
1584 assert(Tok.is(tok::kw_this) && "Not 'this'!");
1606 assert((Tok.is(tok::l_paren) ||
1607 (getLangOpts().CPlusPlus11 && Tok.is(tok::l_brace)))
1610 if (Tok.is(tok::l_brace)) {
1619 BalancedDelimiterTracker T(*this, tok::l_paren);
1625 if (Tok.isNot(tok::r_paren)) {
1631 SkipUntil(tok::r_paren, StopAtSemi);
1678 if (Tok.is(tok::code_completion)) {
1713 if (Tok.is(tok::kw_asm)) {
1717 SkipUntil(tok::semi, StopAtSemi);
1740 Tok.is(tok::l_brace)) {
1741 Diag(Tok.getLocation(),
1746 } else if (Tok.is(tok::l_paren)) {
1749 if (SkipUntil(tok::r_paren, StopAtSemi | StopBeforeMatch))
1755 Diag(DeclOut ? DeclOut->getLocation() : Tok.getLocation(),
1800 DS.SetRangeStart(Tok.getLocation());
1803 SourceLocation Loc = Tok.getLocation();
1807 switch (Tok.getKind()) {
1808 case tok::identifier: // foo::bar
1809 case tok::coloncolon: // ::foo::bar
1815 case tok::annot_typename: {
1816 if (getTypeAnnotation(Tok))
1818 getTypeAnnotation(Tok), Policy);
1822 DS.SetRangeEnd(Tok.getAnnotationEndLoc());
1830 case tok::kw_short:
1833 case tok::kw_long:
1836 case tok::kw___int64:
1839 case tok::kw_signed:
1842 case tok::kw_unsigned:
1845 case tok::kw_void:
1848 case tok::kw_char:
1851 case tok::kw_int:
1854 case tok::kw___int128:
1857 case tok::kw_half:
1860 case tok::kw_float:
1863 case tok::kw_double:
1866 case tok::kw_wchar_t:
1869 case tok::kw_char16_t:
1872 case tok::kw_char32_t:
1875 case tok::kw_bool:
1878 case tok::annot_decltype:
1879 case tok::kw_decltype:
1884 case tok::kw_typeof:
1889 if (Tok.is(tok::annot_typename))
1890 DS.SetRangeEnd(Tok.getAnnotationEndLoc());
1892 DS.SetRangeEnd(Tok.getLocation());
1954 assert((AssumeTemplateId || Tok.is(tok::less)) &&
2052 if (Tok.is(tok::less) &&
2156 assert(Tok.is(tok::kw_operator) && "Expected 'operator' keyword");
2165 switch (Tok.getKind()) {
2166 case tok::kw_new:
2167 case tok::kw_delete: {
2168 bool isNew = Tok.getKind() == tok::kw_new;
2172 if (Tok.is(tok::l_square) &&
2173 (!getLangOpts().CPlusPlus11 || NextToken().isNot(tok::l_square))) {
2175 BalancedDelimiterTracker T(*this, tok::l_square);
2191 case tok::Token: \
2198 case tok::l_paren: {
2200 BalancedDelimiterTracker T(*this, tok::l_paren);
2212 case tok::l_square: {
2214 BalancedDelimiterTracker T(*this, tok::l_square);
2226 case tok::code_completion: {
2251 Diag(Tok.getLocation(), diag::warn_cxx98_compat_literal_operator);
2261 if (!Tok.is(tok::string_literal) && !DiagId) {
2265 DiagLoc = Tok.getLocation();
2268 Toks.push_back(Tok);
2286 } else if (Tok.is(tok::identifier)) {
2287 II = Tok.getIdentifierInfo();
2291 Diag(Tok.getLocation(), diag::err_expected) << tok::identifier;
2392 if (getLangOpts().CPlusPlus && Tok.is(tok::kw_template) &&
2401 if (Tok.is(tok::identifier)) {
2403 IdentifierInfo *Id = Tok.getIdentifierInfo();
2428 if (TemplateSpecified || Tok.is(tok::less))
2438 if (Tok.is(tok::annot_template_id)) {
2439 TemplateIdAnnotation *TemplateId = takeTemplateIdAnnotation(Tok);
2483 if (Tok.is(tok::kw_operator)) {
2494 (TemplateSpecified || Tok.is(tok::less)))
2504 (AllowDestructorName || SS.isSet()) && Tok.is(tok::tilde)) {
2513 if (SS.isEmpty() && Tok.is(tok::kw_decltype)) {
2524 if (Tok.isNot(tok::identifier)) {
2525 Diag(Tok, diag::err_destructor_tilde_identifier);
2531 if (!TemplateSpecified && NextToken().is(tok::coloncolon)) {
2545 if (Tok.isNot(tok::identifier) || NextToken().is(tok::coloncolon) ||
2554 << FixItHint::CreateInsertion(Tok.getLocation(), "~");
2562 IdentifierInfo *ClassName = Tok.getIdentifierInfo();
2565 if (TemplateSpecified || Tok.is(tok::less)) {
2585 Diag(Tok, diag::err_expected_unqualified_id)
2620 assert(Tok.is(tok::kw_new) && "expected 'new' token");
2632 if (Tok.is(tok::l_paren)) {
2634 BalancedDelimiterTracker T(*this, tok::l_paren);
2638 SkipUntil(tok::semi, StopAtSemi | StopBeforeMatch);
2645 SkipUntil(tok::semi, StopAtSemi | StopBeforeMatch);
2655 if (Tok.is(tok::l_paren)) {
2656 BalancedDelimiterTracker T(*this, tok::l_paren);
2688 SkipUntil(tok::semi, StopAtSemi | StopBeforeMatch);
2694 if (Tok.is(tok::l_paren)) {
2697 BalancedDelimiterTracker T(*this, tok::l_paren);
2700 if (Tok.isNot(tok::r_paren)) {
2710 SkipUntil(tok::semi, StopAtSemi | StopBeforeMatch);
2717 SkipUntil(tok::semi, StopAtSemi | StopBeforeMatch);
2723 } else if (Tok.is(tok::l_brace) && getLangOpts().CPlusPlus11) {
2724 Diag(Tok.getLocation(),
2746 while (Tok.is(tok::l_square)) {
2751 BalancedDelimiterTracker T(*this, tok::l_square);
2758 SkipUntil(tok::r_square, StopAtSemi);
2821 assert(Tok.is(tok::kw_delete) && "Expected 'delete' keyword");
2826 if (Tok.is(tok::l_square) && NextToken().is(tok::r_square)) {
2836 BalancedDelimiterTracker T(*this, tok::l_square);
2851 static TypeTrait TypeTraitFromTokKind(tok::TokenKind kind) {
2855 case tok::kw_ ## Spelling: return UTT_ ## Name;
2857 case tok::kw_ ## Spelling: return BTT_ ## Name;
2860 case tok::kw_ ## Spelling: return TT_ ## Name;
2865 static ArrayTypeTrait ArrayTypeTraitFromTokKind(tok::TokenKind kind) {
2868 case tok::kw___array_rank: return ATT_ArrayRank;
2869 case tok::kw___array_extent: return ATT_ArrayExtent;
2873 static ExpressionTrait ExpressionTraitFromTokKind(tok::TokenKind kind) {
2876 case tok::kw___is_lvalue_expr: return ET_IsLValueExpr;
2877 case tok::kw___is_rvalue_expr: return ET_IsRValueExpr;
2881 static unsigned TypeTraitArity(tok::TokenKind kind) {
2884 #define TYPE_TRAIT(N,Spelling,K) case tok::kw_##Spelling: return N;
2901 tok::TokenKind Kind = Tok.getKind();
2906 BalancedDelimiterTracker Parens(*this, tok::l_paren);
2920 if (Tok.is(tok::ellipsis)) {
2930 } while (TryConsumeToken(tok::comma));
2960 ArrayTypeTrait ATT = ArrayTypeTraitFromTokKind(Tok.getKind());
2963 BalancedDelimiterTracker T(*this, tok::l_paren);
2969 SkipUntil(tok::comma, StopAtSemi);
2970 SkipUntil(tok::r_paren, StopAtSemi);
2981 if (ExpectAndConsume(tok::comma)) {
2982 SkipUntil(tok::r_paren, StopAtSemi);
3003 ExpressionTrait ET = ExpressionTraitFromTokKind(Tok.getKind());
3006 BalancedDelimiterTracker T(*this, tok::l_paren);
3058 if (!ConsumeAndStoreUntil(tok::r_paren, Toks)) {
3064 if (Tok.is(tok::l_brace)) {
3068 if (Tok.is(tok::l_paren) && NextToken().is(tok::r_paren)) {
3088 Toks.push_back(Tok);
3141 if (!Result.isInvalid() && Tok.is(tok::r_paren))
3143 Tok.getLocation(), Result.get());
3147 SkipUntil(tok::r_paren, StopAtSemi);