Lines Matching defs:Tok
532 Callbacks->MacroExpands(Info.Tok, Info.MD, Info.Range,
760 Token Tok;
764 LexUnexpandedToken(Tok);
765 assert(Tok.is(tok::l_paren) && "Error computing l-paren-ness?");
777 while (Tok.isNot(tok::r_paren)) {
778 if (ContainsCodeCompletionTok && Tok.isOneOf(tok::eof, tok::eod))
781 assert(Tok.isOneOf(tok::l_paren, tok::comma) &&
785 SourceLocation ArgStartLoc = Tok.getLocation();
794 LexUnexpandedToken(Tok);
796 if (Tok.isOneOf(tok::eof, tok::eod)) { // "#if f(<eof>" & "#if f(\n"
802 MacroName = Tok;
807 Toks[0] = Tok;
810 } else if (Tok.is(tok::r_paren)) {
813 MacroEnd = Tok.getLocation();
820 } else if (Tok.is(tok::l_paren)) {
822 } else if (Tok.is(tok::comma)) {
826 if (Tok.getFlags() & Token::IgnoredComma) {
832 Tok.clearFlag(Token::IgnoredComma);
842 } else if (Tok.is(tok::comment) && !KeepMacroComments) {
846 } else if (!Tok.isAnnotation() && Tok.getIdentifierInfo() != nullptr) {
853 if (MacroInfo *MI = getMacroInfo(Tok.getIdentifierInfo()))
855 Tok.setFlag(Token::DisableExpand);
856 } else if (Tok.is(tok::code_completion)) {
866 ArgTokens.push_back(Tok);
871 if (ArgTokens.empty() && Tok.getKind() == tok::r_paren)
886 Diag(Tok, getLangOpts().CPlusPlus11
894 EOFTok.setLocation(Tok.getLocation());
955 EOFTok.setLocation(Tok.getLocation());
993 Diag(Tok, ID);
1007 Diag(Tok, diag::err_too_few_args_in_macro_invoc);
1014 SourceLocation EndLoc = Tok.getLocation();
1015 Tok.startToken();
1016 Tok.setKind(tok::eof);
1017 Tok.setLocation(EndLoc);
1018 Tok.setLength(0);
1019 ArgTokens.push_back(Tok);
1023 ArgTokens.push_back(Tok);
1175 static bool EvaluateHasIncludeCommon(Token &Tok, IdentifierInfo *II,
1181 SourceLocation LParenLoc = Tok.getLocation();
1187 assert(Tok.is(tok::identifier));
1188 Tok.setIdentifierInfo(II);
1194 if (PP.LexHeaderName(Tok))
1196 } while (Tok.getKind() == tok::comment);
1199 if (Tok.isNot(tok::l_paren)) {
1205 if (Tok.isNot(tok::header_name))
1209 LParenLoc = Tok.getLocation();
1210 if (PP.LexHeaderName(Tok))
1214 if (Tok.isNot(tok::header_name)) {
1215 PP.Diag(Tok.getLocation(), diag::err_pp_expects_filename);
1222 StringRef Filename = PP.getSpelling(Tok, FilenameBuffer, &Invalid);
1226 SourceLocation FilenameLoc = Tok.getLocation();
1229 PP.LexNonComment(Tok);
1232 if (Tok.isNot(tok::r_paren)) {
1239 bool isAngled = PP.GetIncludeFilenameSpelling(Tok.getLocation(), Filename);
1268 EmbedResult Preprocessor::EvaluateHasEmbed(Token &Tok, IdentifierInfo *II) {
1271 Diag(Tok, diag::err_pp_directive_required) << II;
1273 assert(Tok.is(tok::identifier));
1274 Tok.setIdentifierInfo(II);
1279 LexUnexpandedToken(Tok);
1280 if (Tok.isNot(tok::l_paren)) {
1281 Diag(Tok, diag::err_pp_expected_after) << II << tok::l_paren;
1289 SourceLocation LParenLoc = Tok.getLocation();
1290 if (this->LexHeaderName(Tok))
1293 if (Tok.isNot(tok::header_name)) {
1294 Diag(Tok.getLocation(), diag::err_pp_expects_filename);
1298 SourceLocation FilenameLoc = Tok.getLocation();
1299 Token FilenameTok = Tok;
1302 this->LexEmbedParameters(Tok, /*ForHasEmbed=*/true);
1303 assert((Params || Tok.is(tok::eod)) &&
1312 if (!Tok.is(tok::r_paren)) {
1316 if (Tok.isNot(tok::eod))
1365 bool Preprocessor::EvaluateHasInclude(Token &Tok, IdentifierInfo *II) {
1366 return EvaluateHasIncludeCommon(Tok, II, *this, nullptr, nullptr);
1369 bool Preprocessor::EvaluateHasIncludeNext(Token &Tok, IdentifierInfo *II) {
1372 std::tie(Lookup, LookupFromFile) = getIncludeNextStart(Tok);
1374 return EvaluateHasIncludeCommon(Tok, II, *this, Lookup, LookupFromFile);
1380 Token &Tok, IdentifierInfo *II,
1383 int(Token &Tok,
1386 PP.LexUnexpandedToken(Tok);
1387 if (Tok.isNot(tok::l_paren)) {
1388 PP.Diag(Tok.getLocation(), diag::err_pp_expected_after) << II
1392 if (!Tok.isOneOf(tok::eof, tok::eod)) {
1394 Tok.setKind(tok::numeric_constant);
1400 SourceLocation LParenLoc = Tok.getLocation();
1408 PP.Lex(Tok);
1410 PP.LexUnexpandedToken(Tok);
1413 switch (Tok.getKind()) {
1418 PP.Diag(Tok.getLocation(), diag::err_unterm_macro_invoc);
1423 PP.Diag(Tok.getLocation(), diag::err_too_many_args_in_macro_invoc);
1433 PP.Diag(Tok.getLocation(), diag::err_pp_nested_paren) << II;
1453 PP.Diag(Tok.getLocation(), diag::err_too_few_args_in_macro_invoc);
1455 Tok.setKind(tok::numeric_constant);
1464 Result = Op(Tok, HasLexedNextToken);
1465 ResultTok = Tok;
1474 if (auto Diag = PP.Diag(Tok.getLocation(), diag::err_pp_expected_after)) {
1489 static IdentifierInfo *ExpectFeatureIdentifierInfo(Token &Tok,
1493 if (!Tok.isAnnotation() && (II = Tok.getIdentifierInfo()))
1496 PP.Diag(Tok.getLocation(), DiagID);
1600 static bool IsBuiltinTrait(Token &Tok) {
1621 switch (Tok.getKind()) {
1629 /// as a builtin macro, handle it and return the next token as 'Tok'.
1630 void Preprocessor::ExpandBuiltinMacro(Token &Tok) {
1632 IdentifierInfo *II = Tok.getIdentifierInfo();
1638 return Handle_Pragma(Tok);
1640 return HandleMicrosoft__pragma(Tok);
1648 Tok.setIdentifierInfo(nullptr);
1649 Tok.clearFlag(Token::NeedsCleaning);
1650 bool IsAtStartOfLine = Tok.isAtStartOfLine();
1651 bool HasLeadingSpace = Tok.hasLeadingSpace();
1657 SourceLocation Loc = Tok.getLocation();
1673 Tok.setKind(tok::numeric_constant);
1678 PresumedLoc PLoc = SourceMgr.getPresumedLoc(Tok.getLocation());
1707 Tok.setKind(tok::string_literal);
1709 Diag(Tok.getLocation(), diag::warn_pp_date_time);
1712 Tok.setKind(tok::string_literal);
1713 Tok.setLength(strlen("\"Mmm dd yyyy\""));
1714 Tok.setLocation(SourceMgr.createExpansionLoc(DATELoc, Tok.getLocation(),
1715 Tok.getLocation(),
1716 Tok.getLength()));
1719 Diag(Tok.getLocation(), diag::warn_pp_date_time);
1722 Tok.setKind(tok::string_literal);
1723 Tok.setLength(strlen("\"hh:mm:ss\""));
1724 Tok.setLocation(SourceMgr.createExpansionLoc(TIMELoc, Tok.getLocation(),
1725 Tok.getLocation(),
1726 Tok.getLength()));
1733 PresumedLoc PLoc = SourceMgr.getPresumedLoc(Tok.getLocation());
1742 Tok.setKind(tok::numeric_constant);
1744 Diag(Tok.getLocation(), diag::warn_pp_date_time);
1770 Tok.setKind(tok::string_literal);
1775 Tok.setKind(tok::numeric_constant);
1779 Diag(Tok, diag::err_illegal_use_of_flt_eval_macro);
1785 Tok.setKind(tok::numeric_constant);
1787 EvaluateFeatureLikeBuiltinMacro(OS, Tok, II, *this, false,
1788 [this](Token &Tok, bool &HasLexedNextToken) -> int {
1789 IdentifierInfo *II = ExpectFeatureIdentifierInfo(Tok, *this,
1794 EvaluateFeatureLikeBuiltinMacro(OS, Tok, II, *this, false,
1795 [this](Token &Tok, bool &HasLexedNextToken) -> int {
1796 IdentifierInfo *II = ExpectFeatureIdentifierInfo(Tok, *this,
1801 EvaluateFeatureLikeBuiltinMacro(OS, Tok, II, *this, false,
1802 [this](Token &Tok, bool &HasLexedNextToken) -> int {
1803 IdentifierInfo *II = ExpectFeatureIdentifierInfo(Tok, *this,
1826 } else if (IsBuiltinTrait(Tok)) {
1851 OS, Tok, II, *this, false,
1852 [this](Token &Tok, bool &HasLexedNextToken) -> int {
1854 Tok, *this, diag::err_feature_check_malformed);
1862 EvaluateFeatureLikeBuiltinMacro(OS, Tok, II, *this, false,
1863 [](Token &Tok, bool &HasLexedNextToken) -> int {
1864 return Tok.is(tok::identifier);
1867 EvaluateFeatureLikeBuiltinMacro(OS, Tok, II, *this, true,
1868 [this](Token &Tok, bool &HasLexedNextToken) -> int {
1869 IdentifierInfo *II = ExpectFeatureIdentifierInfo(Tok, *this,
1876 EvaluateFeatureLikeBuiltinMacro(OS, Tok, II, *this, true,
1877 [this](Token &Tok, bool &HasLexedNextToken) -> int {
1878 IdentifierInfo *II = ExpectFeatureIdentifierInfo(Tok, *this,
1892 EvaluateFeatureLikeBuiltinMacro(OS, Tok, II, *this, true,
1893 [&](Token &Tok, bool &HasLexedNextToken) -> int {
1896 Tok, *this, diag::err_feature_check_malformed);
1902 LexUnexpandedToken(Tok);
1903 if (Tok.isNot(tok::coloncolon))
1908 Lex(Tok);
1909 II = ExpectFeatureIdentifierInfo(Tok, *this,
1927 Value = EvaluateHasInclude(Tok, II);
1929 Value = EvaluateHasIncludeNext(Tok, II);
1931 if (Tok.isNot(tok::r_paren))
1934 Tok.setKind(tok::numeric_constant);
1940 EmbedResult Value = EvaluateHasEmbed(Tok, II);
1944 Tok.setKind(tok::numeric_constant);
1948 EvaluateFeatureLikeBuiltinMacro(OS, Tok, II, *this, false,
1949 [this](Token &Tok, bool &HasLexedNextToken) -> int {
1951 SourceLocation StrStartLoc = Tok.getLocation();
1953 HasLexedNextToken = Tok.is(tok::string_literal);
1954 if (!FinishLexStringLiteral(Tok, WarningName, "'__has_warning'",
1979 EvaluateFeatureLikeBuiltinMacro(OS, Tok, II, *this, false,
1980 [this](Token &Tok, bool &HasLexedNextToken) -> int {
1981 IdentifierInfo *II = ExpectFeatureIdentifierInfo(Tok, *this,
1990 Tok.setIdentifierInfo(ModuleII);
1991 Tok.setKind(ModuleII->getTokenID());
1993 SourceLocation Loc = Tok.getLocation();
1997 LexNonComment(Tok);
1998 if (Tok.isNot(tok::l_paren)) {
2003 if (!Tok.isAnnotation() && Tok.getIdentifierInfo())
2004 Tok.setKind(tok::identifier);
2008 SourceLocation LParenLoc = Tok.getLocation();
2009 LexNonComment(Tok);
2011 if (!Tok.isAnnotation() && Tok.getIdentifierInfo())
2012 Tok.setKind(tok::identifier);
2013 else if (Tok.is(tok::string_literal) && !Tok.hasUDSuffix()) {
2014 StringLiteralParser Literal(Tok, *this,
2019 Tok.setIdentifierInfo(getIdentifierInfo(Literal.GetString()));
2020 Tok.setKind(tok::identifier);
2022 Diag(Tok.getLocation(), diag::err_pp_identifier_arg_not_identifier)
2023 << Tok.getKind();
2025 if (Tok.isOneOf(tok::eof, tok::eod) || Tok.isAnnotation())
2029 // Discard the ')', preserving 'Tok' as our result.
2033 Diag(getLocForEndOfToken(Tok.getLocation()), diag::err_pp_expected_after)
2034 << Tok.getKind() << tok::r_paren;
2040 OS, Tok, II, *this, false,
2041 [this](Token &Tok, bool &HasLexedNextToken) -> int {
2043 Tok, *this, diag::err_feature_check_malformed);
2048 OS, Tok, II, *this, false,
2049 [this](Token &Tok, bool &HasLexedNextToken) -> int {
2051 Tok, *this, diag::err_feature_check_malformed);
2056 OS, Tok, II, *this, false,
2057 [this](Token &Tok, bool &HasLexedNextToken) -> int {
2059 Tok, *this, diag::err_feature_check_malformed);
2064 OS, Tok, II, *this, false,
2065 [this](Token &Tok, bool &HasLexedNextToken) -> int {
2067 Tok, *this, diag::err_feature_check_malformed);
2072 OS, Tok, II, *this, false,
2073 [this](Token &Tok, bool &HasLexedNextToken) -> int {
2075 Tok, *this, diag::err_feature_check_malformed);
2080 OS, Tok, II, *this, false,
2081 [this](Token &Tok, bool &HasLexedNextToken) -> int {
2083 Tok, *this, diag::err_feature_check_malformed);
2089 CreateString(OS.str(), Tok, Tok.getLocation(), Tok.getLocation());
2090 Tok.setFlagValue(Token::StartOfLine, IsAtStartOfLine);
2091 Tok.setFlagValue(Token::LeadingSpace, HasLeadingSpace);