Lines Matching refs:Left

65 static bool isLambdaParameterList(const FormatToken *Left) {  in isLambdaParameterList()  argument
67 if (Left->Previous && Left->Previous->is(tok::greater) && in isLambdaParameterList()
68 Left->Previous->MatchingParen && in isLambdaParameterList()
69 Left->Previous->MatchingParen->is(TT_TemplateOpener)) { in isLambdaParameterList()
70 Left = Left->Previous->MatchingParen; in isLambdaParameterList()
74 return Left->Previous && Left->Previous->is(tok::r_square) && in isLambdaParameterList()
75 Left->Previous->MatchingParen && in isLambdaParameterList()
76 Left->Previous->MatchingParen->is(TT_LambdaLSquare); in isLambdaParameterList()
173 FormatToken *Left = CurrentToken->Previous; in parseAngle() local
174 Left->ParentBracket = Contexts.back().ContextKind; in parseAngle()
184 if (Left->Previous && Left->Previous->isNot(tok::kw_template)) in parseAngle()
201 Left->ParentBracket != tok::less && in parseAngle()
207 Left->MatchingParen = CurrentToken; in parseAngle()
208 CurrentToken->MatchingParen = Left; in parseAngle()
215 (Style.Language == FormatStyle::LK_Proto && Left->Previous && in parseAngle()
216 Left->Previous->isOneOf(TT_SelectorName, TT_DictLiteral))) { in parseAngle()
249 updateParameterCount(Left, CurrentToken); in parseAngle()
621 FormatToken *Left = CurrentToken->Previous; in parseSquare() local
622 Left->ParentBracket = Contexts.back().ContextKind; in parseSquare()
623 FormatToken *Parent = Left->getPreviousNonComment(); in parseSquare()
635 isCppAttribute(Style.isCpp(), *Left) || IsInnerSquare; in parseSquare()
639 isCSharpAttributeSpecifier(*Left) || in parseSquare()
643 bool IsCppStructuredBinding = Left->isCppStructuredBinding(Style); in parseSquare()
648 Left->isNot(TT_LambdaLSquare) && in parseSquare()
662 Left->setType(TT_StructuredBindingLSquare); in parseSquare()
663 } else if (Left->is(TT_Unknown)) { in parseSquare()
665 Left->setType(TT_ObjCMethodExpr); in parseSquare()
667 Left->setType(TT_InlineASMSymbolicNameLSquare); in parseSquare()
669 Left->setType(TT_AttributeSquare); in parseSquare()
670 if (!IsInnerSquare && Left->Previous) in parseSquare()
671 Left->Previous->EndsCppAttributeGroup = false; in parseSquare()
675 Left->setType(TT_JsComputedPropertyName); in parseSquare()
678 Left->setType(TT_DesignatedInitializerLSquare); in parseSquare()
680 Left->setType(TT_AttributeSquare); in parseSquare()
683 Left->setType(TT_ArraySubscriptLSquare); in parseSquare()
711 Left->setType(TT_ArrayInitializerLSquare); in parseSquare()
712 if (!Left->endsSequence(tok::l_square, tok::numeric_constant, in parseSquare()
714 !Left->endsSequence(tok::l_square, tok::numeric_constant, in parseSquare()
716 !Left->endsSequence(tok::l_square, tok::colon, TT_SelectorName)) { in parseSquare()
717 Left->setType(TT_ProtoExtensionLSquare); in parseSquare()
726 Left->setType(TT_ArrayInitializerLSquare); in parseSquare()
729 Left->setType(TT_ArraySubscriptLSquare); in parseSquare()
754 CurrentToken->Previous->Previous == Left)) && in parseSquare()
755 Left->is(TT_ObjCMethodExpr)) { in parseSquare()
761 Left->setType(TT_Unknown); in parseSquare()
763 if (StartsObjCMethodExpr && CurrentToken->Previous != Left) { in parseSquare()
784 Left->MatchingParen = CurrentToken; in parseSquare()
785 CurrentToken->MatchingParen = Left; in parseSquare()
797 Left->ParameterCount = in parseSquare()
803 if (Left->BlockParameterCount > 1) in parseSquare()
819 Left->isOneOf(TT_ArraySubscriptLSquare, in parseSquare()
821 Left->setType(TT_ObjCMethodExpr); in parseSquare()
831 if (CurrentToken->is(tok::comma) && Left->is(TT_ObjCMethodExpr) && in parseSquare()
833 Left->setType(TT_ArrayInitializerLSquare); in parseSquare()
838 updateParameterCount(Left, Tok); in parseSquare()
934 void updateParameterCount(FormatToken *Left, FormatToken *Current) { in updateParameterCount() argument
939 ++Left->BlockParameterCount; in updateParameterCount()
941 ++Left->ParameterCount; in updateParameterCount()
942 if (!Left->Role) in updateParameterCount()
943 Left->Role.reset(new CommaSeparatedList(Style)); in updateParameterCount()
944 Left->Role->CommaFound(Current); in updateParameterCount()
945 } else if (Left->ParameterCount == 0 && Current->isNot(tok::comment)) { in updateParameterCount()
946 Left->ParameterCount = 1; in updateParameterCount()
3724 const FormatToken &Left = *Tok.Previous; in splitPenalty() local
3727 if (Left.is(tok::semi)) in splitPenalty()
3736 if (Left.is(tok::comma) && Left.NestingLevel == 0) in splitPenalty()
3739 if (Right.is(Keywords.kw_function) && Left.isNot(tok::comma)) in splitPenalty()
3741 if (Left.is(TT_JsTypeColon)) in splitPenalty()
3743 if ((Left.is(TT_TemplateString) && Left.TokenText.ends_with("${")) || in splitPenalty()
3748 if (Left.opensScope() && Right.closesScope()) in splitPenalty()
3760 if (Left.is(tok::r_square)) in splitPenalty()
3763 if (Right.is(TT_LambdaLSquare) && Left.is(tok::equal)) in splitPenalty()
3772 if (Left.is(tok::coloncolon)) in splitPenalty()
3778 if (Left.is(TT_StartOfName)) in splitPenalty()
3788 if (Left.is(tok::equal) && Right.is(tok::l_brace)) in splitPenalty()
3790 if (Left.is(TT_CastRParen)) in splitPenalty()
3792 if (Left.isOneOf(tok::kw_class, tok::kw_struct, tok::kw_union)) in splitPenalty()
3794 if (Left.is(tok::comment)) in splitPenalty()
3797 if (Left.isOneOf(TT_RangeBasedForLoopColon, TT_InheritanceColon, in splitPenalty()
3839 return (Left.is(tok::r_paren) ? 100 : 120) + (is_short_annotation ? 50 : 0); in splitPenalty()
3843 if (Line.startsWith(tok::kw_for) && Left.is(tok::equal)) in splitPenalty()
3850 if (Left.is(tok::colon) && Left.is(TT_ObjCMethodExpr)) in splitPenalty()
3856 if (Line.Type == LT_ObjCDecl && Left.is(tok::l_paren) && Left.Previous && in splitPenalty()
3857 Left.Previous->isOneOf(tok::identifier, tok::greater)) { in splitPenalty()
3861 if (Left.is(tok::l_paren) && Style.PenaltyBreakOpenParenthesis != 0) in splitPenalty()
3863 if (Left.is(tok::l_paren) && InFunctionDecl && in splitPenalty()
3867 if (Left.is(tok::l_paren) && Left.Previous && in splitPenalty()
3868 (Left.Previous->isOneOf(tok::kw_for, tok::kw__Generic) || in splitPenalty()
3869 Left.Previous->isIf())) { in splitPenalty()
3872 if (Left.is(tok::equal) && InFunctionDecl) in splitPenalty()
3876 if (Left.is(TT_TemplateOpener)) in splitPenalty()
3878 if (Left.opensScope()) { in splitPenalty()
3883 (Left.ParameterCount <= 1 || Style.AllowAllArgumentsOnNextLine)) { in splitPenalty()
3886 if (Left.is(tok::l_brace) && !Style.Cpp11BracedListStyle) in splitPenalty()
3888 return Left.ParameterCount > 1 ? Style.PenaltyBreakBeforeFirstCallParameter in splitPenalty()
3891 if (Left.is(TT_JavaAnnotation)) in splitPenalty()
3894 if (Left.is(TT_UnaryOperator)) in splitPenalty()
3896 if (Left.isOneOf(tok::plus, tok::comma) && Left.Previous && in splitPenalty()
3897 Left.Previous->isLabelString() && in splitPenalty()
3898 (Left.NextOperator || Left.OperatorIndex != 0)) { in splitPenalty()
3901 if (Right.is(tok::plus) && Left.isLabelString() && in splitPenalty()
3905 if (Left.is(tok::comma)) in splitPenalty()
3907 if (Right.is(tok::lessless) && Left.isLabelString() && in splitPenalty()
3913 if (Left.isNot(tok::r_paren) || Right.OperatorIndex > 0) { in splitPenalty()
3919 if (Left.ClosesTemplateDeclaration) in splitPenalty()
3921 if (Left.ClosesRequiresClause) in splitPenalty()
3923 if (Left.is(TT_ConditionalExpr)) in splitPenalty()
3925 prec::Level Level = Left.getPrecedence(); in splitPenalty()
3951 const FormatToken &Left, in spaceRequiredBetween() argument
3953 if (Left.is(tok::kw_return) && in spaceRequiredBetween()
3957 if (Left.is(tok::kw_throw) && Right.is(tok::l_paren) && Right.MatchingParen && in spaceRequiredBetween()
3961 if (Left.is(Keywords.kw_assert) && Style.Language == FormatStyle::LK_Java) in spaceRequiredBetween()
3964 Left.Tok.getObjCKeywordID() == tok::objc_property) { in spaceRequiredBetween()
3968 return Left.is(tok::hash); in spaceRequiredBetween()
3969 if (Left.isOneOf(tok::hashhash, tok::hash)) in spaceRequiredBetween()
3971 if ((Left.is(tok::l_paren) && Right.is(tok::r_paren)) || in spaceRequiredBetween()
3972 (Left.is(tok::l_brace) && Left.isNot(BK_Block) && in spaceRequiredBetween()
3978 if (Left.is(tok::l_paren)) in spaceRequiredBetween()
3979 LeftParen = &Left; in spaceRequiredBetween()
3991 if (Left.is(tok::kw_auto) && Right.isOneOf(TT_LambdaLBrace, TT_FunctionLBrace, in spaceRequiredBetween()
3998 if (Left.is(tok::kw_auto) && Right.isOneOf(tok::l_paren, tok::l_brace)) in spaceRequiredBetween()
4002 if (Right.is(tok::l_paren) && Left.is(tok::kw_co_await) && Left.Previous && in spaceRequiredBetween()
4003 Left.Previous->is(tok::kw_operator)) { in spaceRequiredBetween()
4007 if (Left.isOneOf(tok::kw_co_await, tok::kw_co_yield, tok::kw_co_return) && in spaceRequiredBetween()
4012 if (Left.is(tok::l_paren) || Right.is(tok::r_paren)) { in spaceRequiredBetween()
4014 (Left.MatchingParen && Left.MatchingParen->is(TT_CastRParen))) in spaceRequiredBetween()
4026 if (Right.is(tok::less) && Left.is(tok::kw_template)) in spaceRequiredBetween()
4028 if (Left.isOneOf(tok::exclaim, tok::tilde)) in spaceRequiredBetween()
4030 if (Left.is(tok::at) && in spaceRequiredBetween()
4036 if (Left.is(tok::colon)) in spaceRequiredBetween()
4037 return Left.isNot(TT_ObjCMethodExpr); in spaceRequiredBetween()
4038 if (Left.is(tok::coloncolon)) in spaceRequiredBetween()
4040 if (Left.is(tok::less) || Right.isOneOf(tok::greater, tok::less)) { in spaceRequiredBetween()
4043 (Left.is(TT_DictLiteral) || Right.is(TT_DictLiteral)))) { in spaceRequiredBetween()
4045 if (Left.is(tok::less) && Right.is(tok::greater)) in spaceRequiredBetween()
4054 return Left.Tok.isLiteral() || (Left.is(tok::identifier) && Left.Previous && in spaceRequiredBetween()
4055 Left.Previous->is(tok::kw_case)); in spaceRequiredBetween()
4057 if (Left.is(tok::l_square) && Right.is(tok::amp)) in spaceRequiredBetween()
4060 if (Left.is(tok::r_paren) && Line.MightBeFunctionDecl) { in spaceRequiredBetween()
4061 if (!Left.MatchingParen) in spaceRequiredBetween()
4064 Left.MatchingParen->getPreviousNonComment(); in spaceRequiredBetween()
4065 if (!TokenBeforeMatchingParen || Left.isNot(TT_TypeDeclarationParen)) in spaceRequiredBetween()
4073 (Left.is(TT_AttributeRParen) || in spaceRequiredBetween()
4074 Left.canBePointerOrReferenceQualifier())) { in spaceRequiredBetween()
4077 if (Left.Tok.isLiteral()) in spaceRequiredBetween()
4080 if (Left.isTypeOrIdentifier() && Right.Next && Right.Next->Next && in spaceRequiredBetween()
4085 return !Left.isOneOf(TT_PointerOrReference, tok::l_paren) && in spaceRequiredBetween()
4089 (Left.NestingLevel == 0 || in spaceRequiredBetween()
4090 (Left.NestingLevel == 1 && startsWithInitStatement(Line))))); in spaceRequiredBetween()
4092 if (Right.is(TT_FunctionTypeLParen) && Left.isNot(tok::l_paren) && in spaceRequiredBetween()
4093 (Left.isNot(TT_PointerOrReference) || in spaceRequiredBetween()
4094 (getTokenPointerOrReferenceAlignment(Left) != FormatStyle::PAS_Right && in spaceRequiredBetween()
4098 if (Left.is(TT_PointerOrReference)) { in spaceRequiredBetween()
4123 if (Left.Previous && Left.Previous->isTypeOrIdentifier() && Right.Next && in spaceRequiredBetween()
4125 return getTokenPointerOrReferenceAlignment(Left) != in spaceRequiredBetween()
4132 if (getTokenPointerOrReferenceAlignment(Left) == FormatStyle::PAS_Right) in spaceRequiredBetween()
4141 (Left.NestingLevel == Line.First->NestingLevel || in spaceRequiredBetween()
4142 ((Left.NestingLevel == Line.First->NestingLevel + 1) && in spaceRequiredBetween()
4146 return Left.Previous && !Left.Previous->isOneOf( in spaceRequiredBetween()
4150 if (Left.is(tok::ellipsis) && Left.Previous && in spaceRequiredBetween()
4151 Left.Previous->isPointerOrReference()) { in spaceRequiredBetween()
4155 if (Right.is(tok::star) && Left.is(tok::l_paren)) in spaceRequiredBetween()
4157 if (Left.is(tok::star) && Right.isPointerOrReference()) in spaceRequiredBetween()
4160 const FormatToken *Previous = &Left; in spaceRequiredBetween()
4199 if (Style.isCSharp() && Left.is(Keywords.kw_is) && Right.is(tok::l_square)) in spaceRequiredBetween()
4208 if (Left.is(tok::l_square)) { in spaceRequiredBetween()
4209 return (Left.is(TT_ArrayInitializerLSquare) && Right.isNot(tok::r_square) && in spaceRequiredBetween()
4210 SpaceRequiredForArrayInitializerLSquare(Left, Style)) || in spaceRequiredBetween()
4211 (Left.isOneOf(TT_ArraySubscriptLSquare, TT_StructuredBindingLSquare, in spaceRequiredBetween()
4229 !Left.isOneOf(tok::numeric_constant, TT_DictLiteral) && in spaceRequiredBetween()
4230 !(Left.isNot(tok::r_square) && Style.SpaceBeforeSquareBrackets && in spaceRequiredBetween()
4234 if (Left.is(tok::l_brace) && Right.is(tok::r_brace)) in spaceRequiredBetween()
4235 return !Left.Children.empty(); // No spaces in "{}". in spaceRequiredBetween()
4236 if ((Left.is(tok::l_brace) && Left.isNot(BK_Block)) || in spaceRequiredBetween()
4241 if (Left.is(TT_BlockComment)) { in spaceRequiredBetween()
4243 return Style.isJavaScript() || !Left.TokenText.ends_with("=*/"); in spaceRequiredBetween()
4248 if (Left.is(TT_TemplateCloser) && Right.is(TT_AttributeSquare)) in spaceRequiredBetween()
4252 if (Left.is(TT_TemplateCloser) && Right.isNot(TT_FunctionTypeLParen)) in spaceRequiredBetween()
4254 if (Left.isOneOf(TT_RequiresClause, in spaceRequiredBetween()
4259 if (Left.is(TT_RequiresExpression)) { in spaceRequiredBetween()
4263 if (Left.is(TT_AttributeRParen) || in spaceRequiredBetween()
4264 (Left.is(tok::r_square) && Left.is(TT_AttributeSquare))) { in spaceRequiredBetween()
4267 if (Left.is(TT_ForEachMacro)) { in spaceRequiredBetween()
4271 if (Left.is(TT_IfMacro)) { in spaceRequiredBetween()
4276 Left.isOneOf(tok::kw_new, tok::kw_delete) && in spaceRequiredBetween()
4278 !(Line.MightBeFunctionDecl && Left.is(TT_FunctionDeclarationName))) { in spaceRequiredBetween()
4283 if (Left.is(tok::semi)) in spaceRequiredBetween()
4285 if (Left.isOneOf(tok::pp_elif, tok::kw_for, tok::kw_while, tok::kw_switch, in spaceRequiredBetween()
4287 Left.isIf(Line.Type != LT_PreprocessorDirective) || in spaceRequiredBetween()
4298 if (Line.MightBeFunctionDecl && (Left.is(TT_FunctionDeclarationName))) { in spaceRequiredBetween()
4308 if (Line.Type != LT_PreprocessorDirective && Left.is(tok::r_square) && in spaceRequiredBetween()
4309 Left.MatchingParen && Left.MatchingParen->is(TT_LambdaLSquare)) { in spaceRequiredBetween()
4313 if (!Left.Previous || Left.Previous->isNot(tok::period)) { in spaceRequiredBetween()
4314 if (Left.isOneOf(tok::kw_try, Keywords.kw___except, tok::kw_catch)) { in spaceRequiredBetween()
4318 if (Left.isOneOf(tok::kw_new, tok::kw_delete)) { in spaceRequiredBetween()
4319 return ((!Line.MightBeFunctionDecl || !Left.Previous) && in spaceRequiredBetween()
4324 if (Left.is(tok::r_square) && Left.MatchingParen && in spaceRequiredBetween()
4325 Left.MatchingParen->Previous && in spaceRequiredBetween()
4326 Left.MatchingParen->Previous->is(tok::kw_delete)) { in spaceRequiredBetween()
4333 (Left.Tok.getIdentifierInfo() || Left.is(tok::r_paren))) { in spaceRequiredBetween()
4338 if (Left.is(tok::at) && Right.Tok.getObjCKeywordID() != tok::objc_not_keyword) in spaceRequiredBetween()
4341 return !Left.isOneOf(tok::l_paren, tok::l_square, tok::at) && in spaceRequiredBetween()
4342 (Left.isNot(tok::colon) || Left.isNot(TT_ObjCMethodExpr)); in spaceRequiredBetween()
4349 (Left.isOneOf(tok::identifier, tok::greater, tok::r_square, in spaceRequiredBetween()
4351 Left.isSimpleTypeSpecifier()) && in spaceRequiredBetween()
4356 if (Left.is(tok::period) || Right.is(tok::period)) in spaceRequiredBetween()
4360 if (Right.is(tok::hash) && Left.is(tok::identifier) && in spaceRequiredBetween()
4361 (Left.TokenText == "L" || Left.TokenText == "u" || in spaceRequiredBetween()
4362 Left.TokenText == "U" || Left.TokenText == "u8" || in spaceRequiredBetween()
4363 Left.TokenText == "LR" || Left.TokenText == "uR" || in spaceRequiredBetween()
4364 Left.TokenText == "UR" || Left.TokenText == "u8R")) { in spaceRequiredBetween()
4367 if (Left.is(TT_TemplateCloser) && Left.MatchingParen && in spaceRequiredBetween()
4368 Left.MatchingParen->Previous && in spaceRequiredBetween()
4369 (Left.MatchingParen->Previous->is(tok::period) || in spaceRequiredBetween()
4370 Left.MatchingParen->Previous->is(tok::coloncolon))) { in spaceRequiredBetween()
4376 if (Left.is(TT_TemplateCloser) && Right.is(tok::l_square)) in spaceRequiredBetween()
4378 if (Left.is(tok::l_brace) && Left.endsSequence(TT_DictLiteral, tok::at)) { in spaceRequiredBetween()
4389 Left.isOneOf(tok::kw_const, tok::kw_volatile) && in spaceRequiredBetween()
4402 const FormatToken &Left = *Right.Previous; in spaceRequiredBefore() local
4406 if (Left.Finalized) in spaceRequiredBefore()
4410 if (Keywords.isWordLike(Right) && Keywords.isWordLike(Left)) in spaceRequiredBefore()
4415 if (Left.is(tok::star) && Right.is(tok::comment)) in spaceRequiredBefore()
4419 if (Left.is(TT_OverloadedOperator) && in spaceRequiredBefore()
4424 if (Right.is(tok::period) && Left.is(tok::numeric_constant)) in spaceRequiredBefore()
4428 if (Left.is(Keywords.kw_import) && Right.isOneOf(tok::less, tok::ellipsis)) in spaceRequiredBefore()
4431 if (Left.isOneOf(Keywords.kw_module, Keywords.kw_import) && in spaceRequiredBefore()
4436 if (Left.is(tok::identifier) && Right.is(TT_ModulePartitionColon)) in spaceRequiredBefore()
4439 if (Left.is(TT_ModulePartitionColon) && in spaceRequiredBefore()
4443 if (Left.is(tok::ellipsis) && Right.is(tok::identifier) && in spaceRequiredBefore()
4448 if (Left.isOneOf(TT_AttributeRParen, TT_AttributeMacro) && in spaceRequiredBefore()
4453 if (Left.is(tok::kw_operator)) in spaceRequiredBefore()
4456 !Left.opensScope() && Style.SpaceBeforeCpp11BracedList) { in spaceRequiredBefore()
4459 if (Left.is(tok::less) && Left.is(TT_OverloadedOperator) && in spaceRequiredBefore()
4465 Left.isOneOf(Keywords.kw_optional, Keywords.kw_required, in spaceRequiredBefore()
4470 Left.isOneOf(Keywords.kw_returns, Keywords.kw_option)) { in spaceRequiredBefore()
4473 if (Right.isOneOf(tok::l_brace, tok::less) && Left.is(TT_SelectorName)) in spaceRequiredBefore()
4476 if (Left.is(tok::slash) || Right.is(tok::slash)) in spaceRequiredBefore()
4478 if (Left.MatchingParen && in spaceRequiredBefore()
4479 Left.MatchingParen->is(TT_ProtoExtensionLSquare) && in spaceRequiredBefore()
4484 if (Left.is(tok::percent)) in spaceRequiredBefore()
4488 if (Left.is(tok::numeric_constant) && Right.is(tok::percent)) in spaceRequiredBefore()
4491 if (Right.is(tok::colon) && Left.is(tok::string_literal)) in spaceRequiredBefore()
4499 if (Left.is(tok::kw_this) && Right.is(tok::l_square)) in spaceRequiredBefore()
4503 if (Left.is(tok::kw_new) && Right.is(tok::l_paren)) in spaceRequiredBefore()
4511 if (Left.is(tok::l_brace) && Right.isNot(tok::r_brace)) in spaceRequiredBefore()
4514 if (Left.isNot(tok::l_brace) && Right.is(tok::r_brace)) in spaceRequiredBefore()
4518 if (Left.is(TT_FatArrow) || Right.is(TT_FatArrow)) in spaceRequiredBefore()
4522 if (Left.is(TT_AttributeColon) || Right.is(TT_AttributeColon)) in spaceRequiredBefore()
4526 if (Left.is(TT_TemplateCloser) && Right.is(TT_StartOfName)) in spaceRequiredBefore()
4530 if (Left.is(tok::l_square) || Right.is(tok::r_square)) in spaceRequiredBefore()
4542 if (Left.is(tok::comma) && Right.is(tok::comma)) in spaceRequiredBefore()
4546 if (Left.is(Keywords.kw_var) && Right.is(tok::l_paren)) in spaceRequiredBefore()
4551 if (Left.isOneOf(tok::kw_using, Keywords.kw_async, Keywords.kw_when, in spaceRequiredBefore()
4560 if (Left.isOneOf(tok::kw_public, tok::kw_private, tok::kw_protected, in spaceRequiredBefore()
4569 if (Left.is(TT_FatArrow)) in spaceRequiredBefore()
4572 if (Right.is(tok::l_paren) && Left.is(Keywords.kw_await) && Left.Previous && in spaceRequiredBefore()
4573 Left.Previous->is(tok::kw_for)) { in spaceRequiredBefore()
4576 if (Left.is(Keywords.kw_async) && Right.is(tok::l_paren) && in spaceRequiredBefore()
4584 if ((Left.is(TT_TemplateString) && Left.TokenText.ends_with("${")) || in spaceRequiredBefore()
4590 if (Keywords.IsJavaScriptIdentifier(Left, in spaceRequiredBefore()
4596 Left.isOneOf(Keywords.kw_function, Keywords.kw_yield)) { in spaceRequiredBefore()
4600 Left.isOneOf(Keywords.kw_function, Keywords.kw_yield, in spaceRequiredBefore()
4606 if (Line.MustBeDeclaration && Left.Tok.getIdentifierInfo()) in spaceRequiredBefore()
4610 if (Left.Previous && Left.Previous->is(tok::period) && in spaceRequiredBefore()
4611 Left.Tok.getIdentifierInfo()) { in spaceRequiredBefore()
4615 if (Left.isOneOf(tok::kw_throw, Keywords.kw_await, Keywords.kw_typeof, in spaceRequiredBefore()
4621 if (Left.endsSequence(tok::kw_const, Keywords.kw_as)) in spaceRequiredBefore()
4623 if ((Left.isOneOf(Keywords.kw_let, Keywords.kw_var, Keywords.kw_in, in spaceRequiredBefore()
4628 (Left.is(Keywords.kw_of) && Left.Previous && in spaceRequiredBefore()
4629 (Left.Previous->is(tok::identifier) || in spaceRequiredBefore()
4630 Left.Previous->isOneOf(tok::r_square, tok::r_brace)))) && in spaceRequiredBefore()
4631 (!Left.Previous || Left.Previous->isNot(tok::period))) { in spaceRequiredBefore()
4634 if (Left.isOneOf(tok::kw_for, Keywords.kw_as) && Left.Previous && in spaceRequiredBefore()
4635 Left.Previous->is(tok::period) && Right.is(tok::l_paren)) { in spaceRequiredBefore()
4638 if (Left.is(Keywords.kw_as) && in spaceRequiredBefore()
4642 if (Left.is(tok::kw_default) && Left.Previous && in spaceRequiredBefore()
4643 Left.Previous->is(tok::kw_export)) { in spaceRequiredBefore()
4646 if (Left.is(Keywords.kw_is) && Right.is(tok::l_brace)) in spaceRequiredBefore()
4650 if (Left.is(TT_JsTypeOperator) || Right.is(TT_JsTypeOperator)) in spaceRequiredBefore()
4652 if ((Left.is(tok::l_brace) || Right.is(tok::r_brace)) && in spaceRequiredBefore()
4656 if (Left.is(tok::ellipsis)) in spaceRequiredBefore()
4658 if (Left.is(TT_TemplateCloser) && in spaceRequiredBefore()
4668 if (Left.is(TT_NonNullAssertion) && in spaceRequiredBefore()
4673 if (Left.is(tok::r_square) && Right.is(tok::l_brace)) in spaceRequiredBefore()
4676 if (Left.is(tok::l_square) || Right.is(tok::r_square)) in spaceRequiredBefore()
4679 if (Left.is(Keywords.kw_synchronized) && Right.is(tok::l_paren)) { in spaceRequiredBefore()
4683 if ((Left.isOneOf(tok::kw_static, tok::kw_public, tok::kw_private, in spaceRequiredBefore()
4685 Left.isOneOf(Keywords.kw_final, Keywords.kw_abstract, in spaceRequiredBefore()
4692 if (Style.isVerilog() && Left.is(tok::identifier) && in spaceRequiredBefore()
4693 Left.TokenText[0] == '\\') { in spaceRequiredBefore()
4698 if ((Left.is(TT_VerilogTableItem) && in spaceRequiredBefore()
4700 (Right.is(TT_VerilogTableItem) && Left.isNot(tok::l_paren))) { in spaceRequiredBefore()
4705 if (Left.isNot(TT_BinaryOperator) && in spaceRequiredBefore()
4706 Left.isOneOf(Keywords.kw_verilogHash, Keywords.kw_verilogHashHash)) { in spaceRequiredBefore()
4711 (Left.endsSequence(tok::numeric_constant, Keywords.kw_verilogHash) || in spaceRequiredBefore()
4712 Left.endsSequence(tok::numeric_constant, in spaceRequiredBefore()
4714 (Left.is(tok::r_paren) && Left.MatchingParen && in spaceRequiredBefore()
4715 Left.MatchingParen->endsSequence(tok::l_paren, tok::at)))) { in spaceRequiredBefore()
4720 if (Left.is(Keywords.kw_apostrophe) || in spaceRequiredBefore()
4721 (Left.is(TT_VerilogNumberBase) && Right.is(tok::numeric_constant))) { in spaceRequiredBefore()
4725 if (Left.is(tok::arrow) || Right.is(tok::arrow)) in spaceRequiredBefore()
4730 if (Left.is(tok::at) && Right.isOneOf(tok::l_paren, tok::star, tok::at)) in spaceRequiredBefore()
4734 Left.isOneOf(TT_VerilogDimensionedTypeName, Keywords.kw_function)) { in spaceRequiredBefore()
4739 Keywords.isVerilogIdentifier(Left) && Left.getPreviousNonComment() && in spaceRequiredBefore()
4740 Left.getPreviousNonComment()->is(Keywords.kw_tagged)) { in spaceRequiredBefore()
4748 !(Left.isOneOf(Keywords.kw_assign, Keywords.kw_unique) || in spaceRequiredBefore()
4749 Keywords.isVerilogWordOperator(Left)) && in spaceRequiredBefore()
4750 (Left.isOneOf(tok::r_square, tok::r_paren, tok::r_brace, in spaceRequiredBefore()
4752 Keywords.isWordLike(Left))) { in spaceRequiredBefore()
4756 if ((Right.is(tok::star) && Left.is(tok::coloncolon)) || in spaceRequiredBefore()
4757 (Left.is(tok::star) && Right.is(tok::semi))) { in spaceRequiredBefore()
4761 if (Left.endsSequence(tok::star, tok::l_paren) && Right.is(tok::identifier)) in spaceRequiredBefore()
4767 if ((Left.is(tok::l_brace) && in spaceRequiredBefore()
4769 (Left.endsSequence(tok::lessless, tok::l_brace) || in spaceRequiredBefore()
4770 Left.endsSequence(tok::greatergreater, tok::l_brace))) { in spaceRequiredBefore()
4774 if (Left.is(TT_ImplicitStringLiteral)) in spaceRequiredBefore()
4777 if (Left.is(TT_ObjCMethodSpecifier)) in spaceRequiredBefore()
4779 if (Left.is(tok::r_paren) && Left.isNot(TT_AttributeRParen) && in spaceRequiredBefore()
4788 (Right.is(tok::equal) || Left.is(tok::equal))) { in spaceRequiredBefore()
4792 if (Right.is(TT_TrailingReturnArrow) || Left.is(TT_TrailingReturnArrow)) in spaceRequiredBefore()
4795 if (Left.is(tok::comma) && Right.isNot(TT_OverloadedOperatorLParen) && in spaceRequiredBefore()
4798 (Left.Children.empty() || !Left.MacroParent)) { in spaceRequiredBefore()
4813 if (Left.is(TT_BitFieldColon)) { in spaceRequiredBefore()
4827 if (Left.is(tok::question)) in spaceRequiredBefore()
4829 if (Right.is(TT_InlineASMColon) && Left.is(tok::coloncolon)) in spaceRequiredBefore()
4846 if ((Left.isOneOf(tok::minus, tok::minusminus) && in spaceRequiredBefore()
4848 (Left.isOneOf(tok::plus, tok::plusplus) && in spaceRequiredBefore()
4852 if (Left.is(TT_UnaryOperator)) { in spaceRequiredBefore()
4857 if (Left.is(tok::exclaim) && Left.TokenText == "not") in spaceRequiredBefore()
4859 if (Left.is(tok::tilde) && Left.TokenText == "compl") in spaceRequiredBefore()
4863 if (Left.is(tok::amp) && Right.is(tok::r_square)) in spaceRequiredBefore()
4866 return (Style.SpaceAfterLogicalNot && Left.is(tok::exclaim)) || in spaceRequiredBefore()
4872 if (Left.is(TT_CastRParen)) { in spaceRequiredBefore()
4885 if (Left.is(tok::greater) && Right.is(tok::greater)) { in spaceRequiredBefore()
4887 (Style.Language == FormatStyle::LK_Proto && Left.is(TT_DictLiteral))) { in spaceRequiredBefore()
4890 return Right.is(TT_TemplateCloser) && Left.is(TT_TemplateCloser) && in spaceRequiredBefore()
4895 Left.isOneOf(tok::arrow, tok::period, tok::arrowstar, tok::periodstar) || in spaceRequiredBefore()
4899 if (!Style.SpaceBeforeAssignmentOperators && Left.isNot(TT_TemplateCloser) && in spaceRequiredBefore()
4904 (Left.is(tok::identifier) || Left.is(tok::kw_this))) { in spaceRequiredBefore()
4907 if (Right.is(tok::coloncolon) && Left.is(tok::identifier)) { in spaceRequiredBefore()
4914 !Left.isOneOf(tok::l_brace, tok::comment, tok::l_paren)) { in spaceRequiredBefore()
4916 return (Left.is(TT_TemplateOpener) && in spaceRequiredBefore()
4919 !(Left.isOneOf(tok::l_paren, tok::r_paren, tok::l_square, in spaceRequiredBefore()
4922 (Left.is(tok::l_paren) && Style.SpacesInParensOptions.Other); in spaceRequiredBefore()
4924 if ((Left.is(TT_TemplateOpener)) != (Right.is(TT_TemplateCloser))) in spaceRequiredBefore()
4928 return !Left.isOneOf(tok::amp, tok::ampamp) || in spaceRequiredBefore()
4929 getTokenReferenceAlignment(Left) != FormatStyle::PAS_Right; in spaceRequiredBefore()
4936 if ((Right.is(TT_BinaryOperator) && Left.isNot(tok::l_paren)) || in spaceRequiredBefore()
4937 (Left.isOneOf(TT_BinaryOperator, TT_ConditionalExpr) && in spaceRequiredBefore()
4941 if (Right.is(TT_TemplateOpener) && Left.is(tok::r_paren) && in spaceRequiredBefore()
4942 Left.MatchingParen && in spaceRequiredBefore()
4943 Left.MatchingParen->is(TT_OverloadedOperatorLParen)) { in spaceRequiredBefore()
4946 if (Right.is(tok::less) && Left.isNot(tok::l_paren) && in spaceRequiredBefore()
4952 if (Left.is(TT_RegexLiteral)) in spaceRequiredBefore()
4954 return spaceRequiredBetween(Line, Left, Right); in spaceRequiredBefore()
4982 const FormatToken &Left = *Right.Previous; in mustBreakBefore() local
4987 if (Left.is(TT_FatArrow) && Right.is(tok::l_brace) && in mustBreakBefore()
4992 Left.is(TT_CSharpNamedArgumentColon)) { in mustBreakBefore()
5004 if (Left.is(TT_AttributeSquare) && Left.is(tok::r_square) && in mustBreakBefore()
5010 if (Left.is(TT_AttributeSquare) && Right.is(TT_AttributeSquare) && in mustBreakBefore()
5011 Left.is(tok::r_square) && Right.is(tok::l_square)) { in mustBreakBefore()
5017 if (Right.is(tok::string_literal) && Left.is(tok::plus) && Left.Previous && in mustBreakBefore()
5018 Left.Previous->is(tok::string_literal)) { in mustBreakBefore()
5021 if (Left.is(TT_DictLiteral) && Left.is(tok::l_brace) && Line.Level == 0 && in mustBreakBefore()
5022 Left.Previous && Left.Previous->is(tok::equal) && in mustBreakBefore()
5032 if (Left.is(tok::l_brace) && Line.Level == 0 && in mustBreakBefore()
5041 if (Right.is(tok::r_brace) && Left.is(tok::l_brace) && Left.Previous && in mustBreakBefore()
5042 Left.Previous->is(TT_FatArrow)) { in mustBreakBefore()
5050 return !Left.Children.empty(); in mustBreakBefore()
5054 return (Left.NestingLevel == 0 && Line.Level == 0) && in mustBreakBefore()
5055 !Left.Children.empty(); in mustBreakBefore()
5060 if (Right.is(tok::r_brace) && Left.is(tok::l_brace) && in mustBreakBefore()
5061 !Left.Children.empty()) { in mustBreakBefore()
5065 (Left.NestingLevel == 0 && Line.Level == 0 && in mustBreakBefore()
5070 if (Right.is(tok::plus) && Left.is(tok::string_literal) && Right.Next && in mustBreakBefore()
5076 if (Left.is(TT_VerilogAssignComma)) in mustBreakBefore()
5079 if (Left.is(TT_VerilogTypeComma)) in mustBreakBefore()
5084 (Left.is(TT_VerilogInstancePortComma) || in mustBreakBefore()
5085 (Left.is(tok::r_paren) && Keywords.isVerilogIdentifier(Right) && in mustBreakBefore()
5086 Left.MatchingParen && in mustBreakBefore()
5087 Left.MatchingParen->is(TT_VerilogInstancePortLParen)))) { in mustBreakBefore()
5092 if (!Keywords.isVerilogBegin(Right) && Keywords.isVerilogEndOfLabel(Left)) in mustBreakBefore()
5097 if (Left.isStringLiteral() && Right.isStringLiteral()) in mustBreakBefore()
5106 if (Left.is(TT_DictLiteral) && Left.is(tok::l_brace)) in mustBreakBefore()
5109 if ((Left.is(TT_ArrayInitializerLSquare) && Left.is(tok::l_square) && in mustBreakBefore()
5111 Left.is(tok::comma)) { in mustBreakBefore()
5137 if ((Left.isOneOf(tok::l_brace, TT_ArrayInitializerLSquare) || in mustBreakBefore()
5138 (Style.isJavaScript() && Left.is(tok::l_paren))) && in mustBreakBefore()
5139 Left.isNot(BK_Block) && Left.MatchingParen) { in mustBreakBefore()
5140 BeforeClosingBrace = Left.MatchingParen->Previous; in mustBreakBefore()
5146 BeforeClosingBrace = &Left; in mustBreakBefore()
5155 return Left.isNot(BK_BracedInit) && Left.isNot(TT_CtorInitializerColon) && in mustBreakBefore()
5158 if (Left.isTrailingComment()) in mustBreakBefore()
5160 if (Left.IsUnterminatedLiteral) in mustBreakBefore()
5162 if (Right.is(tok::lessless) && Right.Next && Left.is(tok::string_literal) && in mustBreakBefore()
5176 if (Left.ClosesTemplateDeclaration && Left.MatchingParen && in mustBreakBefore()
5177 Left.MatchingParen->NestingLevel == 0) { in mustBreakBefore()
5185 if (Left.ClosesRequiresClause && Right.isNot(tok::semi)) { in mustBreakBefore()
5196 (Left.is(TT_CtorInitializerComma) || in mustBreakBefore()
5202 Left.isOneOf(TT_CtorInitializerColon, TT_CtorInitializerComma)) { in mustBreakBefore()
5219 Left.is(TT_CtorInitializerColon)) { in mustBreakBefore()
5229 Left.is(TT_InheritanceComma)) { in mustBreakBefore()
5238 if ((Left.is(tok::l_brace) || (Left.is(tok::less) && Left.Previous && in mustBreakBefore()
5239 Left.Previous->is(tok::equal))) && in mustBreakBefore()
5248 if (isAllmanBrace(Left) || isAllmanBrace(Right)) { in mustBreakBefore()
5284 if (Left.is(TT_ObjCBlockLBrace) && in mustBreakBefore()
5290 if (Left.isOneOf(TT_AttributeRParen, TT_AttributeMacro) && in mustBreakBefore()
5295 if (Left.is(TT_LambdaLBrace)) { in mustBreakBefore()
5296 if (IsFunctionArgument(Left) && in mustBreakBefore()
5303 (!Left.Children.empty() && in mustBreakBefore()
5310 (Left.isPointerOrReference() || Left.is(TT_TemplateCloser))) { in mustBreakBefore()
5316 Left.is(TT_LeadingJavaAnnotation) && in mustBreakBefore()
5356 if (Left.is(tok::at)) in mustBreakBefore()
5390 if (Left.ParameterCount == 0) in mustBreakBefore()
5405 if (Left.isOneOf(tok::r_brace, tok::greater, tok::r_square)) in mustBreakBefore()
5414 const FormatToken &Left = *Right.Previous; in canBreakBefore() local
5417 if (Left.isOneOf(TT_CSharpNamedArgumentColon, TT_AttributeColon) || in canBreakBefore()
5423 return Left.is(TT_CSharpGenericTypeConstraintComma); in canBreakBefore()
5428 if (Left.isOneOf(Keywords.kw_throws, Keywords.kw_extends, in canBreakBefore()
5449 (Left.Tok.getIdentifierInfo() || in canBreakBefore()
5450 Left.isOneOf(tok::r_square, tok::r_paren)) && in canBreakBefore()
5458 if (Left.is(TT_FatArrow) && Right.is(tok::l_brace)) in canBreakBefore()
5460 if (Left.is(TT_JsTypeColon)) in canBreakBefore()
5463 if (Left.is(tok::exclaim) && Right.is(tok::colon)) in canBreakBefore()
5480 if (Left.is(Keywords.kw_in)) in canBreakBefore()
5492 if (Left.is(Keywords.kw_as)) in canBreakBefore()
5494 if (Left.is(TT_NonNullAssertion)) in canBreakBefore()
5496 if (Left.is(Keywords.kw_declare) && in canBreakBefore()
5505 if (Left.isOneOf(Keywords.kw_module, tok::kw_namespace) && in canBreakBefore()
5513 if (Left.is(tok::identifier) && Right.is(TT_TemplateString)) in canBreakBefore()
5515 if (Left.is(TT_TemplateString) && Left.opensScope()) in canBreakBefore()
5519 if (Left.is(tok::at)) in canBreakBefore()
5521 if (Left.Tok.getObjCKeywordID() == tok::objc_interface) in canBreakBefore()
5523 if (Left.isOneOf(TT_JavaAnnotation, TT_LeadingJavaAnnotation)) in canBreakBefore()
5535 if (Left.is(TT_PointerOrReference)) in canBreakBefore()
5543 return Left.is(BK_BracedInit) || in canBreakBefore()
5544 (Left.is(TT_CtorInitializerColon) && Right.NewlinesBefore > 0 && in canBreakBefore()
5547 if (Left.is(tok::question) && Right.is(tok::colon)) in canBreakBefore()
5551 if (Left.is(TT_ConditionalExpr) || Left.is(tok::question)) in canBreakBefore()
5553 if (Left.is(TT_InheritanceColon)) in canBreakBefore()
5558 Left.isNot(TT_SelectorName)) { in canBreakBefore()
5566 if (Left.is(tok::colon) && Left.isOneOf(TT_DictLiteral, TT_ObjCMethodExpr)) { in canBreakBefore()
5608 return Left.isNot(tok::period); // FIXME: Properly parse ObjC calls. in canBreakBefore()
5610 if (Left.is(tok::r_paren) && Line.Type == LT_ObjCProperty) in canBreakBefore()
5616 if (Left.ClosesTemplateDeclaration || Left.is(TT_FunctionAnnotationRParen)) in canBreakBefore()
5618 if (Left.ClosesRequiresClause) in canBreakBefore()
5624 if (Left.is(TT_RangeBasedForLoopColon)) in canBreakBefore()
5628 if (Left.is(TT_TemplateCloser) && Right.is(TT_TemplateOpener)) in canBreakBefore()
5630 if ((Left.is(tok::greater) && Right.is(tok::greater)) || in canBreakBefore()
5631 (Left.is(tok::less) && Right.is(tok::less))) { in canBreakBefore()
5640 if (Left.isOneOf(TT_TemplateCloser, TT_UnaryOperator) || in canBreakBefore()
5641 Left.is(tok::kw_operator)) { in canBreakBefore()
5644 if (Left.is(tok::equal) && !Right.isOneOf(tok::kw_default, tok::kw_delete) && in canBreakBefore()
5645 Line.Type == LT_VirtualFunctionDecl && Left.NestingLevel == 0) { in canBreakBefore()
5648 if (Left.is(tok::equal) && Right.is(tok::l_brace) && in canBreakBefore()
5652 if (Left.is(TT_AttributeLParen) || in canBreakBefore()
5653 (Left.is(tok::l_paren) && Left.is(TT_TypeDeclarationParen))) { in canBreakBefore()
5656 if (Left.is(tok::l_paren) && Left.Previous && in canBreakBefore()
5657 (Left.Previous->isOneOf(TT_BinaryOperator, TT_CastRParen))) { in canBreakBefore()
5694 if (Left.is(TT_TrailingAnnotation)) { in canBreakBefore()
5703 return Left.isNot(TT_AttributeSquare); in canBreakBefore()
5705 if (Left.is(tok::identifier) && Right.is(tok::string_literal)) in canBreakBefore()
5711 if (Left.is(TT_CtorInitializerColon)) { in canBreakBefore()
5717 if (Left.is(TT_CtorInitializerComma) && in canBreakBefore()
5725 if (Left.is(TT_InheritanceComma) && in canBreakBefore()
5733 if (Left.is(TT_ArrayInitializerLSquare)) in canBreakBefore()
5735 if (Right.is(tok::kw_typename) && Left.isNot(tok::kw_const)) in canBreakBefore()
5737 if ((Left.isBinaryOperator() || Left.is(TT_BinaryOperator)) && in canBreakBefore()
5738 !Left.isOneOf(tok::arrowstar, tok::lessless) && in canBreakBefore()
5741 Left.getPrecedence() == prec::Assignment)) { in canBreakBefore()
5744 if ((Left.is(TT_AttributeSquare) && Right.is(tok::l_square)) || in canBreakBefore()
5745 (Left.is(tok::r_square) && Right.is(TT_AttributeSquare))) { in canBreakBefore()
5751 if (isAllmanLambdaBrace(Left)) in canBreakBefore()
5752 return !isItAnEmptyLambdaAllowed(Left, ShortLambdaOption); in canBreakBefore()
5768 return Left.isOneOf(tok::comma, tok::coloncolon, tok::semi, tok::l_brace, in canBreakBefore()
5773 (Left.is(tok::r_paren) && in canBreakBefore()
5775 (Left.is(tok::l_paren) && Right.isNot(tok::r_paren)) || in canBreakBefore()
5776 (Left.is(TT_TemplateOpener) && Right.isNot(TT_TemplateCloser)); in canBreakBefore()