• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /freebsd-13-stable/contrib/llvm-project/clang/lib/Format/

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)) {
120 if (CurrentToken->Next && CurrentToken->Next->is(tok::greater) &&
121 Left->ParentBracket != tok::less &&
140 if (CurrentToken->is(tok::question) &&
145 if (CurrentToken->isOneOf(tok::r_paren, tok::r_square, tok::r_brace) ||
146 (CurrentToken->isOneOf(tok::colon, tok::question) && InExprContext &&
156 if (CurrentToken->Previous->isOneOf(tok::pipepipe, tok::ampamp) &&
159 !Line.startsWith(tok::kw_template))
164 if (CurrentToken->is(tok::colon) ||
165 (CurrentToken->isOneOf(tok::l_brace, tok::less) &&
166 Previous->isNot(tok::colon)))
180 case tok::l_paren:
185 case tok::r_paren:
202 ScopedContextCreator ContextCreator(*this, tok::l_paren, 1);
216 if (MaybeSel->isObjCAtKeyword(tok::objc_selector) && MaybeSel->Previous &&
217 MaybeSel->Previous->is(tok::at)) {
225 (Line.startsWith(Keywords.kw_type, tok::identifier) ||
226 Line.startsWith(tok::kw_export, Keywords.kw_type,
227 tok::identifier))) {
232 (Left->Previous->isOneOf(tok::kw_static_assert, tok::kw_decltype,
233 tok::kw_while, tok::l_paren,
234 tok::comma) ||
241 (Left->Previous->endsSequence(tok::identifier,
253 (!Left->Previous || !Left->Previous->is(tok::identifier))) {
258 } else if (Left->Previous && Left->Previous->is(tok::kw___attribute)) {
269 Left->Previous && Left->Previous->isOneOf(tok::kw_for, tok::kw_catch);
287 CurrentToken->isOneOf(tok::star, tok::amp, tok::caret);
291 Left->Previous && Left->Previous->is(tok::kw_for);
303 if (PrevPrev && PrevPrev->is(tok::identifier) &&
304 Prev->isOneOf(tok::star, tok::amp, tok::ampamp) &&
305 CurrentToken->is(tok::identifier) && Next->isNot(tok::equal)) {
313 CurrentToken->Previous->Previous->isOneOf(tok::l_paren,
314 tok::coloncolon))
316 if (CurrentToken->is(tok::comma))
320 if (CurrentToken->is(tok::r_paren)) {
322 (CurrentToken->Next->is(tok::l_paren) ||
323 (CurrentToken->Next->is(tok::l_square) && Line.MustBeDeclaration)))
324 Left->setType(Left->Next->is(tok::caret) ? TT_ObjCBlockLParen
329 if (CurrentToken->Next && CurrentToken->Next->is(tok::l_brace) &&
330 Left->Previous && Left->Previous->is(tok::l_paren)) {
336 Tok->isOneOf(tok::star, tok::amp, tok::ampamp))
368 if (CurrentToken->isOneOf(tok::r_square, tok::r_brace))
371 if (CurrentToken->is(tok::l_brace))
373 if (CurrentToken->is(tok::comma) && CurrentToken->Next &&
377 if ((CurrentToken->Previous->isOneOf(tok::kw_const, tok::kw_auto) ||
379 !CurrentToken->is(tok::l_brace))
381 if (CurrentToken->isOneOf(tok::semi, tok::colon)) {
394 if (CurrentToken->is(tok::comma))
412 if (Tok.Previous && Tok.Previous->is(tok::identifier))
416 if (Tok.Previous && Tok.Previous->is(tok::r_square)) {
427 if (AttrTok->is(tok::r_square))
431 while (AttrTok && AttrTok->isNot(tok::r_square)) {
444 if (AttrTok->isOneOf(tok::kw_public, tok::kw_private, tok::kw_protected,
445 tok::comment, tok::kw_class, tok::kw_static,
446 tok::l_square, Keywords.kw_internal)) {
452 AttrTok->Next->startsSequence(tok::identifier, tok::l_paren))
459 if (!Style.isCpp() || !Tok.startsSequence(tok::l_square, tok::l_square))
462 if (Tok.Previous && Tok.Previous->is(tok::at)) {
470 if (AttrTok->startsSequence(tok::kw_using, tok::identifier, tok::colon))
472 if (AttrTok->isNot(tok::identifier))
474 while (AttrTok && !AttrTok->startsSequence(tok::r_square, tok::r_square)) {
478 if (AttrTok->is(tok::colon) ||
479 AttrTok->startsSequence(tok::identifier, tok::identifier) ||
480 AttrTok->startsSequence(tok::r_paren, tok::identifier))
482 if (AttrTok->is(tok::ellipsis))
486 return AttrTok && AttrTok->startsSequence(tok::r_square, tok::r_square);
517 bool InsideInlineASM = Line.startsWith(tok::kw_asm);
524 !CurrentToken->isOneOf(tok::l_brace, tok::r_square) &&
526 Parent->isOneOf(tok::colon, tok::l_square, tok::l_paren,
527 tok::kw_return, tok::kw_throw) ||
546 Contexts.back().ContextKind == tok::l_brace &&
547 Parent->isOneOf(tok::l_brace, tok::comma)) {
549 } else if (Style.isCpp() && Contexts.back().ContextKind == tok::l_brace &&
550 Parent && Parent->isOneOf(tok::l_brace, tok::comma)) {
554 } else if (CurrentToken->is(tok::r_square) && Parent &&
586 if (!Left->endsSequence(tok::l_square, tok::numeric_constant,
587 tok::equal) &&
588 !Left->endsSequence(tok::l_square, tok::numeric_constant,
589 tok::identifier) &&
590 !Left->endsSequence(tok::l_square, tok::colon, TT_SelectorName)) {
595 Parent->isOneOf(TT_BinaryOperator, TT_TemplateCloser, tok::at,
596 tok::comma, tok::l_paren, tok::l_square,
597 tok::question, tok::colon, tok::kw_return,
599 tok::kw_default)) {
607 ScopedContextCreator ContextCreator(*this, tok::l_square, BindingIncrease);
618 if (CurrentToken->is(tok::r_square)) {
624 CurrentToken->Next->is(tok::l_paren)) ||
678 if (CurrentToken->isOneOf(tok::r_paren, tok::r_brace))
680 if (CurrentToken->is(tok::colon)) {
682 CurrentToken->endsSequence(tok::colon, tok::identifier,
683 tok::kw_using)) {
692 if (Parent && Parent->is(tok::r_paren))
698 if (CurrentToken->is(tok::comma) && Left->is(TT_ObjCMethodExpr) &&
718 ScopedContextCreator ContextCreator(*this, tok::l_brace, 1);
727 if (CurrentToken->is(tok::r_brace)) {
733 if (CurrentToken->isOneOf(tok::r_paren, tok::r_square))
736 if (CurrentToken->isOneOf(tok::colon, tok::l_brace, tok::less)) {
740 if ((CurrentToken->is(tok::colon) &&
746 Previous->is(tok::string_literal))
749 if (CurrentToken->is(tok::colon) ||
753 if (CurrentToken->is(tok::comma) &&
767 if (Current->is(tok::l_brace) && Current->BlockKind == BK_Block)
769 if (Current->is(tok::comma)) {
774 } else if (Left->ParameterCount == 0 && Current->isNot(tok::comment)) {
781 if (CurrentToken->is(tok::colon)) {
793 if (CurrentToken && CurrentToken->is(tok::less)) {
809 case tok::plus:
810 case tok::minus:
814 case tok::colon:
821 !Line.First->isOneOf(tok::kw_enum, tok::kw_case)) ||
822 Contexts.back().ContextKind == tok::l_paren || // function params
823 Contexts.back().ContextKind == tok::l_square || // array type
825 Contexts.back().ContextKind == tok::l_brace) || // object type
837 if (Contexts.back().ContextKind == tok::l_paren) {
858 Tok->Previous->is(tok::identifier) && Tok->Previous->is(TT_Unknown);
863 BeforePrevious->is(tok::colon))) ||
864 BeforePrevious->is(tok::r_square) ||
880 } else if (CurrentToken && CurrentToken->is(tok::numeric_constant)) {
883 !Line.First->isOneOf(tok::kw_enum, tok::kw_case)) {
885 if (Prev->isOneOf(tok::r_paren, tok::kw_noexcept))
887 else if (Prev->is(tok::kw_try)) {
890 if (PrevPrev && PrevPrev->isOneOf(tok::r_paren, tok::kw_noexcept))
895 (Tok->Next->isOneOf(tok::r_paren, tok::comma) ||
897 Tok->Next->Next->is(tok::colon)))) {
901 } else if (Contexts.back().ContextKind == tok::l_paren) {
905 case tok::pipe:
906 case tok::amp:
913 case tok::kw_if:
914 case tok::kw_while:
915 if (Tok->is(tok::kw_if) && CurrentToken &&
916 CurrentToken->isOneOf(tok::kw_constexpr, tok::identifier))
918 if (CurrentToken && CurrentToken->is(tok::l_paren)) {
924 case tok::kw_for:
927 if ((Tok->Previous && Tok->Previous->is(tok::period)) ||
928 (Tok->Next && Tok->Next->is(tok::colon)))
939 case tok::l_paren:
944 if (Tok->Previous && Tok->Previous->is(tok::r_paren) &&
957 !Tok->Previous->isOneOf(tok::kw_decltype, tok::kw___attribute,
961 case tok::l_square:
965 case tok::l_brace:
974 case tok::less:
997 case tok::r_paren:
998 case tok::r_square:
1000 case tok::r_brace:
1005 case tok::greater:
1011 case tok::kw_operator:
1016 !CurrentToken->isOneOf(tok::l_paren, tok::semi, tok::r_paren)) {
1017 if (CurrentToken->isOneOf(tok::star, tok::amp))
1020 if (CurrentToken && CurrentToken->is(tok::comma) &&
1021 CurrentToken->Previous->isNot(tok::kw_operator))
1024 TT_BinaryOperator, TT_UnaryOperator, tok::comma,
1025 tok::star, tok::arrow, tok::amp, tok::ampamp))
1028 if (CurrentToken && CurrentToken->is(tok::l_paren))
1033 case tok::question:
1042 Tok->Next->isOneOf(tok::semi, tok::comma, tok::colon, tok::r_paren,
1043 tok::r_brace)) {
1061 (Tok->Next && Tok->Next->isOneOf(tok::r_paren, tok::greater)) ||
1062 (Tok->Next && Tok->Next->is(tok::identifier) && Tok->Next->Next &&
1063 Tok->Next->Next->is(tok::equal))) {
1070 case tok::kw_template:
1073 case tok::comma:
1079 (Contexts.size() == 1 || Line.startsWith(tok::kw_for))) {
1086 case tok::identifier:
1092 Tok->Next->isNot(tok::l_paren)) {
1106 if (CurrentToken->is(tok::less)) {
1111 } else if (CurrentToken->is(tok::greater)) {
1115 } else if (CurrentToken->is(tok::comma) && OpenAngleBracketsCount == 0) {
1123 } else if (CurrentToken->is(tok::colon)) {
1133 if (CurrentToken && CurrentToken->is(tok::less)) {
1138 if (CurrentToken->isNot(tok::comment) &&
1173 if (!CurrentToken || !CurrentToken->is(tok::l_paren))
1199 if (CurrentToken->Tok.is(tok::numeric_constant)) {
1208 case tok::pp_include:
1209 case tok::pp_include_next:
1210 case tok::pp_import:
1215 case tok::pp_error:
1216 case tok::pp_warning:
1219 case tok::pp_pragma:
1222 case tok::pp_if:
1223 case tok::pp_elif:
1234 if (Tok->is(tok::l_paren))
1248 if (CurrentToken->is(tok::hash))
1257 (Info && Info->getPPKeywordID() == tok::pp_import &&
1259 CurrentToken->Next->isOneOf(tok::string_literal, tok::identifier,
1260 tok::kw_static))) {
1268 if (CurrentToken->is(tok::less) && Line.Last->is(tok::greater)) {
1278 if (CurrentToken && CurrentToken->is(tok::identifier)) {
1294 if (CurrentToken->is(tok::kw_virtual))
1303 if (Line.First->is(tok::kw_export) &&
1332 return Tok.TokenText == "goog" && Tok.Next && Tok.Next->is(tok::period) &&
1339 Tok.Next->Next->Next && Tok.Next->Next->Next->is(tok::l_paren);
1376 Context(tok::TokenKind ContextKind, unsigned BindingStrength,
1381 tok::TokenKind ContextKind;
1405 ScopedContextCreator(AnnotatingParser &P, tok::TokenKind ContextKind,
1418 !Line.First->isOneOf(tok::kw_template, tok::kw_using, tok::kw_return) &&
1422 (Line.startsWith(Keywords.kw_type, tok::identifier) ||
1423 Line.startsWith(tok::kw_export, Keywords.kw_type,
1424 tok::identifier))) &&
1425 (!Current.Previous || Current.Previous->isNot(tok::kw_operator))) {
1430 !Previous->Previous->isOneOf(tok::comma, tok::semi);
1432 if (Previous->isOneOf(tok::r_square, tok::r_paren)) {
1440 Previous->isOneOf(tok::star, tok::amp, tok::ampamp) &&
1441 Previous->Previous && Previous->Previous->isNot(tok::equal))
1445 } else if (Current.is(tok::lessless) &&
1446 (!Current.Previous || !Current.Previous->is(tok::kw_operator))) {
1448 } else if (Current.isOneOf(tok::kw_return, tok::kw_throw)) {
1460 } else if (Current.isOneOf(tok::r_paren, tok::greater, tok::comma)) {
1462 Previous && Previous->isOneOf(tok::star, tok::amp);
1467 } else if (Current.is(tok::kw_new)) {
1469 } else if (Current.is(tok::semi) ||
1470 (Current.is(tok::exclaim) && Current.Previous &&
1471 !Current.Previous->is(tok::kw_operator))) {
1483 if (Current->is(tok::l_paren))
1485 if (Current->is(tok::r_paren))
1496 if (Current.Previous && Current.Previous->is(tok::r_paren) &&
1497 Current.startsSequence(tok::arrow, tok::identifier, tok::less)) {
1503 if (TemplateCloser->is(tok::l_paren)) {
1507 if (TemplateCloser->is(tok::less))
1509 if (TemplateCloser->is(tok::greater))
1518 TemplateCloser->Next->is(tok::semi) &&
1531 PriorLeadingIdentifier->is(tok::kw_explicit))
1548 if (Style.isCSharp() && CurrentToken->is(tok::question)) {
1564 if (Current.is(tok::exclaim)) {
1569 tok::kw_namespace, tok::r_paren, tok::r_square, tok::r_brace,
1592 } else if (Current.is(tok::semi)) {
1597 } else if (Current.isOneOf(tok::kw_auto, tok::kw___auto_type)) {
1599 } else if (Current.is(tok::arrow) &&
1602 } else if (Current.is(tok::arrow) && AutoFound && Line.MustBeDeclaration &&
1604 !Current.Previous->is(tok::kw_operator)) {
1611 } else if (Current.isOneOf(tok::star, tok::amp, tok::ampamp)) {
1616 } else if (Current.isOneOf(tok::minus, tok::plus, tok::caret)) {
1618 if (Current.is(TT_UnaryOperator) && Current.is(tok::caret))
1620 } else if (Current.isOneOf(tok::minusminus, tok::plusplus)) {
1622 } else if (Current.isOneOf(tok::exclaim, tok::tilde)) {
1624 } else if (Current.is(tok::question)) {
1634 (!Current.Previous || Current.Previous->isNot(tok::l_square)) &&
1635 (!Current.is(tok::greater) &&
1638 } else if (Current.is(tok::comment)) {
1645 Current.Tok.setKind(tok::unknown);
1649 } else if (Current.is(tok::r_paren)) {
1654 !Current.Next->isOneOf(tok::semi, tok::colon, tok::l_brace,
1655 tok::comma, tok::period, tok::arrow,
1656 tok::coloncolon))
1659 if (AfterParen->Tok.isNot(tok::caret)) {
1661 if (BeforeParen->is(tok::identifier) &&
1669 } else if (Current.is(tok::at) && Current.Next &&
1675 case tok::objc_interface:
1676 case tok::objc_implementation:
1677 case tok::objc_protocol:
1680 case tok::objc_property:
1686 } else if (Current.is(tok::period)) {
1689 PreviousNoComment->isOneOf(tok::comma, tok::l_brace))
1708 } else if (Current.isOneOf(tok::identifier, tok::kw_const,
1709 tok::kw_noexcept) &&
1711 !Current.Previous->isOneOf(tok::equal, tok::at) &&
1719 if (Current.Previous->is(tok::at) &&
1727 } else if (Current.Previous->is(tok::period) &&
1741 if (Tok.isNot(tok::identifier) || !Tok.Previous)
1753 while (PreviousNotConst && PreviousNotConst->is(tok::kw_const))
1759 bool IsPPKeyword = PreviousNotConst->is(tok::identifier) &&
1761 PreviousNotConst->Previous->is(tok::hash);
1766 PreviousNotConst->MatchingParen->Previous->isNot(tok::period) &&
1767 PreviousNotConst->MatchingParen->Previous->isNot(tok::kw_template);
1769 if (PreviousNotConst->is(tok::r_paren) && PreviousNotConst->MatchingParen &&
1771 PreviousNotConst->MatchingParen->Previous->is(tok::kw_decltype))
1775 PreviousNotConst->isOneOf(tok::identifier, tok::kw_auto)) ||
1795 if (LeftOfParens->is(tok::r_paren)) {
1805 !LeftOfParens->isOneOf(Keywords.kw_in, tok::kw_return, tok::kw_case,
1806 tok::kw_delete))
1811 if (LeftOfParens->isOneOf(tok::at, tok::r_square, TT_OverloadedOperator,
1812 TT_TemplateCloser, tok::ellipsis))
1816 if (Tok.Next->is(tok::question))
1825 if (Tok.Next->isOneOf(tok::kw_noexcept, tok::kw_volatile, tok::kw_const,
1826 tok::kw_throw, tok::arrow, Keywords.kw_override,
1833 if (Style.Language == FormatStyle::LK_Java && Tok.Next->is(tok::l_paren))
1837 if (Tok.Next->isNot(tok::string_literal) &&
1839 Tok.Next->isOneOf(tok::kw_sizeof, tok::kw_alignof)))
1848 Tok.Next->isOneOf(tok::equal, tok::semi, tok::l_brace, tok::greater);
1867 if (Tok.Next->isOneOf(tok::identifier, tok::kw_this))
1877 Tok.Next->isUnaryOperator() || Tok.Next->isOneOf(tok::amp, tok::star);
1878 if (!NextIsUnary || Tok.Next->is(tok::plus) ||
1879 !Tok.Next->Next->isOneOf(tok::identifier, tok::numeric_constant))
1884 if (!Prev->isOneOf(tok::kw_const, tok::identifier, tok::coloncolon))
1897 if (Style.isCSharp() && Tok.is(tok::ampamp))
1906 NextToken->isOneOf(tok::arrow, tok::equal, tok::kw_const,
1907 tok::kw_noexcept) ||
1908 (NextToken->is(tok::l_brace) && !NextToken->getNextNonComment()))
1911 if (PrevToken->is(tok::coloncolon))
1914 if (PrevToken->isOneOf(tok::l_paren, tok::l_square, tok::l_brace,
1915 tok::comma, tok::semi, tok::kw_return, tok::colon,
1916 tok::equal, tok::kw_delete, tok::kw_sizeof,
1917 tok::kw_throw) ||
1922 if (NextToken->is(tok::l_square) && NextToken->isNot(TT_LambdaLSquare))
1924 if (NextToken->is(tok::kw_operator) && !IsExpression)
1926 if (NextToken->isOneOf(tok::comma, tok::semi))
1929 if (PrevToken->is(tok::r_paren) && PrevToken->MatchingParen) {
1933 TokenBeforeMatchingParen->isOneOf(tok::kw_typeof, tok::kw_decltype,
1939 PrevToken->isOneOf(tok::r_paren, tok::r_square, tok::kw_true,
1940 tok::kw_false, tok::r_brace) ||
1942 NextToken->isOneOf(tok::kw_true, tok::kw_false) ||
1951 if (Tok.is(tok::ampamp) && NextToken->is(tok::l_paren))
1958 if (NextNextToken && NextNextToken->is(tok::arrow))
1980 if (PrevToken->isOneOf(tok::equal, tok::l_paren, tok::comma, tok::l_square,
1981 tok::question, tok::colon, tok::kw_return,
1982 tok::kw_case, tok::at, tok::l_brace, tok::kw_throw,
1983 tok::kw_co_return, tok::kw_co_yield))
1999 if (PrevToken->isOneOf(tok::r_paren, tok::r_square, tok::identifier))
2035 while (Current && (Current->is(tok::kw_return) ||
2036 (Current->is(tok::colon) &&
2080 Precedence == prec::Assignment && Current->is(tok::colon))) {
2129 NextNonComment->is(tok::less))))
2137 if (Current->isOneOf(tok::semi, TT_InlineASMColon, TT_SelectorName) ||
2138 (Current->is(tok::comment) && NextNonComment &&
2150 if (Current->is(TT_BinaryOperator) || Current->is(tok::comma))
2152 if (Current->isOneOf(tok::period, tok::arrow))
2169 while (Previous->is(tok::comment) && Previous->Previous)
2197 if (!Current || !Current->is(tok::question))
2232 if (!Tok->is(tok::comment)) {
2254 NextNonCommentLine = (*I)->First->isNot(tok::r_brace) ? (*I) : nullptr;
2311 if (Next->isOneOf(tok::kw_new, tok::kw_delete)) {
2314 Next->Next->startsSequence(tok::l_square, tok::r_square))
2318 if (Next->startsSequence(tok::l_square, tok::r_square)) {
2323 if ((Next->isSimpleTypeSpecifier() || Next->is(tok::identifier)) &&
2324 Next->Next && Next->Next->isOneOf(tok::star, tok::amp, tok::ampamp)) {
2341 if (Current.is(tok::kw_operator)) {
2342 if (Current.Previous && Current.Previous->is(tok::coloncolon))
2351 } else if (Next->is(tok::coloncolon)) {
2355 if (Next->is(tok::kw_operator)) {
2359 if (!Next->is(tok::identifier))
2361 } else if (Next->is(tok::l_paren)) {
2370 if (!Next || !Next->is(tok::l_paren) || !Next->MatchingParen)
2373 if (Line.Last->is(tok::l_brace))
2383 if (Tok->isOneOf(tok::l_paren, TT_TemplateOpener) && Tok->MatchingParen) {
2387 if (Tok->is(tok::kw_const) || Tok->isSimpleTypeSpecifier() ||
2388 Tok->isOneOf(TT_PointerOrReference, TT_StartOfName, tok::ellipsis))
2390 if (Tok->isOneOf(tok::l_brace, tok::string_literal, TT_ObjCMethodExpr) ||
2453 if (Parameter->isOneOf(tok::comment, tok::r_brace))
2455 if (Parameter->Previous && Parameter->Previous->is(tok::comma)) {
2541 Current->isOneOf(tok::comment, tok::string_literal)) {
2557 if (Left.is(tok::semi))
2565 if (Left.is(tok::comma) && Left.NestingLevel == 0)
2568 if (Right.is(Keywords.kw_function) && Left.isNot(tok::comma))
2580 if (Right.is(tok::identifier) && Right.Next && Right.Next->is(TT_DictLiteral))
2582 if (Right.is(tok::l_square)) {
2585 if (Left.is(tok::r_square))
2588 if (Right.is(TT_LambdaLSquare) && Left.is(tok::equal))
2596 if (Left.is(tok::coloncolon) ||
2597 (Right.is(tok::period) && Style.Language == FormatStyle::LK_Proto))
2600 Right.is(tok::kw_operator)) {
2601 if (Line.startsWith(tok::kw_for) && Right.PartOfMultiVariableDeclStmt)
2613 if (Left.is(tok::equal) && Right.is(tok::l_brace))
2617 if (Left.isOneOf(tok::kw_class, tok::kw_struct))
2619 if (Left.is(tok::comment))
2652 (!Right.Next || Right.Next->isNot(tok::l_paren))) {
2663 return (Left.is(tok::r_paren) ? 100 : 120) + (is_short_annotation ? 50 : 0);
2667 if (Line.startsWith(tok::kw_for) && Left.is(tok::equal))
2674 if (Left.is(tok::colon) && Left.is(TT_ObjCMethodExpr))
2680 if (Line.Type == LT_ObjCDecl && Left.is(tok::l_paren) && Left.Previous &&
2681 Left.Previous->isOneOf(tok::identifier, tok::greater))
2684 if (Left.is(tok::l_paren) && InFunctionDecl &&
2687 if (Left.is(tok::l_paren) && Left.Previous &&
2688 (Left.Previous->is(tok::kw_for) || Left.Previous->isIf()))
2690 if (Left.is(tok::equal) && InFunctionDecl)
2692 if (Right.is(tok::r_brace))
2699 if (Left.is(tok::l_brace) && !Style.Cpp11BracedListStyle)
2709 if (Left.isOneOf(tok::plus, tok::comma) && Left.Previous &&
2713 if (Right.is(tok::plus) && Left.isLabelString() &&
2716 if (Left.is(tok::comma))
2718 if (Right.is(tok::lessless) && Left.isLabelString() &&
2721 if (Right.is(tok::lessless)) {
2723 if (!Left.is(tok::r_paren) || Right.OperatorIndex > 0)
2752 if (Left.is(tok::kw_return) && Right.isNot(tok::semi))
2757 Left.Tok.getObjCKeywordID() == tok::objc_property)
2759 if (Right.is(tok::hashhash))
2760 return Left.is(tok::hash);
2761 if (Left.isOneOf(tok::hashhash, tok::hash))
2762 return Right.is(tok::hash);
2763 if ((Left.is(tok::l_paren) && Right.is(tok::r_paren)) ||
2764 (Left.is(tok::l_brace) && Left.BlockKind != BK_Block &&
2765 Right.is(tok::r_brace) && Right.BlockKind != BK_Block))
2768 if (Left.is(tok::l_paren) && Left.Previous &&
2771 if (Right.is(tok::r_paren) && Right.MatchingParen &&
2776 if (Left.is(tok::l_paren) || Right.is(tok::r_paren))
2781 if (Right.isOneOf(tok::semi, tok::comma))
2783 if (Right.is(tok::less) && Line.Type == LT_ObjCDecl) {
2786 Right.MatchingParen->Next->is(tok::colon);
2789 if (Right.is(tok::less) && Left.is(tok::kw_template))
2791 if (Left.isOneOf(tok::exclaim, tok::tilde))
2793 if (Left.is(tok::at) &&
2794 Right.isOneOf(tok::identifier, tok::string_literal, tok::char_constant,
2795 tok::numeric_constant, tok::l_paren, tok::l_brace,
2796 tok::kw_true, tok::kw_false))
2798 if (Left.is(tok::colon))
2800 if (Left.is(tok::coloncolon))
2802 if (Left.is(tok::less) || Right.isOneOf(tok::greater, tok::less)) {
2807 if (Left.is(tok::less) && Right.is(tok::greater))
2813 if (Right.is(tok::ellipsis))
2814 return Left.Tok.isLiteral() || (Left.is(tok::identifier) && Left.Previous &&
2815 Left.Previous->is(tok::kw_case));
2816 if (Left.is(tok::l_square) && Right.is(tok::amp))
2819 if (Left.is(tok::r_paren) && Line.MightBeFunctionDecl) {
2825 !TokenBeforeMatchingParen->isOneOf(tok::kw_typeof, tok::kw_decltype,
2830 (!Left.isOneOf(TT_PointerOrReference, tok::l_paren) &&
2834 (Left.NestingLevel == 1 && Line.First->is(tok::kw_for)))))));
2836 if (Right.is(TT_FunctionTypeLParen) && Left.isNot(tok::l_paren) &&
2845 (Right.is(tok::l_brace) && Right.BlockKind == BK_Block) ||
2847 tok::l_paren) &&
2851 !Left.Previous->isOneOf(tok::l_paren, tok::coloncolon,
2852 tok::l_square));
2854 if (Left.is(tok::ellipsis) && Left.Previous &&
2855 Left.Previous->isOneOf(tok::star, tok::amp, tok::ampamp))
2858 if (Right.is(tok::star) && Left.is(tok::l_paren))
2860 if (Left.is(tok::star) && Right.isOneOf(tok::star, tok::amp, tok::ampamp))
2862 if (Right.isOneOf(tok::star, tok::amp, tok::ampamp)) {
2864 while (Previous && !Previous->is(tok::kw_operator)) {
2865 if (Previous->is(tok::identifier) || Previous->isSimpleTypeSpecifier()) {
2873 if (Previous->is(tok::coloncolon)) {
2890 (Previous->endsSequence(tok::kw_operator) ||
2891 Previous->endsSequence(tok::kw_const, tok::kw_operator) ||
2892 Previous->endsSequence(tok::kw_volatile, tok::kw_operator)))
2901 LSquareTok.endsSequence(tok::l_square, tok::colon,
2904 if (Left.is(tok::l_square))
2905 return (Left.is(TT_ArrayInitializerLSquare) && Right.isNot(tok::r_square) &&
2909 Style.SpacesInSquareBrackets && Right.isNot(tok::r_square));
2910 if (Right.is(tok::r_square))
2920 if (Right.is(tok::l_square) &&
2924 !Left.isOneOf(tok::numeric_constant, TT_DictLiteral) &&
2925 !(!Left.is(tok::r_square) && Style.SpaceBeforeSquareBrackets &&
2928 if (Left.is(tok::l_brace) && Right.is(tok::r_brace))
2930 if ((Left.is(tok::l_brace) && Left.BlockKind != BK_Block) ||
2931 (Right.is(tok::r_brace) && Right.MatchingParen &&
2943 if (Right.is(tok::l_paren)) {
2944 if ((Left.is(tok::r_paren) && Left.is(TT_AttributeParen)) ||
2945 (Left.is(tok::r_square) && Left.is(TT_AttributeSquare)))
2951 return Line.Type == LT_ObjCDecl || Left.is(tok::semi) ||
2953 (Left.isOneOf(tok::pp_elif, tok::kw_for, tok::kw_while,
2954 tok::kw_switch, tok::kw_case, TT_ForEachMacro,
2957 (Left.isOneOf(tok::kw_try, Keywords.kw___except, tok::kw_catch,
2958 tok::kw_new, tok::kw_delete) &&
2959 (!Left.Previous || Left.Previous->isNot(tok::period))))) ||
2961 (Left.is(tok::identifier) || Left.isFunctionLikeKeyword() ||
2962 Left.is(tok::r_paren) || Left.isSimpleTypeSpecifier() ||
2963 (Left.is(tok::r_square) && Left.MatchingParen &&
2967 if (Left.is(tok::at) && Right.Tok.getObjCKeywordID() != tok::objc_not_keyword)
2970 return !Left.isOneOf(tok::l_paren, tok::l_square, tok::at) &&
2971 (Left.isNot(tok::colon) || Left.isNot(TT_ObjCMethodExpr));
2972 if ((Left.isOneOf(tok::identifier, tok::greater, tok::r_square,
2973 tok::r_paren) ||
2975 Right.is(tok::l_brace) && Right.getNextNonComment() &&
2978 if (Left.is(tok::period) || Right.is(tok::period))
2980 if (Right.is(tok::hash) && Left.is(tok::identifier) && Left.TokenText == "L")
2984 (Left.MatchingParen->Previous->is(tok::period) ||
2985 Left.MatchingParen->Previous->is(tok::coloncolon)))
2990 if (Left.is(TT_TemplateCloser) && Right.is(tok::l_square))
2992 if (Left.is(tok::l_brace) && Left.endsSequence(TT_DictLiteral, tok::at))
2995 if (Right.is(tok::r_brace) && Right.MatchingParen &&
2996 Right.MatchingParen->endsSequence(TT_DictLiteral, tok::at))
3000 Right.isOneOf(tok::amp, tok::ampamp) &&
3001 Left.isOneOf(tok::kw_const, tok::kw_volatile) &&
3002 (!Right.Next || Right.Next->is(tok::semi)))
3016 if (Left.is(tok::kw_operator))
3017 return Right.is(tok::coloncolon);
3018 if (Right.is(tok::l_brace) && Right.BlockKind == BK_BracedInit &&
3023 if (Right.is(tok::period) &&
3027 if (Right.is(tok::l_paren) &&
3030 if (Right.isOneOf(tok::l_brace, tok::less) && Left.is(TT_SelectorName))
3033 if (Left.is(tok::slash) || Right.is(tok::slash))
3037 Right.isOneOf(tok::l_brace, tok::less))
3040 if (Left.is(tok::percent))
3044 if (Left.is(tok::numeric_constant) && Right.is(tok::percent))
3052 if (Left.is(tok::kw_this) && Right.is(tok::l_square))
3056 if (Left.is(tok::kw_new) && Right.is(tok::l_paren))
3060 if (Right.is(tok::l_brace))
3064 if (Left.is(tok::l_brace) && Right.isNot(tok::r_brace))
3067 if (Left.isNot(tok::l_brace) && Right.is(tok::r_brace))
3083 if (Left.is(tok::l_square) || Right.is(tok::r_square))
3092 return !Right.isOneOf(TT_TemplateCloser, tok::r_paren);
3107 if (Left.is(tok::comma) && Right.is(tok::comma))
3115 if (Left.is(Keywords.kw_var) && Right.is(tok::l_paren))
3119 if (Right.is(tok::l_paren))
3120 if (Left.isOneOf(tok::kw_using, Keywords.kw_async, Keywords.kw_when,
3128 if (Right.is(tok::l_paren) && Left.is(Keywords.kw_await) && Left.Previous &&
3129 Left.Previous->is(tok::kw_for))
3131 if (Left.is(Keywords.kw_async) && Right.is(tok::l_paren) &&
3148 if (Right.is(tok::star) &&
3151 if (Right.isOneOf(tok::l_brace, tok::l_square) &&
3155 if (Right.is(tok::l_paren)) {
3161 if (Left.Previous && Left.Previous->is(tok::period) &&
3165 if (Left.isOneOf(tok::kw_throw, Keywords.kw_await, Keywords.kw_typeof,
3166 tok::kw_void))
3170 if (Left.endsSequence(tok::kw_const, Keywords.kw_as)) {
3174 tok::kw_const) ||
3179 (Left.Previous->Tok.is(tok::identifier) ||
3180 Left.Previous->isOneOf(tok::r_square, tok::r_brace)))) &&
3181 (!Left.Previous || !Left.Previous->is(tok::period)))
3183 if (Left.isOneOf(tok::kw_for, Keywords.kw_as) && Left.Previous &&
3184 Left.Previous->is(tok::period) && Right.is(tok::l_paren))
3187 Right.isOneOf(tok::l_square, tok::l_brace, tok::l_paren))
3189 if (Left.is(tok::kw_default) && Left.Previous &&
3190 Left.Previous->is(tok::kw_export))
3192 if (Left.is(Keywords.kw_is) && Right.is(tok::l_brace))
3198 if ((Left.is(tok::l_brace) || Right.is(tok::r_brace)) &&
3199 Line.First->isOneOf(Keywords.kw_import, tok::kw_export))
3201 if (Left.is(tok::ellipsis))
3204 !Right.isOneOf(tok::equal, tok::l_brace, tok::comma, tok::l_square,
3216 if (Left.is(tok::r_square) && Right.is(tok::l_brace))
3218 if (Left.is(Keywords.kw_synchronized) && Right.is(tok::l_paren))
3220 if ((Left.isOneOf(tok::kw_static, tok::kw_public, tok::kw_private,
3221 tok::kw_protected) ||
3232 if (Left.is(tok::r_paren) && canBeObjCSelectorComponent(Right))
3239 (Right.is(tok::equal) || Left.is(tok::equal)))
3247 if (Left.is(tok::comma))
3249 if (Right.is(tok::comma))
3260 if (Right.is(tok::colon)) {
3261 if (Line.First->isOneOf(tok::kw_case, tok::kw_default) ||
3262 !Right.getNextNonComment() || Right.getNextNonComment()->is(tok::semi))
3266 if (Left.is(tok::question))
3268 if (Right.is(TT_InlineASMColon) && Left.is(tok::coloncolon))
3279 if (!Right.is(tok::l_paren)) {
3283 if (Left.is(tok::exclaim) && Left.TokenText == "not")
3285 if (Left.is(tok::tilde) && Left.TokenText == "compl")
3289 if (Left.is(tok::amp) && Right.is(tok::r_square))
3292 return (Style.SpaceAfterLogicalNot && Left.is(tok::exclaim)) ||
3302 if (Left.is(tok::greater) && Right.is(tok::greater)) {
3309 if (Right.isOneOf(tok::arrow, tok::arrowstar, tok::periodstar) ||
3310 Left.isOneOf(tok::arrow, tok::period, tok::arrowstar, tok::periodstar) ||
3311 (Right.is(tok::period) && Right.isNot(TT_DesignatedInitializerPeriod)))
3316 if (Style.Language == FormatStyle::LK_Java && Right.is(tok::coloncolon) &&
3317 (Left.is(tok::identifier) || Left.is(tok::kw_this)))
3319 if (Right.is(tok::coloncolon) && Left.is(tok::identifier))
3324 if (Right.is(tok::coloncolon) &&
3325 !Left.isOneOf(tok::l_brace, tok::comment, tok::l_paren))
3329 !(Left.isOneOf(tok::l_paren, tok::r_paren, tok::l_square,
3330 tok::kw___super, TT_TemplateOpener,
3332 (Left.is(tok::l_paren) && Style.SpacesInParentheses);
3337 return !Left.isOneOf(tok::amp, tok::ampamp) ||
3341 Right.isOneOf(tok::amp, tok::ampamp))
3343 if ((Right.is(TT_BinaryOperator) && !Left.is(tok::l_paren)) ||
3345 !Right.is(tok::r_paren)))
3347 if (Left.is(TT_TemplateCloser) && Right.is(tok::l_paren) &&
3350 if (Right.is(TT_TemplateOpener) && Left.is(tok::r_paren) &&
3353 if (Right.is(tok::less) && Left.isNot(tok::l_paren) &&
3354 Line.startsWith(tok::hash))
3365 return Tok.is(tok::l_brace) && Tok.BlockKind == BK_Block &&
3372 Tok.MatchingParen->Next->isOneOf(tok::comma, tok::r_paren);
3401 return (Tok.is(tok::l_brace) && Tok.BlockKind == BK_Block &&
3431 if (Right.is(tok::string_literal) && Left.is(tok::plus) && Left.Previous &&
3432 Left.Previous->is(tok::string_literal))
3434 if (Left.is(TT_DictLiteral) && Left.is(tok::l_brace) && Line.Level == 0 &&
3435 Left.Previous && Left.Previous->is(tok::equal) &&
3436 Line.First->isOneOf(tok::identifier, Keywords.kw_import, tok::kw_export,
3437 tok::kw_const) &&
3438 // kw_var/kw_let are pseudo-tokens that are tok::identifier, so match
3444 if (Left.is(tok::l_brace) && Line.Level == 0 &&
3445 (Line.startsWith(tok::kw_enum) ||
3446 Line.startsWith(tok::kw_const, tok::kw_enum) ||
3447 Line.startsWith(tok::kw_export, tok::kw_enum) ||
3448 Line.startsWith(tok::kw_export, tok::kw_const, tok::kw_enum)))
3452 if (Right.is(tok::r_brace) && Left.is(tok::l_brace) && Left.Previous &&
3471 if (Right.is(tok::r_brace) && Left.is(tok::l_brace) &&
3480 if (Right.is(tok::plus) && Left.is(tok::string_literal) && Right.Next &&
3481 Right.Next->is(tok::string_literal))
3498 if ((Left.isOneOf(tok::l_brace, TT_ArrayInitializerLSquare) ||
3500 Left.is(tok::l_paren))) &&
3504 (Right.MatchingParen->isOneOf(tok::l_brace,
3507 Right.MatchingParen->is(tok::l_paren))))
3509 if (BeforeClosingBrace && (BeforeClosingBrace->is(tok::comma) ||
3514 if (Right.is(tok::comment))
3522 if (Right.is(tok::lessless) && Right.Next &&
3523 Right.Previous->is(tok::string_literal) &&
3524 Right.Next->is(tok::string_literal))
3543 if (Right.is(tok::string_literal) && Right.TokenText.startswith("R\""))
3548 if ((Right.Previous->is(tok::l_brace) ||
3549 (Right.Previous->is(tok::less) && Right.Previous->Previous &&
3550 Right.Previous->Previous->is(tok::equal))) &&
3567 return (Line.startsWith(tok::kw_enum) && Style.BraceWrapping.AfterEnum) ||
3568 (Line.startsWith(tok::kw_typedef, tok::kw_enum) &&
3570 (Line.startsWith(tok::kw_class) && Style.BraceWrapping.AfterClass) ||
3571 (Line.startsWith(tok::kw_struct) && Style.BraceWrapping.AfterStruct);
3592 Right.isNot(TT_LeadingJavaAnnotation) && Right.isNot(tok::l_paren) &&
3593 (Line.Last->is(tok::l_brace) || Style.BreakAfterJavaFieldAnnotations))
3628 Right.is(TT_SelectorName) && !Right.is(tok::r_square) && Right.Next) {
3631 if (Right.Previous && Right.Previous->is(tok::at))
3638 if (LBrace && LBrace->is(tok::colon)) {
3640 if (LBrace && LBrace->is(tok::at)) {
3655 ((LBrace->is(tok::l_brace) &&
3657 (LBrace->Next && LBrace->Next->is(tok::r_brace)))) ||
3658 LBrace->is(TT_ArrayInitializerLSquare) || LBrace->is(tok::less))) {
3680 if (Left.isOneOf(tok::r_brace, tok::greater, tok::r_square))
3689 Left.is(tok::l_paren) && Left.BlockParameterCount > 0 &&
3690 !Right.isOneOf(tok::l_paren, TT_LambdaLSquare)) {
3704 if (!Next->isOneOf(TT_LambdaLSquare, tok::l_brace, tok::caret))
3733 tok::kw_return, Keywords.kw_yield, tok::kw_continue, tok::kw_break,
3734 tok::kw_throw, Keywords.kw_interface, Keywords.kw_type,
3735 tok::kw_static, tok::kw_public, tok::kw_private, tok::kw_protected,
3741 Left.isOneOf(tok::r_square, tok::r_paren)) &&
3742 Right.isOneOf(tok::l_square, tok::l_paren))
3744 if (Left.is(TT_JsFatArrow) && Right.is(tok::l_brace))
3749 if (Left.is(tok::exclaim) && Right.is(tok::colon))
3763 if (!Next || !Next->is(tok::colon))
3783 Right.isOneOf(Keywords.kw_module, tok::kw_namespace,
3784 Keywords.kw_function, tok::kw_class, tok::kw_enum,
3786 Keywords.kw_let, tok::kw_const))
3790 if (Left.isOneOf(Keywords.kw_module, tok::kw_namespace) &&
3791 Right.isOneOf(tok::identifier, tok::string_literal))
3797 if (Left.is(tok::identifier) && Right.is(TT_TemplateString)) {
3804 if (Left.is(tok::at))
3806 if (Left.Tok.getObjCKeywordID() == tok::objc_interface)
3809 return !Right.is(tok::l_paren);
3815 Right.is(tok::kw_operator))
3828 if (Left.is(tok::question) && Right.is(tok::colon))
3830 if (Right.is(TT_ConditionalExpr) || Right.is(tok::question))
3832 if (Left.is(TT_ConditionalExpr) || Left.is(tok::question))
3838 if (Right.is(TT_ObjCMethodExpr) && !Right.is(tok::r_square) &&
3842 if (Right.is(tok::colon) &&
3845 if (Left.is(tok::colon) && Left.isOneOf(TT_DictLiteral, TT_ObjCMethodExpr)) {
3874 if (((Right.is(tok::l_brace) || Right.is(tok::less)) &&
3881 if (Right.is(tok::r_square) && Right.MatchingParen &&
3884 if (Right.is(TT_SelectorName) || (Right.is(tok::identifier) && Right.Next &&
3886 return Left.isNot(tok::period); // FIXME: Properly parse ObjC calls.
3887 if (Left.is(tok::r_paren) && Line.Type == LT_ObjCProperty)
3901 Left.is(tok::kw_operator))
3903 if (Left.is(tok::equal) && !Right.isOneOf(tok::kw_default, tok::kw_delete) &&
3906 if (Left.is(tok::equal) && Right.is(tok::l_brace) &&
3909 if (Left.is(tok::l_paren) && Left.is(TT_AttributeParen))
3911 if (Left.is(tok::l_paren) && Left.Previous &&
3917 if (Right.is(tok::r_paren) || Right.is(TT_TemplateCloser))
3919 if (Right.is(tok::r_square) && Right.MatchingParen &&
3925 if (Right.is(tok::r_brace))
3931 return !Right.isOneOf(tok::l_brace, tok::semi, tok::equal, tok::l_paren,
3932 tok::less, tok::coloncolon);
3934 if (Right.is(tok::kw___attribute) ||
3935 (Right.is(tok::l_square) && Right.is(TT_AttributeSquare)))
3938 if (Left.is(tok::identifier) && Right.is(tok::string_literal))
3941 if (Right.is(tok::identifier) && Right.Next && Right.Next->is(TT_DictLiteral))
3960 if ((Left.is(tok::greater) && Right.is(tok::greater)) ||
3961 (Left.is(tok::less) && Right.is(tok::less)))
3970 if (Right.is(tok::kw_typename) && Left.isNot(tok::kw_const))
3973 !Left.isOneOf(tok::arrowstar, tok::lessless) &&
3978 if ((Left.is(TT_AttributeSquare) && Right.is(tok::l_square)) ||
3979 (Left.is(tok::r_square) && Right.is(TT_AttributeSquare)))
3990 return Left.isOneOf(tok::comma, tok::coloncolon, tok::semi, tok::l_brace,
3991 tok::kw_class, tok::kw_struct, tok::comment) ||
3993 Right.isOneOf(TT_TrailingReturnArrow, TT_LambdaArrow, tok::lessless,
3994 tok::colon, tok::l_square, tok::at) ||
3996 (Left.is(tok::r_paren) &&
3997 Right.isOneOf(tok::identifier, tok::kw_const)) ||
3998 (Left.is(tok::l_paren) && !Right.is(tok::r_paren)) ||