Lines Matching defs:Tok
286 Callbacks->MacroExpands(Info.Tok, Info.MD, Info.Range,
390 if (I->is(tok::l_paren)) {
392 } else if (I->is(tok::r_paren)) {
396 } else if (I->is(tok::l_brace)) {
398 } else if (I->is(tok::r_brace)) {
444 if (I->is(tok::l_brace)) {
446 } else if (I->is(tok::r_brace)) {
450 } else if (I->is(tok::eof)) {
456 I->setKind(tok::comma);
464 if (FoundSeparatorToken && ArgStartIterator->is(tok::l_brace)) {
474 TempToken.setKind(tok::l_paren);
487 TempToken.setKind(tok::r_paren);
520 Token Tok;
524 LexUnexpandedToken(Tok);
525 assert(Tok.is(tok::l_paren) && "Error computing l-paren-ness?");
536 while (Tok.isNot(tok::r_paren)) {
537 if (ContainsCodeCompletionTok && (Tok.is(tok::eof) || Tok.is(tok::eod)))
540 assert((Tok.is(tok::l_paren) || Tok.is(tok::comma)) &&
544 SourceLocation ArgStartLoc = Tok.getLocation();
553 LexUnexpandedToken(Tok);
555 if (Tok.is(tok::eof) || Tok.is(tok::eod)) { // "#if f(<eof>" & "#if f(\n"
561 MacroName = Tok;
566 Toks[0] = Tok;
570 } else if (Tok.is(tok::r_paren)) {
573 MacroEnd = Tok.getLocation();
576 } else if (Tok.is(tok::l_paren)) {
578 } else if (Tok.is(tok::comma) && NumParens == 0 &&
579 !(Tok.getFlags() & Token::IgnoredComma)) {
590 } else if (Tok.is(tok::comment) && !KeepMacroComments) {
594 } else if (Tok.getIdentifierInfo() != nullptr) {
601 if (MacroInfo *MI = getMacroInfo(Tok.getIdentifierInfo()))
603 Tok.setFlag(Token::DisableExpand);
604 } else if (Tok.is(tok::code_completion)) {
614 ArgTokens.push_back(Tok);
619 if (ArgTokens.empty() && Tok.getKind() == tok::r_paren)
634 Diag(Tok, LangOpts.CPlusPlus11 ?
641 EOFTok.setKind(tok::eof);
642 EOFTok.setLocation(Tok.getLocation());
702 EOFTok.setKind(tok::eof);
703 EOFTok.setLocation(Tok.getLocation());
728 Diag(Tok, diag::ext_missing_varargs_arg);
742 Diag(Tok, diag::err_too_few_args_in_macro_invoc);
749 SourceLocation EndLoc = Tok.getLocation();
750 Tok.startToken();
751 Tok.setKind(tok::eof);
752 Tok.setLocation(EndLoc);
753 Tok.setLength(0);
754 ArgTokens.push_back(Tok);
758 ArgTokens.push_back(Tok);
1051 static bool EvaluateHasIncludeCommon(Token &Tok,
1056 SourceLocation LParenLoc = Tok.getLocation();
1065 PP.LexNonComment(Tok);
1068 if (Tok.isNot(tok::l_paren)) {
1071 PP.Diag(LParenLoc, diag::err_pp_expected_after) << II << tok::l_paren;
1074 if (!Tok.is(tok::angle_string_literal) && !Tok.is(tok::string_literal) &&
1075 !Tok.is(tok::less))
1079 LParenLoc = Tok.getLocation();
1083 PP.getCurrentLexer()->LexIncludeFilename(Tok);
1087 PP.Lex(Tok);
1096 switch (Tok.getKind()) {
1097 case tok::eod:
1101 case tok::angle_string_literal:
1102 case tok::string_literal: {
1104 Filename = PP.getSpelling(Tok, FilenameBuffer, &Invalid);
1110 case tok::less:
1116 Tok.setKind(tok::eod);
1122 PP.Diag(Tok.getLocation(), diag::err_pp_expects_filename);
1126 SourceLocation FilenameLoc = Tok.getLocation();
1129 PP.LexNonComment(Tok);
1132 if (Tok.isNot(tok::r_paren)) {
1134 << II << tok::r_paren;
1135 PP.Diag(LParenLoc, diag::note_matching) << tok::l_paren;
1139 bool isAngled = PP.GetIncludeFilenameSpelling(Tok.getLocation(), Filename);
1157 static bool EvaluateHasInclude(Token &Tok, IdentifierInfo *II,
1159 return EvaluateHasIncludeCommon(Tok, II, PP, nullptr);
1164 static bool EvaluateHasIncludeNext(Token &Tok,
1172 PP.Diag(Tok, diag::pp_include_next_in_primary);
1174 PP.Diag(Tok, diag::pp_include_next_absolute_path);
1180 return EvaluateHasIncludeCommon(Tok, II, PP, Lookup);
1185 static bool EvaluateBuildingModule(Token &Tok,
1188 PP.LexNonComment(Tok);
1191 if (Tok.isNot(tok::l_paren)) {
1192 PP.Diag(Tok.getLocation(), diag::err_pp_expected_after) << II
1193 << tok::l_paren;
1198 SourceLocation LParenLoc = Tok.getLocation();
1201 PP.LexNonComment(Tok);
1204 if (Tok.isNot(tok::identifier)) {
1205 PP.Diag(Tok.getLocation(), diag::err_expected_id_building_module);
1210 = Tok.getIdentifierInfo()->getName() == PP.getLangOpts().CurrentModule;
1213 PP.LexNonComment(Tok);
1216 if (Tok.isNot(tok::r_paren)) {
1217 PP.Diag(Tok.getLocation(), diag::err_pp_expected_after) << II
1218 << tok::r_paren;
1219 PP.Diag(LParenLoc, diag::note_matching) << tok::l_paren;
1227 /// as a builtin macro, handle it and return the next token as 'Tok'.
1228 void Preprocessor::ExpandBuiltinMacro(Token &Tok) {
1230 IdentifierInfo *II = Tok.getIdentifierInfo();
1236 return Handle_Pragma(Tok);
1238 return HandleMicrosoft__pragma(Tok);
1246 Tok.setIdentifierInfo(nullptr);
1247 Tok.clearFlag(Token::NeedsCleaning);
1253 SourceLocation Loc = Tok.getLocation();
1269 Tok.setKind(tok::numeric_constant);
1273 PresumedLoc PLoc = SourceMgr.getPresumedLoc(Tok.getLocation());
1295 Tok.setKind(tok::string_literal);
1297 Diag(Tok.getLocation(), diag::warn_pp_date_time);
1300 Tok.setKind(tok::string_literal);
1301 Tok.setLength(strlen("\"Mmm dd yyyy\""));
1302 Tok.setLocation(SourceMgr.createExpansionLoc(DATELoc, Tok.getLocation(),
1303 Tok.getLocation(),
1304 Tok.getLength()));
1307 Diag(Tok.getLocation(), diag::warn_pp_date_time);
1310 Tok.setKind(tok::string_literal);
1311 Tok.setLength(strlen("\"hh:mm:ss\""));
1312 Tok.setLocation(SourceMgr.createExpansionLoc(TIMELoc, Tok.getLocation(),
1313 Tok.getLocation(),
1314 Tok.getLength()));
1321 PresumedLoc PLoc = SourceMgr.getPresumedLoc(Tok.getLocation());
1330 Tok.setKind(tok::numeric_constant);
1332 Diag(Tok.getLocation(), diag::warn_pp_date_time);
1354 Tok.setKind(tok::string_literal);
1358 Tok.setKind(tok::numeric_constant);
1365 SourceLocation StartLoc = Tok.getLocation();
1371 LexUnexpandedToken(Tok);
1372 if (Tok.is(tok::l_paren)) {
1374 LexUnexpandedToken(Tok);
1375 if ((FeatureII = Tok.getIdentifierInfo())) {
1377 LexUnexpandedToken(Tok);
1378 if (Tok.is(tok::r_paren))
1387 Value = FeatureII->getTokenID() == tok::identifier;
1403 Tok.setKind(tok::numeric_constant);
1411 Value = EvaluateHasInclude(Tok, II, *this);
1413 Value = EvaluateHasIncludeNext(Tok, II, *this);
1415 if (Tok.is(tok::r_paren))
1416 Tok.setKind(tok::numeric_constant);
1420 SourceLocation StartLoc = Tok.getLocation();
1424 LexUnexpandedToken(Tok);
1426 if (Tok.isNot(tok::l_paren)) {
1431 LexUnexpandedToken(Tok);
1433 SourceLocation StrStartLoc = Tok.getLocation();
1434 if (!FinishLexStringLiteral(Tok, WarningName, "'__has_warning'",
1437 while (Tok.isNot(tok::r_paren) && Tok.isNot(tok::eod) &&
1438 Tok.isNot(tok::eof))
1439 LexUnexpandedToken(Tok);
1444 if (!(IsValid = Tok.is(tok::r_paren))) {
1466 Tok.setKind(tok::numeric_constant);
1471 OS << (int)EvaluateBuildingModule(Tok, II, *this);
1472 Tok.setKind(tok::numeric_constant);
1477 Tok.setIdentifierInfo(ModuleII);
1478 Tok.setKind(ModuleII->getTokenID());
1480 SourceLocation Loc = Tok.getLocation();
1484 LexNonComment(Tok);
1485 if (Tok.isNot(tok::l_paren)) {
1488 << II << tok::l_paren;
1490 if (!Tok.isAnnotation() && Tok.getIdentifierInfo())
1491 Tok.setKind(tok::identifier);
1495 SourceLocation LParenLoc = Tok.getLocation();
1496 LexNonComment(Tok);
1498 if (!Tok.isAnnotation() && Tok.getIdentifierInfo())
1499 Tok.setKind(tok::identifier);
1501 Diag(Tok.getLocation(), diag::err_pp_identifier_arg_not_identifier)
1502 << Tok.getKind();
1504 if (Tok.is(tok::eof) || Tok.is(tok::eod) || Tok.isAnnotation())
1508 // Discard the ')', preserving 'Tok' as our result.
1511 if (RParen.isNot(tok::r_paren)) {
1512 Diag(getLocForEndOfToken(Tok.getLocation()), diag::err_pp_expected_after)
1513 << Tok.getKind() << tok::r_paren;
1514 Diag(LParenLoc, diag::note_matching) << tok::l_paren;
1520 CreateString(OS.str(), Tok, Tok.getLocation(), Tok.getLocation());