Lines Matching refs:tok

34 /// lexed as tok::kw_*, not tok::identifier, even for Objective-C.
48 if (Left->Previous && Left->Previous->is(tok::greater) &&
54 return Left->Previous && Left->Previous->is(tok::r_square) &&
62 return Tok.isOneOf(tok::kw_if, tok::kw_for, tok::kw_while, tok::kw_switch,
63 tok::kw_constexpr, tok::kw_catch);
77 Contexts.push_back(Context(tok::unknown, 1, /*IsExpression=*/false));
92 if (Previous.Previous->is(tok::r_paren) && Contexts.size() > 1 &&
100 ScopedContextCreator ContextCreator(*this, tok::less, 12);
110 Left->Previous && Left->Previous->Tok.isNot(tok::kw_template);
113 CurrentToken->is(tok::question))
117 if (CurrentToken->is(tok::greater)) {
124 if (CurrentToken->Next && CurrentToken->Next->is(tok::greater) &&
125 Left->ParentBracket != tok::less &&
147 if (CurrentToken->is(tok::question) &&
152 if (CurrentToken->isOneOf(tok::r_paren, tok::r_square, tok::r_brace) ||
153 (CurrentToken->isOneOf(tok::colon, tok::question) && InExprContext &&
163 if (CurrentToken->Previous->isOneOf(tok::pipepipe, tok::ampamp) &&
166 !Line.startsWith(tok::kw_template))
171 if (CurrentToken->is(tok::colon) ||
172 (CurrentToken->isOneOf(tok::l_brace, tok::less) &&
173 Previous->isNot(tok::colon)))
187 case tok::l_paren:
192 case tok::r_paren:
211 ScopedContextCreator ContextCreator(*this, tok::l_paren, 1);
225 if (MaybeSel->isObjCAtKeyword(tok::objc_selector) && MaybeSel->Previous &&
226 MaybeSel->Previous->is(tok::at)) {
234 (Line.startsWith(Keywords.kw_type, tok::identifier) ||
235 Line.startsWith(tok::kw_export, Keywords.kw_type,
236 tok::identifier))) {
241 (Left->Previous->isOneOf(tok::kw_static_assert, tok::kw_while,
242 tok::l_paren, tok::comma) ||
249 (Left->Previous->endsSequence(tok::identifier,
261 (!Left->Previous || !Left->Previous->is(tok::identifier))) {
275 Left->Previous && Left->Previous->isOneOf(tok::kw_for, tok::kw_catch);
282 if (PrevNonComment->is(tok::kw___attribute)) {
284 } else if (PrevNonComment->isOneOf(TT_TypenameMacro, tok::kw_decltype,
285 tok::kw_typeof, tok::kw__Atomic,
286 tok::kw___underlying_type)) {
289 if (PrevNonComment->isOneOf(tok::kw_decltype, tok::kw_typeof))
308 CurrentToken->isOneOf(tok::star, tok::amp, tok::caret);
312 Left->Previous && Left->Previous->is(tok::kw_for);
324 if (PrevPrev && PrevPrev->is(tok::identifier) &&
325 Prev->isOneOf(tok::star, tok::amp, tok::ampamp) &&
326 CurrentToken->is(tok::identifier) && Next->isNot(tok::equal)) {
334 CurrentToken->Previous->Previous->isOneOf(tok::l_paren,
335 tok::coloncolon))
337 if (CurrentToken->is(tok::comma))
341 if (CurrentToken->is(tok::r_paren)) {
343 (CurrentToken->Next->is(tok::l_paren) ||
344 (CurrentToken->Next->is(tok::l_square) && Line.MustBeDeclaration)))
345 Left->setType(Left->Next->is(tok::caret) ? TT_ObjCBlockLParen
350 if (CurrentToken->Next && CurrentToken->Next->is(tok::l_brace) &&
351 Left->Previous && Left->Previous->is(tok::l_paren)) {
357 Tok->isOneOf(tok::star, tok::amp, tok::ampamp))
391 if (CurrentToken->isOneOf(tok::r_square, tok::r_brace))
394 if (CurrentToken->is(tok::l_brace))
396 if (CurrentToken->is(tok::comma) && CurrentToken->Next &&
400 if ((CurrentToken->Previous->isOneOf(tok::kw_const, tok::kw_auto) ||
402 !CurrentToken->is(tok::l_brace))
404 if (CurrentToken->isOneOf(tok::semi, tok::colon)) {
417 if (CurrentToken->is(tok::comma))
435 if (Tok.Previous && Tok.Previous->is(tok::identifier))
439 if (Tok.Previous && Tok.Previous->is(tok::r_square)) {
450 if (AttrTok->is(tok::r_square))
454 while (AttrTok && AttrTok->isNot(tok::r_square)) {
467 if (AttrTok->isOneOf(tok::kw_public, tok::kw_private, tok::kw_protected,
468 tok::comment, tok::kw_class, tok::kw_static,
469 tok::l_square, Keywords.kw_internal)) {
475 AttrTok->Next->startsSequence(tok::identifier, tok::l_paren))
482 if (!Style.isCpp() || !Tok.startsSequence(tok::l_square, tok::l_square))
485 if (Tok.Previous && Tok.Previous->is(tok::at)) {
493 if (AttrTok->startsSequence(tok::kw_using, tok::identifier, tok::colon))
495 if (AttrTok->isNot(tok::identifier))
497 while (AttrTok && !AttrTok->startsSequence(tok::r_square, tok::r_square)) {
501 if (AttrTok->is(tok::colon) ||
502 AttrTok->startsSequence(tok::identifier, tok::identifier) ||
503 AttrTok->startsSequence(tok::r_paren, tok::identifier))
505 if (AttrTok->is(tok::ellipsis))
509 return AttrTok && AttrTok->startsSequence(tok::r_square, tok::r_square);
540 bool InsideInlineASM = Line.startsWith(tok::kw_asm);
547 !CurrentToken->isOneOf(tok::l_brace, tok::r_square) &&
549 Parent->isOneOf(tok::colon, tok::l_square, tok::l_paren,
550 tok::kw_return, tok::kw_throw) ||
569 Contexts.back().ContextKind == tok::l_brace &&
570 Parent->isOneOf(tok::l_brace, tok::comma)) {
572 } else if (Style.isCpp() && Contexts.back().ContextKind == tok::l_brace &&
573 Parent && Parent->isOneOf(tok::l_brace, tok::comma)) {
577 } else if (CurrentToken->is(tok::r_square) && Parent &&
609 if (!Left->endsSequence(tok::l_square, tok::numeric_constant,
610 tok::equal) &&
611 !Left->endsSequence(tok::l_square, tok::numeric_constant,
612 tok::identifier) &&
613 !Left->endsSequence(tok::l_square, tok::colon, TT_SelectorName)) {
618 Parent->isOneOf(TT_BinaryOperator, TT_TemplateCloser, tok::at,
619 tok::comma, tok::l_paren, tok::l_square,
620 tok::question, tok::colon, tok::kw_return,
622 tok::kw_default)) {
630 ScopedContextCreator ContextCreator(*this, tok::l_square, BindingIncrease);
641 if (CurrentToken->is(tok::r_square)) {
647 CurrentToken->Next->is(tok::l_paren)) ||
701 if (CurrentToken->isOneOf(tok::r_paren, tok::r_brace))
703 if (CurrentToken->is(tok::colon)) {
705 CurrentToken->endsSequence(tok::colon, tok::identifier,
706 tok::kw_using)) {
715 if (Parent && Parent->is(tok::r_paren))
721 if (CurrentToken->is(tok::comma) && Left->is(TT_ObjCMethodExpr) &&
741 ScopedContextCreator ContextCreator(*this, tok::l_brace, 1);
750 if (CurrentToken->is(tok::r_brace)) {
756 if (CurrentToken->isOneOf(tok::r_paren, tok::r_square))
759 if (CurrentToken->isOneOf(tok::colon, tok::l_brace, tok::less)) {
763 if ((CurrentToken->is(tok::colon) &&
769 Previous->is(tok::string_literal))
772 if (CurrentToken->is(tok::colon) ||
776 if (CurrentToken->is(tok::comma) &&
790 if (Current->is(tok::l_brace) && Current->is(BK_Block))
792 if (Current->is(tok::comma)) {
797 } else if (Left->ParameterCount == 0 && Current->isNot(tok::comment)) {
804 if (CurrentToken->is(tok::colon)) {
816 if (CurrentToken && CurrentToken->is(tok::less)) {
832 case tok::plus:
833 case tok::minus:
837 case tok::colon:
844 !Line.First->isOneOf(tok::kw_enum, tok::kw_case)) ||
845 Contexts.back().ContextKind == tok::l_paren || // function params
846 Contexts.back().ContextKind == tok::l_square || // array type
848 Contexts.back().ContextKind == tok::l_brace) || // object type
860 if (Contexts.back().ContextKind == tok::l_paren) {
881 Tok->Previous->is(tok::identifier) && Tok->Previous->is(TT_Unknown);
886 BeforePrevious->is(tok::colon))) ||
887 BeforePrevious->is(tok::r_square) ||
903 } else if (CurrentToken && CurrentToken->is(tok::numeric_constant)) {
906 !Line.First->isOneOf(tok::kw_enum, tok::kw_case,
907 tok::kw_default)) {
909 if (Prev->isOneOf(tok::r_paren, tok::kw_noexcept))
911 else if (Prev->is(tok::kw_try)) {
914 if (PrevPrev && PrevPrev->isOneOf(tok::r_paren, tok::kw_noexcept))
919 (Tok->Next->isOneOf(tok::r_paren, tok::comma) ||
921 Tok->Next->Next->is(tok::colon)))) {
925 } else if (Contexts.back().ContextKind == tok::l_paren) {
929 case tok::pipe:
930 case tok::amp:
937 case tok::kw_if:
938 case tok::kw_while:
939 if (Tok->is(tok::kw_if) && CurrentToken &&
940 CurrentToken->isOneOf(tok::kw_constexpr, tok::identifier))
942 if (CurrentToken && CurrentToken->is(tok::l_paren)) {
948 case tok::kw_for:
951 if ((Tok->Previous && Tok->Previous->is(tok::period)) ||
952 (Tok->Next && Tok->Next->is(tok::colon)))
963 case tok::l_paren:
968 if (Tok->Previous && Tok->Previous->is(tok::r_paren) &&
981 (!Tok->Previous || !Tok->Previous->isOneOf(tok::kw___attribute,
985 case tok::l_square:
989 case tok::l_brace:
998 case tok::less:
1021 case tok::r_paren:
1022 case tok::r_square:
1024 case tok::r_brace:
1029 case tok::greater:
1035 case tok::kw_operator:
1040 !CurrentToken->isOneOf(tok::l_paren, tok::semi, tok::r_paren)) {
1041 if (CurrentToken->isOneOf(tok::star, tok::amp))
1044 if (CurrentToken && CurrentToken->is(tok::comma) &&
1045 CurrentToken->Previous->isNot(tok::kw_operator))
1048 TT_BinaryOperator, TT_UnaryOperator, tok::comma,
1049 tok::star, tok::arrow, tok::amp, tok::ampamp))
1052 if (CurrentToken && CurrentToken->is(tok::l_paren))
1057 case tok::question:
1059 Tok->Next->isOneOf(tok::semi, tok::comma, tok::colon, tok::r_paren,
1060 tok::r_brace)) {
1078 (Tok->Next && Tok->Next->isOneOf(tok::r_paren, tok::greater)) ||
1079 (Tok->Next && Tok->Next->is(tok::identifier) && Tok->Next->Next &&
1080 Tok->Next->Next->is(tok::equal))) {
1087 case tok::kw_template:
1090 case tok::comma:
1096 (Contexts.size() == 1 || Line.startsWith(tok::kw_for))) {
1103 case tok::identifier:
1109 Tok->Next->isNot(tok::l_paren)) {
1123 if (CurrentToken->is(tok::less)) {
1128 } else if (CurrentToken->is(tok::greater)) {
1132 } else if (CurrentToken->is(tok::comma) && OpenAngleBracketsCount == 0) {
1140 } else if (CurrentToken->is(tok::colon)) {
1150 if (CurrentToken && CurrentToken->is(tok::less)) {
1155 if (CurrentToken->isNot(tok::comment) &&
1190 if (!CurrentToken || !CurrentToken->is(tok::l_paren))
1216 if (CurrentToken->Tok.is(tok::numeric_constant)) {
1225 case tok::pp_include:
1226 case tok::pp_include_next:
1227 case tok::pp_import:
1232 case tok::pp_error:
1233 case tok::pp_warning:
1236 case tok::pp_pragma:
1239 case tok::pp_if:
1240 case tok::pp_elif:
1251 if (Tok->is(tok::l_paren))
1265 if (CurrentToken->is(tok::hash))
1274 (Info && Info->getPPKeywordID() == tok::pp_import &&
1276 CurrentToken->Next->isOneOf(tok::string_literal, tok::identifier,
1277 tok::kw_static))) {
1285 if (CurrentToken->is(tok::less) && Line.Last->is(tok::greater)) {
1295 if (CurrentToken && CurrentToken->is(tok::identifier)) {
1311 if (CurrentToken->is(tok::kw_virtual))
1320 if (Line.First->is(tok::kw_export) &&
1349 return Tok.TokenText == "goog" && Tok.Next && Tok.Next->is(tok::period) &&
1356 Tok.Next->Next->Next && Tok.Next->Next->Next->is(tok::l_paren);
1395 Context(tok::TokenKind ContextKind, unsigned BindingStrength,
1400 tok::TokenKind ContextKind;
1424 ScopedContextCreator(AnnotatingParser &P, tok::TokenKind ContextKind,
1437 !Line.First->isOneOf(tok::kw_template, tok::kw_using, tok::kw_return) &&
1441 (Line.startsWith(Keywords.kw_type, tok::identifier) ||
1442 Line.startsWith(tok::kw_export, Keywords.kw_type,
1443 tok::identifier))) &&
1444 (!Current.Previous || Current.Previous->isNot(tok::kw_operator))) {
1449 !Previous->Previous->isOneOf(tok::comma, tok::semi);
1451 if (Previous->isOneOf(tok::r_square, tok::r_paren)) {
1459 Previous->isOneOf(tok::star, tok::amp, tok::ampamp) &&
1460 Previous->Previous && Previous->Previous->isNot(tok::equal))
1464 } else if (Current.is(tok::lessless) &&
1465 (!Current.Previous || !Current.Previous->is(tok::kw_operator))) {
1467 } else if (Current.isOneOf(tok::kw_return, tok::kw_throw)) {
1479 } else if (Current.isOneOf(tok::r_paren, tok::greater, tok::comma)) {
1481 Previous && Previous->isOneOf(tok::star, tok::amp);
1486 } else if (Current.is(tok::kw_new)) {
1488 } else if (Current.is(tok::semi) ||
1489 (Current.is(tok::exclaim) && Current.Previous &&
1490 !Current.Previous->is(tok::kw_operator))) {
1502 if (Current->is(tok::l_paren))
1504 if (Current->is(tok::r_paren))
1515 if (Current.Previous && Current.Previous->is(tok::r_paren) &&
1516 Current.startsSequence(tok::arrow, tok::identifier, tok::less)) {
1522 if (TemplateCloser->is(tok::l_paren)) {
1526 if (TemplateCloser->is(tok::less))
1528 if (TemplateCloser->is(tok::greater))
1537 TemplateCloser->Next->is(tok::semi) &&
1550 PriorLeadingIdentifier->is(tok::kw_explicit))
1568 Current.is(tok::exclaim)) {
1574 : Current.Previous->is(tok::identifier);
1577 tok::kw_namespace, tok::r_paren, tok::r_square, tok::r_brace,
1578 tok::kw_false, tok::kw_true, Keywords.kw_type, Keywords.kw_get,
1601 } else if (Current.is(tok::semi)) {
1606 } else if (Current.isOneOf(tok::kw_auto, tok::kw___auto_type)) {
1608 } else if (Current.is(tok::arrow) &&
1611 } else if (Current.is(tok::arrow) && AutoFound && Line.MustBeDeclaration &&
1613 !Current.Previous->is(tok::kw_operator)) {
1616 } else if (Current.is(tok::arrow) && Current.Previous &&
1617 Current.Previous->is(tok::r_brace)) {
1624 } else if (Current.isOneOf(tok::star, tok::amp, tok::ampamp)) {
1629 } else if (Current.isOneOf(tok::minus, tok::plus, tok::caret)) {
1631 if (Current.is(TT_UnaryOperator) && Current.is(tok::caret))
1633 } else if (Current.isOneOf(tok::minusminus, tok::plusplus)) {
1635 } else if (Current.isOneOf(tok::exclaim, tok::tilde)) {
1637 } else if (Current.is(tok::question)) {
1647 (!Current.Previous || Current.Previous->isNot(tok::l_square)) &&
1648 (!Current.is(tok::greater) &&
1651 } else if (Current.is(tok::comment)) {
1658 Current.Tok.setKind(tok::unknown);
1662 } else if (Current.is(tok::r_paren)) {
1667 !Current.Next->isOneOf(tok::semi, tok::colon, tok::l_brace,
1668 tok::comma, tok::period, tok::arrow,
1669 tok::coloncolon))
1672 if (AfterParen->Tok.isNot(tok::caret)) {
1674 if (BeforeParen->is(tok::identifier) &&
1682 } else if (Current.is(tok::at) && Current.Next &&
1688 case tok::objc_interface:
1689 case tok::objc_implementation:
1690 case tok::objc_protocol:
1693 case tok::objc_property:
1699 } else if (Current.is(tok::period)) {
1702 PreviousNoComment->isOneOf(tok::comma, tok::l_brace))
1721 } else if (Current.isOneOf(tok::identifier, tok::kw_const, tok::kw_noexcept,
1722 tok::kw_requires) &&
1724 !Current.Previous->isOneOf(tok::equal, tok::at) &&
1732 if (Current.Previous->is(tok::at) &&
1740 } else if (Current.Previous->is(tok::period) &&
1754 if (Tok.isNot(tok::identifier) || !Tok.Previous)
1766 while (PreviousNotConst && PreviousNotConst->is(tok::kw_const))
1772 bool IsPPKeyword = PreviousNotConst->is(tok::identifier) &&
1774 PreviousNotConst->Previous->is(tok::hash);
1779 PreviousNotConst->MatchingParen->Previous->isNot(tok::period) &&
1780 PreviousNotConst->MatchingParen->Previous->isNot(tok::kw_template);
1782 if (PreviousNotConst->is(tok::r_paren) &&
1787 PreviousNotConst->isOneOf(tok::identifier, tok::kw_auto)) ||
1807 if (LeftOfParens->is(tok::r_paren)) {
1817 !LeftOfParens->isOneOf(Keywords.kw_in, tok::kw_return, tok::kw_case,
1818 tok::kw_delete))
1823 if (LeftOfParens->isOneOf(tok::at, tok::r_square, TT_OverloadedOperator,
1824 TT_TemplateCloser, tok::ellipsis))
1828 if (Tok.Next->is(tok::question))
1837 if (Tok.Next->isOneOf(tok::kw_noexcept, tok::kw_volatile, tok::kw_const,
1838 tok::kw_requires, tok::kw_throw, tok::arrow,
1845 if (Style.Language == FormatStyle::LK_Java && Tok.Next->is(tok::l_paren))
1849 if (Tok.Next->isNot(tok::string_literal) &&
1851 Tok.Next->isOneOf(tok::kw_sizeof, tok::kw_alignof)))
1864 T->MatchingParen->Previous->is(tok::kw___attribute)) {
1888 Tok.Next->isOneOf(tok::equal, tok::semi, tok::l_brace, tok::greater);
1907 if (Tok.Next->isOneOf(tok::identifier, tok::kw_this))
1911 if (Tok.Next->is(tok::l_paren) && Tok.Previous && Tok.Previous->Previous) {
1912 if (Tok.Previous->is(tok::identifier) &&
1913 Tok.Previous->Previous->is(tok::l_paren))
1924 Tok.Next->isUnaryOperator() || Tok.Next->isOneOf(tok::amp, tok::star);
1925 if (!NextIsUnary || Tok.Next->is(tok::plus) ||
1926 !Tok.Next->Next->isOneOf(tok::identifier, tok::numeric_constant))
1931 if (!Prev->isOneOf(tok::kw_const, tok::identifier, tok::coloncolon))
1944 if (Style.isCSharp() && Tok.is(tok::ampamp))
1953 NextToken->isOneOf(tok::arrow, tok::equal, tok::kw_noexcept) ||
1955 (NextToken->is(tok::l_brace) && !NextToken->getNextNonComment()))
1958 if (PrevToken->is(tok::coloncolon))
1961 if (PrevToken->is(tok::r_paren) && PrevToken->is(TT_TypeDeclarationParen))
1964 if (PrevToken->isOneOf(tok::l_paren, tok::l_square, tok::l_brace,
1965 tok::comma, tok::semi, tok::kw_return, tok::colon,
1966 tok::kw_co_return, tok::kw_co_await,
1967 tok::kw_co_yield, tok::equal, tok::kw_delete,
1968 tok::kw_sizeof, tok::kw_throw) ||
1973 if (NextToken->is(tok::l_square) && NextToken->isNot(TT_LambdaLSquare))
1975 if (NextToken->is(tok::kw_operator) && !IsExpression)
1977 if (NextToken->isOneOf(tok::comma, tok::semi))
1981 PrevToken->isOneOf(tok::r_paren, tok::r_square, tok::kw_true,
1982 tok::kw_false, tok::r_brace) ||
1984 NextToken->isOneOf(tok::kw_true, tok::kw_false) ||
1993 if (Tok.is(tok::ampamp) && NextToken->is(tok::l_paren))
2000 if (NextNextToken && NextNextToken->is(tok::arrow))
2022 if (PrevToken->isOneOf(tok::equal, tok::l_paren, tok::comma, tok::l_square,
2023 tok::question, tok::colon, tok::kw_return,
2024 tok::kw_case, tok::at, tok::l_brace, tok::kw_throw,
2025 tok::kw_co_return, tok::kw_co_yield))
2041 if (PrevToken->isOneOf(tok::r_paren, tok::r_square, tok::identifier))
2077 while (Current && (Current->is(tok::kw_return) ||
2078 (Current->is(tok::colon) &&
2122 Precedence == prec::Assignment && Current->is(tok::colon))) {
2171 NextNonComment->is(tok::less))))
2179 if (Current->isOneOf(tok::semi, TT_InlineASMColon, TT_SelectorName) ||
2180 (Current->is(tok::comment) && NextNonComment &&
2192 if (Current->is(TT_BinaryOperator) || Current->is(tok::comma))
2194 if (Current->isOneOf(tok::period, tok::arrow))
2211 while (Previous->is(tok::comment) && Previous->Previous)
2239 if (!Current || !Current->is(tok::question))
2274 if (!Tok->is(tok::comment)) {
2296 NextNonCommentLine = (*I)->First->isNot(tok::r_brace) ? (*I) : nullptr;
2353 if (Next->isOneOf(tok::kw_new, tok::kw_delete)) {
2356 Next->Next->startsSequence(tok::l_square, tok::r_square))
2360 if (Next->startsSequence(tok::l_square, tok::r_square)) {
2365 if ((Next->isSimpleTypeSpecifier() || Next->is(tok::identifier)) &&
2366 Next->Next && Next->Next->isOneOf(tok::star, tok::amp, tok::ampamp)) {
2383 if (Current.is(tok::kw_operator)) {
2384 if (Current.Previous && Current.Previous->is(tok::coloncolon))
2393 } else if (Next->is(tok::coloncolon)) {
2397 if (Next->is(tok::kw_operator)) {
2401 if (!Next->is(tok::identifier))
2403 } else if (Next->is(tok::l_paren)) {
2412 if (!Next || !Next->is(tok::l_paren) || !Next->MatchingParen)
2415 if (Line.Last->is(tok::l_brace))
2427 if (Tok->isOneOf(tok::l_paren, TT_TemplateOpener) && Tok->MatchingParen) {
2431 if (Tok->is(tok::kw_const) || Tok->isSimpleTypeSpecifier() ||
2432 Tok->isOneOf(TT_PointerOrReference, TT_StartOfName, tok::ellipsis))
2434 if (Tok->isOneOf(tok::l_brace, tok::string_literal, TT_ObjCMethodExpr) ||
2497 if (Parameter->isOneOf(tok::comment, tok::r_brace))
2499 if (Parameter->Previous && Parameter->Previous->is(tok::comma)) {
2585 Current->isOneOf(tok::comment, tok::string_literal)) {
2601 if (Left.is(tok::semi))
2609 if (Left.is(tok::comma) && Left.NestingLevel == 0)
2612 if (Right.is(Keywords.kw_function) && Left.isNot(tok::comma))
2624 if (Right.is(tok::identifier) && Right.Next && Right.Next->is(TT_DictLiteral))
2626 if (Right.is(tok::l_square)) {
2629 if (Left.is(tok::r_square))
2632 if (Right.is(TT_LambdaLSquare) && Left.is(tok::equal))
2640 if (Left.is(tok::coloncolon) ||
2641 (Right.is(tok::period) && Style.Language == FormatStyle::LK_Proto))
2644 Right.is(tok::kw_operator)) {
2645 if (Line.startsWith(tok::kw_for) && Right.PartOfMultiVariableDeclStmt)
2657 if (Left.is(tok::equal) && Right.is(tok::l_brace))
2661 if (Left.isOneOf(tok::kw_class, tok::kw_struct))
2663 if (Left.is(tok::comment))
2696 (!Right.Next || Right.Next->isNot(tok::l_paren))) {
2707 return (Left.is(tok::r_paren) ? 100 : 120) + (is_short_annotation ? 50 : 0);
2711 if (Line.startsWith(tok::kw_for) && Left.is(tok::equal))
2718 if (Left.is(tok::colon) && Left.is(TT_ObjCMethodExpr))
2724 if (Line.Type == LT_ObjCDecl && Left.is(tok::l_paren) && Left.Previous &&
2725 Left.Previous->isOneOf(tok::identifier, tok::greater))
2728 if (Left.is(tok::l_paren) && InFunctionDecl &&
2731 if (Left.is(tok::l_paren) && Left.Previous &&
2732 (Left.Previous->is(tok::kw_for) || Left.Previous->isIf()))
2734 if (Left.is(tok::equal) && InFunctionDecl)
2736 if (Right.is(tok::r_brace))
2747 if (Left.is(tok::l_brace) && !Style.Cpp11BracedListStyle)
2757 if (Left.isOneOf(tok::plus, tok::comma) && Left.Previous &&
2761 if (Right.is(tok::plus) && Left.isLabelString() &&
2764 if (Left.is(tok::comma))
2766 if (Right.is(tok::lessless) && Left.isLabelString() &&
2769 if (Right.is(tok::lessless)) {
2771 if (!Left.is(tok::r_paren) || Right.OperatorIndex > 0)
2800 if (Left.is(tok::kw_return) && Right.isNot(tok::semi))
2805 Left.Tok.getObjCKeywordID() == tok::objc_property)
2807 if (Right.is(tok::hashhash))
2808 return Left.is(tok::hash);
2809 if (Left.isOneOf(tok::hashhash, tok::hash))
2810 return Right.is(tok::hash);
2811 if ((Left.is(tok::l_paren) && Right.is(tok::r_paren)) ||
2812 (Left.is(tok::l_brace) && Left.isNot(BK_Block) &&
2813 Right.is(tok::r_brace) && Right.isNot(BK_Block)))
2816 if (Left.is(tok::l_paren) && Left.Previous &&
2819 if (Right.is(tok::r_paren) && Right.MatchingParen &&
2826 if (Right.is(tok::l_paren) && Left.is(tok::kw_requires))
2829 if (Left.is(TT_ConstraintJunctions) && Right.is(tok::identifier))
2832 if (Left.is(tok::l_paren) || Right.is(tok::r_paren))
2837 if (Right.isOneOf(tok::semi, tok::comma))
2839 if (Right.is(tok::less) && Line.Type == LT_ObjCDecl) {
2842 Right.MatchingParen->Next->is(tok::colon);
2845 if (Right.is(tok::less) && Left.is(tok::kw_template))
2847 if (Left.isOneOf(tok::exclaim, tok::tilde))
2849 if (Left.is(tok::at) &&
2850 Right.isOneOf(tok::identifier, tok::string_literal, tok::char_constant,
2851 tok::numeric_constant, tok::l_paren, tok::l_brace,
2852 tok::kw_true, tok::kw_false))
2854 if (Left.is(tok::colon))
2856 if (Left.is(tok::coloncolon))
2858 if (Left.is(tok::less) || Right.isOneOf(tok::greater, tok::less)) {
2863 if (Left.is(tok::less) && Right.is(tok::greater))
2869 if (Right.is(tok::ellipsis))
2870 return Left.Tok.isLiteral() || (Left.is(tok::identifier) && Left.Previous &&
2871 Left.Previous->is(tok::kw_case));
2872 if (Left.is(tok::l_square) && Right.is(tok::amp))
2875 if (Left.is(tok::r_paren) && Line.MightBeFunctionDecl) {
2891 (!Left.isOneOf(TT_PointerOrReference, tok::l_paren) &&
2895 (Left.NestingLevel == 1 && Line.First->is(tok::kw_for)))))));
2897 if (Right.is(TT_FunctionTypeLParen) && Left.isNot(tok::l_paren) &&
2912 (Right.is(tok::l_brace) && Right.is(BK_Block)) ||
2914 tok::l_paren) &&
2918 !Left.Previous->isOneOf(tok::l_paren, tok::coloncolon,
2919 tok::l_square));
2922 if (Left.is(tok::ellipsis) && Left.Previous &&
2923 Left.Previous->isOneOf(tok::star, tok::amp, tok::ampamp))
2926 if (Right.is(tok::star) && Left.is(tok::l_paren))
2928 if (Left.is(tok::star) && Right.isOneOf(tok::star, tok::amp, tok::ampamp))
2930 if (Right.isOneOf(tok::star, tok::amp, tok::ampamp)) {
2932 while (Previous && !Previous->is(tok::kw_operator)) {
2933 if (Previous->is(tok::identifier) || Previous->isSimpleTypeSpecifier()) {
2941 if (Previous->is(tok::coloncolon)) {
2960 if (Previous->endsSequence(tok::kw_operator))
2962 if (Previous->is(tok::kw_const) || Previous->is(tok::kw_volatile))
2975 LSquareTok.endsSequence(tok::l_square, tok::colon,
2978 if (Left.is(tok::l_square))
2979 return (Left.is(TT_ArrayInitializerLSquare) && Right.isNot(tok::r_square) &&
2983 Style.SpacesInSquareBrackets && Right.isNot(tok::r_square));
2984 if (Right.is(tok::r_square))
2994 if (Right.is(tok::l_square) &&
2998 !Left.isOneOf(tok::numeric_constant, TT_DictLiteral) &&
2999 !(!Left.is(tok::r_square) && Style.SpaceBeforeSquareBrackets &&
3002 if (Left.is(tok::l_brace) && Right.is(tok::r_brace))
3004 if ((Left.is(tok::l_brace) && Left.isNot(BK_Block)) ||
3005 (Right.is(tok::r_brace) && Right.MatchingParen &&
3017 if (Right.is(tok::l_paren)) {
3018 if ((Left.is(tok::r_paren) && Left.is(TT_AttributeParen)) ||
3019 (Left.is(tok::r_square) && Left.is(TT_AttributeSquare)))
3025 return Line.Type == LT_ObjCDecl || Left.is(tok::semi) ||
3027 (Left.isOneOf(tok::pp_elif, tok::kw_for, tok::kw_while,
3028 tok::kw_switch, tok::kw_case, TT_ForEachMacro,
3031 (Left.isOneOf(tok::kw_try, Keywords.kw___except, tok::kw_catch,
3032 tok::kw_new, tok::kw_delete) &&
3033 (!Left.Previous || Left.Previous->isNot(tok::period))))) ||
3035 (Left.is(tok::identifier) || Left.isFunctionLikeKeyword() ||
3036 Left.is(tok::r_paren) || Left.isSimpleTypeSpecifier() ||
3037 (Left.is(tok::r_square) && Left.MatchingParen &&
3041 if (Left.is(tok::at) && Right.Tok.getObjCKeywordID() != tok::objc_not_keyword)
3044 return !Left.isOneOf(tok::l_paren, tok::l_square, tok::at) &&
3045 (Left.isNot(tok::colon) || Left.isNot(TT_ObjCMethodExpr));
3046 if ((Left.isOneOf(tok::identifier, tok::greater, tok::r_square,
3047 tok::r_paren) ||
3049 Right.is(tok::l_brace) && Right.getNextNonComment() &&
3052 if (Left.is(tok::period) || Right.is(tok::period))
3054 if (Right.is(tok::hash) && Left.is(tok::identifier) && Left.TokenText == "L")
3058 (Left.MatchingParen->Previous->is(tok::period) ||
3059 Left.MatchingParen->Previous->is(tok::coloncolon)))
3064 if (Left.is(TT_TemplateCloser) && Right.is(tok::l_square))
3066 if (Left.is(tok::l_brace) && Left.endsSequence(TT_DictLiteral, tok::at))
3069 if (Right.is(tok::r_brace) && Right.MatchingParen &&
3070 Right.MatchingParen->endsSequence(TT_DictLiteral, tok::at))
3074 Right.isOneOf(tok::amp, tok::ampamp) &&
3075 Left.isOneOf(tok::kw_const, tok::kw_volatile) &&
3076 (!Right.Next || Right.Next->is(tok::semi)))
3093 if (Left.is(tok::kw_operator))
3094 return Right.is(tok::coloncolon);
3095 if (Right.is(tok::l_brace) && Right.is(BK_BracedInit) &&
3100 if (Right.is(tok::period) &&
3104 if (Right.is(tok::l_paren) &&
3107 if (Right.isOneOf(tok::l_brace, tok::less) && Left.is(TT_SelectorName))
3110 if (Left.is(tok::slash) || Right.is(tok::slash))
3114 Right.isOneOf(tok::l_brace, tok::less))
3117 if (Left.is(tok::percent))
3121 if (Left.is(tok::numeric_constant) && Right.is(tok::percent))
3129 if (Left.is(tok::kw_this) && Right.is(tok::l_square))
3133 if (Left.is(tok::kw_new) && Right.is(tok::l_paren))
3137 if (Right.is(tok::l_brace))
3141 if (Left.is(tok::l_brace) && Right.isNot(tok::r_brace))
3144 if (Left.isNot(tok::l_brace) && Right.is(tok::r_brace))
3160 if (Left.is(tok::l_square) || Right.is(tok::r_square))
3172 if (Left.is(tok::comma) && Right.is(tok::comma))
3176 if (Left.is(Keywords.kw_var) && Right.is(tok::l_paren))
3180 if (Right.is(tok::l_paren))
3181 if (Left.isOneOf(tok::kw_using, Keywords.kw_async, Keywords.kw_when,
3188 if (Left.isOneOf(tok::kw_public, tok::kw_private, tok::kw_protected,
3189 tok::kw_virtual, tok::kw_extern, tok::kw_static,
3193 Right.is(tok::l_paren))
3199 if (Right.is(tok::l_paren) && Left.is(Keywords.kw_await) && Left.Previous &&
3200 Left.Previous->is(tok::kw_for))
3202 if (Left.is(Keywords.kw_async) && Right.is(tok::l_paren) &&
3219 if (Right.is(tok::star) &&
3222 if (Right.isOneOf(tok::l_brace, tok::l_square) &&
3226 if (Right.is(tok::l_paren)) {
3232 if (Left.Previous && Left.Previous->is(tok::period) &&
3236 if (Left.isOneOf(tok::kw_throw, Keywords.kw_await, Keywords.kw_typeof,
3237 tok::kw_void))
3241 if (Left.endsSequence(tok::kw_const, Keywords.kw_as)) {
3245 tok::kw_const) ||
3250 (Left.Previous->Tok.is(tok::identifier) ||
3251 Left.Previous->isOneOf(tok::r_square, tok::r_brace)))) &&
3252 (!Left.Previous || !Left.Previous->is(tok::period)))
3254 if (Left.isOneOf(tok::kw_for, Keywords.kw_as) && Left.Previous &&
3255 Left.Previous->is(tok::period) && Right.is(tok::l_paren))
3258 Right.isOneOf(tok::l_square, tok::l_brace, tok::l_paren))
3260 if (Left.is(tok::kw_default) && Left.Previous &&
3261 Left.Previous->is(tok::kw_export))
3263 if (Left.is(Keywords.kw_is) && Right.is(tok::l_brace))
3269 if ((Left.is(tok::l_brace) || Right.is(tok::r_brace)) &&
3270 Line.First->isOneOf(Keywords.kw_import, tok::kw_export))
3272 if (Left.is(tok::ellipsis))
3275 !Right.isOneOf(tok::equal, tok::l_brace, tok::comma, tok::l_square,
3287 if (Left.is(tok::r_square) && Right.is(tok::l_brace))
3289 if (Left.is(Keywords.kw_synchronized) && Right.is(tok::l_paren))
3291 if ((Left.isOneOf(tok::kw_static, tok::kw_public, tok::kw_private,
3292 tok::kw_protected) ||
3303 if (Left.is(tok::r_paren) && canBeObjCSelectorComponent(Right))
3310 (Right.is(tok::equal) || Left.is(tok::equal)))
3318 if (Left.is(tok::comma))
3320 if (Right.is(tok::comma))
3334 if (Right.is(tok::colon)) {
3335 if (Line.First->isOneOf(tok::kw_default, tok::kw_case))
3337 if (!Right.getNextNonComment() || Right.getNextNonComment()->is(tok::semi))
3341 if (Left.is(tok::question))
3343 if (Right.is(TT_InlineASMColon) && Left.is(tok::coloncolon))
3357 if ((Left.isOneOf(tok::minus, tok::minusminus) &&
3358 Right.isOneOf(tok::minus, tok::minusminus)) ||
3359 (Left.isOneOf(tok::plus, tok::plusplus) &&
3360 Right.isOneOf(tok::plus, tok::plusplus)))
3363 if (!Right.is(tok::l_paren)) {
3367 if (Left.is(tok::exclaim) && Left.TokenText == "not")
3369 if (Left.is(tok::tilde) && Left.TokenText == "compl")
3373 if (Left.is(tok::amp) && Right.is(tok::r_square))
3376 return (Style.SpaceAfterLogicalNot && Left.is(tok::exclaim)) ||
3394 if (Left.is(tok::greater) && Right.is(tok::greater)) {
3402 if (Right.isOneOf(tok::arrow, tok::arrowstar, tok::periodstar) ||
3403 Left.isOneOf(tok::arrow, tok::period, tok::arrowstar, tok::periodstar) ||
3404 (Right.is(tok::period) && Right.isNot(TT_DesignatedInitializerPeriod)))
3409 if (Style.Language == FormatStyle::LK_Java && Right.is(tok::coloncolon) &&
3410 (Left.is(tok::identifier) || Left.is(tok::kw_this)))
3412 if (Right.is(tok::coloncolon) && Left.is(tok::identifier))
3417 if (Right.is(tok::coloncolon) &&
3418 !Left.isOneOf(tok::l_brace, tok::comment, tok::l_paren))
3423 !(Left.isOneOf(tok::l_paren, tok::r_paren, tok::l_square,
3424 tok::kw___super, TT_TemplateOpener,
3426 (Left.is(tok::l_paren) && Style.SpacesInParentheses);
3431 return !Left.isOneOf(tok::amp, tok::ampamp) ||
3435 Right.isOneOf(tok::amp, tok::ampamp))
3437 if ((Right.is(TT_BinaryOperator) && !Left.is(tok::l_paren)) ||
3439 !Right.is(tok::r_paren)))
3441 if (Left.is(TT_TemplateCloser) && Right.is(tok::l_paren) &&
3444 if (Right.is(TT_TemplateOpener) && Left.is(tok::r_paren) &&
3447 if (Right.is(tok::less) && Left.isNot(tok::l_paren) &&
3448 Line.startsWith(tok::hash))
3459 return Tok.is(tok::l_brace) && Tok.is(BK_Block) &&
3466 Tok.MatchingParen->Next->isOneOf(tok::comma, tok::r_paren);
3495 return (Tok.is(tok::l_brace) && Tok.is(BK_Block) &&
3525 if (Right.is(tok::string_literal) && Left.is(tok::plus) && Left.Previous &&
3526 Left.Previous->is(tok::string_literal))
3528 if (Left.is(TT_DictLiteral) && Left.is(tok::l_brace) && Line.Level == 0 &&
3529 Left.Previous && Left.Previous->is(tok::equal) &&
3530 Line.First->isOneOf(tok::identifier, Keywords.kw_import, tok::kw_export,
3531 tok::kw_const) &&
3532 // kw_var/kw_let are pseudo-tokens that are tok::identifier, so match
3538 if (Left.is(tok::l_brace) && Line.Level == 0 &&
3539 (Line.startsWith(tok::kw_enum) ||
3540 Line.startsWith(tok::kw_const, tok::kw_enum) ||
3541 Line.startsWith(tok::kw_export, tok::kw_enum) ||
3542 Line.startsWith(tok::kw_export, tok::kw_const, tok::kw_enum)))
3546 if (Right.is(tok::r_brace) && Left.is(tok::l_brace) && Left.Previous &&
3565 if (Right.is(tok::r_brace) && Left.is(tok::l_brace) &&
3574 if (Right.is(tok::plus) && Left.is(tok::string_literal) && Right.Next &&
3575 Right.Next->is(tok::string_literal))
3592 if ((Left.isOneOf(tok::l_brace, TT_ArrayInitializerLSquare) ||
3594 Left.is(tok::l_paren))) &&
3598 (Right.MatchingParen->isOneOf(tok::l_brace,
3601 Right.MatchingParen->is(tok::l_paren))))
3603 if (BeforeClosingBrace && (BeforeClosingBrace->is(tok::comma) ||
3608 if (Right.is(tok::comment))
3615 if (Right.is(tok::lessless) && Right.Next &&
3616 Right.Previous->is(tok::string_literal) &&
3617 Right.Next->is(tok::string_literal))
3626 if (Right.is(tok::kw_concept))
3642 if (Right.is(tok::string_literal) && Right.TokenText.startswith("R\""))
3647 if ((Right.Previous->is(tok::l_brace) ||
3648 (Right.Previous->is(tok::less) && Right.Previous->Previous &&
3649 Right.Previous->Previous->is(tok::equal))) &&
3666 return (Line.startsWith(tok::kw_enum) && Style.BraceWrapping.AfterEnum) ||
3667 (Line.startsWith(tok::kw_typedef, tok::kw_enum) &&
3669 (Line.startsWith(tok::kw_class) && Style.BraceWrapping.AfterClass) ||
3670 (Line.startsWith(tok::kw_struct) && Style.BraceWrapping.AfterStruct);
3691 Right.isNot(TT_LeadingJavaAnnotation) && Right.isNot(tok::l_paren) &&
3692 (Line.Last->is(tok::l_brace) || Style.BreakAfterJavaFieldAnnotations))
3727 Right.is(TT_SelectorName) && !Right.is(tok::r_square) && Right.Next) {
3730 if (Right.Previous && Right.Previous->is(tok::at))
3737 if (LBrace && LBrace->is(tok::colon)) {
3739 if (LBrace && LBrace->is(tok::at)) {
3754 ((LBrace->is(tok::l_brace) &&
3756 (LBrace->Next && LBrace->Next->is(tok::r_brace)))) ||
3757 LBrace->is(TT_ArrayInitializerLSquare) || LBrace->is(tok::less))) {
3779 if (Left.isOneOf(tok::r_brace, tok::greater, tok::r_square))
3788 Left.is(tok::l_paren) && Left.BlockParameterCount > 0 &&
3789 !Right.isOneOf(tok::l_paren, TT_LambdaLSquare)) {
3803 if (!Next->isOneOf(TT_LambdaLSquare, tok::l_brace, tok::caret))
3836 tok::kw_return, Keywords.kw_yield, tok::kw_continue, tok::kw_break,
3837 tok::kw_throw, Keywords.kw_interface, Keywords.kw_type,
3838 tok::kw_static, tok::kw_public, tok::kw_private, tok::kw_protected,
3844 Left.isOneOf(tok::r_square, tok::r_paren)) &&
3845 Right.isOneOf(tok::l_square, tok::l_paren))
3847 if (NonComment && NonComment->is(tok::identifier) &&
3850 if (Left.is(TT_FatArrow) && Right.is(tok::l_brace))
3855 if (Left.is(tok::exclaim) && Right.is(tok::colon))
3869 if (!Next || !Next->is(tok::colon))
3889 Right.isOneOf(Keywords.kw_module, tok::kw_namespace,
3890 Keywords.kw_function, tok::kw_class, tok::kw_enum,
3892 Keywords.kw_let, tok::kw_const))
3896 if (Left.isOneOf(Keywords.kw_module, tok::kw_namespace) &&
3897 Right.isOneOf(tok::identifier, tok::string_literal))
3903 if (Left.is(tok::identifier) && Right.is(TT_TemplateString)) {
3910 if (Left.is(tok::at))
3912 if (Left.Tok.getObjCKeywordID() == tok::objc_interface)
3915 return !Right.is(tok::l_paren);
3921 Right.is(tok::kw_operator))
3934 if (Left.is(tok::question) && Right.is(tok::colon))
3936 if (Right.is(TT_ConditionalExpr) || Right.is(tok::question))
3938 if (Left.is(TT_ConditionalExpr) || Left.is(tok::question))
3944 if (Right.is(TT_ObjCMethodExpr) && !Right.is(tok::r_square) &&
3948 if (Right.is(tok::colon) &&
3951 if (Left.is(tok::colon) && Left.isOneOf(TT_DictLiteral, TT_ObjCMethodExpr)) {
3980 if (((Right.is(tok::l_brace) || Right.is(tok::less)) &&
3987 if (Right.is(tok::r_square) && Right.MatchingParen &&
3990 if (Right.is(TT_SelectorName) || (Right.is(tok::identifier) && Right.Next &&
3992 return Left.isNot(tok::period); // FIXME: Properly parse ObjC calls.
3993 if (Left.is(tok::r_paren) && Line.Type == LT_ObjCProperty)
4007 Left.is(tok::kw_operator))
4009 if (Left.is(tok::equal) && !Right.isOneOf(tok::kw_default, tok::kw_delete) &&
4012 if (Left.is(tok::equal) && Right.is(tok::l_brace) &&
4015 if (Left.is(tok::l_paren) &&
4018 if (Left.is(tok::l_paren) && Left.Previous &&
4024 if (Right.is(tok::r_paren) || Right.is(TT_TemplateCloser))
4026 if (Right.is(tok::r_square) && Right.MatchingParen &&
4032 if (Right.is(tok::r_brace))
4038 return !Right.isOneOf(tok::l_brace, tok::semi, tok::equal, tok::l_paren,
4039 tok::less, tok::coloncolon);
4041 if (Right.is(tok::kw___attribute) ||
4042 (Right.is(tok::l_square) && Right.is(TT_AttributeSquare)))
4045 if (Left.is(tok::identifier) && Right.is(tok::string_literal))
4048 if (Right.is(tok::identifier) && Right.Next && Right.Next->is(TT_DictLiteral))
4067 if ((Left.is(tok::greater) && Right.is(tok::greater)) ||
4068 (Left.is(tok::less) && Right.is(tok::less)))
4077 if (Right.is(tok::kw_typename) && Left.isNot(tok::kw_const))
4080 !Left.isOneOf(tok::arrowstar, tok::lessless) &&
4085 if ((Left.is(TT_AttributeSquare) && Right.is(tok::l_square)) ||
4086 (Left.is(tok::r_square) && Right.is(TT_AttributeSquare)))
4097 return Left.isOneOf(tok::comma, tok::coloncolon, tok::semi, tok::l_brace,
4098 tok::kw_class, tok::kw_struct, tok::comment) ||
4100 Right.isOneOf(TT_TrailingReturnArrow, TT_LambdaArrow, tok::lessless,
4101 tok::colon, tok::l_square, tok::at) ||
4103 (Left.is(tok::r_paren) &&
4104 Right.isOneOf(tok::identifier, tok::kw_const)) ||
4105 (Left.is(tok::l_paren) && !Right.is(tok::r_paren)) ||