Lines Matching refs:Tok
101 FormatTok.Tok.startToken();
102 FormatTok.Tok.setKind(tok::eof);
270 tok::TokenKind kind = FormatTok->Tok.getKind();
272 kind = tok::l_brace;
274 kind = tok::r_brace;
278 case tok::comment:
282 case tok::l_brace:
290 case tok::r_brace:
296 case tok::kw_default:
297 case tok::kw_case:
317 FormatToken *Tok = FormatTok;
322 assert(Tok->Tok.is(tok::l_brace));
330 } while (NextTok->is(tok::comment));
332 switch (Tok->Tok.getKind()) {
333 case tok::l_brace:
334 Tok->BlockKind = BK_Unknown;
335 LBraceStack.push_back(Tok);
337 case tok::r_brace:
342 ProbablyBracedList = NextTok->isOneOf(tok::comma, tok::r_square);
346 bool NextIsObjCMethod = NextTok->isOneOf(tok::plus, tok::minus) &&
358 NextTok->isOneOf(tok::comma, tok::period, tok::colon,
359 tok::r_paren, tok::r_square, tok::l_brace,
360 tok::l_paren, tok::ellipsis) ||
361 (NextTok->is(tok::semi) &&
366 Tok->BlockKind = BK_BracedInit;
369 Tok->BlockKind = BK_Block;
376 case tok::at:
377 case tok::semi:
378 case tok::kw_if:
379 case tok::kw_while:
380 case tok::kw_for:
381 case tok::kw_switch:
382 case tok::kw_try:
383 case tok::kw___try:
390 Tok = NextTok;
391 } while (Tok->Tok.isNot(tok::eof) && !LBraceStack.empty());
403 assert(FormatTok->isOneOf(tok::l_brace, TT_MacroBlockBegin) &&
411 if (MacroBlock && FormatTok->is(tok::l_paren))
423 : !FormatTok->is(tok::r_brace)) {
431 if (MacroBlock && FormatTok->is(tok::l_paren))
434 if (MunchSemi && FormatTok->Tok.is(tok::semi))
445 if (I->Tok->TokenText != "goog")
448 if (I->Tok->isNot(tok::period))
451 if (I->Tok->TokenText != "scope")
454 return I->Tok->is(tok::l_paren);
459 if (InitialToken.is(tok::kw_namespace))
461 if (InitialToken.is(tok::kw_class))
463 if (InitialToken.is(tok::kw_union))
465 if (InitialToken.is(tok::kw_struct))
488 assert(FormatTok->Tok.is(tok::hash) && "'#' expected");
492 if (!FormatTok->Tok.getIdentifierInfo()) {
497 switch (FormatTok->Tok.getIdentifierInfo()->getPPKeywordID()) {
498 case tok::pp_define:
501 case tok::pp_if:
504 case tok::pp_ifdef:
505 case tok::pp_ifndef:
508 case tok::pp_else:
511 case tok::pp_elif:
514 case tok::pp_endif:
571 bool IsLiteralFalse = (FormatTok->Tok.isLiteral() &&
572 FormatTok->Tok.getLiteralData() != nullptr &&
573 StringRef(FormatTok->Tok.getLiteralData(),
574 FormatTok->Tok.getLength()) == "0") ||
575 FormatTok->Tok.is(tok::kw_false);
595 if (FormatTok->Tok.getKind() != tok::identifier) {
600 if (FormatTok->Tok.getKind() == tok::l_paren &&
626 static bool tokenCanStartNewLine(const clang::Token &Tok) {
629 return Tok.isNot(tok::semi) && Tok.isNot(tok::l_brace) &&
630 Tok.isNot(tok::l_square) &&
633 Tok.isNot(tok::period) && Tok.isNot(tok::periodstar) &&
634 Tok.isNot(tok::arrow) && Tok.isNot(tok::arrowstar) &&
635 Tok.isNot(tok::less) && Tok.isNot(tok::greater) &&
636 Tok.isNot(tok::slash) && Tok.isNot(tok::percent) &&
637 Tok.isNot(tok::lessless) && Tok.isNot(tok::greatergreater) &&
638 Tok.isNot(tok::equal) && Tok.isNot(tok::plusequal) &&
639 Tok.isNot(tok::minusequal) && Tok.isNot(tok::starequal) &&
640 Tok.isNot(tok::slashequal) && Tok.isNot(tok::percentequal) &&
641 Tok.isNot(tok::ampequal) && Tok.isNot(tok::pipeequal) &&
642 Tok.isNot(tok::caretequal) && Tok.isNot(tok::greatergreaterequal) &&
643 Tok.isNot(tok::lesslessequal) &&
647 Tok.isNot(tok::colon) &&
649 Tok.isNot(tok::kw_noexcept);
653 assert(!FormatTok->Tok.is(tok::l_brace));
654 switch (FormatTok->Tok.getKind()) {
655 case tok::at:
657 if (FormatTok->Tok.is(tok::l_brace)) {
661 switch (FormatTok->Tok.getObjCKeywordID()) {
662 case tok::objc_public:
663 case tok::objc_protected:
664 case tok::objc_package:
665 case tok::objc_private:
667 case tok::objc_interface:
668 case tok::objc_implementation:
670 case tok::objc_protocol:
672 case tok::objc_end:
674 case tok::objc_optional:
675 case tok::objc_required:
679 case tok::objc_autoreleasepool:
681 if (FormatTok->Tok.is(tok::l_brace)) {
688 case tok::objc_try:
690 // do this too after the tok::at is parsed above). But be explicit.
697 case tok::kw_asm:
699 if (FormatTok->is(tok::l_brace)) {
702 while (FormatTok && FormatTok->isNot(tok::eof)) {
703 if (FormatTok->is(tok::r_brace)) {
714 case tok::kw_namespace:
717 case tok::kw_inline:
719 if (FormatTok->Tok.is(tok::kw_namespace)) {
724 case tok::kw_public:
725 case tok::kw_protected:
726 case tok::kw_private:
733 case tok::kw_if:
736 case tok::kw_for:
737 case tok::kw_while:
740 case tok::kw_do:
743 case tok::kw_switch:
746 case tok::kw_default:
750 case tok::kw_case:
753 case tok::kw_try:
754 case tok::kw___try:
757 case tok::kw_extern:
759 if (FormatTok->Tok.is(tok::string_literal)) {
761 if (FormatTok->Tok.is(tok::l_brace)) {
768 case tok::kw_export:
774 case tok::identifier:
792 if (FormatTok->is(tok::colon)) {
804 switch (FormatTok->Tok.getKind()) {
805 case tok::at:
807 if (FormatTok->Tok.is(tok::l_brace))
810 case tok::kw_enum:
820 case tok::kw_typedef:
826 case tok::kw_struct:
827 case tok::kw_union:
828 case tok::kw_class:
839 case tok::period:
843 FormatTok->is(tok::kw_class))
846 FormatTok->Tok.getIdentifierInfo())
851 case tok::semi:
855 case tok::r_brace:
858 case tok::l_paren:
861 case tok::kw_operator:
866 case tok::caret:
868 if (FormatTok->Tok.isAnyIdentifier() ||
871 if (FormatTok->is(tok::l_paren))
873 if (FormatTok->is(tok::l_brace))
876 case tok::l_brace:
892 case tok::kw_try:
896 case tok::identifier: {
923 if (FormatTok->Tok.is(tok::colon) && !Line->MustBeDeclaration) {
929 bool FunctionLike = FormatTok->is(tok::l_paren);
939 tokenCanStartNewLine(FormatTok->Tok) && Text == Text.upper()) {
946 case tok::equal:
947 // Fat arrows (=>) have tok::TokenKind tok::equal but TokenType
952 if (FormatTok->is(tok::l_brace))
958 if (FormatTok->Tok.is(tok::l_brace)) {
962 case tok::l_square:
965 case tok::kw_new:
983 (Line->Tokens.back().Tok->isOneOf(tok::identifier, tok::kw_operator,
984 tok::kw_new, tok::kw_delete) ||
985 Line->Tokens.back().Tok->closesScope() ||
986 Line->Tokens.back().Tok->isSimpleTypeSpecifier())) {
990 assert(FormatTok->is(tok::l_square));
995 while (FormatTok->isNot(tok::l_brace)) {
1000 switch (FormatTok->Tok.getKind()) {
1001 case tok::l_brace:
1003 case tok::l_paren:
1006 case tok::amp:
1007 case tok::star:
1008 case tok::kw_const:
1009 case tok::comma:
1010 case tok::less:
1011 case tok::greater:
1012 case tok::identifier:
1013 case tok::numeric_constant:
1014 case tok::coloncolon:
1015 case tok::kw_mutable:
1018 case tok::arrow:
1033 if (FormatTok->is(tok::equal)) {
1035 if (FormatTok->is(tok::r_square)) {
1039 if (FormatTok->isNot(tok::comma))
1042 } else if (FormatTok->is(tok::amp)) {
1044 if (FormatTok->is(tok::r_square)) {
1048 if (!FormatTok->isOneOf(tok::comma, tok::identifier)) {
1051 if (FormatTok->is(tok::comma))
1053 } else if (FormatTok->is(tok::r_square)) {
1058 if (FormatTok->is(tok::amp))
1060 if (!FormatTok->isOneOf(tok::identifier, tok::kw_this))
1063 if (FormatTok->is(tok::ellipsis))
1065 if (FormatTok->is(tok::comma)) {
1067 } else if (FormatTok->is(tok::r_square)) {
1081 if (FormatTok->is(tok::identifier))
1084 if (FormatTok->isNot(tok::l_paren))
1090 if (FormatTok->is(tok::colon)) {
1096 if (FormatTok->is(tok::l_brace))
1099 while (FormatTok->isNot(tok::l_brace) && !eof())
1132 if (FormatTok->is(tok::l_brace)) {
1138 switch (FormatTok->Tok.getKind()) {
1139 case tok::caret:
1141 if (FormatTok->is(tok::l_brace)) {
1145 case tok::l_square:
1148 case tok::l_brace:
1154 case tok::l_paren:
1159 if (FormatTok->is(tok::l_brace))
1164 case tok::r_brace:
1167 case tok::semi:
1173 case tok::comma:
1185 assert(FormatTok->Tok.is(tok::l_paren) && "'(' expected.");
1188 switch (FormatTok->Tok.getKind()) {
1189 case tok::l_paren:
1191 if (Style.Language == FormatStyle::LK_Java && FormatTok->is(tok::l_brace))
1194 case tok::r_paren:
1197 case tok::r_brace:
1200 case tok::l_square:
1203 case tok::l_brace:
1207 case tok::at:
1209 if (FormatTok->Tok.is(tok::l_brace))
1212 case tok::identifier:
1227 assert(FormatTok->Tok.is(tok::l_square) && "'[' expected.");
1231 switch (FormatTok->Tok.getKind()) {
1232 case tok::l_paren:
1235 case tok::r_square:
1238 case tok::r_brace:
1241 case tok::l_square:
1244 case tok::l_brace: {
1249 case tok::at:
1251 if (FormatTok->Tok.is(tok::l_brace))
1262 assert(FormatTok->Tok.is(tok::kw_if) && "'if' expected");
1264 if (FormatTok->Tok.is(tok::l_paren))
1267 if (FormatTok->Tok.is(tok::l_brace)) {
1280 if (FormatTok->Tok.is(tok::kw_else)) {
1282 if (FormatTok->Tok.is(tok::l_brace)) {
1286 } else if (FormatTok->Tok.is(tok::kw_if)) {
1300 assert(FormatTok->isOneOf(tok::kw_try, tok::kw___try) && "'try' expected");
1303 if (FormatTok->is(tok::colon)) {
1306 while (FormatTok->is(tok::identifier)) {
1308 if (FormatTok->is(tok::l_paren))
1310 if (FormatTok->is(tok::comma))
1315 if (Style.Language == FormatStyle::LK_Java && FormatTok->is(tok::l_paren)) {
1318 if (FormatTok->is(tok::l_brace)) {
1326 } else if (!FormatTok->is(tok::kw_catch)) {
1336 if (FormatTok->is(tok::at))
1338 if (!(FormatTok->isOneOf(tok::kw_catch, Keywords.kw___except,
1339 tok::kw___finally) ||
1343 (FormatTok->Tok.isObjCAtKeyword(tok::objc_catch) ||
1344 FormatTok->Tok.isObjCAtKeyword(tok::objc_finally))))
1347 while (FormatTok->isNot(tok::l_brace)) {
1348 if (FormatTok->is(tok::l_paren)) {
1352 if (FormatTok->isOneOf(tok::semi, tok::r_brace, tok::eof))
1369 assert(FormatTok->Tok.is(tok::kw_namespace) && "'namespace' expected");
1373 while (FormatTok->isOneOf(tok::identifier, tok::coloncolon))
1375 if (FormatTok->Tok.is(tok::l_brace)) {
1385 if (FormatTok->Tok.is(tok::semi))
1393 assert(FormatTok->is(tok::kw_new) && "'new' expected");
1401 if (FormatTok->isOneOf(tok::semi, tok::l_brace, tok::r_brace))
1405 if (FormatTok->is(tok::l_paren)) {
1409 if (FormatTok->is(tok::l_brace))
1418 assert(FormatTok->isOneOf(tok::kw_for, tok::kw_while, TT_ForEachMacro) &&
1421 if (FormatTok->Tok.is(tok::l_paren))
1423 if (FormatTok->Tok.is(tok::l_brace)) {
1436 assert(FormatTok->Tok.is(tok::kw_do) && "'do' expected");
1438 if (FormatTok->Tok.is(tok::l_brace)) {
1451 if (!FormatTok->Tok.is(tok::kw_while)) {
1465 if (CommentsBeforeNextToken.empty() && FormatTok->Tok.is(tok::l_brace)) {
1468 if (FormatTok->Tok.is(tok::kw_break)) {
1475 if (FormatTok->is(tok::semi))
1483 assert(FormatTok->Tok.is(tok::kw_case) && "'case' expected");
1487 } while (!eof() && !FormatTok->Tok.is(tok::colon));
1492 assert(FormatTok->Tok.is(tok::kw_switch) && "'switch' expected");
1494 if (FormatTok->Tok.is(tok::l_paren))
1496 if (FormatTok->Tok.is(tok::l_brace)) {
1514 if (FormatTok->Tok.is(tok::colon))
1521 if (FormatTok->Tok.is(tok::kw_enum))
1525 if (FormatTok->Tok.is(tok::kw_class) || FormatTok->Tok.is(tok::kw_struct))
1528 while (FormatTok->Tok.getIdentifierInfo() ||
1529 FormatTok->isOneOf(tok::colon, tok::coloncolon, tok::less,
1530 tok::greater, tok::comma, tok::question)) {
1533 if (FormatTok->is(tok::l_paren))
1535 if (FormatTok->is(tok::identifier)) {
1540 FormatTok->is(tok::identifier))
1546 if (FormatTok->isNot(tok::l_brace))
1562 if (FormatTok->is(tok::semi))
1578 FormatToken *Tok = Tokens->getNextToken();
1579 while (Tok) {
1580 if (Tok->is(tok::r_brace))
1582 if (Tok->isOneOf(tok::l_brace, tok::semi)) {
1588 Tok = Tokens->getNextToken();
1606 if (FormatTok->is(tok::l_brace)) {
1610 } else if (FormatTok->is(tok::l_paren)) {
1612 } else if (FormatTok->is(tok::comma)) {
1615 } else if (FormatTok->is(tok::semi)) {
1619 } else if (FormatTok->is(tok::r_brace)) {
1640 while (FormatTok->isOneOf(tok::identifier, tok::coloncolon, tok::hashhash,
1641 tok::kw___attribute, tok::kw___declspec,
1642 tok::kw_alignas) ||
1645 FormatTok->isOneOf(toktok::comma))) {
1647 FormatTok->is(tok::identifier) &&
1651 if (!IsNonMacroIdentifier && FormatTok->Tok.is(tok::l_paren))
1665 if (FormatTok->isOneOf(tok::colon, tok::less)) {
1667 if (FormatTok->is(tok::l_brace)) {
1672 if (FormatTok->Tok.is(tok::semi))
1677 if (FormatTok->Tok.is(tok::l_brace)) {
1690 assert(FormatTok->Tok.is(tok::less) && "'<' expected.");
1693 while (!eof() && FormatTok->Tok.isNot(tok::greater));
1699 if (FormatTok->Tok.isObjCAtKeyword(tok::objc_end)) {
1704 if (FormatTok->is(tok::l_brace)) {
1708 } else if (FormatTok->is(tok::r_brace)) {
1723 if (FormatTok->Tok.is(tok::colon)) {
1726 } else if (FormatTok->Tok.is(tok::l_paren))
1730 if (FormatTok->Tok.is(tok::less))
1733 if (FormatTok->Tok.is(tok::l_brace)) {
1750 if (FormatTok->Tok.is(tok::less))
1754 if (FormatTok->Tok.is(tok::semi)) {
1764 assert(FormatTok->isOneOf(Keywords.kw_import, tok::kw_export));
1768 if (FormatTok->is(tok::kw_default))
1778 if (FormatTok->isOneOf(tok::kw_const, tok::kw_class, tok::kw_enum,
1782 if (FormatTok->is(tok::l_brace)) {
1787 while (!eof() && FormatTok->isNot(tok::semi) &&
1788 FormatTok->isNot(tok::l_brace)) {
1800 llvm::dbgs() << I->Tok->Tok.getName() << "[" << I->Tok->Type << "] ";
1833 bool UnwrappedLineParser::eof() const { return FormatTok->Tok.is(tok::eof); }
1868 while (!Line->InPPDirective && FormatTok->Tok.is(tok::hash) &&
1899 if (!FormatTok->Tok.is(tok::comment))
1912 void UnwrappedLineParser::pushToken(FormatToken *Tok) {
1913 Line->Tokens.push_back(UnwrappedLineNode(Tok));
1915 Line->Tokens.back().Tok->MustBreakBefore = true;