Lines Matching refs:is
283 // LK_TextProto is special since its top-level is parsed as the body of a
305 if (FormatTok->is(Keywords.kw_where)) {
345 return Previous && Previous->is(tok::comment) &&
349 /// \brief Parses a level, that is ???.
359 OpeningBrace && OpeningBrace->is(TT_RequiresExpressionLBrace);
371 if (FormatTok->is(tok::l_paren))
376 if (FormatTok->is(TT_MacroBlockBegin))
378 else if (FormatTok->is(TT_MacroBlockEnd))
427 if (Next->is(tok::comment) && Next->NewlinesBefore == 0)
441 // default not followed by `:` or `->` is not a case label; treat it
446 // Else, if it is 'default:', fall through to the case handling.
461 (OpeningBrace && OpeningBrace->is(TT_SwitchExpressionLBrace)) ||
502 assert(Tok->is(tok::l_brace));
509 while (NextTok->is(tok::hash)) {
511 if (NextTok->is(tok::pp_not_keyword))
517 while (NextTok->is(tok::comment))
526 // A ':' indicates this code is in a type, or a braced list
528 // A '<' could be an object used in a comparison, but that is nonsense
529 // code (can never return true), so more likely it is a generic type
536 } else if (PrevTok->is(tok::r_paren)) {
548 if (auto *LBrace = LBraceStack.back().Tok; LBrace->is(BK_Unknown)) {
554 // binary operators is a bit hacky.
566 ProbablyBracedList = LBrace->is(TT_BracedListLBrace);
574 NextTok->is(tok::l_paren)));
576 // If there is a comma, semicolon or right paren after the closing
577 // brace, we assume this is a braced initializer list.
589 (NextTok->is(tok::l_brace) && LBraceStack.back().PrevTok &&
595 (NextTok->is(tok::identifier) &&
599 (NextTok->is(tok::semi) &&
606 if (!Style.isCSharp() && NextTok->is(tok::l_square)) {
613 // Cpp macro definition body that is a nonempty braced list or block:
615 !FormatTok->Previous && NextTok->is(tok::eof) &&
618 // If PrevTok is a block opening brace, Tok ends an empty block.
641 if (!LBraceStack.empty() && LBraceStack.back().Tok->is(BK_Unknown))
654 if (Entry.Tok->is(BK_Unknown))
663 Prev && Prev->is(tok::r_brace)) {
684 // is not null, subtracts its length (plus the preceding space) when computing
727 if (const auto *FirstToken = Line.First; FirstToken->is(tok::r_brace)) {
728 assert(!OpeningBrace || OpeningBrace->is(TT_ControlStatementLBrace));
753 if (Style.isVerilog() && FormatTok->is(tok::colon)) {
760 // Whether this is a Verilog-specific block that has a special header like a
769 const bool FollowedByComment = Tokens->peekNextToken()->is(tok::comment);
771 const bool MacroBlock = FormatTok->is(TT_MacroBlockBegin);
795 if (MacroBlock && FormatTok->is(tok::l_paren))
806 // Whitesmiths is weird here. The brace needs to be indented for the namespace
830 if (FormatTok->is(tok::r_brace)) {
832 if (Tok->is(TT_NamespaceLBrace))
837 FormatTok->is(tok::r_brace) && Tok->is(TT_FunctionLBrace);
843 assert(FormatTok->is(tok::r_brace));
853 if (Previous->is(tok::r_brace) && !Previous->Optional)
860 if (Tok->is(TT_ElseLBrace))
879 // When this is a function block and there is an unnecessary semicolon
883 while (FormatTok->is(tok::semi)) {
891 if (MacroBlock && FormatTok->is(tok::l_paren))
896 if (FormatTok->is(tok::kw_noexcept)) {
901 if (FormatTok->is(tok::arrow)) {
908 if (MunchSemi && FormatTok->is(tok::semi))
938 return I->Tok->is(tok::l_paren);
945 // This is commonly done in JavaScript to create a new, anonymous scope.
956 return I->Tok->is(tok::l_paren);
962 if (InitialToken.is(TT_NamespaceMacro))
982 assert(FormatTok->is(tok::l_brace));
1001 assert(FormatTok->is(tok::hash) && "'#' expected");
1092 bool IfNDef = FormatTok->is(tok::pp_ifndef);
1095 if (!IfDef && (FormatTok->is(tok::kw_false) || FormatTok->TokenText == "0"))
1126 // Don't crash when there is an #else without an #if.
1139 // If the #endif of a potential include guard is the last thing in the file,
1170 // identifiers. Setting the kind to identifier is not enough, because we need
1222 // unwrapped line. This is used in attempt to distinguish macro calls without
1237 // Colon is used in labels, base class lists, initializer
1241 // 'noexcept' is a trailing annotation.
1248 return FormatTok->is(tok::identifier) &&
1288 // Checks whether a token is a type in K&R C (aka C78).
1335 assert(FormatTok->is(Keywords.kw_import) && "'import' expected");
1345 if (FormatTok->is(tok::colon)) {
1349 else if (FormatTok->is(tok::less)) {
1361 if (FormatTok->is(tok::semi)) {
1376 // This method is conservative - it cannot cover all edge cases of JavaScript,
1393 Previous->is(TT_TemplateString) && Previous->TokenText.ends_with("${");
1394 if (PreviousMustBeValue || Previous->is(tok::r_paren)) {
1398 return LineNode.Tok->is(tok::at);
1403 if (Next->is(tok::exclaim) && PreviousMustBeValue)
1407 Next->is(TT_TemplateString) && Next->TokenText.starts_with("}");
1414 if ((PreviousMustBeValue || Previous->is(tok::r_paren)) &&
1424 FormatTok->is(tok::pp_include)) {
1426 if (FormatTok->is(tok::string_literal))
1433 while (FormatTok->is(tok::l_square) && handleCppAttributes()) {
1455 } else if (FormatTok->is(tok::l_paren) &&
1456 Tokens->peekNextToken()->is(tok::star)) {
1477 if (FormatTok->is(tok::l_brace)) {
1481 if (FormatTok->is(tok::r_brace)) {
1539 if (FormatTok->is(tok::colon)) {
1544 if (FormatTok->is(tok::arrow)) {
1583 // But there is no body and endmodule. So we handle it separately.
1588 } else if (FormatTok->is(tok::string_literal)) {
1590 if (FormatTok->is(tok::l_brace)) {
1615 if (FormatTok->is(tok::kw_namespace)) {
1619 if (FormatTok->is(Keywords.kw_import) && parseModuleImport())
1625 if (FormatTok->is(tok::kw_namespace)) {
1631 if (FormatTok->is(TT_ForEachMacro)) {
1635 if (FormatTok->is(TT_MacroBlockBegin)) {
1640 if (FormatTok->is(Keywords.kw_import)) {
1647 if (FormatTok->is(tok::kw_public))
1652 if (FormatTok->is(tok::semi))
1663 if (FormatTok->is(tok::colon)) {
1669 if (IsCpp && FormatTok->is(TT_StatementMacro)) {
1673 if (IsCpp && FormatTok->is(TT_NamespaceMacro)) {
1682 Tokens->peekNextToken()->is(tok::colon) && !Line->MustBeDeclaration) {
1699 OpeningBrace && OpeningBrace->is(TT_RequiresExpressionLBrace);
1711 if (FormatTok->is(tok::l_brace)) {
1716 FormatTok->is(Keywords.kw_interface)) {
1742 if (FormatTok->is(tok::l_brace)) {
1753 if (FormatTok->is(tok::l_paren)) {
1757 if (FormatTok->is(tok::l_brace)) {
1768 // do this too after the tok::at is parsed above). But be explicit.
1786 // Ignore if this is part of "template <enum ..." or "... -> enum" or
1820 // This is same as def and so on.
1832 if (FormatTok->is(tok::l_paren)) {
1845 FormatTok->is(tok::kw_class)) {
1887 while (FormatTok->is(tok::star))
1891 if (FormatTok->is(tok::l_paren))
1894 if (FormatTok->is(tok::l_brace))
1904 // FIXME: Figure out cases where this is not true, and add projections
1905 // for them (the one we know is missing are lambdas).
1907 Line->Tokens.front().Tok->is(Keywords.kw_synchronized)) {
1939 if (Style.isCSharp() && FormatTok->is(Keywords.kw_where) &&
1945 if (FormatTok->is(TT_MacroBlockEnd)) {
1955 if (Style.isJavaScript() && FormatTok->is(Keywords.kw_function) &&
1963 FormatTok->is(Keywords.kw_interface)) {
1966 // identifier, e.g. in `var interface = 1;`. If "interface" is
1967 // followed by another identifier, it is very like to be an actual
1983 if (FormatTok->is(Keywords.kw_table)) {
1995 if (!IsCpp && FormatTok->is(Keywords.kw_interface)) {
2001 if (IsCpp && FormatTok->is(TT_StatementMacro)) {
2019 while (I != E && I->Tok->is(tok::comment))
2022 while (I != E && I->Tok->is(tok::hash))
2029 bool FunctionLike = FormatTok->is(tok::l_paren);
2050 FormatTok->is(TT_FatArrow)) {
2056 if (FormatTok->is(tok::l_brace)) {
2065 Line->Tokens.begin()->Tok->is(Keywords.kw_defset)) {
2075 FormatTok->is(tok::less)) {
2098 // In Verilog switch is called case.
2114 if (FormatTok->is(tok::colon)) {
2118 if (FormatTok->is(Keywords.kw_clocking)) {
2137 if (FormatTok->is(tok::l_brace))
2148 assert(FormatTok->is(tok::l_brace));
2158 // reset the current token. `Next` is not set yet so we need
2163 // A trivial property accessor is of the form:
2197 if (FormatTok->is(tok::equal)) {
2211 if (FormatTok->is(TT_FatArrow)) {
2239 assert(FormatTok->is(tok::l_square));
2267 if (FormatTok->Previous->is(tok::r_square))
2374 if (FormatTok->is(tok::l_square) || tok::isLiteral(FormatTok->Tok.getKind()))
2376 if (FormatTok->is(tok::r_square)) {
2378 if (Next->is(tok::greater))
2386 assert(FormatTok->is(Keywords.kw_function));
2387 if (FormatTok->is(Keywords.kw_async))
2393 if (FormatTok->is(tok::star)) {
2399 if (FormatTok->is(tok::identifier))
2408 if (FormatTok->is(tok::colon)) {
2414 if (FormatTok->is(tok::l_brace))
2421 if (FormatTok->is(tok::semi))
2428 if (FormatTok->is(BK_Unknown))
2431 if (FormatTok->is(BK_Block))
2440 assert(FormatTok->is(TT_FatArrow));
2458 if (Style.isCSharp() && FormatTok->is(TT_FatArrow) &&
2463 if (FormatTok->is(Keywords.kw_function)) {
2467 if (FormatTok->is(tok::l_brace)) {
2474 if (FormatTok->is(IsAngleBracket ? tok::greater : tok::r_brace)) {
2495 if (FormatTok->is(tok::l_brace))
2506 if (Prev && Prev->is(tok::greater))
2520 // used for error recovery if we have otherwise determined that this is
2548 /// Returns whether there is a `=` token between the parentheses.
2550 assert(FormatTok->is(tok::l_paren) && "'(' expected.");
2554 const bool MightBeStmtExpr = Tokens->peekNextToken()->is(tok::l_brace);
2561 if (Style.Language == FormatStyle::LK_Java && FormatTok->is(tok::l_brace))
2570 Prev && Prev->is(tok::l_paren) && Next && Next->is(tok::r_paren);
2583 Next->is(tok::semi);
2590 if (Prev->is(TT_TypenameMacro)) {
2593 } else if (Prev->is(tok::greater) && FormatTok->Previous == LeftParen) {
2601 // A "}" inside parenthesis is an error if there wasn't a matching "{".
2612 if (FormatTok->is(tok::l_brace)) {
2623 if (Style.isCSharp() && FormatTok->is(TT_FatArrow))
2635 if (Style.isJavaScript() && (FormatTok->is(Keywords.kw_function)))
2666 assert(FormatTok->is(tok::l_square) && "'[' expected.");
2679 // A "}" inside parenthesis is an error if there wasn't a matching "{".
2692 if (FormatTok->is(tok::l_brace)) {
2769 assert(LeftBrace->is(tok::l_brace));
2777 assert(RightBrace->is(tok::r_brace));
2789 else if (FormatTok->is(tok::l_square))
2795 assert(FormatTok->is(tok::l_square));
2807 : Tok.is(tok::l_brace);
2813 assert((FormatTok->is(tok::kw_if) ||
2822 if (FormatTok->is(Keywords.kw_verilogHash)) {
2824 if (FormatTok->is(tok::numeric_constant))
2841 if (FormatTok->is(tok::exclaim))
2845 if (FormatTok->is(tok::kw_consteval)) {
2851 if (FormatTok->is(tok::l_paren)) {
2857 // The then action is optional in Verilog assert statements.
2858 if (IsVerilogAssert && FormatTok->is(tok::semi)) {
2881 } else if (IsVerilogAssert && FormatTok->is(tok::kw_else)) {
2899 if (FormatTok->is(tok::kw_else)) {
2907 const bool FollowedByIf = Tokens->peekNextToken()->is(tok::kw_if);
2916 if (FormatTok->is(tok::kw_else)) {
2926 } else if (!IsVerilogAssert && FormatTok->is(tok::kw_if)) {
2929 const bool IsPrecededByComment = Previous->is(tok::comment);
2988 if (FormatTok->is(tok::colon)) {
2990 // We are in a function try block, what comes is an initializer list.
2992 if (FormatTok->is(tok::identifier)) {
2997 // In case identifiers were removed by clang-tidy, what might follow is
2999 while (FormatTok->is(tok::comma))
3002 while (FormatTok->is(tok::identifier)) {
3004 if (FormatTok->is(tok::l_paren)) {
3006 } else if (FormatTok->is(tok::l_brace)) {
3011 // In case identifiers were removed by clang-tidy, what might follow is
3013 while (FormatTok->is(tok::comma))
3018 if (Style.Language == FormatStyle::LK_Java && FormatTok->is(tok::l_paren))
3023 if (FormatTok->is(tok::l_brace)) {
3042 if (FormatTok->is(tok::at))
3047 FormatTok->is(Keywords.kw_finally)) ||
3054 if (FormatTok->is(tok::l_paren)) {
3088 if (InitialToken.is(TT_NamespaceMacro)) {
3093 (Style.isCSharp() && FormatTok->is(tok::kw_union))) {
3094 if (FormatTok->is(tok::l_square))
3096 else if (FormatTok->is(tok::l_paren))
3102 if (FormatTok->is(tok::l_brace)) {
3123 // Munch the semicolon after a namespace. This is more common than one would
3124 // think. Putting the semicolon into its own line is very ugly.
3138 assert(FormatTok->is(tok::kw_new) && "'new' expected");
3144 if (FormatTok->is(tok::l_paren))
3148 if (FormatTok->is(tok::l_brace))
3168 if (FormatTok->is(tok::l_paren)) {
3171 // If there is a class body of an anonymous class, consume that as child.
3172 if (FormatTok->is(tok::l_brace))
3219 if (Style.isJavaScript() && FormatTok->is(Keywords.kw_await))
3221 if (IsCpp && FormatTok->is(tok::kw_co_await))
3223 if (HasParens && FormatTok->is(tok::l_paren)) {
3224 // The type is only set for Verilog basically because we were afraid to
3235 } else if (Style.AllowShortLoopsOnASingleLine && FormatTok->is(tok::semi) &&
3236 Tokens->getPreviousToken()->is(tok::r_paren)) {
3247 assert(FormatTok->is(tok::kw_do) && "'do' expected");
3279 FormatTok->is(tok::l_brace)) {
3285 if (FormatTok->is(tok::kw_break)) {
3298 if (FormatTok->is(tok::semi))
3310 assert(FormatTok->is(tok::kw_case) && "'case' expected");
3316 if (FormatTok->is(tok::colon)) {
3320 if (Style.Language == FormatStyle::LK_Java && FormatTok->is(tok::arrow)) {
3330 assert(FormatTok->is(tok::kw_switch) && "'switch' expected");
3332 if (FormatTok->is(tok::l_paren))
3337 if (FormatTok->is(tok::l_brace)) {
3416 // Otherwise, we don't know what it is, and we'd better keep the next token.
3417 if (FormatTok->is(tok::colon)) {
3430 /// \brief Parses a requires, decides if it is a clause or an expression.
3434 assert(FormatTok->is(tok::kw_requires) && "'requires' expected");
3437 // We try to guess if it is a requires clause, or a requires expression. For
3458 // Or there is a constraint expression for the requires clause:
3465 PreviousNonComment->is(TT_RequiresExpressionLBrace)) {
3466 // If there is no token, or an expression left brace, we are a requires
3477 // This is a requires clause.
3489 if (PrevPrev && PrevPrev->is(tok::kw_const)) {
3497 // This is a requires clause.
3506 // Now we look forward and try to check if the paren content is a parameter
3579 /// the clause is incorrect.
3582 assert(RequiresToken->is(tok::kw_requires) && "'requires' expected");
3584 // If there is no previous token, we are within a requires expression,
3589 RequiresToken->Previous->is(TT_RequiresExpressionLBrace);
3595 // NOTE: parseConstraintExpression is only ever called from this function.
3609 /// that the expression is incorrect.
3612 assert(RequiresToken->is(tok::kw_requires) && "'requires' expected");
3616 if (FormatTok->is(tok::l_paren)) {
3621 if (FormatTok->is(tok::l_brace)) {
3629 /// This is the body of a requires clause. It returns, when the parsing is
3630 /// complete, or the expression is incorrect.
3632 // The special handling for lambdas is needed since tryToParseLambda() eats a
3633 // token and if a requires expression is the last part of a requires clause
3634 // and followed by an attribute like [[nodiscard]] the ClosesRequiresClause is
3640 // Within lambda declarations, it is permitted to put a requires clause after
3765 if (FormatTok->is(tok::less)) {
3779 if (FormatTok->is(tok::kw_enum))
3784 // error and thus assume it is just an identifier.
3789 if (Style.Language == FormatStyle::LK_Proto && FormatTok->is(tok::equal))
3796 while (FormatTok->is(tok::l_square))
3809 while (FormatTok->is(tok::l_square))
3815 if (FormatTok->is(tok::l_paren))
3817 if (FormatTok->is(tok::identifier)) {
3819 // If there are two identifiers in a row, this is likely an elaborate
3821 if (IsCpp && FormatTok->is(tok::identifier))
3826 // Just a declaration or something is wrong.
3856 if (FormatTok->is(tok::semi))
3863 // There is no addUnwrappedLine() here so that we fall through to parsing a
3875 if (FormatTok->is(tok::semi))
3908 // Double check that the attribute is just something
3911 if (Tok->is(tok::r_square))
3915 if (Tok->is(tok::eof))
3921 if (Tok->is(tok::semi))
3927 assert(FormatTok->is(tok::l_brace));
3930 // Determine whether the enum is simple, i.e. does not have a semicolon or
3937 if (Tok->is(tok::r_brace))
3944 // constants as "not simple". This is probably fine in practice, though.
3964 if (FormatTok->is(tok::l_brace)) {
3968 } else if (FormatTok->is(tok::l_paren)) {
3970 } else if (FormatTok->is(tok::comma)) {
3973 } else if (FormatTok->is(tok::semi)) {
3977 } else if (FormatTok->is(tok::r_brace)) {
3999 return Tok->is(tok::identifier) && Tok->TokenText != Tok->TokenText.upper();
4005 // it is often token-pasted.
4019 if (FormatTok->is(tok::l_brace)) {
4024 if (FormatTok->is(tok::l_square) && handleCppAttributes())
4042 Previous->is(tok::identifier) && Previous->isNot(TT_AttributeMacro)) {
4051 assert(FormatTok->is(tok::l_brace));
4054 return Prev != ClassName && Prev->is(tok::identifier) &&
4061 if (FormatTok->is(tok::less))
4063 else if (FormatTok->is(tok::greater))
4067 if (FormatTok->is(tok::colon)) {
4069 } else if (FormatTok->is(tok::identifier) &&
4070 FormatTok->Previous->is(tok::coloncolon)) {
4072 } else if (FormatTok->is(tok::l_paren) &&
4077 if (FormatTok->is(tok::l_brace)) {
4084 if (FormatTok->is(tok::l_square)) {
4097 if (FormatTok->is(tok::semi))
4099 if (Style.isCSharp() && FormatTok->is(Keywords.kw_where)) {
4123 if (FormatTok->is(tok::l_brace)) {
4139 // There is no addUnwrappedLine() here so that we fall through to parsing a
4148 if (FormatTok->is(tok::semi)) {
4152 } else if (FormatTok->is(tok::l_brace)) {
4165 assert(FormatTok->is(tok::less) && "'<' expected.");
4184 if (FormatTok->is(tok::l_brace)) {
4188 } else if (FormatTok->is(tok::r_brace)) {
4209 if (FormatTok->is(tok::less))
4211 if (FormatTok->is(tok::colon)) {
4215 if (FormatTok->is(tok::less))
4217 } else if (FormatTok->is(tok::l_paren)) {
4222 if (FormatTok->is(tok::less))
4225 if (FormatTok->is(tok::l_brace)) {
4239 assert(FormatTok->is(tok::less));
4255 if (FormatTok->is(tok::less)) {
4257 } else if (FormatTok->is(tok::greater)) {
4271 if (FormatTok->is(tok::l_paren)) {
4283 if (FormatTok->is(tok::less))
4287 if (FormatTok->is(tok::semi)) {
4299 bool IsImport = FormatTok->is(Keywords.kw_import);
4300 assert(IsImport || FormatTok->is(tok::kw_export));
4304 if (FormatTok->is(tok::kw_default))
4310 if (FormatTok->is(Keywords.kw_async))
4312 if (FormatTok->is(Keywords.kw_function)) {
4323 !(FormatTok->is(Keywords.kw_type) &&
4329 if (FormatTok->is(tok::semi))
4336 if (FormatTok->is(tok::l_brace)) {
4348 if (FormatTok->is(tok::l_paren))
4350 if (FormatTok->is(tok::semi))
4362 } else if (FormatTok->is(tok::l_square)) {
4375 if (FormatTok->is(tok::at))
4393 if (FormatTok->is(Keywords.kw_clocking)) {
4398 if (FormatTok->is(tok::semi))
4406 if (FormatTok->is(tok::l_paren)) {
4419 if (FormatTok->is(tok::l_square)) {
4438 while (FormatTok->is(Keywords.kw_import)) {
4442 if (FormatTok->is(tok::semi))
4447 if (FormatTok->is(Keywords.kw_verilogHash)) {
4450 if (FormatTok->is(tok::l_paren)) {
4455 if (FormatTok->is(tok::l_paren)) {
4462 if (FormatTok->is(Keywords.kw_extends)) {
4466 if (FormatTok->is(tok::l_paren))
4469 if (FormatTok->is(Keywords.kw_implements)) {
4474 } while (FormatTok->is(tok::comma));
4478 if (FormatTok->is(tok::at)) {
4483 if (FormatTok->is(tok::semi))
4492 assert(FormatTok->is(Keywords.kw_table));
4500 if (Tok->is(tok::semi))
4514 // don't know whether this colon is a label or a ternary expression at this
4552 // information so that the level can be decreased after the line is added.
4587 // At the top level we only get here when no unexpansion is going on, or
4610 bool UnwrappedLineParser::eof() const { return FormatTok->is(tok::eof); }
4617 // Checks if \p FormatTok is a line comment that continues the line comment
4635 // section if its original column is greater or equal to the original start
4639 // contains a '{' followed by a line comment, then the min column token is
4640 // that '{'. Otherwise, the min column token of the line is the first token of
4644 // continues the comment section if its original column is greater than the
4706 if (PreviousToken && PreviousToken->is(tok::l_brace) &&
4717 if (PreviousToken && PreviousToken->is(tok::l_brace))
4729 // Additional fine-grained breaking of line comment sections is controlled
4730 // by the class BreakableLineCommentSection in case it is desirable to keep
4762 // statement, but it is not a block. For keywords like `end`, we simply
4772 // Whether or not a line comment token continues a line is controlled by
4776 // that each comment line from the trail is aligned with the next token, if
4778 // trail is marked as a start of a new comment section.
4832 if (FormatTok->is(TT_ConflictStart))
4834 else if (FormatTok->is(TT_ConflictAlternative))
4836 else if (FormatTok->is(TT_ConflictEnd))
4859 PreviousWasComment = FormatTok->is(tok::comment);
4861 while (!Line->InPPDirective && FormatTok->is(tok::hash) &&
4867 // If there is an unfinished unwrapped line, we flush the preprocessor
4886 PreviousWasComment = FormatTok->is(tok::comment);
4896 if (FormatTok->is(tok::identifier) &&
4931 // The macro is either