Lines Matching defs:Tok

549           Callbacks->MacroExpands(Info.Tok, Info.MD, Info.Range,
777 Token Tok;
781 LexUnexpandedToken(Tok);
782 assert(Tok.is(tok::l_paren) && "Error computing l-paren-ness?");
794 while (Tok.isNot(tok::r_paren)) {
795 if (ContainsCodeCompletionTok && Tok.isOneOf(tok::eof, tok::eod))
798 assert(Tok.isOneOf(tok::l_paren, tok::comma) &&
802 SourceLocation ArgStartLoc = Tok.getLocation();
811 LexUnexpandedToken(Tok);
813 if (Tok.isOneOf(tok::eof, tok::eod)) { // "#if f(<eof>" & "#if f(\n"
819 MacroName = Tok;
824 Toks[0] = Tok;
827 } else if (Tok.is(tok::r_paren)) {
830 MacroEnd = Tok.getLocation();
837 } else if (Tok.is(tok::l_paren)) {
839 } else if (Tok.is(tok::comma)) {
843 if (Tok.getFlags() & Token::IgnoredComma) {
849 Tok.clearFlag(Token::IgnoredComma);
859 } else if (Tok.is(tok::comment) && !KeepMacroComments) {
863 } else if (!Tok.isAnnotation() && Tok.getIdentifierInfo() != nullptr) {
870 if (MacroInfo *MI = getMacroInfo(Tok.getIdentifierInfo()))
872 Tok.setFlag(Token::DisableExpand);
873 } else if (Tok.is(tok::code_completion)) {
883 ArgTokens.push_back(Tok);
888 if (ArgTokens.empty() && Tok.getKind() == tok::r_paren)
903 Diag(Tok, getLangOpts().CPlusPlus11
911 EOFTok.setLocation(Tok.getLocation());
972 EOFTok.setLocation(Tok.getLocation());
1010 Diag(Tok, ID);
1024 Diag(Tok, diag::err_too_few_args_in_macro_invoc);
1031 SourceLocation EndLoc = Tok.getLocation();
1032 Tok.startToken();
1033 Tok.setKind(tok::eof);
1034 Tok.setLocation(EndLoc);
1035 Tok.setLength(0);
1036 ArgTokens.push_back(Tok);
1040 ArgTokens.push_back(Tok);
1192 static bool EvaluateHasIncludeCommon(Token &Tok, IdentifierInfo *II,
1198 SourceLocation LParenLoc = Tok.getLocation();
1204 assert(Tok.is(tok::identifier));
1205 Tok.setIdentifierInfo(II);
1211 if (PP.LexHeaderName(Tok))
1213 } while (Tok.getKind() == tok::comment);
1216 if (Tok.isNot(tok::l_paren)) {
1222 if (Tok.isNot(tok::header_name))
1226 LParenLoc = Tok.getLocation();
1227 if (PP.LexHeaderName(Tok))
1231 if (Tok.isNot(tok::header_name)) {
1232 PP.Diag(Tok.getLocation(), diag::err_pp_expects_filename);
1239 StringRef Filename = PP.getSpelling(Tok, FilenameBuffer, &Invalid);
1243 SourceLocation FilenameLoc = Tok.getLocation();
1246 PP.LexNonComment(Tok);
1249 if (Tok.isNot(tok::r_paren)) {
1256 bool isAngled = PP.GetIncludeFilenameSpelling(Tok.getLocation(), Filename);
1285 EmbedResult Preprocessor::EvaluateHasEmbed(Token &Tok, IdentifierInfo *II) {
1288 Diag(Tok, diag::err_pp_directive_required) << II;
1290 assert(Tok.is(tok::identifier));
1291 Tok.setIdentifierInfo(II);
1296 LexUnexpandedToken(Tok);
1297 if (Tok.isNot(tok::l_paren)) {
1298 Diag(Tok, diag::err_pp_expected_after) << II << tok::l_paren;
1306 SourceLocation LParenLoc = Tok.getLocation();
1307 if (this->LexHeaderName(Tok))
1310 if (Tok.isNot(tok::header_name)) {
1311 Diag(Tok.getLocation(), diag::err_pp_expects_filename);
1315 SourceLocation FilenameLoc = Tok.getLocation();
1316 Token FilenameTok = Tok;
1319 this->LexEmbedParameters(Tok, /*ForHasEmbed=*/true);
1320 assert((Params || Tok.is(tok::eod)) &&
1329 if (!Tok.is(tok::r_paren)) {
1333 if (Tok.isNot(tok::eod))
1382 bool Preprocessor::EvaluateHasInclude(Token &Tok, IdentifierInfo *II) {
1383 return EvaluateHasIncludeCommon(Tok, II, *this, nullptr, nullptr);
1386 bool Preprocessor::EvaluateHasIncludeNext(Token &Tok, IdentifierInfo *II) {
1389 std::tie(Lookup, LookupFromFile) = getIncludeNextStart(Tok);
1391 return EvaluateHasIncludeCommon(Tok, II, *this, Lookup, LookupFromFile);
1397 Token &Tok, IdentifierInfo *II,
1400 int(Token &Tok,
1403 PP.LexUnexpandedToken(Tok);
1404 if (Tok.isNot(tok::l_paren)) {
1405 PP.Diag(Tok.getLocation(), diag::err_pp_expected_after) << II
1409 if (!Tok.isOneOf(tok::eof, tok::eod)) {
1411 Tok.setKind(tok::numeric_constant);
1417 SourceLocation LParenLoc = Tok.getLocation();
1425 PP.Lex(Tok);
1427 PP.LexUnexpandedToken(Tok);
1430 switch (Tok.getKind()) {
1435 PP.Diag(Tok.getLocation(), diag::err_unterm_macro_invoc);
1440 PP.Diag(Tok.getLocation(), diag::err_too_many_args_in_macro_invoc);
1450 PP.Diag(Tok.getLocation(), diag::err_pp_nested_paren) << II;
1470 PP.Diag(Tok.getLocation(), diag::err_too_few_args_in_macro_invoc);
1472 Tok.setKind(tok::numeric_constant);
1481 Result = Op(Tok, HasLexedNextToken);
1482 ResultTok = Tok;
1491 if (auto Diag = PP.Diag(Tok.getLocation(), diag::err_pp_expected_after)) {
1506 static IdentifierInfo *ExpectFeatureIdentifierInfo(Token &Tok,
1510 if (!Tok.isAnnotation() && (II = Tok.getIdentifierInfo()))
1513 PP.Diag(Tok.getLocation(), DiagID);
1605 static bool IsBuiltinTrait(Token &Tok) {
1626 switch (Tok.getKind()) {
1634 /// as a builtin macro, handle it and return the next token as 'Tok'.
1635 void Preprocessor::ExpandBuiltinMacro(Token &Tok) {
1637 IdentifierInfo *II = Tok.getIdentifierInfo();
1643 return Handle_Pragma(Tok);
1645 return HandleMicrosoft__pragma(Tok);
1653 Tok.setIdentifierInfo(nullptr);
1654 Tok.clearFlag(Token::NeedsCleaning);
1655 bool IsAtStartOfLine = Tok.isAtStartOfLine();
1656 bool HasLeadingSpace = Tok.hasLeadingSpace();
1662 SourceLocation Loc = Tok.getLocation();
1678 Tok.setKind(tok::numeric_constant);
1683 PresumedLoc PLoc = SourceMgr.getPresumedLoc(Tok.getLocation());
1712 Tok.setKind(tok::string_literal);
1714 Diag(Tok.getLocation(), diag::warn_pp_date_time);
1717 Tok.setKind(tok::string_literal);
1718 Tok.setLength(strlen("\"Mmm dd yyyy\""));
1719 Tok.setLocation(SourceMgr.createExpansionLoc(DATELoc, Tok.getLocation(),
1720 Tok.getLocation(),
1721 Tok.getLength()));
1724 Diag(Tok.getLocation(), diag::warn_pp_date_time);
1727 Tok.setKind(tok::string_literal);
1728 Tok.setLength(strlen("\"hh:mm:ss\""));
1729 Tok.setLocation(SourceMgr.createExpansionLoc(TIMELoc, Tok.getLocation(),
1730 Tok.getLocation(),
1731 Tok.getLength()));
1738 PresumedLoc PLoc = SourceMgr.getPresumedLoc(Tok.getLocation());
1747 Tok.setKind(tok::numeric_constant);
1749 Diag(Tok.getLocation(), diag::warn_pp_date_time);
1773 Tok.setKind(tok::string_literal);
1778 Tok.setKind(tok::numeric_constant);
1782 Diag(Tok, diag::err_illegal_use_of_flt_eval_macro);
1788 Tok.setKind(tok::numeric_constant);
1790 EvaluateFeatureLikeBuiltinMacro(OS, Tok, II, *this, false,
1791 [this](Token &Tok, bool &HasLexedNextToken) -> int {
1792 IdentifierInfo *II = ExpectFeatureIdentifierInfo(Tok, *this,
1797 EvaluateFeatureLikeBuiltinMacro(OS, Tok, II, *this, false,
1798 [this](Token &Tok, bool &HasLexedNextToken) -> int {
1799 IdentifierInfo *II = ExpectFeatureIdentifierInfo(Tok, *this,
1804 EvaluateFeatureLikeBuiltinMacro(OS, Tok, II, *this, false,
1805 [this](Token &Tok, bool &HasLexedNextToken) -> int {
1806 IdentifierInfo *II = ExpectFeatureIdentifierInfo(Tok, *this,
1829 } else if (IsBuiltinTrait(Tok)) {
1853 OS, Tok, II, *this, false,
1854 [this](Token &Tok, bool &HasLexedNextToken) -> int {
1856 Tok, *this, diag::err_feature_check_malformed);
1864 EvaluateFeatureLikeBuiltinMacro(OS, Tok, II, *this, false,
1865 [](Token &Tok, bool &HasLexedNextToken) -> int {
1866 return Tok.is(tok::identifier);
1869 EvaluateFeatureLikeBuiltinMacro(OS, Tok, II, *this, true,
1870 [this](Token &Tok, bool &HasLexedNextToken) -> int {
1871 IdentifierInfo *II = ExpectFeatureIdentifierInfo(Tok, *this,
1878 EvaluateFeatureLikeBuiltinMacro(OS, Tok, II, *this, true,
1879 [this](Token &Tok, bool &HasLexedNextToken) -> int {
1880 IdentifierInfo *II = ExpectFeatureIdentifierInfo(Tok, *this,
1894 EvaluateFeatureLikeBuiltinMacro(OS, Tok, II, *this, true,
1895 [&](Token &Tok, bool &HasLexedNextToken) -> int {
1898 Tok, *this, diag::err_feature_check_malformed);
1904 LexUnexpandedToken(Tok);
1905 if (Tok.isNot(tok::coloncolon))
1910 Lex(Tok);
1911 II = ExpectFeatureIdentifierInfo(Tok, *this,
1929 Value = EvaluateHasInclude(Tok, II);
1931 Value = EvaluateHasIncludeNext(Tok, II);
1933 if (Tok.isNot(tok::r_paren))
1936 Tok.setKind(tok::numeric_constant);
1942 EmbedResult Value = EvaluateHasEmbed(Tok, II);
1946 Tok.setKind(tok::numeric_constant);
1950 EvaluateFeatureLikeBuiltinMacro(OS, Tok, II, *this, false,
1951 [this](Token &Tok, bool &HasLexedNextToken) -> int {
1953 SourceLocation StrStartLoc = Tok.getLocation();
1955 HasLexedNextToken = Tok.is(tok::string_literal);
1956 if (!FinishLexStringLiteral(Tok, WarningName, "'__has_warning'",
1981 EvaluateFeatureLikeBuiltinMacro(OS, Tok, II, *this, false,
1982 [this](Token &Tok, bool &HasLexedNextToken) -> int {
1983 IdentifierInfo *II = ExpectFeatureIdentifierInfo(Tok, *this,
1992 Tok.setIdentifierInfo(ModuleII);
1993 Tok.setKind(ModuleII->getTokenID());
1995 SourceLocation Loc = Tok.getLocation();
1999 LexNonComment(Tok);
2000 if (Tok.isNot(tok::l_paren)) {
2005 if (!Tok.isAnnotation() && Tok.getIdentifierInfo())
2006 Tok.setKind(tok::identifier);
2010 SourceLocation LParenLoc = Tok.getLocation();
2011 LexNonComment(Tok);
2013 if (!Tok.isAnnotation() && Tok.getIdentifierInfo())
2014 Tok.setKind(tok::identifier);
2015 else if (Tok.is(tok::string_literal) && !Tok.hasUDSuffix()) {
2016 StringLiteralParser Literal(Tok, *this,
2021 Tok.setIdentifierInfo(getIdentifierInfo(Literal.GetString()));
2022 Tok.setKind(tok::identifier);
2024 Diag(Tok.getLocation(), diag::err_pp_identifier_arg_not_identifier)
2025 << Tok.getKind();
2027 if (Tok.isOneOf(tok::eof, tok::eod) || Tok.isAnnotation())
2031 // Discard the ')', preserving 'Tok' as our result.
2035 Diag(getLocForEndOfToken(Tok.getLocation()), diag::err_pp_expected_after)
2036 << Tok.getKind() << tok::r_paren;
2042 OS, Tok, II, *this, false,
2043 [this](Token &Tok, bool &HasLexedNextToken) -> int {
2045 Tok, *this, diag::err_feature_check_malformed);
2050 OS, Tok, II, *this, false,
2051 [this](Token &Tok, bool &HasLexedNextToken) -> int {
2053 Tok, *this, diag::err_feature_check_malformed);
2058 OS, Tok, II, *this, false,
2059 [this](Token &Tok, bool &HasLexedNextToken) -> int {
2061 Tok, *this, diag::err_feature_check_malformed);
2066 OS, Tok, II, *this, false,
2067 [this](Token &Tok, bool &HasLexedNextToken) -> int {
2069 Tok, *this, diag::err_feature_check_malformed);
2074 OS, Tok, II, *this, false,
2075 [this](Token &Tok, bool &HasLexedNextToken) -> int {
2077 Tok, *this, diag::err_feature_check_malformed);
2082 OS, Tok, II, *this, false,
2083 [this](Token &Tok, bool &HasLexedNextToken) -> int {
2085 Tok, *this, diag::err_feature_check_malformed);
2091 CreateString(OS.str(), Tok, Tok.getLocation(), Tok.getLocation());
2092 Tok.setFlagValue(Token::StartOfLine, IsAtStartOfLine);
2093 Tok.setFlagValue(Token::LeadingSpace, HasLeadingSpace);