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()
715 case tok::identifier: in ParseTopLevelDecl()
722 NextToken().isNot(tok::coloncolon)) { in ParseTopLevelDecl()
792 case tok::annot_pragma_vis: in ParseExternalDeclaration()
795 case tok::annot_pragma_pack: in ParseExternalDeclaration()
798 case tok::annot_pragma_msstruct: in ParseExternalDeclaration()
801 case tok::annot_pragma_align: in ParseExternalDeclaration()
804 case tok::annot_pragma_weak: in ParseExternalDeclaration()
807 case tok::annot_pragma_weakalias: in ParseExternalDeclaration()
810 case tok::annot_pragma_redefine_extname: in ParseExternalDeclaration()
813 case tok::annot_pragma_fp_contract: in ParseExternalDeclaration()
816 case tok::annot_pragma_fenv_access: in ParseExternalDeclaration()
817 case tok::annot_pragma_fenv_access_ms: in ParseExternalDeclaration()
820 case tok::annot_pragma_fenv_round: in ParseExternalDeclaration()
823 case tok::annot_pragma_float_control: in ParseExternalDeclaration()
826 case tok::annot_pragma_fp: in ParseExternalDeclaration()
829 case tok::annot_pragma_opencl_extension: in ParseExternalDeclaration()
832 case tok::annot_attr_openmp: in ParseExternalDeclaration()
833 case tok::annot_pragma_openmp: { in ParseExternalDeclaration()
837 case tok::annot_pragma_ms_pointers_to_members: in ParseExternalDeclaration()
840 case tok::annot_pragma_ms_vtordisp: in ParseExternalDeclaration()
843 case tok::annot_pragma_ms_pragma: in ParseExternalDeclaration()
846 case tok::annot_pragma_dump: in ParseExternalDeclaration()
849 case tok::annot_pragma_attribute: in ParseExternalDeclaration()
852 case tok::semi: in ParseExternalDeclaration()
858 case tok::r_brace: in ParseExternalDeclaration()
862 case tok::eof: in ParseExternalDeclaration()
865 case tok::kw___extension__: { in ParseExternalDeclaration()
871 case tok::kw_asm: { in ParseExternalDeclaration()
888 ExpectAndConsume(tok::semi, diag::err_expected_after, in ParseExternalDeclaration()
896 case tok::at: in ParseExternalDeclaration()
898 case tok::minus: in ParseExternalDeclaration()
899 case tok::plus: in ParseExternalDeclaration()
907 case tok::code_completion: in ParseExternalDeclaration()
919 case tok::kw_import: { in ParseExternalDeclaration()
927 case tok::kw_export: in ParseExternalDeclaration()
936 case tok::kw_using: in ParseExternalDeclaration()
937 case tok::kw_namespace: in ParseExternalDeclaration()
938 case tok::kw_typedef: in ParseExternalDeclaration()
939 case tok::kw_template: in ParseExternalDeclaration()
940 case tok::kw_static_assert: in ParseExternalDeclaration()
941 case tok::kw__Static_assert: in ParseExternalDeclaration()
950 case tok::kw_static: in ParseExternalDeclaration()
953 if (getLangOpts().CPlusPlus && NextToken().is(tok::kw_template)) { in ParseExternalDeclaration()
963 case tok::kw_inline: in ParseExternalDeclaration()
965 tok::TokenKind NextKind = NextToken().getKind(); in ParseExternalDeclaration()
968 if (NextKind == tok::kw_namespace) { in ParseExternalDeclaration()
977 if (NextKind == tok::kw_template) { in ParseExternalDeclaration()
988 case tok::kw_extern: in ParseExternalDeclaration()
989 if (getLangOpts().CPlusPlus && NextToken().is(tok::kw_template)) { in ParseExternalDeclaration()
1002 case tok::kw___if_exists: in ParseExternalDeclaration()
1003 case tok::kw___if_not_exists: in ParseExternalDeclaration()
1007 case tok::kw_module: in ParseExternalDeclaration()
1009 SkipUntil(tok::semi); in ParseExternalDeclaration()
1031 if (getLangOpts().CPlusPlus && Tok.is(tok::equal)) { in isDeclarationAfterDeclarator()
1033 if (KW.is(tok::kw_default) || KW.is(tok::kw_delete)) in isDeclarationAfterDeclarator()
1037 return Tok.is(tok::equal) || // int X()= -> not a function def in isDeclarationAfterDeclarator()
1038 Tok.is(tok::comma) || // int X(), -> not a function def in isDeclarationAfterDeclarator()
1039 Tok.is(tok::semi) || // int X(); -> not a function def in isDeclarationAfterDeclarator()
1040 Tok.is(tok::kw_asm) || // int X() __asm__ -> not a function def in isDeclarationAfterDeclarator()
1041 Tok.is(tok::kw___attribute) || // int X() __attr__ -> not a function def in isDeclarationAfterDeclarator()
1043 Tok.is(tok::l_paren)); // int X(0) -> not a function def [C++] in isDeclarationAfterDeclarator()
1050 if (Tok.is(tok::l_brace)) // int X() {} in isStartOfFunctionDefinition()
1058 if (getLangOpts().CPlusPlus && Tok.is(tok::equal)) { in isStartOfFunctionDefinition()
1060 return KW.is(tok::kw_default) || KW.is(tok::kw_delete); in isStartOfFunctionDefinition()
1063 return Tok.is(tok::colon) || // X() : Base() {} (used for ctors) in isStartOfFunctionDefinition()
1064 Tok.is(tok::kw_try); // X() try { ... } in isStartOfFunctionDefinition()
1098 if (Tok.is(tok::semi)) { in ParseDeclOrFunctionDefInternal()
1139 if (getLangOpts().ObjC && Tok.is(tok::at)) { in ParseDeclOrFunctionDefInternal()
1141 if (!Tok.isObjCAtKeyword(tok::objc_interface) && in ParseDeclOrFunctionDefInternal()
1142 !Tok.isObjCAtKeyword(tok::objc_protocol) && in ParseDeclOrFunctionDefInternal()
1143 !Tok.isObjCAtKeyword(tok::objc_implementation)) { in ParseDeclOrFunctionDefInternal()
1145 SkipUntil(tok::semi); in ParseDeclOrFunctionDefInternal()
1158 if (Tok.isObjCAtKeyword(tok::objc_protocol)) in ParseDeclOrFunctionDefInternal()
1161 if (Tok.isObjCAtKeyword(tok::objc_implementation)) in ParseDeclOrFunctionDefInternal()
1243 if (Tok.isNot(tok::l_brace) && in ParseFunctionDefinition()
1245 (Tok.isNot(tok::colon) && Tok.isNot(tok::kw_try) && in ParseFunctionDefinition()
1246 Tok.isNot(tok::equal)))) { in ParseFunctionDefinition()
1250 SkipUntil(tok::l_brace, StopAtSemi | StopBeforeMatch); in ParseFunctionDefinition()
1253 if (Tok.isNot(tok::l_brace)) in ParseFunctionDefinition()
1259 if (Tok.isNot(tok::equal)) { in ParseFunctionDefinition()
1267 if (getLangOpts().DelayedTemplateParsing && Tok.isNot(tok::equal) && in ParseFunctionDefinition()
1300 (Tok.is(tok::l_brace) || Tok.is(tok::kw_try) || in ParseFunctionDefinition()
1301 Tok.is(tok::colon)) && in ParseFunctionDefinition()
1329 if (TryConsumeToken(tok::equal)) { in ParseFunctionDefinition()
1332 if (TryConsumeToken(tok::kw_delete, KWLoc)) { in ParseFunctionDefinition()
1338 } else if (TryConsumeToken(tok::kw_default, KWLoc)) { in ParseFunctionDefinition()
1348 if (Tok.is(tok::comma)) { in ParseFunctionDefinition()
1351 SkipUntil(tok::semi); in ParseFunctionDefinition()
1352 } else if (ExpectAndConsume(tok::semi, diag::err_expected_after, in ParseFunctionDefinition()
1356 SkipUntil(tok::semi); in ParseFunctionDefinition()
1407 if (Tok.is(tok::kw_try)) in ParseFunctionDefinition()
1412 if (Tok.is(tok::colon)) { in ParseFunctionDefinition()
1416 if (!Tok.is(tok::l_brace)) { in ParseFunctionDefinition()
1432 if (Tok.is(tok::equal)) { in SkipFunctionBody()
1433 SkipUntil(tok::semi); in SkipFunctionBody()
1437 bool IsFunctionTryBlock = Tok.is(tok::kw_try); in SkipFunctionBody()
1445 SkipUntil(tok::r_brace); in SkipFunctionBody()
1446 while (IsFunctionTryBlock && Tok.is(tok::kw_catch)) { in SkipFunctionBody()
1447 SkipUntil(tok::l_brace); in SkipFunctionBody()
1448 SkipUntil(tok::r_brace); in SkipFunctionBody()
1477 if (TryConsumeToken(tok::semi)) { in ParseKNRParamDeclarations()
1541 if (Tok.isNot(tok::comma)) in ParseKNRParamDeclarations()
1558 if (SkipUntil(tok::l_brace, StopAtSemi | StopBeforeMatch)) in ParseKNRParamDeclarations()
1560 TryConsumeToken(tok::semi); in ParseKNRParamDeclarations()
1608 assert(Tok.is(tok::kw_asm) && "Not an asm!"); in ParseSimpleAsm()
1621 BalancedDelimiterTracker T(*this, tok::l_paren); in ParseSimpleAsm()
1634 } else if (SkipUntil(tok::r_paren, StopAtSemi | StopBeforeMatch)) { in ParseSimpleAsm()
1646 TemplateIdAnnotation *Parser::takeTemplateIdAnnotation(const Token &tok) { in takeTemplateIdAnnotation() argument
1647 assert(tok.is(tok::annot_template_id) && "Expected template-id token"); in takeTemplateIdAnnotation()
1649 Id = static_cast<TemplateIdAnnotation *>(tok.getAnnotationValue()); in takeTemplateIdAnnotation()
1660 Tok.setKind(tok::annot_cxxscope); in AnnotateScopeToken()
1680 assert(Tok.is(tok::identifier) || Tok.is(tok::annot_cxxscope)); in TryAnnotateName()
1683 const bool WasScopeAnnotation = Tok.is(tok::annot_cxxscope); in TryAnnotateName()
1692 if (Tok.isNot(tok::identifier) || SS.isInvalid()) { in TryAnnotateName()
1708 return Tok.is(tok::annot_typename) ? ANK_Success : ANK_TentativeDecl; in TryAnnotateName()
1728 FakeNext.setKind(tok::unknown); in TryAnnotateName()
1765 if (getLangOpts().ObjC && NextToken().is(tok::less) && in TryAnnotateName()
1777 else if (Tok.is(tok::eof)) // Nothing to do here, bail out... in TryAnnotateName()
1781 Tok.setKind(tok::annot_typename); in TryAnnotateName()
1790 Tok.setKind(tok::annot_overload_set); in TryAnnotateName()
1804 Tok.setKind(tok::annot_non_type); in TryAnnotateName()
1816 ? tok::annot_non_type_undeclared in TryAnnotateName()
1817 : tok::annot_non_type_dependent); in TryAnnotateName()
1827 if (Next.isNot(tok::less)) { in TryAnnotateName()
1850 if (Next.is(tok::less)) in TryAnnotateName()
1870 assert(Tok.isNot(tok::identifier)); in TryKeywordIdentFallback()
1876 Tok.setKind(tok::identifier); in TryKeywordIdentFallback()
1903 assert((Tok.is(tok::identifier) || Tok.is(tok::coloncolon) || in TryAnnotateTypeOrScopeToken()
1904 Tok.is(tok::kw_typename) || Tok.is(tok::annot_cxxscope) || in TryAnnotateTypeOrScopeToken()
1905 Tok.is(tok::kw_decltype) || Tok.is(tok::annot_template_id) || in TryAnnotateTypeOrScopeToken()
1906 Tok.is(tok::kw___super)) && in TryAnnotateTypeOrScopeToken()
1909 if (Tok.is(tok::kw_typename)) { in TryAnnotateTypeOrScopeToken()
1916 if (getLangOpts().MSVCCompat && NextToken().is(tok::kw_typedef)) { in TryAnnotateTypeOrScopeToken()
1941 if (Tok.is(tok::identifier) || Tok.is(tok::annot_template_id) || in TryAnnotateTypeOrScopeToken()
1942 Tok.is(tok::annot_decltype)) { in TryAnnotateTypeOrScopeToken()
1944 if (Tok.is(tok::annot_decltype) || in TryAnnotateTypeOrScopeToken()
1963 if (Tok.is(tok::identifier)) { in TryAnnotateTypeOrScopeToken()
1968 } else if (Tok.is(tok::annot_template_id)) { in TryAnnotateTypeOrScopeToken()
1993 Tok.setKind(tok::annot_typename); in TryAnnotateTypeOrScopeToken()
2002 bool WasScopeAnnotation = Tok.is(tok::annot_cxxscope); in TryAnnotateTypeOrScopeToken()
2019 if (Tok.is(tok::identifier)) { in TryAnnotateTypeOrScopeTokenAfterScopeSpec()
2023 false, NextToken().is(tok::period), nullptr, in TryAnnotateTypeOrScopeTokenAfterScopeSpec()
2033 if (getLangOpts().ObjC && NextToken().is(tok::less) && in TryAnnotateTypeOrScopeTokenAfterScopeSpec()
2045 else if (Tok.is(tok::eof)) // Nothing to do here, bail out... in TryAnnotateTypeOrScopeTokenAfterScopeSpec()
2051 Tok.setKind(tok::annot_typename); in TryAnnotateTypeOrScopeTokenAfterScopeSpec()
2072 if (NextToken().is(tok::less)) { in TryAnnotateTypeOrScopeTokenAfterScopeSpec()
2105 if (Tok.is(tok::annot_template_id)) { in TryAnnotateTypeOrScopeTokenAfterScopeSpec()
2149 tok::TokenKind Kind = Tok.getKind(); in isTokenEqualOrEqualTypo()
2153 case tok::ampequal: // &= in isTokenEqualOrEqualTypo()
2154 case tok::starequal: // *= in isTokenEqualOrEqualTypo()
2155 case tok::plusequal: // += in isTokenEqualOrEqualTypo()
2156 case tok::minusequal: // -= in isTokenEqualOrEqualTypo()
2157 case tok::exclaimequal: // != in isTokenEqualOrEqualTypo()
2158 case tok::slashequal: // /= in isTokenEqualOrEqualTypo()
2159 case tok::percentequal: // %= in isTokenEqualOrEqualTypo()
2160 case tok::lessequal: // <= in isTokenEqualOrEqualTypo()
2161 case tok::lesslessequal: // <<= in isTokenEqualOrEqualTypo()
2162 case tok::greaterequal: // >= in isTokenEqualOrEqualTypo()
2163 case tok::greatergreaterequal: // >>= in isTokenEqualOrEqualTypo()
2164 case tok::caretequal: // ^= in isTokenEqualOrEqualTypo()
2165 case tok::pipeequal: // |= in isTokenEqualOrEqualTypo()
2166 case tok::equalequal: // == in isTokenEqualOrEqualTypo()
2171 case tok::equal: in isTokenEqualOrEqualTypo()
2177 assert(Tok.is(tok::code_completion)); in handleUnexpectedCodeCompletionToken()
2234 assert((Tok.is(tok::kw___if_exists) || Tok.is(tok::kw___if_not_exists)) && in ParseMicrosoftIfExistsCondition()
2236 Result.IsIfExists = Tok.is(tok::kw___if_exists); in ParseMicrosoftIfExistsCondition()
2239 BalancedDelimiterTracker T(*this, tok::l_paren); in ParseMicrosoftIfExistsCondition()
2301 BalancedDelimiterTracker Braces(*this, tok::l_brace); in ParseMicrosoftIfExistsExternalDeclaration()
2303 Diag(Tok, diag::err_expected) << tok::l_brace; in ParseMicrosoftIfExistsExternalDeclaration()
2322 while (Tok.isNot(tok::r_brace) && !isEofOrEom()) { in ParseMicrosoftIfExistsExternalDeclaration()
2349 Sema::ModuleDeclKind MDK = TryConsumeToken(tok::kw_export) in ParseModuleDecl()
2354 (Tok.is(tok::kw_module) || in ParseModuleDecl()
2355 (Tok.is(tok::identifier) && Tok.getIdentifierInfo() == Ident_module)) && in ParseModuleDecl()
2364 if (getLangOpts().CPlusPlusModules && Tok.is(tok::semi)) { in ParseModuleDecl()
2380 if (getLangOpts().CPlusPlusModules && Tok.is(tok::colon) && in ParseModuleDecl()
2381 NextToken().is(tok::kw_private)) { in ParseModuleDecl()
2400 if (Tok.is(tok::colon)) { in ParseModuleDecl()
2443 TryConsumeToken(tok::kw_export, ExportLoc); in ParseModuleImport()
2445 assert((AtLoc.isInvalid() ? Tok.isOneOf(tok::kw_import, tok::identifier) in ParseModuleImport()
2446 : Tok.isObjCAtKeyword(tok::objc_import)) && in ParseModuleImport()
2448 bool IsObjCAtImport = Tok.isObjCAtKeyword(tok::objc_import); in ParseModuleImport()
2455 if (Tok.is(tok::header_name)) { in ParseModuleImport()
2460 } else if (Tok.is(tok::annot_header_unit)) { in ParseModuleImport()
2464 } else if (Tok.is(tok::colon)) { in ParseModuleImport()
2567 if (!Tok.is(tok::identifier)) { in ParseModuleName()
2568 if (Tok.is(tok::code_completion)) { in ParseModuleName()
2575 SkipUntil(tok::semi); in ParseModuleName()
2583 if (Tok.isNot(tok::period)) in ParseModuleName()
2597 case tok::annot_module_end: in parseMisplacedModuleImport()
2613 case tok::annot_module_begin: in parseMisplacedModuleImport()
2621 case tok::annot_module_include: in parseMisplacedModuleImport()
2647 tok::TokenKind SkipToTok) { in expectAndConsume()
2650 if (SkipToTok != tok::unknown) in expectAndConsume()
2664 if (P.Tok.is(tok::annot_module_end)) in diagnoseMissingClose()
2672 if (P.Tok.isNot(tok::r_paren) && P.Tok.isNot(tok::r_brace) && in diagnoseMissingClose()
2673 P.Tok.isNot(tok::r_square) && in diagnoseMissingClose()