Lines Matching refs:Tok

57   Tok.startToken();  in Parser()
58 Tok.setKind(tok::eof); in Parser()
77 DiagnosticBuilder Parser::Diag(const Token &Tok, unsigned DiagID) { in Diag() argument
78 return Diag(Tok.getLocation(), DiagID); in Diag()
102 static bool IsCommonTypo(tok::TokenKind ExpectedTok, const Token &Tok) { in IsCommonTypo() argument
105 return Tok.is(tok::colon) || Tok.is(tok::comma); // : or , for ; in IsCommonTypo()
112 if (Tok.is(ExpectedTok) || Tok.is(tok::code_completion)) { in ExpectAndConsume()
118 if (IsCommonTypo(ExpectedTok, Tok)) { in ExpectAndConsume()
119 SourceLocation Loc = Tok.getLocation(); in ExpectAndConsume()
145 : Diag(Tok, DiagID); in ExpectAndConsume()
160 if (Tok.is(tok::code_completion)) { in ExpectAndConsumeSemi()
165 if ((Tok.is(tok::r_paren) || Tok.is(tok::r_square)) && in ExpectAndConsumeSemi()
167 Diag(Tok, diag::err_extraneous_token_before_semi) in ExpectAndConsumeSemi()
168 << PP.getSpelling(Tok) in ExpectAndConsumeSemi()
169 << FixItHint::CreateRemoval(Tok.getLocation()); in ExpectAndConsumeSemi()
179 if (!Tok.is(tok::semi)) return; in ConsumeExtraSemi()
182 SourceLocation StartLoc = Tok.getLocation(); in ConsumeExtraSemi()
183 SourceLocation EndLoc = Tok.getLocation(); in ConsumeExtraSemi()
186 while ((Tok.is(tok::semi) && !Tok.isAtStartOfLine())) { in ConsumeExtraSemi()
188 EndLoc = Tok.getLocation(); in ConsumeExtraSemi()
216 if (Tok.is(tok::identifier)) in expectIdentifier()
218 if (const auto *II = Tok.getIdentifierInfo()) { in expectIdentifier()
220 Diag(Tok, diag::err_expected_token_instead_of_objcxx_keyword) in expectIdentifier()
221 << tok::identifier << Tok.getIdentifierInfo(); in expectIdentifier()
226 Diag(Tok, diag::err_expected) << tok::identifier; in expectIdentifier()
234 SourceLocation SecondTokLoc = Tok.getLocation(); in checkCompoundToken()
242 << (FirstTokKind == Tok.getKind()) << FirstTokKind << Tok.getKind() in checkCompoundToken()
245 << (FirstTokKind == Tok.getKind()) << Tok.getKind() in checkCompoundToken()
251 if (Tok.hasLeadingSpace() || Tok.isAtStartOfLine()) { in checkCompoundToken()
256 << (FirstTokKind == Tok.getKind()) << FirstTokKind << Tok.getKind() in checkCompoundToken()
285 if (Tok.is(Toks[i])) { in SkipUntil()
301 while (Tok.isNot(tok::eof)) in SkipUntil()
306 switch (Tok.getKind()) { in SkipUntil()
420 Actions.ActOnPopScope(Tok.getLocation(), getCurScope()); in ExitScope()
617 if (PP.isIncrementalProcessingEnabled() && Tok.is(tok::eof)) in ParseTopLevelDecl()
621 switch (Tok.getKind()) { in ParseTopLevelDecl()
667 auto Loc = Tok.getLocation(); in ParseTopLevelDecl()
668 Module *Mod = reinterpret_cast<Module *>(Tok.getAnnotationValue()); in ParseTopLevelDecl()
684 Actions.ActOnModuleBegin(Tok.getLocation(), reinterpret_cast<Module *>( in ParseTopLevelDecl()
685 Tok.getAnnotationValue())); in ParseTopLevelDecl()
691 Actions.ActOnModuleEnd(Tok.getLocation(), reinterpret_cast<Module *>( in ParseTopLevelDecl()
692 Tok.getAnnotationValue())); in ParseTopLevelDecl()
700 PP.Diag(Tok.getLocation(), diag::warn_max_tokens_total) in ParseTopLevelDecl()
720 if ((Tok.getIdentifierInfo() == Ident_module || in ParseTopLevelDecl()
721 Tok.getIdentifierInfo() == Ident_import) && in ParseTopLevelDecl()
723 if (Tok.getIdentifierInfo() == Ident_module) in ParseTopLevelDecl()
791 switch (Tok.getKind()) { in ParseExternalDeclaration()
855 Actions.ActOnEmptyDeclaration(getCurScope(), Attrs, Tok.getLocation()); in ParseExternalDeclaration()
859 Diag(Tok, diag::err_extraneous_closing_brace); in ParseExternalDeclaration()
863 Diag(Tok, diag::err_expected_external_declaration); in ParseExternalDeclaration()
874 SourceLocation StartLoc = Tok.getLocation(); in ParseExternalDeclaration()
901 Diag(Tok, diag::err_expected_external_declaration); in ParseExternalDeclaration()
1008 Diag(Tok, diag::err_unexpected_module_decl); in ParseExternalDeclaration()
1014 if (Tok.isEditorPlaceholder()) { in ParseExternalDeclaration()
1031 if (getLangOpts().CPlusPlus && Tok.is(tok::equal)) { 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()
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()
1144 Diag(Tok, diag::err_objc_unexpected_attr); 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()
1247 Diag(Tok, diag::err_expected_fn_body); 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()
1348 if (Tok.is(tok::comma)) { 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()
1437 bool IsFunctionTryBlock = Tok.is(tok::kw_try); in SkipFunctionBody()
1446 while (IsFunctionTryBlock && Tok.is(tok::kw_catch)) { in SkipFunctionBody()
1466 SourceLocation DSStart = Tok.getLocation(); in ParseKNRParamDeclarations()
1541 if (Tok.isNot(tok::comma)) in ParseKNRParamDeclarations()
1564 Actions.ActOnFinishKNRParamDeclarations(getCurScope(), D, Tok.getLocation()); in ParseKNRParamDeclarations()
1579 Diag(Tok, diag::err_expected_string_literal) in ParseAsmStringLiteral()
1588 Diag(Tok, diag::err_asm_operand_wide_string_literal) in ParseAsmStringLiteral()
1594 Diag(Tok, diag::err_asm_operand_wide_string_literal) in ParseAsmStringLiteral()
1608 assert(Tok.is(tok::kw_asm) && "Not an asm!"); in ParseSimpleAsm()
1611 if (isGNUAsmQualifier(Tok)) { in ParseSimpleAsm()
1614 PP.getLocForEndOfToken(Tok.getLocation())); in ParseSimpleAsm()
1615 Diag(Tok, diag::err_global_asm_qualifier_ignored) in ParseSimpleAsm()
1616 << GNUAsmQualifiers::getQualifierName(getGNUAsmQualifier(Tok)) in ParseSimpleAsm()
1623 Diag(Tok, diag::err_expected_lparen_after) << "asm"; in ParseSimpleAsm()
1636 *EndLoc = Tok.getLocation(); in ParseSimpleAsm()
1659 PP.EnterToken(Tok, /*IsReinject=*/true); in AnnotateScopeToken()
1660 Tok.setKind(tok::annot_cxxscope); in AnnotateScopeToken()
1661 Tok.setAnnotationValue(Actions.SaveNestedNameSpecifierAnnotation(SS)); in AnnotateScopeToken()
1662 Tok.setAnnotationRange(SS.getRange()); in AnnotateScopeToken()
1668 PP.AnnotateCachedTokens(Tok); 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()
1698 IdentifierInfo *Name = Tok.getIdentifierInfo(); in TryAnnotateName()
1699 SourceLocation NameLoc = Tok.getLocation(); in TryAnnotateName()
1708 return Tok.is(tok::annot_typename) ? ANK_Success : ANK_TentativeDecl; in TryAnnotateName()
1740 Tok.setIdentifierInfo(Name); in TryAnnotateName()
1741 Tok.setKind(Name->getTokenID()); in TryAnnotateName()
1742 PP.TypoCorrectToken(Tok); 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()
1782 setTypeAnnotation(Tok, Ty); in TryAnnotateName()
1783 Tok.setAnnotationEndLoc(Tok.getLocation()); in TryAnnotateName()
1784 Tok.setLocation(BeginLoc); in TryAnnotateName()
1785 PP.AnnotateCachedTokens(Tok); in TryAnnotateName()
1790 Tok.setKind(tok::annot_overload_set); in TryAnnotateName()
1791 setExprAnnotation(Tok, Classification.getExpression()); in TryAnnotateName()
1792 Tok.setAnnotationEndLoc(NameLoc); in TryAnnotateName()
1794 Tok.setLocation(SS.getBeginLoc()); in TryAnnotateName()
1795 PP.AnnotateCachedTokens(Tok); in TryAnnotateName()
1804 Tok.setKind(tok::annot_non_type); in TryAnnotateName()
1805 setNonTypeAnnotation(Tok, Classification.getNonTypeDecl()); in TryAnnotateName()
1806 Tok.setLocation(NameLoc); in TryAnnotateName()
1807 Tok.setAnnotationEndLoc(NameLoc); in TryAnnotateName()
1808 PP.AnnotateCachedTokens(Tok); in TryAnnotateName()
1815 Tok.setKind(Classification.getKind() == Sema::NC_UndeclaredNonType in TryAnnotateName()
1818 setIdentifierAnnotation(Tok, Name); in TryAnnotateName()
1819 Tok.setLocation(NameLoc); in TryAnnotateName()
1820 Tok.setAnnotationEndLoc(NameLoc); in TryAnnotateName()
1821 PP.AnnotateCachedTokens(Tok); in TryAnnotateName()
1870 assert(Tok.isNot(tok::identifier)); in TryKeywordIdentFallback()
1871 Diag(Tok, diag::ext_keyword_as_ident) in TryKeywordIdentFallback()
1872 << PP.getSpelling(Tok) in TryKeywordIdentFallback()
1875 Tok.getIdentifierInfo()->revertTokenIDToIdentifier(); 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()
1920 PP.EnterToken(Tok, /*IsReinject=*/true); in TryAnnotateTypeOrScopeToken()
1921 Tok = TypedefToken; in TryAnnotateTypeOrScopeToken()
1923 Diag(Tok.getLocation(), diag::warn_expected_qualified_after_typename); 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()
1945 (!TryAnnotateTypeOrScopeToken() && Tok.isAnnotation())) { in TryAnnotateTypeOrScopeToken()
1951 Diag(Tok.getLocation(), DiagID); in TryAnnotateTypeOrScopeToken()
1955 if (Tok.isEditorPlaceholder()) in TryAnnotateTypeOrScopeToken()
1958 Diag(Tok.getLocation(), diag::err_expected_qualified_after_typename); in TryAnnotateTypeOrScopeToken()
1963 if (Tok.is(tok::identifier)) { in TryAnnotateTypeOrScopeToken()
1966 *Tok.getIdentifierInfo(), in TryAnnotateTypeOrScopeToken()
1967 Tok.getLocation()); in TryAnnotateTypeOrScopeToken()
1968 } else if (Tok.is(tok::annot_template_id)) { in TryAnnotateTypeOrScopeToken()
1969 TemplateIdAnnotation *TemplateId = takeTemplateIdAnnotation(Tok); in TryAnnotateTypeOrScopeToken()
1971 Diag(Tok, diag::err_typename_refers_to_non_type_template) in TryAnnotateTypeOrScopeToken()
1972 << Tok.getAnnotationRange(); in TryAnnotateTypeOrScopeToken()
1987 Diag(Tok, diag::err_expected_type_name_after_typename) in TryAnnotateTypeOrScopeToken()
1992 SourceLocation EndLoc = Tok.getLastLoc(); in TryAnnotateTypeOrScopeToken()
1993 Tok.setKind(tok::annot_typename); in TryAnnotateTypeOrScopeToken()
1994 setTypeAnnotation(Tok, Ty); in TryAnnotateTypeOrScopeToken()
1995 Tok.setAnnotationEndLoc(EndLoc); in TryAnnotateTypeOrScopeToken()
1996 Tok.setLocation(TypenameLoc); in TryAnnotateTypeOrScopeToken()
1997 PP.AnnotateCachedTokens(Tok); in TryAnnotateTypeOrScopeToken()
2002 bool WasScopeAnnotation = Tok.is(tok::annot_cxxscope); in TryAnnotateTypeOrScopeToken()
2019 if (Tok.is(tok::identifier)) { in TryAnnotateTypeOrScopeTokenAfterScopeSpec()
2022 *Tok.getIdentifierInfo(), Tok.getLocation(), getCurScope(), &SS, in TryAnnotateTypeOrScopeTokenAfterScopeSpec()
2027 SourceLocation BeginLoc = Tok.getLocation(); 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()
2052 setTypeAnnotation(Tok, Ty); in TryAnnotateTypeOrScopeTokenAfterScopeSpec()
2053 Tok.setAnnotationEndLoc(Tok.getLocation()); in TryAnnotateTypeOrScopeTokenAfterScopeSpec()
2054 Tok.setLocation(BeginLoc); in TryAnnotateTypeOrScopeTokenAfterScopeSpec()
2058 PP.AnnotateCachedTokens(Tok); in TryAnnotateTypeOrScopeTokenAfterScopeSpec()
2075 TemplateName.setIdentifier(Tok.getIdentifierInfo(), Tok.getLocation()); in TryAnnotateTypeOrScopeTokenAfterScopeSpec()
2105 if (Tok.is(tok::annot_template_id)) { in TryAnnotateTypeOrScopeTokenAfterScopeSpec()
2106 TemplateIdAnnotation *TemplateId = takeTemplateIdAnnotation(Tok); in TryAnnotateTypeOrScopeTokenAfterScopeSpec()
2149 tok::TokenKind Kind = Tok.getKind(); in isTokenEqualOrEqualTypo()
2167 Diag(Tok, diag::err_invalid_token_after_declarator_suggest_equal) in isTokenEqualOrEqualTypo()
2169 << FixItHint::CreateReplacement(SourceRange(Tok.getLocation()), "="); in isTokenEqualOrEqualTypo()
2177 assert(Tok.is(tok::code_completion)); in handleUnexpectedCodeCompletionToken()
2178 PrevTokLocation = Tok.getLocation(); 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()
2241 Diag(Tok, diag::err_expected_lparen_after) in ParseMicrosoftIfExistsCondition()
2303 Diag(Tok, diag::err_expected) << tok::l_brace; in ParseMicrosoftIfExistsExternalDeclaration()
2322 while (Tok.isNot(tok::r_brace) && !isEofOrEom()) { in ParseMicrosoftIfExistsExternalDeclaration()
2347 SourceLocation StartLoc = Tok.getLocation(); 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()
2400 if (Tok.is(tok::colon)) { in ParseModuleDecl()
2440 SourceLocation StartLoc = AtLoc.isInvalid() ? Tok.getLocation() : AtLoc; 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()
2462 HeaderUnit = reinterpret_cast<Module *>(Tok.getAnnotationValue()); 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()
2574 Diag(Tok, diag::err_module_expected_ident) << IsImport; in ParseModuleName()
2580 Path.push_back(std::make_pair(Tok.getIdentifierInfo(), Tok.getLocation())); in ParseModuleName()
2583 if (Tok.isNot(tok::period)) in ParseModuleName()
2596 switch (Tok.getKind()) { in parseMisplacedModuleImport()
2603 Actions.ActOnModuleEnd(Tok.getLocation(), in parseMisplacedModuleImport()
2605 Tok.getAnnotationValue())); in parseMisplacedModuleImport()
2615 Actions.ActOnModuleBegin(Tok.getLocation(), in parseMisplacedModuleImport()
2617 Tok.getAnnotationValue())); in parseMisplacedModuleImport()
2624 Actions.ActOnModuleInclude(Tok.getLocation(), in parseMisplacedModuleImport()
2626 Tok.getAnnotationValue())); in parseMisplacedModuleImport()
2638 P.Diag(P.Tok, diag::err_bracket_depth_exceeded) in diagnoseOverflow()
2640 P.Diag(P.Tok, diag::note_bracket_depth); in diagnoseOverflow()
2648 LOpen = P.Tok.getLocation(); in expectAndConsume()
2662 assert(!P.Tok.is(Close) && "Should have consumed closing delimiter"); in diagnoseMissingClose()
2664 if (P.Tok.is(tok::annot_module_end)) in diagnoseMissingClose()
2665 P.Diag(P.Tok, diag::err_missing_before_module_end) << Close; in diagnoseMissingClose()
2667 P.Diag(P.Tok, diag::err_expected) << Close; 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()
2676 P.Tok.is(Close)) in diagnoseMissingClose()