Lines Matching refs:tok
58 Tok.setKind(tok::eof); in Parser()
102 static bool IsCommonTypo(tok::TokenKind ExpectedTok, const Token &Tok) { in IsCommonTypo()
104 case tok::semi: in IsCommonTypo()
105 return Tok.is(tok::colon) || Tok.is(tok::comma); // : or , for ; in IsCommonTypo()
110 bool Parser::ExpectAndConsume(tok::TokenKind ExpectedTok, unsigned DiagID, in ExpectAndConsume()
112 if (Tok.is(ExpectedTok) || Tok.is(tok::code_completion)) { in ExpectAndConsume()
123 SourceRange(Loc), tok::getPunctuatorSpelling(ExpectedTok)); in ExpectAndConsume()
140 Spelling = tok::getPunctuatorSpelling(ExpectedTok); in ExpectAndConsume()
157 if (TryConsumeToken(tok::semi)) in ExpectAndConsumeSemi()
160 if (Tok.is(tok::code_completion)) { in ExpectAndConsumeSemi()
165 if ((Tok.is(tok::r_paren) || Tok.is(tok::r_square)) && in ExpectAndConsumeSemi()
166 NextToken().is(tok::semi)) { in ExpectAndConsumeSemi()
175 return ExpectAndConsume(tok::semi, DiagID , TokenUsed); in ExpectAndConsumeSemi()
179 if (!Tok.is(tok::semi)) return; in ConsumeExtraSemi()
186 while ((Tok.is(tok::semi) && !Tok.isAtStartOfLine())) { in ConsumeExtraSemi()
216 if (Tok.is(tok::identifier)) in expectIdentifier()
221 << tok::identifier << Tok.getIdentifierInfo(); in expectIdentifier()
226 Diag(Tok, diag::err_expected) << tok::identifier; in expectIdentifier()
231 tok::TokenKind FirstTokKind, CompoundToken Op) { in checkCompoundToken()
278 bool Parser::SkipUntil(ArrayRef<tok::TokenKind> Toks, SkipUntilFlags Flags) { in SkipUntil()
298 if (Toks.size() == 1 && Toks[0] == tok::eof && in SkipUntil()
301 while (Tok.isNot(tok::eof)) in SkipUntil()
307 case tok::eof: in SkipUntil()
311 case tok::annot_pragma_openmp: in SkipUntil()
312 case tok::annot_attr_openmp: in SkipUntil()
313 case tok::annot_pragma_openmp_end: in SkipUntil()
319 case tok::annot_module_begin: in SkipUntil()
320 case tok::annot_module_end: in SkipUntil()
321 case tok::annot_module_include: in SkipUntil()
327 case tok::code_completion: in SkipUntil()
332 case tok::l_paren: in SkipUntil()
336 SkipUntil(tok::r_paren, StopAtCodeCompletion); in SkipUntil()
338 SkipUntil(tok::r_paren); in SkipUntil()
340 case tok::l_square: in SkipUntil()
344 SkipUntil(tok::r_square, StopAtCodeCompletion); in SkipUntil()
346 SkipUntil(tok::r_square); in SkipUntil()
348 case tok::l_brace: in SkipUntil()
352 SkipUntil(tok::r_brace, StopAtCodeCompletion); in SkipUntil()
354 SkipUntil(tok::r_brace); in SkipUntil()
356 case tok::question: in SkipUntil()
360 SkipUntil(tok::colon, in SkipUntil()
370 case tok::r_paren: in SkipUntil()
375 case tok::r_square: in SkipUntil()
380 case tok::r_brace: in SkipUntil()
386 case tok::semi: in SkipUntil()
617 if (PP.isIncrementalProcessingEnabled() && Tok.is(tok::eof)) in ParseTopLevelDecl()
622 case tok::annot_pragma_unused: in ParseTopLevelDecl()
626 case tok::kw_export: in ParseTopLevelDecl()
628 case tok::kw_module: in ParseTopLevelDecl()
637 case tok::identifier: { in ParseTopLevelDecl()
640 GetLookAheadToken(2).isNot(tok::coloncolon)) { in ParseTopLevelDecl()
654 case tok::kw_module: in ParseTopLevelDecl()
659 case tok::kw_import: in ParseTopLevelDecl()
666 case tok::annot_module_include: { in ParseTopLevelDecl()
683 case tok::annot_module_begin: in ParseTopLevelDecl()
690 case tok::annot_module_end: in ParseTopLevelDecl()
697 case tok::eof: in ParseTopLevelDecl()
714 case tok::identifier: in ParseTopLevelDecl()
721 NextToken().isNot(tok::coloncolon)) { in ParseTopLevelDecl()
804 case tok::annot_pragma_vis: in ParseExternalDeclaration()
807 case tok::annot_pragma_pack: in ParseExternalDeclaration()
810 case tok::annot_pragma_msstruct: in ParseExternalDeclaration()
813 case tok::annot_pragma_align: in ParseExternalDeclaration()
816 case tok::annot_pragma_weak: in ParseExternalDeclaration()
819 case tok::annot_pragma_weakalias: in ParseExternalDeclaration()
822 case tok::annot_pragma_redefine_extname: in ParseExternalDeclaration()
825 case tok::annot_pragma_fp_contract: in ParseExternalDeclaration()
828 case tok::annot_pragma_fenv_access: in ParseExternalDeclaration()
829 case tok::annot_pragma_fenv_access_ms: in ParseExternalDeclaration()
832 case tok::annot_pragma_fenv_round: in ParseExternalDeclaration()
835 case tok::annot_pragma_float_control: in ParseExternalDeclaration()
838 case tok::annot_pragma_fp: in ParseExternalDeclaration()
841 case tok::annot_pragma_opencl_extension: in ParseExternalDeclaration()
844 case tok::annot_attr_openmp: in ParseExternalDeclaration()
845 case tok::annot_pragma_openmp: { in ParseExternalDeclaration()
849 case tok::annot_pragma_ms_pointers_to_members: in ParseExternalDeclaration()
852 case tok::annot_pragma_ms_vtordisp: in ParseExternalDeclaration()
855 case tok::annot_pragma_ms_pragma: in ParseExternalDeclaration()
858 case tok::annot_pragma_dump: in ParseExternalDeclaration()
861 case tok::annot_pragma_attribute: in ParseExternalDeclaration()
864 case tok::semi: in ParseExternalDeclaration()
870 case tok::r_brace: in ParseExternalDeclaration()
874 case tok::eof: in ParseExternalDeclaration()
877 case tok::kw___extension__: { in ParseExternalDeclaration()
883 case tok::kw_asm: { in ParseExternalDeclaration()
900 ExpectAndConsume(tok::semi, diag::err_expected_after, in ParseExternalDeclaration()
908 case tok::at: in ParseExternalDeclaration()
910 case tok::minus: in ParseExternalDeclaration()
911 case tok::plus: in ParseExternalDeclaration()
919 case tok::code_completion: in ParseExternalDeclaration()
931 case tok::kw_import: { in ParseExternalDeclaration()
939 case tok::kw_export: in ParseExternalDeclaration()
948 case tok::kw_using: in ParseExternalDeclaration()
949 case tok::kw_namespace: in ParseExternalDeclaration()
950 case tok::kw_typedef: in ParseExternalDeclaration()
951 case tok::kw_template: in ParseExternalDeclaration()
952 case tok::kw_static_assert: in ParseExternalDeclaration()
953 case tok::kw__Static_assert: in ParseExternalDeclaration()
961 case tok::kw_cbuffer: in ParseExternalDeclaration()
962 case tok::kw_tbuffer: in ParseExternalDeclaration()
970 case tok::kw_static: in ParseExternalDeclaration()
973 if (getLangOpts().CPlusPlus && NextToken().is(tok::kw_template)) { in ParseExternalDeclaration()
982 case tok::kw_inline: in ParseExternalDeclaration()
984 tok::TokenKind NextKind = NextToken().getKind(); in ParseExternalDeclaration()
987 if (NextKind == tok::kw_namespace) { in ParseExternalDeclaration()
995 if (NextKind == tok::kw_template) { in ParseExternalDeclaration()
1005 case tok::kw_extern: in ParseExternalDeclaration()
1006 if (getLangOpts().CPlusPlus && NextToken().is(tok::kw_template)) { in ParseExternalDeclaration()
1019 case tok::kw___if_exists: in ParseExternalDeclaration()
1020 case tok::kw___if_not_exists: in ParseExternalDeclaration()
1024 case tok::kw_module: in ParseExternalDeclaration()
1026 SkipUntil(tok::semi); in ParseExternalDeclaration()
1053 if (getLangOpts().CPlusPlus && Tok.is(tok::equal)) { in isDeclarationAfterDeclarator()
1055 if (KW.is(tok::kw_default) || KW.is(tok::kw_delete)) in isDeclarationAfterDeclarator()
1059 return Tok.is(tok::equal) || // int X()= -> not a function def in isDeclarationAfterDeclarator()
1060 Tok.is(tok::comma) || // int X(), -> not a function def in isDeclarationAfterDeclarator()
1061 Tok.is(tok::semi) || // int X(); -> not a function def in isDeclarationAfterDeclarator()
1062 Tok.is(tok::kw_asm) || // int X() __asm__ -> not a function def in isDeclarationAfterDeclarator()
1063 Tok.is(tok::kw___attribute) || // int X() __attr__ -> not a function def in isDeclarationAfterDeclarator()
1065 Tok.is(tok::l_paren)); // int X(0) -> not a function def [C++] in isDeclarationAfterDeclarator()
1072 if (Tok.is(tok::l_brace)) // int X() {} in isStartOfFunctionDefinition()
1080 if (getLangOpts().CPlusPlus && Tok.is(tok::equal)) { in isStartOfFunctionDefinition()
1082 return KW.is(tok::kw_default) || KW.is(tok::kw_delete); in isStartOfFunctionDefinition()
1085 return Tok.is(tok::colon) || // X() : Base() {} (used for ctors) in isStartOfFunctionDefinition()
1086 Tok.is(tok::kw_try); // X() try { ... } in isStartOfFunctionDefinition()
1130 if (Tok.is(tok::semi)) { in ParseDeclOrFunctionDefInternal()
1171 if (getLangOpts().ObjC && Tok.is(tok::at)) { in ParseDeclOrFunctionDefInternal()
1173 if (!Tok.isObjCAtKeyword(tok::objc_interface) && in ParseDeclOrFunctionDefInternal()
1174 !Tok.isObjCAtKeyword(tok::objc_protocol) && in ParseDeclOrFunctionDefInternal()
1175 !Tok.isObjCAtKeyword(tok::objc_implementation)) { in ParseDeclOrFunctionDefInternal()
1177 SkipUntil(tok::semi); in ParseDeclOrFunctionDefInternal()
1190 if (Tok.isObjCAtKeyword(tok::objc_protocol)) in ParseDeclOrFunctionDefInternal()
1193 if (Tok.isObjCAtKeyword(tok::objc_implementation)) in ParseDeclOrFunctionDefInternal()
1276 if (Tok.isNot(tok::l_brace) && in ParseFunctionDefinition()
1278 (Tok.isNot(tok::colon) && Tok.isNot(tok::kw_try) && in ParseFunctionDefinition()
1279 Tok.isNot(tok::equal)))) { in ParseFunctionDefinition()
1283 SkipUntil(tok::l_brace, StopAtSemi | StopBeforeMatch); in ParseFunctionDefinition()
1286 if (Tok.isNot(tok::l_brace)) in ParseFunctionDefinition()
1292 if (Tok.isNot(tok::equal)) { in ParseFunctionDefinition()
1300 if (getLangOpts().DelayedTemplateParsing && Tok.isNot(tok::equal) && in ParseFunctionDefinition()
1333 (Tok.is(tok::l_brace) || Tok.is(tok::kw_try) || in ParseFunctionDefinition()
1334 Tok.is(tok::colon)) && in ParseFunctionDefinition()
1362 if (TryConsumeToken(tok::equal)) { in ParseFunctionDefinition()
1365 if (TryConsumeToken(tok::kw_delete, KWLoc)) { in ParseFunctionDefinition()
1371 } else if (TryConsumeToken(tok::kw_default, KWLoc)) { in ParseFunctionDefinition()
1381 if (Tok.is(tok::comma)) { in ParseFunctionDefinition()
1384 SkipUntil(tok::semi); in ParseFunctionDefinition()
1385 } else if (ExpectAndConsume(tok::semi, diag::err_expected_after, in ParseFunctionDefinition()
1389 SkipUntil(tok::semi); in ParseFunctionDefinition()
1440 if (Tok.is(tok::kw_try)) in ParseFunctionDefinition()
1445 if (Tok.is(tok::colon)) { in ParseFunctionDefinition()
1449 if (!Tok.is(tok::l_brace)) { in ParseFunctionDefinition()
1465 if (Tok.is(tok::equal)) { in SkipFunctionBody()
1466 SkipUntil(tok::semi); in SkipFunctionBody()
1470 bool IsFunctionTryBlock = Tok.is(tok::kw_try); in SkipFunctionBody()
1478 SkipUntil(tok::r_brace); in SkipFunctionBody()
1479 while (IsFunctionTryBlock && Tok.is(tok::kw_catch)) { in SkipFunctionBody()
1480 SkipUntil(tok::l_brace); in SkipFunctionBody()
1481 SkipUntil(tok::r_brace); in SkipFunctionBody()
1510 if (TryConsumeToken(tok::semi)) { in ParseKNRParamDeclarations()
1574 if (Tok.isNot(tok::comma)) in ParseKNRParamDeclarations()
1591 if (SkipUntil(tok::l_brace, StopAtSemi | StopBeforeMatch)) in ParseKNRParamDeclarations()
1593 TryConsumeToken(tok::semi); in ParseKNRParamDeclarations()
1641 assert(Tok.is(tok::kw_asm) && "Not an asm!"); in ParseSimpleAsm()
1654 BalancedDelimiterTracker T(*this, tok::l_paren); in ParseSimpleAsm()
1667 } else if (SkipUntil(tok::r_paren, StopAtSemi | StopBeforeMatch)) { in ParseSimpleAsm()
1679 TemplateIdAnnotation *Parser::takeTemplateIdAnnotation(const Token &tok) { in takeTemplateIdAnnotation() argument
1680 assert(tok.is(tok::annot_template_id) && "Expected template-id token"); in takeTemplateIdAnnotation()
1682 Id = static_cast<TemplateIdAnnotation *>(tok.getAnnotationValue()); in takeTemplateIdAnnotation()
1693 Tok.setKind(tok::annot_cxxscope); in AnnotateScopeToken()
1717 assert(Tok.is(tok::identifier) || Tok.is(tok::annot_cxxscope)); in TryAnnotateName()
1720 const bool WasScopeAnnotation = Tok.is(tok::annot_cxxscope); in TryAnnotateName()
1729 if (Tok.isNot(tok::identifier) || SS.isInvalid()) { in TryAnnotateName()
1747 return Tok.is(tok::annot_typename) ? ANK_Success : ANK_TentativeDecl; in TryAnnotateName()
1767 FakeNext.setKind(tok::unknown); in TryAnnotateName()
1804 if (getLangOpts().ObjC && NextToken().is(tok::less) && in TryAnnotateName()
1816 else if (Tok.is(tok::eof)) // Nothing to do here, bail out... in TryAnnotateName()
1820 Tok.setKind(tok::annot_typename); in TryAnnotateName()
1829 Tok.setKind(tok::annot_overload_set); in TryAnnotateName()
1843 Tok.setKind(tok::annot_non_type); in TryAnnotateName()
1855 ? tok::annot_non_type_undeclared in TryAnnotateName()
1856 : tok::annot_non_type_dependent); in TryAnnotateName()
1866 if (Next.isNot(tok::less)) { in TryAnnotateName()
1889 if (Next.is(tok::less)) in TryAnnotateName()
1909 assert(Tok.isNot(tok::identifier)); in TryKeywordIdentFallback()
1915 Tok.setKind(tok::identifier); in TryKeywordIdentFallback()
1943 assert((Tok.is(tok::identifier) || Tok.is(tok::coloncolon) || in TryAnnotateTypeOrScopeToken()
1944 Tok.is(tok::kw_typename) || Tok.is(tok::annot_cxxscope) || in TryAnnotateTypeOrScopeToken()
1945 Tok.is(tok::kw_decltype) || Tok.is(tok::annot_template_id) || in TryAnnotateTypeOrScopeToken()
1946 Tok.is(tok::kw___super)) && in TryAnnotateTypeOrScopeToken()
1949 if (Tok.is(tok::kw_typename)) { in TryAnnotateTypeOrScopeToken()
1956 if (getLangOpts().MSVCCompat && NextToken().is(tok::kw_typedef)) { in TryAnnotateTypeOrScopeToken()
1981 if (Tok.is(tok::identifier) || Tok.is(tok::annot_template_id) || in TryAnnotateTypeOrScopeToken()
1982 Tok.is(tok::annot_decltype)) { in TryAnnotateTypeOrScopeToken()
1984 if (Tok.is(tok::annot_decltype) || in TryAnnotateTypeOrScopeToken()
2004 if (Tok.is(tok::identifier)) { in TryAnnotateTypeOrScopeToken()
2009 } else if (Tok.is(tok::annot_template_id)) { in TryAnnotateTypeOrScopeToken()
2034 Tok.setKind(tok::annot_typename); in TryAnnotateTypeOrScopeToken()
2043 bool WasScopeAnnotation = Tok.is(tok::annot_cxxscope); in TryAnnotateTypeOrScopeToken()
2062 if (Tok.is(tok::identifier)) { in TryAnnotateTypeOrScopeTokenAfterScopeSpec()
2066 false, NextToken().is(tok::period), nullptr, in TryAnnotateTypeOrScopeTokenAfterScopeSpec()
2076 if (getLangOpts().ObjC && NextToken().is(tok::less) && in TryAnnotateTypeOrScopeTokenAfterScopeSpec()
2088 else if (Tok.is(tok::eof)) // Nothing to do here, bail out... in TryAnnotateTypeOrScopeTokenAfterScopeSpec()
2094 Tok.setKind(tok::annot_typename); in TryAnnotateTypeOrScopeTokenAfterScopeSpec()
2115 if (NextToken().is(tok::less)) { in TryAnnotateTypeOrScopeTokenAfterScopeSpec()
2148 if (Tok.is(tok::annot_template_id)) { in TryAnnotateTypeOrScopeTokenAfterScopeSpec()
2192 tok::TokenKind Kind = Tok.getKind(); in isTokenEqualOrEqualTypo()
2196 case tok::ampequal: // &= in isTokenEqualOrEqualTypo()
2197 case tok::starequal: // *= in isTokenEqualOrEqualTypo()
2198 case tok::plusequal: // += in isTokenEqualOrEqualTypo()
2199 case tok::minusequal: // -= in isTokenEqualOrEqualTypo()
2200 case tok::exclaimequal: // != in isTokenEqualOrEqualTypo()
2201 case tok::slashequal: // /= in isTokenEqualOrEqualTypo()
2202 case tok::percentequal: // %= in isTokenEqualOrEqualTypo()
2203 case tok::lessequal: // <= in isTokenEqualOrEqualTypo()
2204 case tok::lesslessequal: // <<= in isTokenEqualOrEqualTypo()
2205 case tok::greaterequal: // >= in isTokenEqualOrEqualTypo()
2206 case tok::greatergreaterequal: // >>= in isTokenEqualOrEqualTypo()
2207 case tok::caretequal: // ^= in isTokenEqualOrEqualTypo()
2208 case tok::pipeequal: // |= in isTokenEqualOrEqualTypo()
2209 case tok::equalequal: // == in isTokenEqualOrEqualTypo()
2214 case tok::equal: in isTokenEqualOrEqualTypo()
2220 assert(Tok.is(tok::code_completion)); in handleUnexpectedCodeCompletionToken()
2277 assert((Tok.is(tok::kw___if_exists) || Tok.is(tok::kw___if_not_exists)) && in ParseMicrosoftIfExistsCondition()
2279 Result.IsIfExists = Tok.is(tok::kw___if_exists); in ParseMicrosoftIfExistsCondition()
2282 BalancedDelimiterTracker T(*this, tok::l_paren); in ParseMicrosoftIfExistsCondition()
2344 BalancedDelimiterTracker Braces(*this, tok::l_brace); in ParseMicrosoftIfExistsExternalDeclaration()
2346 Diag(Tok, diag::err_expected) << tok::l_brace; in ParseMicrosoftIfExistsExternalDeclaration()
2365 while (Tok.isNot(tok::r_brace) && !isEofOrEom()) { in ParseMicrosoftIfExistsExternalDeclaration()
2393 Sema::ModuleDeclKind MDK = TryConsumeToken(tok::kw_export) in ParseModuleDecl()
2398 (Tok.is(tok::kw_module) || in ParseModuleDecl()
2399 (Tok.is(tok::identifier) && Tok.getIdentifierInfo() == Ident_module)) && in ParseModuleDecl()
2408 if (getLangOpts().CPlusPlusModules && Tok.is(tok::semi)) { in ParseModuleDecl()
2424 if (getLangOpts().CPlusPlusModules && Tok.is(tok::colon) && in ParseModuleDecl()
2425 NextToken().is(tok::kw_private)) { in ParseModuleDecl()
2446 if (Tok.is(tok::colon)) { in ParseModuleDecl()
2489 TryConsumeToken(tok::kw_export, ExportLoc); in ParseModuleImport()
2491 assert((AtLoc.isInvalid() ? Tok.isOneOf(tok::kw_import, tok::identifier) in ParseModuleImport()
2492 : Tok.isObjCAtKeyword(tok::objc_import)) && in ParseModuleImport()
2494 bool IsObjCAtImport = Tok.isObjCAtKeyword(tok::objc_import); in ParseModuleImport()
2501 if (Tok.is(tok::header_name)) { in ParseModuleImport()
2506 } else if (Tok.is(tok::annot_header_unit)) { in ParseModuleImport()
2510 } else if (Tok.is(tok::colon)) { in ParseModuleImport()
2618 if (!Tok.is(tok::identifier)) { in ParseModuleName()
2619 if (Tok.is(tok::code_completion)) { in ParseModuleName()
2626 SkipUntil(tok::semi); in ParseModuleName()
2634 if (Tok.isNot(tok::period)) in ParseModuleName()
2648 case tok::annot_module_end: in parseMisplacedModuleImport()
2664 case tok::annot_module_begin: in parseMisplacedModuleImport()
2672 case tok::annot_module_include: in parseMisplacedModuleImport()
2698 tok::TokenKind SkipToTok) { in expectAndConsume()
2701 if (SkipToTok != tok::unknown) in expectAndConsume()
2715 if (P.Tok.is(tok::annot_module_end)) in diagnoseMissingClose()
2723 if (P.Tok.isNot(tok::r_paren) && P.Tok.isNot(tok::r_brace) && in diagnoseMissingClose()
2724 P.Tok.isNot(tok::r_square) && in diagnoseMissingClose()