Lines Matching refs:Tok
77 Tok.startToken();
78 Tok.setKind(tok::eof);
98 DiagnosticBuilder Parser::Diag(const Token &Tok, unsigned DiagID) {
99 return Diag(Tok.getLocation(), DiagID);
123 static bool IsCommonTypo(tok::TokenKind ExpectedTok, const Token &Tok) {
125 case tok::semi:
126 return Tok.is(tok::colon) || Tok.is(tok::comma); // : or , for ;
131 bool Parser::ExpectAndConsume(tok::TokenKind ExpectedTok, unsigned DiagID,
133 if (Tok.is(ExpectedTok) || Tok.is(tok::code_completion)) {
139 if (IsCommonTypo(ExpectedTok, Tok)) {
140 SourceLocation Loc = Tok.getLocation();
144 SourceRange(Loc), tok::getPunctuatorSpelling(ExpectedTok));
161 Spelling = tok::getPunctuatorSpelling(ExpectedTok);
166 : Diag(Tok, DiagID);
178 if (TryConsumeToken(tok::semi))
181 if (Tok.is(tok::code_completion)) {
186 if ((Tok.is(tok::r_paren) || Tok.is(tok::r_square)) &&
187 NextToken().is(tok::semi)) {
188 Diag(Tok, diag::err_extraneous_token_before_semi)
189 << PP.getSpelling(Tok)
190 << FixItHint::CreateRemoval(Tok.getLocation());
196 return ExpectAndConsume(tok::semi, DiagID);
200 if (!Tok.is(tok::semi)) return;
203 SourceLocation StartLoc = Tok.getLocation();
204 SourceLocation EndLoc = Tok.getLocation();
207 while ((Tok.is(tok::semi) && !Tok.isAtStartOfLine())) {
209 EndLoc = Tok.getLocation();
252 bool Parser::SkipUntil(ArrayRef<tok::TokenKind> Toks, SkipUntilFlags Flags) {
259 if (Tok.is(Toks[i])) {
272 if (Toks.size() == 1 && Toks[0] == tok::eof &&
275 while (Tok.isNot(tok::eof))
280 switch (Tok.getKind()) {
281 case tok::eof:
285 case tok::annot_pragma_openmp:
286 case tok::annot_pragma_openmp_end:
288 case tok::annot_module_begin:
289 case tok::annot_module_end:
290 case tok::annot_module_include:
296 case tok::code_completion:
301 case tok::l_paren:
305 SkipUntil(tok::r_paren, StopAtCodeCompletion);
307 SkipUntil(tok::r_paren);
309 case tok::l_square:
313 SkipUntil(tok::r_square, StopAtCodeCompletion);
315 SkipUntil(tok::r_square);
317 case tok::l_brace:
321 SkipUntil(tok::r_brace, StopAtCodeCompletion);
323 SkipUntil(tok::r_brace);
331 case tok::r_paren:
336 case tok::r_square:
341 case tok::r_brace:
347 case tok::string_literal:
348 case tok::wide_string_literal:
349 case tok::utf8_string_literal:
350 case tok::utf16_string_literal:
351 case tok::utf32_string_literal:
355 case tok::semi:
389 Actions.ActOnPopScope(Tok.getLocation(), getCurScope());
545 if (PP.isIncrementalProcessingEnabled() && Tok.is(tok::eof))
549 switch (Tok.getKind()) {
550 case tok::annot_pragma_unused:
554 case tok::annot_module_include:
555 Actions.ActOnModuleInclude(Tok.getLocation(),
557 Tok.getAnnotationValue()));
561 case tok::annot_module_begin:
562 Actions.ActOnModuleBegin(Tok.getLocation(), reinterpret_cast<Module *>(
563 Tok.getAnnotationValue()));
567 case tok::annot_module_end:
568 Actions.ActOnModuleEnd(Tok.getLocation(), reinterpret_cast<Module *>(
569 Tok.getAnnotationValue()));
573 case tok::eof:
632 switch (Tok.getKind()) {
633 case tok::annot_pragma_vis:
636 case tok::annot_pragma_pack:
639 case tok::annot_pragma_msstruct:
642 case tok::annot_pragma_align:
645 case tok::annot_pragma_weak:
648 case tok::annot_pragma_weakalias:
651 case tok::annot_pragma_redefine_extname:
654 case tok::annot_pragma_fp_contract:
657 case tok::annot_pragma_opencl_extension:
660 case tok::annot_pragma_openmp:
662 case tok::annot_pragma_ms_pointers_to_members:
665 case tok::annot_pragma_ms_vtordisp:
668 case tok::annot_pragma_ms_pragma:
671 case tok::semi:
675 Tok.getLocation());
678 case tok::r_brace:
679 Diag(Tok, diag::err_extraneous_closing_brace);
682 case tok::eof:
683 Diag(Tok, diag::err_expected_external_declaration);
685 case tok::kw___extension__: {
691 case tok::kw_asm: {
694 SourceLocation StartLoc = Tok.getLocation();
708 ExpectAndConsume(tok::semi, diag::err_expected_after,
716 case tok::at:
718 case tok::minus:
719 case tok::plus:
721 Diag(Tok, diag::err_expected_external_declaration);
727 case tok::code_completion:
733 case tok::kw_using:
734 case tok::kw_namespace:
735 case tok::kw_typedef:
736 case tok::kw_template:
737 case tok::kw_export: // As in 'export template'
738 case tok::kw_static_assert:
739 case tok::kw__Static_assert:
746 case tok::kw_static:
749 if (getLangOpts().CPlusPlus && NextToken().is(tok::kw_template)) {
757 case tok::kw_inline:
759 tok::TokenKind NextKind = NextToken().getKind();
762 if (NextKind == tok::kw_namespace) {
769 if (NextKind == tok::kw_template) {
778 case tok::kw_extern:
779 if (getLangOpts().CPlusPlus && NextToken().is(tok::kw_template)) {
793 case tok::kw___if_exists:
794 case tok::kw___if_not_exists:
813 if (getLangOpts().CPlusPlus && Tok.is(tok::equal)) {
815 if (KW.is(tok::kw_default) || KW.is(tok::kw_delete))
819 return Tok.is(tok::equal) || // int X()= -> not a function def
820 Tok.is(tok::comma) || // int X(), -> not a function def
821 Tok.is(tok::semi) || // int X(); -> not a function def
822 Tok.is(tok::kw_asm) || // int X() __asm__ -> not a function def
823 Tok.is(tok::kw___attribute) || // int X() __attr__ -> not a function def
825 Tok.is(tok::l_paren)); // int X(0) -> not a function def [C++]
832 if (Tok.is(tok::l_brace)) // int X() {}
840 if (getLangOpts().CPlusPlus && Tok.is(tok::equal)) {
842 return KW.is(tok::kw_default) || KW.is(tok::kw_delete);
845 return Tok.is(tok::colon) || // X() : Base() {} (used for ctors)
846 Tok.is(tok::kw_try); // X() try { ... }
880 if (Tok.is(tok::semi)) {
893 if (getLangOpts().ObjC2 && Tok.is(tok::at)) {
895 if (!Tok.isObjCAtKeyword(tok::objc_interface) &&
896 !Tok.isObjCAtKeyword(tok::objc_protocol)) {
897 Diag(Tok, diag::err_objc_unexpected_attr);
898 SkipUntil(tok::semi); // FIXME: better skip?
910 if (Tok.isObjCAtKeyword(tok::objc_protocol))
990 if (Tok.isNot(tok::l_brace) &&
992 (Tok.isNot(tok::colon) && Tok.isNot(tok::kw_try) &&
993 Tok.isNot(tok::equal)))) {
994 Diag(Tok, diag::err_expected_fn_body);
997 SkipUntil(tok::l_brace, StopAtSemi | StopBeforeMatch);
1000 if (Tok.isNot(tok::l_brace))
1006 if (Tok.isNot(tok::equal)) {
1020 if (getLangOpts().DelayedTemplateParsing && Tok.isNot(tok::equal) &&
1046 (Tok.is(tok::l_brace) || Tok.is(tok::kw_try) ||
1047 Tok.is(tok::colon)) &&
1090 if (TryConsumeToken(tok::equal)) {
1095 if (TryConsumeToken(tok::kw_delete, KWLoc)) {
1102 } else if (TryConsumeToken(tok::kw_default, KWLoc)) {
1112 if (Tok.is(tok::comma)) {
1115 SkipUntil(tok::semi);
1116 } else if (ExpectAndConsume(tok::semi, diag::err_expected_after,
1118 SkipUntil(tok::semi);
1126 if (Tok.is(tok::kw_try))
1131 if (Tok.is(tok::colon)) {
1135 if (!Tok.is(tok::l_brace)) {
1151 if (Tok.is(tok::equal)) {
1152 SkipUntil(tok::semi);
1156 bool IsFunctionTryBlock = Tok.is(tok::kw_try);
1164 SkipUntil(tok::r_brace);
1165 while (IsFunctionTryBlock && Tok.is(tok::kw_catch)) {
1166 SkipUntil(tok::l_brace);
1167 SkipUntil(tok::r_brace);
1185 SourceLocation DSStart = Tok.getLocation();
1196 if (TryConsumeToken(tok::semi)) {
1259 if (Tok.isNot(tok::comma))
1276 if (SkipUntil(tok::l_brace, StopAtSemi | StopBeforeMatch))
1278 TryConsumeToken(tok::semi);
1282 Actions.ActOnFinishKNRParamDeclarations(getCurScope(), D, Tok.getLocation());
1294 Diag(Tok, diag::err_expected_string_literal)
1303 Diag(Tok, diag::err_asm_operand_wide_string_literal)
1318 assert(Tok.is(tok::kw_asm) && "Not an asm!");
1321 if (Tok.is(tok::kw_volatile)) {
1324 PP.getLocForEndOfToken(Tok.getLocation()));
1326 Diag(Tok, diag::warn_file_asm_volatile)
1331 BalancedDelimiterTracker T(*this, tok::l_paren);
1333 Diag(Tok, diag::err_expected_lparen_after) << "asm";
1344 } else if (SkipUntil(tok::r_paren, StopAtSemi | StopBeforeMatch)) {
1346 *EndLoc = Tok.getLocation();
1356 TemplateIdAnnotation *Parser::takeTemplateIdAnnotation(const Token &tok) {
1357 assert(tok.is(tok::annot_template_id) && "Expected template-id token");
1359 Id = static_cast<TemplateIdAnnotation *>(tok.getAnnotationValue());
1369 PP.EnterToken(Tok);
1370 Tok.setKind(tok::annot_cxxscope);
1371 Tok.setAnnotationValue(Actions.SaveNestedNameSpecifierAnnotation(SS));
1372 Tok.setAnnotationRange(SS.getRange());
1378 PP.AnnotateCachedTokens(Tok);
1393 assert(Tok.is(tok::identifier) || Tok.is(tok::annot_cxxscope));
1396 const bool WasScopeAnnotation = Tok.is(tok::annot_cxxscope);
1403 if (Tok.isNot(tok::identifier) || SS.isInvalid()) {
1410 IdentifierInfo *Name = Tok.getIdentifierInfo();
1411 SourceLocation NameLoc = Tok.getLocation();
1421 return Tok.is(tok::annot_typename) ? ANK_Success : ANK_TentativeDecl;
1440 Tok.setIdentifierInfo(Name);
1441 Tok.setKind(Name->getTokenID());
1442 PP.TypoCorrectToken(Tok);
1460 if (getLangOpts().ObjC1 && NextToken().is(tok::less) &&
1474 Tok.setKind(tok::annot_typename);
1475 setTypeAnnotation(Tok, Ty);
1476 Tok.setAnnotationEndLoc(Tok.getLocation());
1477 Tok.setLocation(BeginLoc);
1478 PP.AnnotateCachedTokens(Tok);
1483 Tok.setKind(tok::annot_primary_expr);
1484 setExprAnnotation(Tok, Classification.getExpression());
1485 Tok.setAnnotationEndLoc(NameLoc);
1487 Tok.setLocation(SS.getBeginLoc());
1488 PP.AnnotateCachedTokens(Tok);
1492 if (Next.isNot(tok::less)) {
1523 assert(Tok.isNot(tok::identifier));
1524 Diag(Tok, diag::ext_keyword_as_ident)
1525 << PP.getSpelling(Tok)
1528 Tok.getIdentifierInfo()->revertTokenIDToIdentifier();
1529 Tok.setKind(tok::identifier);
1556 assert((Tok.is(tok::identifier) || Tok.is(tok::coloncolon) ||
1557 Tok.is(tok::kw_typename) || Tok.is(tok::annot_cxxscope) ||
1558 Tok.is(tok::kw_decltype) || Tok.is(tok::annot_template_id) ||
1559 Tok.is(tok::kw___super)) &&
1562 if (Tok.is(tok::kw_typename)) {
1569 if (getLangOpts().MSVCCompat && NextToken().is(tok::kw_typedef)) {
1573 PP.EnterToken(Tok);
1574 Tok = TypedefToken;
1576 Diag(Tok.getLocation(), diag::warn_expected_qualified_after_typename);
1593 if (Tok.is(tok::identifier) || Tok.is(tok::annot_template_id) ||
1594 Tok.is(tok::annot_decltype)) {
1596 if (Tok.is(tok::annot_decltype) ||
1598 Tok.isAnnotation())) {
1604 Diag(Tok.getLocation(), DiagID);
1609 Diag(Tok.getLocation(), diag::err_expected_qualified_after_typename);
1614 if (Tok.is(tok::identifier)) {
1617 *Tok.getIdentifierInfo(),
1618 Tok.getLocation());
1619 } else if (Tok.is(tok::annot_template_id)) {
1620 TemplateIdAnnotation *TemplateId = takeTemplateIdAnnotation(Tok);
1623 Diag(Tok, diag::err_typename_refers_to_non_type_template)
1624 << Tok.getAnnotationRange();
1639 Diag(Tok, diag::err_expected_type_name_after_typename)
1644 SourceLocation EndLoc = Tok.getLastLoc();
1645 Tok.setKind(tok::annot_typename);
1646 setTypeAnnotation(Tok, Ty.isInvalid() ? ParsedType() : Ty.get());
1647 Tok.setAnnotationEndLoc(EndLoc);
1648 Tok.setLocation(TypenameLoc);
1649 PP.AnnotateCachedTokens(Tok);
1654 bool WasScopeAnnotation = Tok.is(tok::annot_cxxscope);
1667 /// specifier was extracted from an existing tok::annot_cxxscope annotation.
1672 if (Tok.is(tok::identifier)) {
1675 if (ParsedType Ty = Actions.getTypeName(*Tok.getIdentifierInfo(),
1676 Tok.getLocation(), getCurScope(),
1678 NextToken().is(tok::period),
1686 Tok.setIdentifierInfo(CorrectedII);
1688 SourceLocation BeginLoc = Tok.getLocation();
1694 if (getLangOpts().ObjC1 && NextToken().is(tok::less) &&
1710 Tok.setKind(tok::annot_typename);
1711 setTypeAnnotation(Tok, Ty);
1712 Tok.setAnnotationEndLoc(Tok.getLocation());
1713 Tok.setLocation(BeginLoc);
1717 PP.AnnotateCachedTokens(Tok);
1729 if (NextToken().is(tok::less)) {
1732 TemplateName.setIdentifier(Tok.getIdentifierInfo(), Tok.getLocation());
1758 if (Tok.is(tok::annot_template_id)) {
1759 TemplateIdAnnotation *TemplateId = takeTemplateIdAnnotation(Tok);
1787 assert((Tok.is(tok::identifier) || Tok.is(tok::coloncolon) ||
1788 (Tok.is(tok::annot_template_id) && NextToken().is(tok::coloncolon)) ||
1789 Tok.is(tok::kw_decltype) || Tok.is(tok::kw___super)) &&
1803 tok::TokenKind Kind = Tok.getKind();
1807 case tok::ampequal: // &=
1808 case tok::starequal: // *=
1809 case tok::plusequal: // +=
1810 case tok::minusequal: // -=
1811 case tok::exclaimequal: // !=
1812 case tok::slashequal: // /=
1813 case tok::percentequal: // %=
1814 case tok::lessequal: // <=
1815 case tok::lesslessequal: // <<=
1816 case tok::greaterequal: // >=
1817 case tok::greatergreaterequal: // >>=
1818 case tok::caretequal: // ^=
1819 case tok::pipeequal: // |=
1820 case tok::equalequal: // ==
1821 Diag(Tok, diag::err_invalid_token_after_declarator_suggest_equal)
1823 << FixItHint::CreateReplacement(SourceRange(Tok.getLocation()), "=");
1824 case tok::equal:
1830 assert(Tok.is(tok::code_completion));
1831 PrevTokLocation = Tok.getLocation();
1883 assert((Tok.is(tok::kw___if_exists) || Tok.is(tok::kw___if_not_exists)) &&
1885 Result.IsIfExists = Tok.is(tok::kw___if_exists);
1888 BalancedDelimiterTracker T(*this, tok::l_paren);
1890 Diag(Tok, diag::err_expected_lparen_after)
1945 BalancedDelimiterTracker Braces(*this, tok::l_brace);
1947 Diag(Tok, diag::err_expected) << tok::l_brace;
1966 while (Tok.isNot(tok::r_brace) && !isEofOrEom()) {
1978 assert(Tok.isObjCAtKeyword(tok::objc_import) &&
1986 if (!Tok.is(tok::identifier)) {
1987 if (Tok.is(tok::code_completion)) {
1993 Diag(Tok, diag::err_module_expected_ident);
1994 SkipUntil(tok::semi);
1999 Path.push_back(std::make_pair(Tok.getIdentifierInfo(), Tok.getLocation()));
2002 if (Tok.is(tok::period)) {
2030 switch (Tok.getKind()) {
2031 case tok::annot_module_end:
2035 case tok::annot_module_begin:
2037 Tok.getAnnotationValue()), Tok.getLocation());
2039 case tok::annot_module_include:
2042 Actions.ActOnModuleInclude(Tok.getLocation(),
2044 Tok.getAnnotationValue()));
2056 P.Diag(P.Tok, diag::err_bracket_depth_exceeded)
2058 P.Diag(P.Tok, diag::note_bracket_depth);
2065 tok::TokenKind SkipToTok) {
2066 LOpen = P.Tok.getLocation();
2068 if (SkipToTok != tok::unknown)
2080 assert(!P.Tok.is(Close) && "Should have consumed closing delimiter");
2082 if (P.Tok.is(tok::annot_module_end))
2083 P.Diag(P.Tok, diag::err_missing_before_module_end) << Close;
2085 P.Diag(P.Tok, diag::err_expected) << Close;
2090 if (P.Tok.isNot(tok::r_paren) && P.Tok.isNot(tok::r_brace) &&
2091 P.Tok.isNot(tok::r_square) &&
2094 P.Tok.is(Close))