Lines Matching refs:Tok
486 Callbacks->MacroExpands(Info.Tok, Info.MD, Info.Range,
586 if (I->is(tok::l_paren)) {
588 } else if (I->is(tok::r_paren)) {
592 } else if (I->is(tok::l_brace)) {
594 } else if (I->is(tok::r_brace)) {
640 if (I->is(tok::l_brace)) {
642 } else if (I->is(tok::r_brace)) {
646 } else if (I->is(tok::eof)) {
652 I->setKind(tok::comma);
660 if (FoundSeparatorToken && ArgStartIterator->is(tok::l_brace)) {
670 TempToken.setKind(tok::l_paren);
683 TempToken.setKind(tok::r_paren);
716 Token Tok;
720 LexUnexpandedToken(Tok);
721 assert(Tok.is(tok::l_paren) && "Error computing l-paren-ness?");
732 while (Tok.isNot(tok::r_paren)) {
733 if (ContainsCodeCompletionTok && Tok.isOneOf(tok::eof, tok::eod))
736 assert(Tok.isOneOf(tok::l_paren, tok::comma) &&
740 SourceLocation ArgStartLoc = Tok.getLocation();
749 LexUnexpandedToken(Tok);
751 if (Tok.isOneOf(tok::eof, tok::eod)) { // "#if f(<eof>" & "#if f(\n"
757 MacroName = Tok;
762 Toks[0] = Tok;
766 } else if (Tok.is(tok::r_paren)) {
769 MacroEnd = Tok.getLocation();
772 } else if (Tok.is(tok::l_paren)) {
774 } else if (Tok.is(tok::comma) && NumParens == 0 &&
775 !(Tok.getFlags() & Token::IgnoredComma)) {
786 } else if (Tok.is(tok::comment) && !KeepMacroComments) {
790 } else if (!Tok.isAnnotation() && Tok.getIdentifierInfo() != nullptr) {
797 if (MacroInfo *MI = getMacroInfo(Tok.getIdentifierInfo()))
799 Tok.setFlag(Token::DisableExpand);
800 } else if (Tok.is(tok::code_completion)) {
810 ArgTokens.push_back(Tok);
815 if (ArgTokens.empty() && Tok.getKind() == tok::r_paren)
830 Diag(Tok, LangOpts.CPlusPlus11 ?
837 EOFTok.setKind(tok::eof);
838 EOFTok.setLocation(Tok.getLocation());
898 EOFTok.setKind(tok::eof);
899 EOFTok.setLocation(Tok.getLocation());
924 Diag(Tok, diag::ext_missing_varargs_arg);
938 Diag(Tok, diag::err_too_few_args_in_macro_invoc);
945 SourceLocation EndLoc = Tok.getLocation();
946 Tok.startToken();
947 Tok.setKind(tok::eof);
948 Tok.setLocation(EndLoc);
949 Tok.setLength(0);
950 ArgTokens.push_back(Tok);
954 ArgTokens.push_back(Tok);
1268 static bool EvaluateHasIncludeCommon(Token &Tok,
1274 SourceLocation LParenLoc = Tok.getLocation();
1280 assert(Tok.is(tok::identifier));
1281 Tok.setIdentifierInfo(II);
1286 PP.LexNonComment(Tok);
1289 if (Tok.isNot(tok::l_paren)) {
1292 PP.Diag(LParenLoc, diag::err_pp_expected_after) << II << tok::l_paren;
1295 if (!Tok.is(tok::angle_string_literal) && !Tok.is(tok::string_literal) &&
1296 !Tok.is(tok::less))
1300 LParenLoc = Tok.getLocation();
1304 PP.getCurrentLexer()->LexIncludeFilename(Tok);
1308 PP.Lex(Tok);
1317 switch (Tok.getKind()) {
1318 case tok::eod:
1322 case tok::angle_string_literal:
1323 case tok::string_literal: {
1325 Filename = PP.getSpelling(Tok, FilenameBuffer, &Invalid);
1331 case tok::less:
1337 Tok.setKind(tok::eod);
1343 PP.Diag(Tok.getLocation(), diag::err_pp_expects_filename);
1347 SourceLocation FilenameLoc = Tok.getLocation();
1350 PP.LexNonComment(Tok);
1353 if (Tok.isNot(tok::r_paren)) {
1355 << II << tok::r_paren;
1356 PP.Diag(LParenLoc, diag::note_matching) << tok::l_paren;
1360 bool isAngled = PP.GetIncludeFilenameSpelling(Tok.getLocation(), Filename);
1378 static bool EvaluateHasInclude(Token &Tok, IdentifierInfo *II,
1380 return EvaluateHasIncludeCommon(Tok, II, PP, nullptr, nullptr);
1385 static bool EvaluateHasIncludeNext(Token &Tok,
1396 PP.Diag(Tok, diag::pp_include_next_in_primary);
1404 PP.Diag(Tok, diag::pp_include_next_absolute_path);
1410 return EvaluateHasIncludeCommon(Tok, II, PP, Lookup, LookupFromFile);
1415 static bool EvaluateBuildingModule(Token &Tok,
1418 PP.LexNonComment(Tok);
1421 if (Tok.isNot(tok::l_paren)) {
1422 PP.Diag(Tok.getLocation(), diag::err_pp_expected_after) << II
1423 << tok::l_paren;
1428 SourceLocation LParenLoc = Tok.getLocation();
1431 PP.LexNonComment(Tok);
1434 if (Tok.isNot(tok::identifier)) {
1435 PP.Diag(Tok.getLocation(), diag::err_expected_id_building_module);
1440 = Tok.getIdentifierInfo()->getName() == PP.getLangOpts().CurrentModule;
1443 PP.LexNonComment(Tok);
1446 if (Tok.isNot(tok::r_paren)) {
1447 PP.Diag(Tok.getLocation(), diag::err_pp_expected_after) << II
1448 << tok::r_paren;
1449 PP.Diag(LParenLoc, diag::note_matching) << tok::l_paren;
1457 /// as a builtin macro, handle it and return the next token as 'Tok'.
1458 void Preprocessor::ExpandBuiltinMacro(Token &Tok) {
1460 IdentifierInfo *II = Tok.getIdentifierInfo();
1466 return Handle_Pragma(Tok);
1468 return HandleMicrosoft__pragma(Tok);
1476 Tok.setIdentifierInfo(nullptr);
1477 Tok.clearFlag(Token::NeedsCleaning);
1483 SourceLocation Loc = Tok.getLocation();
1499 Tok.setKind(tok::numeric_constant);
1503 PresumedLoc PLoc = SourceMgr.getPresumedLoc(Tok.getLocation());
1525 Tok.setKind(tok::string_literal);
1527 Diag(Tok.getLocation(), diag::warn_pp_date_time);
1530 Tok.setKind(tok::string_literal);
1531 Tok.setLength(strlen("\"Mmm dd yyyy\""));
1532 Tok.setLocation(SourceMgr.createExpansionLoc(DATELoc, Tok.getLocation(),
1533 Tok.getLocation(),
1534 Tok.getLength()));
1537 Diag(Tok.getLocation(), diag::warn_pp_date_time);
1540 Tok.setKind(tok::string_literal);
1541 Tok.setLength(strlen("\"hh:mm:ss\""));
1542 Tok.setLocation(SourceMgr.createExpansionLoc(TIMELoc, Tok.getLocation(),
1543 Tok.getLocation(),
1544 Tok.getLength()));
1551 PresumedLoc PLoc = SourceMgr.getPresumedLoc(Tok.getLocation());
1560 Tok.setKind(tok::numeric_constant);
1562 Diag(Tok.getLocation(), diag::warn_pp_date_time);
1584 Tok.setKind(tok::string_literal);
1588 Tok.setKind(tok::numeric_constant);
1597 SourceLocation StartLoc = Tok.getLocation();
1604 LexUnexpandedToken(Tok);
1605 if (Tok.is(tok::l_paren)) {
1607 LexUnexpandedToken(Tok);
1608 if ((FeatureII = Tok.getIdentifierInfo())) {
1611 LexUnexpandedToken(Tok);
1613 if (II == Ident__has_cpp_attribute && Tok.is(tok::coloncolon)) {
1614 LexUnexpandedToken(Tok);
1617 if ((FeatureII = Tok.getIdentifierInfo()))
1618 LexUnexpandedToken(Tok);
1623 if (IsScopeValid && Tok.is(tok::r_paren))
1627 while (Tok.isNot(tok::r_paren) && Tok.isNot(tok::eod) &&
1628 Tok.isNot(tok::eof))
1629 LexUnexpandedToken(Tok);
1636 Value = FeatureII->getTokenID() == tok::identifier;
1666 Tok.setKind(tok::numeric_constant);
1674 Value = EvaluateHasInclude(Tok, II, *this);
1676 Value = EvaluateHasIncludeNext(Tok, II, *this);
1678 if (Tok.isNot(tok::r_paren))
1681 Tok.setKind(tok::numeric_constant);
1685 SourceLocation StartLoc = Tok.getLocation();
1689 LexUnexpandedToken(Tok);
1691 if (Tok.isNot(tok::l_paren)) {
1696 LexUnexpandedToken(Tok);
1698 SourceLocation StrStartLoc = Tok.getLocation();
1699 if (!FinishLexStringLiteral(Tok, WarningName, "'__has_warning'",
1702 while (Tok.isNot(tok::r_paren) && Tok.isNot(tok::eod) &&
1703 Tok.isNot(tok::eof))
1704 LexUnexpandedToken(Tok);
1709 if (!(IsValid = Tok.is(tok::r_paren))) {
1735 Tok.setKind(tok::numeric_constant);
1740 OS << (int)EvaluateBuildingModule(Tok, II, *this);
1741 Tok.setKind(tok::numeric_constant);
1746 Tok.setIdentifierInfo(ModuleII);
1747 Tok.setKind(ModuleII->getTokenID());
1749 SourceLocation Loc = Tok.getLocation();
1753 LexNonComment(Tok);
1754 if (Tok.isNot(tok::l_paren)) {
1757 << II << tok::l_paren;
1759 if (!Tok.isAnnotation() && Tok.getIdentifierInfo())
1760 Tok.setKind(tok::identifier);
1764 SourceLocation LParenLoc = Tok.getLocation();
1765 LexNonComment(Tok);
1767 if (!Tok.isAnnotation() && Tok.getIdentifierInfo())
1768 Tok.setKind(tok::identifier);
1770 Diag(Tok.getLocation(), diag::err_pp_identifier_arg_not_identifier)
1771 << Tok.getKind();
1773 if (Tok.isOneOf(tok::eof, tok::eod) || Tok.isAnnotation())
1777 // Discard the ')', preserving 'Tok' as our result.
1780 if (RParen.isNot(tok::r_paren)) {
1781 Diag(getLocForEndOfToken(Tok.getLocation()), diag::err_pp_expected_after)
1782 << Tok.getKind() << tok::r_paren;
1783 Diag(LParenLoc, diag::note_matching) << tok::l_paren;
1789 CreateString(OS.str(), Tok, Tok.getLocation(), Tok.getLocation());