Lines Matching refs:Tok
34 if (Tok.is(tok::kw_template) && NextToken().isNot(tok::less)) {
65 assert(Tok.isOneOf(tok::kw_export, tok::kw_template) &&
105 TryConsumeToken(tok::kw_export, ExportLoc);
109 if (!TryConsumeToken(tok::kw_template, TemplateLoc)) {
110 Diag(Tok.getLocation(), diag::err_expected_template);
120 SkipUntil(tok::r_brace, StopAtSemi | StopBeforeMatch);
121 TryConsumeToken(tok::semi);
136 if (TryConsumeToken(tok::kw_requires)) {
141 SkipUntil(tok::r_brace, StopAtSemi | StopBeforeMatch);
142 TryConsumeToken(tok::semi);
149 } while (Tok.isOneOf(tok::kw_export, tok::kw_template));
181 if (Tok.is(tok::kw_static_assert)) {
183 Diag(Tok.getLocation(), diag::err_templated_invalid_declaration)
199 if (Tok.is(tok::kw_using))
210 if (Tok.is(tok::semi)) {
234 SkipUntil(tok::r_brace, StopAtSemi | StopBeforeMatch);
235 if (Tok.is(tok::semi))
251 Diag(Tok, diag::err_function_definition_not_allowed);
269 Diag(Tok, diag::err_template_defn_explicit_instantiation) << 0;
301 if (Tok.is(tok::comma)) {
302 Diag(Tok, diag::err_multiple_template_declarators)
304 SkipUntil(tok::semi);
330 if (!TryConsumeToken(tok::less, LAngleLoc)) {
331 Diag(Tok.getLocation(), diag::err_expected_less_after) << "template";
337 if (!Tok.is(tok::greater) && !Tok.is(tok::greatergreater))
340 if (Tok.is(tok::greatergreater)) {
346 Tok.setKind(tok::greater);
347 RAngleLoc = Tok.getLocation();
348 Tok.setLocation(Tok.getLocation().getLocWithOffset(1));
349 } else if (!TryConsumeToken(tok::greater, RAngleLoc) && Failed) {
350 Diag(Tok.getLocation(), diag::err_expected) << tok::greater;
374 SkipUntil(tok::comma, tok::greater, tok::greatergreater,
379 if (Tok.is(tok::comma)) {
381 } else if (Tok.isOneOf(tok::greater, tok::greatergreater)) {
388 Diag(Tok.getLocation(), diag::err_expected_comma_greater);
389 SkipUntil(tok::comma, tok::greater, tok::greatergreater,
400 if (Tok.is(tok::kw_class)) {
404 case tok::equal:
405 case tok::comma:
406 case tok::greater:
407 case tok::greatergreater:
408 case tok::ellipsis:
411 case tok::identifier:
421 case tok::equal:
422 case tok::comma:
423 case tok::greater:
424 case tok::greatergreater:
432 if (Tok.isNot(tok::kw_typename))
444 if (Next.getKind() == tok::identifier)
448 case tok::equal:
449 case tok::comma:
450 case tok::greater:
451 case tok::greatergreater:
452 case tok::ellipsis:
479 if (Tok.is(tok::kw_template))
498 assert(Tok.isOneOf(tok::kw_class, tok::kw_typename) &&
502 bool TypenameKeyword = Tok.is(tok::kw_typename);
507 if (TryConsumeToken(tok::ellipsis, EllipsisLoc)) {
517 if (Tok.is(tok::identifier)) {
518 ParamName = Tok.getIdentifierInfo();
520 } else if (Tok.isOneOf(tok::equal, tok::comma, tok::greater,
521 tok::greatergreater)) {
525 Diag(Tok.getLocation(), diag::err_expected) << tok::identifier;
531 if (TryConsumeToken(tok::ellipsis, EllipsisLoc))
539 if (TryConsumeToken(tok::equal, EqualLoc))
561 assert(Tok.is(tok::kw_template) && "Expected 'template' keyword");
580 if (!TryConsumeToken(tok::kw_class)) {
581 bool Replace = Tok.isOneOf(tok::kw_typename, tok::kw_struct);
582 const Token &Next = Tok.is(tok::kw_struct) ? NextToken() : Tok;
583 if (Tok.is(tok::kw_typename)) {
584 Diag(Tok.getLocation(),
589 ? FixItHint::CreateReplacement(Tok.getLocation(), "class")
591 } else if (Next.isOneOf(tok::identifier, tok::comma, tok::greater,
592 tok::greatergreater, tok::ellipsis)) {
593 Diag(Tok.getLocation(), diag::err_class_on_template_template_param)
594 << (Replace ? FixItHint::CreateReplacement(Tok.getLocation(), "class")
595 : FixItHint::CreateInsertion(Tok.getLocation(), "class "));
597 Diag(Tok.getLocation(), diag::err_class_on_template_template_param);
605 if (TryConsumeToken(tok::ellipsis, EllipsisLoc))
614 if (Tok.is(tok::identifier)) {
615 ParamName = Tok.getIdentifierInfo();
617 } else if (Tok.isOneOf(tok::equal, tok::comma, tok::greater,
618 tok::greatergreater)) {
622 Diag(Tok.getLocation(), diag::err_expected) << tok::identifier;
628 if (TryConsumeToken(tok::ellipsis, EllipsisLoc))
643 if (TryConsumeToken(tok::equal, EqualLoc)) {
646 Diag(Tok.getLocation(),
648 SkipUntil(tok::comma, tok::greater, tok::greatergreater,
677 Diag(Tok.getLocation(), diag::err_expected_template_parameter);
683 if (TryConsumeToken(tok::ellipsis, EllipsisLoc))
691 if (TryConsumeToken(tok::equal, EqualLoc)) {
703 SkipUntil(tok::comma, tok::greater, StopAtSemi | StopBeforeMatch);
753 tok::TokenKind RemainingToken;
756 switch (Tok.getKind()) {
758 Diag(Tok.getLocation(), diag::err_expected) << tok::greater;
761 case tok::greater:
764 RAngleLoc = Tok.getLocation();
769 case tok::greatergreater:
770 RemainingToken = tok::greater;
773 case tok::greatergreatergreater:
774 RemainingToken = tok::greatergreater;
777 case tok::greaterequal:
778 RemainingToken = tok::equal;
782 case tok::greatergreaterequal:
783 RemainingToken = tok::greaterequal;
791 // tok::greatergreatergreater, rather than two separate tokens.
795 RAngleLoc = Tok.getLocation();
813 if ((RemainingToken == tok::greater ||
814 RemainingToken == tok::greatergreater) &&
815 (Next.isOneOf(tok::greater, tok::greatergreater,
816 tok::greatergreatergreater, tok::equal,
817 tok::greaterequal, tok::greatergreaterequal,
818 tok::equalequal)) &&
819 areTokensAdjacent(Tok, Next))
824 (Tok.is(tok::greatergreater) || Toktok::greatergreatergreater)))
826 else if (Tok.is(tok::greaterequal))
828 Diag(Tok.getLocation(), DiagId) << Hint1 << Hint2;
832 if (RemainingToken == tok::equal && Next.is(tok::equal) &&
833 areTokensAdjacent(Tok, Next)) {
838 Tok.setKind(tok::equalequal);
839 Tok.setLength(Tok.getLength() + 1);
841 Tok.setKind(RemainingToken);
842 Tok.setLength(Tok.getLength() - 1);
844 Tok.setLocation(Lexer::AdvanceToTokenCharacter(RAngleLoc, 1,
851 PP.EnterToken(Tok);
852 Tok.setKind(tok::greater);
853 Tok.setLength(1);
854 Tok.setLocation(RAngleLoc);
886 assert(Tok.is(tok::less) && "Must have already parsed the template-name");
895 if (Tok.isNot(tok::greater) && Tok.isNot(tok::greatergreater))
901 SkipUntil(tok::greater, StopAtSemi);
903 SkipUntil(tok::greater, StopAtSemi | StopBeforeMatch);
955 assert(Template && Tok.is(tok::less) &&
973 TryConsumeToken(tok::greater);
988 TryConsumeToken(tok::greater);
992 Tok.setKind(tok::annot_typename);
993 setTypeAnnotation(Tok, Type.get());
995 Tok.setLocation(SS.getBeginLoc());
997 Tok.setLocation(TemplateKWLoc);
999 Tok.setLocation(TemplateNameLoc);
1003 Tok.setKind(tok::annot_template_id);
1023 Tok.setAnnotationValue(TemplateId);
1025 Tok.setLocation(TemplateKWLoc);
1027 Tok.setLocation(TemplateNameLoc);
1031 Tok.setAnnotationEndLoc(RAngleLoc);
1035 PP.AnnotateCachedTokens(Tok);
1046 assert(Tok.is(tok::annot_template_id) && "Requires template-id tokens");
1048 TemplateIdAnnotation *TemplateId = takeTemplateIdAnnotation(Tok);
1065 Tok.setKind(tok::annot_typename);
1066 setTypeAnnotation(Tok, Type.isInvalid() ? ParsedType() : Type.get());
1068 Tok.setLocation(TemplateId->SS.getBeginLoc());
1073 PP.AnnotateCachedTokens(Tok);
1077 static bool isEndOfTemplateArgument(Token Tok) {
1078 return Tok.isOneOf(tok::comma, tok::greater, tok::greatergreater);
1083 if (!Tok.is(tok::identifier) && !Tok.is(tok::coloncolon) &&
1084 !Tok.is(tok::annot_cxxscope))
1104 if (SS.isSet() && Tok.is(tok::kw_template)) {
1109 if (Tok.is(tok::identifier)) {
1112 Name.setIdentifier(Tok.getIdentifierInfo(), Tok.getLocation());
1115 TryConsumeToken(tok::ellipsis, EllipsisLoc);
1121 if (isEndOfTemplateArgument(Tok) &&
1129 } else if (Tok.is(tok::identifier)) {
1133 Name.setIdentifier(Tok.getIdentifierInfo(), Tok.getLocation());
1136 TryConsumeToken(tok::ellipsis, EllipsisLoc);
1138 if (isEndOfTemplateArgument(Tok)) {
1176 SourceLocation Loc = Tok.getLocation();
1203 SourceLocation Loc = Tok.getLocation();
1227 if (!TryConsumeToken(tok::less))
1231 if (Tok.is(tok::greater))
1239 return Tok.isOneOf(tok::greater, tok::comma);
1257 if (TryConsumeToken(tok::ellipsis, EllipsisLoc))
1261 SkipUntil(tok::comma, tok::greater, StopAtSemi | StopBeforeMatch);
1270 } while (TryConsumeToken(tok::comma));
1356 LPT.Toks.push_back(Tok);
1361 assert(Tok.isOneOf(tok::l_brace, tok::colon, tok::kw_try) &&
1374 if (Tok.is(tok::kw_try)) {
1377 if (Tok.is(tok::colon))
1382 if (Tok.is(tok::l_brace)) {
1405 tok::TokenKind kind = Tok.getKind();
1408 ConsumeAndStoreUntil(tok::r_brace, Toks, /*StopAtSemi=*/false);
1412 if (kind == tok::kw_try) {
1413 while (Tok.is(tok::kw_catch)) {
1414 ConsumeAndStoreUntil(tok::l_brace, Toks, /*StopAtSemi=*/false);
1415 ConsumeAndStoreUntil(tok::r_brace, Toks, /*StopAtSemi=*/false);