Lines Matching full:left

63 /// With `Left` being '(', check if we're at either `[...](` or
66 static bool isLambdaParameterList(const FormatToken *Left) {
68 if (Left->Previous && Left->Previous->is(tok::greater) &&
69 Left->Previous->MatchingParen &&
70 Left->Previous->MatchingParen->is(TT_TemplateOpener)) {
71 Left = Left->Previous->MatchingParen;
75 return Left->Previous && Left->Previous->is(tok::r_square) &&
76 Left->Previous->MatchingParen &&
77 Left->Previous->MatchingParen->is(TT_LambdaLSquare);
155 auto *Left = CurrentToken->Previous; // The '<'.
156 if (!Left)
159 if (NonTemplateLess.count(Left) > 0)
162 const auto *BeforeLess = Left->Previous;
178 Left->ParentBracket = Contexts.back().ContextKind;
204 Left->ParentBracket != tok::less &&
216 Left->MatchingParen = CurrentToken;
217 CurrentToken->MatchingParen = Left;
262 updateParameterCount(Left, CurrentToken);
680 FormatToken *Left = CurrentToken->Previous;
681 Left->ParentBracket = Contexts.back().ContextKind;
682 FormatToken *Parent = Left->getPreviousNonComment();
694 isCppAttribute(IsCpp, *Left) || IsInnerSquare;
698 isCSharpAttributeSpecifier(*Left) ||
702 bool IsCppStructuredBinding = Left->isCppStructuredBinding(IsCpp);
706 Contexts.back().CanBeExpression && Left->isNot(TT_LambdaLSquare) &&
720 Left->setType(TT_StructuredBindingLSquare);
721 } else if (Left->is(TT_Unknown)) {
723 Left->setType(TT_ObjCMethodExpr);
725 Left->setType(TT_InlineASMSymbolicNameLSquare);
727 Left->setType(TT_AttributeSquare);
728 if (!IsInnerSquare && Left->Previous)
729 Left->Previous->EndsCppAttributeGroup = false;
733 Left->setType(TT_JsComputedPropertyName);
736 Left->setType(TT_DesignatedInitializerLSquare);
738 Left->setType(TT_AttributeSquare);
741 Left->setType(TT_ArraySubscriptLSquare);
769 Left->setType(TT_ArrayInitializerLSquare);
770 if (!Left->endsSequence(tok::l_square, tok::numeric_constant,
772 !Left->endsSequence(tok::l_square, tok::numeric_constant,
774 !Left->endsSequence(tok::l_square, tok::colon, TT_SelectorName)) {
775 Left->setType(TT_ProtoExtensionLSquare);
784 Left->setType(TT_ArrayInitializerLSquare);
787 Left->setType(TT_ArraySubscriptLSquare);
812 CurrentToken->Previous->Previous == Left)) &&
813 Left->is(TT_ObjCMethodExpr)) {
819 Left->setType(TT_Unknown);
821 if (StartsObjCMethodExpr && CurrentToken->Previous != Left) {
841 Left->MatchingParen = CurrentToken;
842 CurrentToken->MatchingParen = Left;
854 Left->ParameterCount =
860 if (Left->BlockParameterCount > 1)
863 if (Style.isTableGen() && Left->is(TT_TableGenListOpener))
878 Left->isOneOf(TT_ArraySubscriptLSquare,
880 Left->setType(TT_ObjCMethodExpr);
890 if (CurrentToken->is(tok::comma) && Left->is(TT_ObjCMethodExpr) &&
892 Left->setType(TT_ArrayInitializerLSquare);
905 updateParameterCount(Left, Tok);
910 updateParameterCount(Left, Tok);
1243 void updateParameterCount(FormatToken *Left, FormatToken *Current) {
1248 ++Left->BlockParameterCount;
1250 ++Left->ParameterCount;
1251 if (!Left->Role)
1252 Left->Role.reset(new CommaSeparatedList(Style));
1253 Left->Role->CommaFound(Current);
1254 } else if (Left->ParameterCount == 0 && Current->isNot(tok::comment)) {
1255 Left->ParameterCount = 1;
1521 // In the following example all 4 left parentheses will be treated as
1846 // We still want to format the whitespace left of the first token of the
2715 // If there is a closing parenthesis left of the current
4218 const FormatToken &Left = *Tok.Previous;
4221 if (Left.is(tok::semi))
4230 if (Left.is(tok::comma) && Left.NestingLevel == 0)
4233 if (Right.is(Keywords.kw_function) && Left.isNot(tok::comma))
4235 if (Left.is(TT_JsTypeColon))
4237 if ((Left.is(TT_TemplateString) && Left.TokenText.ends_with("${")) ||
4242 if (Left.opensScope() && Right.closesScope())
4254 if (Left.is(tok::r_square))
4257 if (Right.is(TT_LambdaLSquare) && Left.is(tok::equal))
4266 if (Left.is(tok::coloncolon))
4272 if (Left.is(TT_StartOfName))
4282 if (Left.is(tok::equal) && Right.is(tok::l_brace))
4284 if (Left.is(TT_CastRParen))
4286 if (Left.isOneOf(tok::kw_class, tok::kw_struct, tok::kw_union))
4288 if (Left.is(tok::comment))
4291 if (Left.isOneOf(TT_RangeBasedForLoopColon, TT_InheritanceColon,
4335 return (Left.is(tok::r_paren) ? 100 : 120) + (is_short_annotation ? 50 : 0);
4339 if (Line.startsWith(tok::kw_for) && Left.is(tok::equal))
4346 if (Left.is(tok::colon) && Left.is(TT_ObjCMethodExpr))
4352 if (Line.Type == LT_ObjCDecl && Left.is(tok::l_paren) && Left.Previous &&
4353 Left.Previous->isOneOf(tok::identifier, tok::greater)) {
4357 if (Left.is(tok::l_paren) && Style.PenaltyBreakOpenParenthesis != 0)
4359 if (Left.is(tok::l_paren) && InFunctionDecl &&
4363 if (Left.is(tok::l_paren) && Left.Previous &&
4364 (Left.Previous->isOneOf(tok::kw_for, tok::kw__Generic) ||
4365 Left.Previous->isIf())) {
4368 if (Left.is(tok::equal) && InFunctionDecl)
4372 if (Left.is(TT_TemplateOpener))
4374 if (Left.opensScope()) {
4379 (Left.ParameterCount <= 1 || Style.AllowAllArgumentsOnNextLine)) {
4382 if (Left.is(tok::l_brace) && !Style.Cpp11BracedListStyle)
4384 return Left.ParameterCount > 1 ? Style.PenaltyBreakBeforeFirstCallParameter
4387 if (Left.is(TT_JavaAnnotation))
4390 if (Left.is(TT_UnaryOperator))
4392 if (Left.isOneOf(tok::plus, tok::comma) && Left.Previous &&
4393 Left.Previous->isLabelString() &&
4394 (Left.NextOperator || Left.OperatorIndex != 0)) {
4397 if (Right.is(tok::plus) && Left.isLabelString() &&
4401 if (Left.is(tok::comma))
4403 if (Right.is(tok::lessless) && Left.isLabelString() &&
4409 if (Left.isNot(tok::r_paren) || Right.OperatorIndex > 0) {
4415 if (Left.ClosesTemplateDeclaration)
4417 if (Left.ClosesRequiresClause)
4419 if (Left.is(TT_ConditionalExpr))
4421 prec::Level Level = Left.getPrecedence();
4447 const FormatToken &Left,
4449 if (Left.is(tok::kw_return) &&
4453 if (Left.is(tok::kw_throw) && Right.is(tok::l_paren) && Right.MatchingParen &&
4457 if (Left.is(Keywords.kw_assert) && Style.Language == FormatStyle::LK_Java)
4460 Left.Tok.getObjCKeywordID() == tok::objc_property) {
4464 return Left.is(tok::hash);
4465 if (Left.isOneOf(tok::hashhash, tok::hash))
4467 if (Left.is(BK_Block) && Right.is(tok::r_brace) &&
4468 Right.MatchingParen == &Left && Line.Children.empty()) {
4472 if ((Left.is(tok::l_paren) && Right.is(tok::r_paren)) ||
4473 (Left.is(tok::l_brace) && Left.isNot(BK_Block) &&
4478 Left.is(tok::r_paren) && Right.is(tok::r_paren)) {
4479 auto *InnerLParen = Left.MatchingParen;
4486 if (Left.is(tok::l_paren))
4487 LeftParen = &Left;
4498 if (Left.is(tok::kw_auto) && Right.isOneOf(TT_LambdaLBrace, TT_FunctionLBrace,
4505 if (Left.is(tok::kw_auto) && Right.isOneOf(tok::l_paren, tok::l_brace))
4508 const auto *BeforeLeft = Left.Previous;
4511 if (Right.is(tok::l_paren) && Left.is(tok::kw_co_await) && BeforeLeft &&
4516 if (Left.isOneOf(tok::kw_co_await, tok::kw_co_yield, tok::kw_co_return) &&
4521 if (Left.is(tok::l_paren) || Right.is(tok::r_paren)) {
4523 (Left.MatchingParen && Left.MatchingParen->is(TT_CastRParen)))
4535 if (Right.is(tok::less) && Left.is(tok::kw_template))
4537 if (Left.isOneOf(tok::exclaim, tok::tilde))
4539 if (Left.is(tok::at) &&
4545 if (Left.is(tok::colon))
4546 return Left.isNot(TT_ObjCMethodExpr);
4547 if (Left.is(tok::coloncolon))
4549 if (Left.is(tok::less) || Right.isOneOf(tok::greater, tok::less)) {
4552 (Left.is(TT_DictLiteral) || Right.is(TT_DictLiteral)))) {
4554 if (Left.is(tok::less) && Right.is(tok::greater))
4563 return Left.Tok.isLiteral() || (Left.is(tok::identifier) && BeforeLeft &&
4566 if (Left.is(tok::l_square) && Right.is(tok::amp))
4569 if (Left.is(tok::r_paren) && Line.MightBeFunctionDecl) {
4570 if (!Left.MatchingParen)
4573 Left.MatchingParen->getPreviousNonComment();
4574 if (!TokenBeforeMatchingParen || Left.isNot(TT_TypeDeclarationParen))
4582 (Left.is(TT_AttributeRParen) ||
4583 Left.canBePointerOrReferenceQualifier())) {
4586 if (Left.Tok.isLiteral())
4589 if (Left.isTypeOrIdentifier(LangOpts) && Right.Next && Right.Next->Next &&
4594 return !Left.isOneOf(TT_PointerOrReference, tok::l_paren) &&
4598 (Left.NestingLevel == 0 ||
4599 (Left.NestingLevel == 1 && startsWithInitStatement(Line)))));
4601 if (Right.is(TT_FunctionTypeLParen) && Left.isNot(tok::l_paren) &&
4602 (Left.isNot(TT_PointerOrReference) ||
4603 (getTokenPointerOrReferenceAlignment(Left) != FormatStyle::PAS_Right &&
4607 if (Left.is(TT_PointerOrReference)) {
4634 return getTokenPointerOrReferenceAlignment(Left) !=
4641 if (getTokenPointerOrReferenceAlignment(Left) == FormatStyle::PAS_Right)
4650 (Left.NestingLevel == Line.First->NestingLevel ||
4651 ((Left.NestingLevel == Line.First->NestingLevel + 1) &&
4658 if (Left.isNot(tok::star))
4670 if (Left.is(tok::ellipsis) && BeforeLeft &&
4675 if (Right.is(tok::star) && Left.is(tok::l_paren))
4677 if (Left.is(tok::star) && Right.isPointerOrReference())
4680 const FormatToken *Previous = &Left;
4719 if (Style.isCSharp() && Left.is(Keywords.kw_is) && Right.is(tok::l_square))
4728 if (Left.is(tok::l_square)) {
4729 return (Left.is(TT_ArrayInitializerLSquare) && Right.isNot(tok::r_square) &&
4730 SpaceRequiredForArrayInitializerLSquare(Left, Style)) ||
4731 (Left.isOneOf(TT_ArraySubscriptLSquare, TT_StructuredBindingLSquare,
4749 !Left.isOneOf(tok::numeric_constant, TT_DictLiteral) &&
4750 !(Left.isNot(tok::r_square) && Style.SpaceBeforeSquareBrackets &&
4754 if (Left.is(tok::l_brace) && Right.is(tok::r_brace))
4755 return !Left.Children.empty(); // No spaces in "{}".
4756 if ((Left.is(tok::l_brace) && Left.isNot(BK_Block)) ||
4761 if (Left.is(TT_BlockComment)) {
4763 return Style.isJavaScript() || !Left.TokenText.ends_with("=*/");
4768 if (Left.is(TT_TemplateCloser) && Right.is(TT_AttributeSquare))
4772 if (Left.is(TT_TemplateCloser) && Right.isNot(TT_FunctionTypeLParen))
4774 if (Left.isOneOf(TT_RequiresClause,
4779 if (Left.is(TT_RequiresExpression)) {
4783 if (Left.is(TT_AttributeRParen) ||
4784 (Left.is(tok::r_square) && Left.is(TT_AttributeSquare))) {
4787 if (Left.is(TT_ForEachMacro)) {
4791 if (Left.is(TT_IfMacro)) {
4796 Left.isOneOf(tok::kw_new, tok::kw_delete) &&
4798 !(Line.MightBeFunctionDecl && Left.is(TT_FunctionDeclarationName))) {
4805 if (Left.is(tok::semi))
4807 if (Left.isOneOf(tok::pp_elif, tok::kw_for, tok::kw_while, tok::kw_switch,
4809 Left.isIf(Line.Type != LT_PreprocessorDirective) ||
4829 if (Line.Type != LT_PreprocessorDirective && Left.is(tok::r_square) &&
4830 Left.MatchingParen && Left.MatchingParen->is(TT_LambdaLSquare)) {
4835 if (Left.isOneOf(tok::kw_try, Keywords.kw___except, tok::kw_catch)) {
4839 if (Left.isOneOf(tok::kw_new, tok::kw_delete)) {
4845 if (Left.is(tok::r_square) && Left.MatchingParen &&
4846 Left.MatchingParen->Previous &&
4847 Left.MatchingParen->Previous->is(tok::kw_delete)) {
4854 (Left.Tok.getIdentifierInfo() || Left.is(tok::r_paren))) {
4859 if (Left.is(tok::at) && Right.Tok.getObjCKeywordID() != tok::objc_not_keyword)
4862 return !Left.isOneOf(tok::l_paren, tok::l_square, tok::at) &&
4863 (Left.isNot(tok::colon) || Left.isNot(TT_ObjCMethodExpr));
4870 (Left.isOneOf(tok::identifier, tok::greater, tok::r_square,
4872 Left.isTypeName(LangOpts)) &&
4877 if (Left.is(tok::period) || Right.is(tok::period))
4881 if (Right.is(tok::hash) && Left.is(tok::identifier) &&
4882 (Left.TokenText == "L" || Left.TokenText == "u" ||
4883 Left.TokenText == "U" || Left.TokenText == "u8" ||
4884 Left.TokenText == "LR" || Left.TokenText == "uR" ||
4885 Left.TokenText == "UR" || Left.TokenText == "u8R")) {
4888 if (Left.is(TT_TemplateCloser) && Left.MatchingParen &&
4889 Left.MatchingParen->Previous &&
4890 (Left.MatchingParen->Previous->is(tok::period) ||
4891 Left.MatchingParen->Previous->is(tok::coloncolon))) {
4897 if (Left.is(TT_TemplateCloser) && Right.is(tok::l_square))
4899 if (Left.is(tok::l_brace) && Left.endsSequence(TT_DictLiteral, tok::at)) {
4909 Left.isOneOf(tok::kw_const, tok::kw_volatile) &&
4922 const FormatToken &Left = *Right.Previous;
4926 if (Left.Finalized)
4934 Keywords.isWordLike(Left, IsVerilog)) {
4940 if (Left.is(tok::star) && Right.is(tok::comment))
4943 const auto *BeforeLeft = Left.Previous;
4946 if (Left.is(TT_OverloadedOperator) &&
4951 if (Right.is(tok::period) && Left.is(tok::numeric_constant))
4955 if (Left.is(Keywords.kw_import) && Right.isOneOf(tok::less, tok::ellipsis))
4958 if (Left.isOneOf(Keywords.kw_module, Keywords.kw_import) &&
4967 if (Left.is(tok::identifier) && Right.is(TT_ModulePartitionColon))
4970 if (Left.is(TT_ModulePartitionColon) &&
4974 if (Left.is(tok::ellipsis) && Right.is(tok::identifier) &&
4979 if (Left.isOneOf(TT_AttributeRParen, TT_AttributeMacro) &&
4984 if (Left.is(tok::kw_operator))
4987 !Left.opensScope() && Style.SpaceBeforeCpp11BracedList) {
4990 if (Left.is(tok::less) && Left.is(TT_OverloadedOperator) &&
4995 if (Left.is(tok::identifier) && Right.is(tok::numeric_constant))
4997 // `Left` is a keyword (including C++ alternative operator) or identifier.
4998 if (Left.Tok.getIdentifierInfo() && Right.Tok.isLiteral())
5002 Left.isOneOf(Keywords.kw_optional, Keywords.kw_required,
5007 Left.isOneOf(Keywords.kw_returns, Keywords.kw_option)) {
5010 if (Right.isOneOf(tok::l_brace, tok::less) && Left.is(TT_SelectorName))
5013 if (Left.is(tok::slash) || Right.is(tok::slash))
5015 if (Left.MatchingParen &&
5016 Left.MatchingParen->is(TT_ProtoExtensionLSquare) &&
5021 if (Left.is(tok::percent))
5025 if (Left.is(tok::numeric_constant) && Right.is(tok::percent))
5028 if (Right.is(tok::colon) && Left.is(tok::string_literal))
5036 if (Left.is(tok::kw_this) && Right.is(tok::l_square))
5040 if (Left.is(tok::kw_new) && Right.is(tok::l_paren))
5048 if (Left.is(tok::l_brace) && Right.isNot(tok::r_brace))
5051 if (Left.isNot(tok::l_brace) && Right.is(tok::r_brace))
5055 if (Left.is(TT_FatArrow) || Right.is(TT_FatArrow))
5059 if (Left.is(TT_AttributeColon) || Right.is(TT_AttributeColon))
5063 if (Left.is(TT_TemplateCloser) && Right.is(TT_StartOfName))
5067 if (Left.is(tok::l_square) || Right.is(tok::r_square))
5079 if (Left.is(tok::comma) && Right.is(tok::comma))
5083 if (Left.is(Keywords.kw_var) && Right.is(tok::l_paren))
5088 if (Left.isOneOf(tok::kw_using, Keywords.kw_async, Keywords.kw_when,
5097 if ((Left.isAccessSpecifierKeyword() ||
5098 Left.isOneOf(tok::kw_virtual, tok::kw_extern, tok::kw_static,
5106 if (Left.is(TT_FatArrow))
5109 if (Right.is(tok::l_paren) && Left.is(Keywords.kw_await) && BeforeLeft &&
5113 if (Left.is(Keywords.kw_async) && Right.is(tok::l_paren) &&
5121 if ((Left.is(TT_TemplateString) && Left.TokenText.ends_with("${")) ||
5127 if (Keywords.isJavaScriptIdentifier(Left,
5133 Left.isOneOf(Keywords.kw_function, Keywords.kw_yield)) {
5137 Left.isOneOf(Keywords.kw_function, Keywords.kw_yield,
5143 if (Line.MustBeDeclaration && Left.Tok.getIdentifierInfo())
5148 Left.Tok.getIdentifierInfo()) {
5152 if (Left.isOneOf(tok::kw_throw, Keywords.kw_await, Keywords.kw_typeof,
5158 if (Left.endsSequence(tok::kw_const, Keywords.kw_as))
5160 if ((Left.isOneOf(Keywords.kw_let, Keywords.kw_var, Keywords.kw_in,
5165 (Left.is(Keywords.kw_of) && BeforeLeft &&
5171 if (Left.isOneOf(tok::kw_for, Keywords.kw_as) && BeforeLeft &&
5175 if (Left.is(Keywords.kw_as) &&
5179 if (Left.is(tok::kw_default) && BeforeLeft &&
5183 if (Left.is(Keywords.kw_is) && Right.is(tok::l_brace))
5187 if (Left.is(TT_JsTypeOperator) || Right.is(TT_JsTypeOperator))
5189 if ((Left.is(tok::l_brace) || Right.is(tok::r_brace)) &&
5193 if (Left.is(tok::ellipsis))
5195 if (Left.is(TT_TemplateCloser) &&
5205 if (Left.is(TT_NonNullAssertion) &&
5210 if (Left.is(TT_CaseLabelArrow) || Right.is(TT_CaseLabelArrow))
5212 if (Left.is(tok::r_square) && Right.is(tok::l_brace))
5215 if (Left.is(tok::l_square) || Right.is(tok::r_square))
5218 if (Left.is(Keywords.kw_synchronized) && Right.is(tok::l_paren)) {
5222 if ((Left.isAccessSpecifierKeyword() ||
5223 Left.isOneOf(tok::kw_static, Keywords.kw_final, Keywords.kw_abstract,
5230 if (Left.is(tok::identifier) && Left.TokenText[0] == '\\')
5234 if ((Left.is(TT_VerilogTableItem) &&
5236 (Right.is(TT_VerilogTableItem) && Left.isNot(tok::l_paren))) {
5241 if (Left.isNot(TT_BinaryOperator) &&
5242 Left.isOneOf(Keywords.kw_verilogHash, Keywords.kw_verilogHashHash)) {
5247 (Left.endsSequence(tok::numeric_constant, Keywords.kw_verilogHash) ||
5248 Left.endsSequence(tok::numeric_constant,
5250 (Left.is(tok::r_paren) && Left.MatchingParen &&
5251 Left.MatchingParen->endsSequence(tok::l_paren, tok::at)))) {
5256 if (Left.is(Keywords.kw_apostrophe) ||
5257 (Left.is(TT_VerilogNumberBase) && Right.is(tok::numeric_constant))) {
5261 if (Left.is(tok::arrow) || Right.is(tok::arrow))
5266 if (Left.is(tok::at) && Right.isOneOf(tok::l_paren, tok::star, tok::at))
5270 Left.isOneOf(TT_VerilogDimensionedTypeName, Keywords.kw_function)) {
5275 Keywords.isVerilogIdentifier(Left) && Left.getPreviousNonComment() &&
5276 Left.getPreviousNonComment()->is(Keywords.kw_tagged)) {
5284 !(Left.isOneOf(Keywords.kw_assign, Keywords.kw_unique) ||
5285 Keywords.isVerilogWordOperator(Left)) &&
5286 (Left.isOneOf(tok::r_square, tok::r_paren, tok::r_brace,
5288 Keywords.isWordLike(Left))) {
5292 if ((Right.is(tok::star) && Left.is(tok::coloncolon)) ||
5293 (Left.is(tok::star) && Right.is(tok::semi))) {
5297 if (Left.endsSequence(tok::star, tok::l_paren) && Right.is(tok::identifier))
5303 if ((Left.is(tok::l_brace) &&
5305 (Left.endsSequence(tok::lessless, tok::l_brace) ||
5306 Left.endsSequence(tok::greatergreater, tok::l_brace))) {
5311 if (Left.is(tok::l_square) && Right.is(tok::l_brace))
5313 if (Left.is(tok::r_brace) && Right.is(tok::r_square))
5318 Left.isOneOf(TT_TableGenDAGArgListColon,
5324 if (Left.isOneOf(TT_TableGenDAGArgOperatorID,
5331 Left.isOneOf(TT_TableGenBangOperator, TT_TableGenCondOperator)) {
5336 if (Left.is(TT_TableGenTrailingPasteOperator) &&
5341 if (Left.is(tok::hash) || Right.is(tok::hash))
5344 if (Keywords.isTableGenDefinition(Left))
5348 if (Left.is(TT_ImplicitStringLiteral))
5351 if (Left.is(TT_ObjCMethodSpecifier))
5353 if (Left.is(tok::r_paren) && Left.isNot(TT_AttributeRParen) &&
5362 (Right.is(tok::equal) || Left.is(tok::equal))) {
5367 Left.isOneOf(TT_TrailingReturnArrow, TT_LambdaArrow)) {
5370 if (Left.is(tok::comma) && Right.isNot(TT_OverloadedOperatorLParen) &&
5373 (Left.Children.empty() || !Left.MacroParent)) {
5388 if (Left.is(TT_BitFieldColon)) {
5402 if (Left.is(tok::question))
5404 if (Right.is(TT_InlineASMColon) && Left.is(tok::coloncolon))
5421 if ((Left.isOneOf(tok::minus, tok::minusminus) &&
5423 (Left.isOneOf(tok::plus, tok::plusplus) &&
5427 if (Left.is(TT_UnaryOperator)) {
5430 if (Left.is(tok::amp) && Right.is(tok::r_square))
5432 return Style.SpaceAfterLogicalNot && Left.is(tok::exclaim);
5437 if (Left.is(TT_CastRParen)) {
5450 if (Left.is(tok::greater) && Right.is(tok::greater)) {
5452 (Style.Language == FormatStyle::LK_Proto && Left.is(TT_DictLiteral))) {
5455 return Right.is(TT_TemplateCloser) && Left.is(TT_TemplateCloser) &&
5460 Left.isOneOf(tok::arrow, tok::period, tok::arrowstar, tok::periodstar) ||
5464 if (!Style.SpaceBeforeAssignmentOperators && Left.isNot(TT_TemplateCloser) &&
5469 (Left.is(tok::identifier) || Left.is(tok::kw_this))) {
5472 if (Right.is(tok::coloncolon) && Left.is(tok::identifier)) {
5479 !Left.isOneOf(tok::l_brace, tok::comment, tok::l_paren)) {
5481 return (Left.is(TT_TemplateOpener) &&
5484 !(Left.isOneOf(tok::l_paren, tok::r_paren, tok::l_square,
5487 (Left.is(tok::l_paren) && Style.SpacesInParensOptions.Other);
5489 if ((Left.is(TT_TemplateOpener)) != (Right.is(TT_TemplateCloser)))
5491 if (Left.is(tok::r_paren) && Left.isNot(TT_TypeDeclarationParen) &&
5497 return !Left.isOneOf(tok::amp, tok::ampamp) ||
5498 getTokenReferenceAlignment(Left) != FormatStyle::PAS_Right;
5505 if ((Right.is(TT_BinaryOperator) && Left.isNot(tok::l_paren)) ||
5506 (Left.isOneOf(TT_BinaryOperator, TT_ConditionalExpr) &&
5510 if (Right.is(TT_TemplateOpener) && Left.is(tok::r_paren) &&
5511 Left.MatchingParen &&
5512 Left.MatchingParen->is(TT_OverloadedOperatorLParen)) {
5515 if (Right.is(tok::less) && Left.isNot(tok::l_paren) &&
5521 if (Left.is(TT_RegexLiteral))
5523 return spaceRequiredBetween(Line, Left, Right);
5551 const FormatToken &Left = *Right.Previous;
5558 Line.mightBeFunctionDefinition() && Left.MightBeFunctionDeclParen &&
5559 Left.ParameterCount > 0) {
5566 Line.MightBeFunctionDecl && !Left.opensScope() &&
5571 const auto *BeforeLeft = Left.Previous;
5575 if (Left.is(TT_FatArrow) && Right.is(tok::l_brace) &&
5580 Left.is(TT_CSharpNamedArgumentColon)) {
5592 if (Left.is(TT_AttributeSquare) && Left.is(tok::r_square) &&
5598 if (Left.is(TT_AttributeSquare) && Right.is(TT_AttributeSquare) &&
5599 Left.is(tok::r_square) && Right.is(tok::l_square)) {
5604 if (Right.is(tok::string_literal) && Left.is(tok::plus) && BeforeLeft &&
5608 if (Left.is(TT_DictLiteral) && Left.is(tok::l_brace) && Line.Level == 0 &&
5619 if (Left.is(tok::l_brace) && Line.Level == 0 &&
5628 if (Right.is(tok::r_brace) && Left.is(tok::l_brace) && BeforeLeft &&
5637 return !Left.Children.empty();
5641 return (Left.NestingLevel == 0 && Line.Level == 0) &&
5642 !Left.Children.empty();
5647 if (Right.is(tok::r_brace) && Left.is(tok::l_brace) &&
5648 !Left.Children.empty()) {
5652 (Left.NestingLevel == 0 && Line.Level == 0 &&
5657 if (Right.is(tok::plus) && Left.is(tok::string_literal) && AfterRight &&
5663 if (Left.is(TT_VerilogAssignComma))
5666 if (Left.is(TT_VerilogTypeComma))
5671 (Left.is(TT_VerilogInstancePortComma) ||
5672 (Left.is(tok::r_paren) && Keywords.isVerilogIdentifier(Right) &&
5673 Left.MatchingParen &&
5674 Left.MatchingParen->is(TT_VerilogInstancePortLParen)))) {
5679 if (!Keywords.isVerilogBegin(Right) && Keywords.isVerilogEndOfLabel(Left))
5684 if (Left.isStringLiteral() && Right.isStringLiteral())
5693 if (Left.is(TT_DictLiteral) && Left.is(tok::l_brace))
5696 if ((Left.is(TT_ArrayInitializerLSquare) && Left.is(tok::l_square) &&
5698 Left.is(tok::comma)) {
5715 if (Left.is(TT_TableGenCondOperatorComma))
5717 if (Left.is(TT_TableGenDAGArgOperatorToBreak) &&
5721 if (Left.is(TT_TableGenDAGArgListCommaToBreak))
5725 &Left != Right.MatchingParen->Next) {
5742 if ((Left.isOneOf(tok::l_brace, TT_ArrayInitializerLSquare) ||
5743 (Style.isJavaScript() && Left.is(tok::l_paren))) &&
5744 Left.isNot(BK_Block) && Left.MatchingParen) {
5745 BeforeClosingBrace = Left.MatchingParen->Previous;
5751 BeforeClosingBrace = &Left;
5760 return Left.isNot(BK_BracedInit) && Left.isNot(TT_CtorInitializerColon) &&
5763 if (Left.isTrailingComment())
5765 if (Left.IsUnterminatedLiteral)
5769 Left.is(tok::string_literal) && Right.is(tok::lessless) && AfterRight &&
5785 if (Left.ClosesTemplateDeclaration && Left.MatchingParen &&
5786 Left.MatchingParen->NestingLevel == 0) {
5796 if (Left.ClosesRequiresClause) {
5809 (Left.is(TT_CtorInitializerComma) ||
5815 Left.isOneOf(TT_CtorInitializerColon, TT_CtorInitializerComma)) {
5832 Left.is(TT_CtorInitializerColon)) {
5842 Left.is(TT_InheritanceComma)) {
5851 if ((Left.is(tok::l_brace) ||
5852 (Left.is(tok::less) && BeforeLeft && BeforeLeft->is(tok::equal))) &&
5861 if (isAllmanBrace(Left) || isAllmanBrace(Right)) {
5896 if (Left.is(TT_ObjCBlockLBrace) &&
5902 if (Left.isOneOf(TT_AttributeRParen, TT_AttributeMacro) &&
5907 if (Left.is(TT_LambdaLBrace)) {
5908 if (IsFunctionArgument(Left) &&
5915 (!Left.Children.empty() &&
5922 (Left.isPointerOrReference() || Left.is(TT_TemplateCloser))) {
5928 Left.is(TT_LeadingJavaAnnotation) &&
5968 if (Left.is(tok::at))
5996 // If Left.ParameterCount is 0, then this submessage entry is not the
5998 // If Left.ParameterCount is greater than 0, then its parent submessage
6002 if (Left.ParameterCount == 0)
6005 // submessage, Left.ParameterCount might be 1 in some cases.
6012 // left---. .---right
6017 if (Left.isOneOf(tok::r_brace, tok::greater, tok::r_square))
6026 const FormatToken &Left = *Right.Previous;
6029 if (Left.isOneOf(TT_CSharpNamedArgumentColon, TT_AttributeColon) ||
6035 return Left.is(TT_CSharpGenericTypeConstraintComma);
6040 if (Left.isOneOf(Keywords.kw_throws, Keywords.kw_extends,
6061 (Left.Tok.getIdentifierInfo() ||
6062 Left.isOneOf(tok::r_square, tok::r_paren)) &&
6070 if (Left.is(TT_FatArrow) && Right.is(tok::l_brace))
6072 if (Left.is(TT_JsTypeColon))
6075 if (Left.is(tok::exclaim) && Right.is(tok::colon))
6092 if (Left.is(Keywords.kw_in))
6104 if (Left.is(Keywords.kw_as))
6106 if (Left.is(TT_NonNullAssertion))
6108 if (Left.is(Keywords.kw_declare) &&
6117 if (Left.isOneOf(Keywords.kw_module, tok::kw_namespace) &&
6125 if (Left.is(tok::identifier) && Right.is(TT_TemplateString))
6127 if (Left.is(TT_TemplateString) && Left.opensScope())
6131 if (Keywords.isTableGenDefinition(Left))
6135 return !Left.isOneOf(TT_TableGenBangOperator, TT_TableGenCondOperator,
6139 if (Left.is(TT_TableGenValueSuffix))
6142 if (Left.is(tok::hash) || Right.is(tok::hash))
6144 if (Left.isOneOf(TT_TableGenBangOperator, TT_TableGenCondOperator))
6171 if (Left.isOneOf(tok::r_paren, TT_TrailingAnnotation) &&
6177 if (Left.is(tok::at))
6179 if (Left.Tok.getObjCKeywordID() == tok::objc_interface)
6181 if (Left.isOneOf(TT_JavaAnnotation, TT_LeadingJavaAnnotation))
6193 if (Left.is(TT_PointerOrReference))
6201 return Left.is(BK_BracedInit) ||
6202 (Left.is(TT_CtorInitializerColon) && Right.NewlinesBefore > 0 &&
6205 if (Left.is(tok::question) && Right.is(tok::colon))
6209 if (Left.is(TT_ConditionalExpr) || Left.is(tok::question))
6211 if (Left.is(TT_InheritanceColon))
6216 Left.isNot(TT_SelectorName)) {
6224 if (Left.is(tok::colon) && Left.isOneOf(TT_DictLiteral, TT_ObjCMethodExpr)) {
6266 return Left.isNot(tok::period); // FIXME: Properly parse ObjC calls.
6268 if (Left.is(tok::r_paren) && Line.Type == LT_ObjCProperty)
6274 if (Left.ClosesTemplateDeclaration) {
6278 if (Left.is(TT_FunctionAnnotationRParen))
6280 if (Left.ClosesRequiresClause)
6286 if (Left.is(TT_RangeBasedForLoopColon))
6290 if (Left.is(TT_TemplateCloser) && Right.is(TT_TemplateOpener))
6292 if ((Left.is(tok::greater) && Right.is(tok::greater)) ||
6293 (Left.is(tok::less) && Right.is(tok::less))) {
6302 if (Left.isOneOf(TT_TemplateCloser, TT_UnaryOperator) ||
6303 Left.is(tok::kw_operator)) {
6306 if (Left.is(tok::equal) && !Right.isOneOf(tok::kw_default, tok::kw_delete) &&
6307 Line.Type == LT_VirtualFunctionDecl && Left.NestingLevel == 0) {
6310 if (Left.is(tok::equal) && Right.is(tok::l_brace) &&
6314 if (Left.is(TT_AttributeLParen) ||
6315 (Left.is(tok::l_paren) && Left.is(TT_TypeDeclarationParen))) {
6318 if (Left.is(tok::l_paren) && Left.Previous &&
6319 (Left.Previous->isOneOf(TT_BinaryOperator, TT_CastRParen))) {
6334 if (Left.is(TT_TrailingAnnotation)) {
6343 return Left.isNot(TT_AttributeSquare);
6345 if (Left.is(tok::identifier) && Right.is(tok::string_literal))
6351 if (Left.is(TT_CtorInitializerColon)) {
6357 if (Left.is(TT_CtorInitializerComma) &&
6365 if (Left.is(TT_InheritanceComma) &&
6373 if (Left.is(TT_ArrayInitializerLSquare))
6375 if (Right.is(tok::kw_typename) && Left.isNot(tok::kw_const))
6377 if ((Left.isBinaryOperator() || Left.is(TT_BinaryOperator)) &&
6378 !Left.isOneOf(tok::arrowstar, tok::lessless) &&
6381 Left.getPrecedence() == prec::Assignment)) {
6384 if ((Left.is(TT_AttributeSquare) && Right.is(tok::l_square)) ||
6385 (Left.is(tok::r_square) && Right.is(TT_AttributeSquare))) {
6391 if (isAllmanLambdaBrace(Left))
6392 return !isItAnEmptyLambdaAllowed(Left, ShortLambdaOption);
6408 return Left.isOneOf(tok::comma, tok::coloncolon, tok::semi, tok::l_brace,
6413 (Left.is(tok::r_paren) &&
6415 (Left.is(tok::l_paren) && Right.isNot(tok::r_paren)) ||
6416 (Left.is(TT_TemplateOpener) && Right.isNot(TT_TemplateCloser));