Lines Matching defs:Current
140 // Returns \c true if \c Current starts the next operand in a binary operation.
141 static bool startsNextOperand(const FormatToken &Current) {
142 assert(Current.Previous);
143 const auto &Previous = *Current.Previous;
144 return isAlignableBinaryOperator(Previous) && !Current.isTrailingComment();
147 // Returns \c true if \c Current is a binary operation that must break.
148 static bool mustBreakBinaryOperation(const FormatToken &Current,
151 Current.CanBreakBefore &&
154 : isAlignableBinaryOperator)(Current);
299 const FormatToken &Current = *State.NextToken;
300 const FormatToken &Previous = *Current.Previous;
302 assert(&Previous == Current.Previous);
303 if (!Current.CanBreakBefore && !(CurrentState.BreakBeforeClosingBrace &&
304 Current.closesBlockOrBlockTypeList(Style))) {
309 if (!Current.MustBreakBefore && Previous.is(tok::l_brace) &&
322 State.LowestLevelOnLine < Current.NestingLevel) {
325 if (Current.isMemberAccess() && CurrentState.ContainsUnwrappedBuilder)
339 if (Current.is(TT_FunctionDeclarationName)) {
354 if (Current.is(tok::r_brace) && Current.MatchingParen &&
355 Current.isBlockIndentedInitRBrace(Style)) {
361 if (!Current.isOneOf(TT_BinaryOperator, tok::comma) &&
366 Current.isNot(TT_LambdaLBrace)) &&
374 if (Current.is(TT_ConditionalExpr) && Previous.is(tok::r_paren) &&
387 const FormatToken &Current = *State.NextToken;
388 const FormatToken &Previous = *Current.Previous;
390 if (Style.BraceWrapping.BeforeLambdaBody && Current.CanBreakBefore &&
391 Current.is(TT_LambdaLBrace) && Previous.isNot(TT_LineComment)) {
392 auto LambdaBodyLength = getLengthToMatchingParen(Current, State.Stack);
395 if (Current.MustBreakBefore ||
396 (Current.is(TT_InlineASMColon) &&
403 (Current.closesBlockOrBlockTypeList(Style) ||
404 (Current.is(tok::r_brace) &&
405 Current.isBlockIndentedInitRBrace(Style)))) {
408 if (CurrentState.BreakBeforeClosingParen && Current.is(tok::r_paren))
412 Current.ObjCSelectorNameParts > 1 &&
413 Current.startsSequence(TT_SelectorName, tok::colon, tok::caret)) {
422 if ((startsNextParameter(Current, Style) || Previous.is(tok::semi) ||
423 (Previous.is(TT_TemplateCloser) && Current.is(TT_StartOfName) &&
431 (Style.BreakBeforeTernaryOperators && Current.is(TT_ConditionalExpr) &&
435 CurrentState.BreakBeforeParameter && !Current.isTrailingComment() &&
436 !Current.isOneOf(tok::r_paren, tok::r_brace)) {
440 ((Style.BreakBeforeTernaryOperators && Current.is(TT_ConditionalExpr) &&
441 Current.is(tok::colon)) ||
459 : Current;
464 (!Current.isTrailingComment() || Current.NewlinesBefore > 0) &&
466 Style.ColumnLimit > 0 || Current.NewlinesBefore > 0)) {
470 if (Current.is(TT_ObjCMethodExpr) && Previous.isNot(TT_SelectorName) &&
474 if (Current.is(TT_SelectorName) && Previous.isNot(tok::at) &&
477 !Current.startsSequence(TT_SelectorName, tok::colon, tok::caret))) {
482 if (Current.isMemberAccess() && Style.ColumnLimit != 0 &&
483 State.Column + getLengthToNextOperator(Current) > Style.ColumnLimit &&
485 Current.NestingLevel < State.StartOfLineLevel)) {
489 if (startsSegmentOfBuilderTypeCall(Current) &&
505 Current.CanBreakBefore) {
514 Previous.is(tok::comma) || Current.NestingLevel < 2) &&
525 if (Previous.is(TT_BinaryOperator) && Current.CanBreakBefore) {
528 CurrentState.BreakBeforeParameter && !Current.isTrailingComment()) {
551 } else if (Current.is(TT_BinaryOperator) && Current.CanBreakBefore &&
557 if (Current.is(tok::lessless) && Current.isNot(TT_OverloadedOperator) &&
562 if (Current.NestingLevel == 0 && !Current.isTrailingComment()) {
568 if (Current.is(tok::kw_concept)) {
578 if (Current.is(TT_RequiresClause)) {
589 Current.NewlinesBefore > 0);
595 if (Previous.is(TT_LeadingJavaAnnotation) && Current.isNot(tok::l_paren) &&
596 Current.isNot(TT_LeadingJavaAnnotation)) {
607 if (BreakBeforeDecoratedTokens.contains(Current.TokenText))
611 if (Current.is(TT_FunctionDeclarationName) &&
628 !Current.isOneOf(tok::r_brace, tok::comment)) {
632 if (Current.is(tok::lessless) &&
651 const FormatToken &Current = *State.NextToken;
658 if (Current.is(TT_ImplicitStringLiteral) &&
663 SourceMgr.getSpellingColumnNumber(Current.WhitespaceRange.getEnd());
664 if (Current.LastNewlineOffset != 0) {
670 SourceMgr.getSpellingColumnNumber(Current.WhitespaceRange.getBegin());
689 FormatToken &Current = *State.NextToken;
703 if (Previous.is(TT_BlockComment) && Current.SpacesRequiredBefore == 0)
705 const auto *PrevNonComment = Current.getPreviousNonComment();
708 if (Current.isOneOf(tok::comment, tok::l_paren, TT_LambdaLSquare))
732 if (Current.is(tok::equal) &&
733 (State.Line->First->is(tok::kw_for) || Current.NestingLevel == 0) &&
750 unsigned Spaces = Current.SpacesRequiredBefore + ExtraSpaces;
770 Whitespaces.replaceWhitespace(Current, /*Newlines=*/0, Spaces,
778 Current.is(TT_InheritanceColon)) {
786 if (Current.is(TT_SelectorName) && !CurrentState.ObjCSelectorNameFound) {
789 unsigned FirstColonPos = State.Column + Spaces + Current.ColumnWidth;
790 if (Current.LongestObjCSelectorName == 0)
792 else if (MinIndent + Current.LongestObjCSelectorName > FirstColonPos)
793 CurrentState.ColonPos = MinIndent + Current.LongestObjCSelectorName;
879 !StartsSimpleOneArgList(Current)) {
895 !(Current.MacroParent && Previous.MacroParent) &&
896 (Current.isNot(TT_LineComment) ||
898 !IsInTemplateString(Current)) {
902 if (CurrentState.AvoidBinPacking && startsNextParameter(Current, Style))
904 if (mustBreakBinaryOperation(Current, Style))
907 if (startsSegmentOfBuilderTypeCall(Current) &&
912 if (Current.is(TT_LambdaArrow) && Style.Language == FormatStyle::LK_Java)
914 if (Current.isMemberAccess() && Previous.is(tok::r_paren) &&
930 const FormatToken *P = Current.getPreviousNonComment();
931 if (Current.isNot(tok::comment) && P &&
957 if (Current.isNot(tok::comment) && Previous.is(tok::l_paren) &&
964 } else if (!Current.isOneOf(tok::comment, tok::caret) &&
970 (!Current.isTrailingComment() || Current.NewlinesBefore > 0) &&
981 Current.StartsBinaryExpression)) {
989 } else if (Current.is(TT_CSharpGenericTypeConstraintColon)) {
1009 FormatToken &Current = *State.NextToken;
1018 const FormatToken *PreviousNonComment = Current.getPreviousNonComment();
1021 NextNonComment = &Current;
1068 if (Current.isNot(TT_LambdaArrow) &&
1069 (!Style.isJavaScript() || Current.NestingLevel != 0 ||
1071 !Current.isOneOf(Keywords.kw_async, Keywords.kw_function))) {
1122 Current.NestingLevel == 0) {
1129 if (Current.is(TT_BinaryOperator) && Current.CanBreakBefore)
1134 if (Current.is(tok::r_brace) && Current.MatchingParen &&
1137 !Current.MatchingParen->Children.empty()) {
1144 std::max(1u, std::min(Current.NewlinesBefore, MaxEmptyLinesToKeep));
1147 Whitespaces.replaceWhitespace(Current, Newlines, State.Column, State.Column,
1151 if (!Current.isTrailingComment())
1153 if (Current.is(tok::lessless)) {
1160 State.StartOfLineLevel = Current.NestingLevel;
1161 State.LowestLevelOnLine = Current.NestingLevel;
1166 (!Style.isCpp() && Current.is(tok::r_brace) && State.Stack.size() > 1 &&
1168 (Style.Language == FormatStyle::LK_ObjC && Current.is(tok::r_brace) &&
1173 (Current.MatchingParen &&
1174 Current.MatchingParen->is(TT_RequiresExpressionLBrace));
1178 Current.MatchingParen && Current.MatchingParen->is(TT_LambdaLBrace)) {
1214 Current.NestingLevel != 0) &&
1218 Current.isNot(TT_BinaryOperator) && !PreviousNonComment->opensScope() &&
1222 Current.isNot(TT_LambdaLBrace))) {
1271 if (mustBreakBinaryOperation(Current, Style))
1281 FormatToken &Current = *State.NextToken;
1285 Current.isNot(TT_CSharpGenericTypeConstraint)) {
1289 const FormatToken &Previous = *Current.Previous;
1294 const FormatToken *PreviousNonComment = Current.getPreviousNonComment();
1297 NextNonComment = &Current;
1301 Current.isOneOf(Keywords.kw_implements, Keywords.kw_extends)) {
1321 if (Current.NestingLevel == 0 ||
1328 if (Current.is(TT_LambdaArrow) &&
1333 if ((Current.isOneOf(tok::r_brace, tok::r_square) ||
1334 (Current.is(tok::greater) && (Style.isProto() || Style.isTableGen()))) &&
1336 if (Current.closesBlockOrBlockTypeList(Style))
1338 if (Current.MatchingParen && Current.MatchingParen->is(BK_BracedInit))
1357 if (Current.is(tok::r_paren) && State.Stack.size() > 1 &&
1358 (!Current.Next ||
1359 Current.Next->isOneOf(tok::semi, tok::kw_const, tok::l_brace))) {
1364 if (Style.isTableGen() && Current.is(TT_TableGenDAGArgCloser) &&
1369 (Current.is(tok::r_paren) ||
1370 (Current.is(tok::r_brace) && Current.MatchingParen &&
1371 Current.MatchingParen->is(BK_BracedInit))) &&
1384 if (Current.is(tok::identifier) && Current.Next &&
1385 (!Style.isVerilog() || Current.Next->is(tok::colon)) &&
1386 (Current.Next->is(TT_DictLiteral) ||
1387 (Style.isProto() && Current.Next->isOneOf(tok::less, tok::l_brace)))) {
1410 (Previous.is(tok::colon) && !Current.FakeLParens.empty() &&
1411 Current.FakeLParens.back() == prec::Conditional)) &&
1428 if (Current.is(TT_RequiresClause)) {
1448 Current.isNot(tok::l_paren)) ||
1530 !Current.isBinaryOperator() &&
1531 !Current.isOneOf(tok::colon, tok::comment)) {
1534 if (Current.is(TT_ProtoExtensionLSquare))
1536 if (Current.isBinaryOperator() && CurrentState.UnindentOperator) {
1537 return CurrentState.Indent - Current.Tok.getLength() -
1538 Current.SpacesRequiredBefore;
1540 if (Current.is(tok::comment) && NextNonComment->isBinaryOperator() &&
1555 const FormatToken &Current,
1563 return Style.BraceWrapping.BeforeLambdaBody && Current.is(TT_LambdaLSquare);
1569 const FormatToken &Current = *State.NextToken;
1572 if (Current.is(TT_CSharpGenericTypeConstraint))
1574 if (Current.isOneOf(tok::comma, TT_BinaryOperator))
1576 if (Current.isOneOf(TT_InheritanceColon, TT_CSharpGenericTypeConstraintColon))
1578 if (Current.is(tok::lessless) && Current.isNot(TT_OverloadedOperator)) {
1584 if (Current.is(TT_BinaryOperator) && Current.isNot(tok::lessless))
1586 if (Current.is(TT_ConditionalExpr) && Current.Previous &&
1587 Current.Previous->isNot(TT_ConditionalExpr)) {
1590 if (Current.is(TT_ArraySubscriptLSquare) &&
1604 if (IsWrappedConditional(Current))
1606 if (Style.BreakBeforeTernaryOperators && Current.is(tok::question))
1608 if (!Style.BreakBeforeTernaryOperators && Current.isNot(tok::colon)) {
1609 const FormatToken *Previous = Current.Previous;
1615 if (!Current.opensScope() && !Current.closesScope() &&
1616 Current.isNot(TT_PointerOrReference)) {
1618 std::min(State.LowestLevelOnLine, Current.NestingLevel);
1620 if (Current.isMemberAccess())
1621 CurrentState.StartOfFunctionCall = !Current.NextOperator ? 0 : State.Column;
1622 if (Current.is(TT_SelectorName))
1624 if (Current.is(TT_CtorInitializerColon) &&
1646 if (Current.is(TT_CtorInitializerColon) &&
1656 if (Current.is(TT_InheritanceColon)) {
1660 if (Current.isOneOf(TT_BinaryOperator, TT_ConditionalExpr) && Newline)
1661 CurrentState.NestedBlockIndent = State.Column + Current.ColumnWidth + 1;
1662 if (Current.isOneOf(TT_LambdaLSquare, TT_LambdaArrow))
1664 if (Current.is(TT_RequiresExpression) &&
1670 const FormatToken *Previous = Current.getPreviousNonComment();
1678 if (Current.isNot(tok::comment) && !Current.ClosesRequiresClause &&
1691 !Newline && hasNestedBlockInlined(Previous, Current, Style);
1703 if (Current.is(TT_ObjCStringLiteral) && State.StartOfStringLiteral == 0)
1705 if (Current.is(TT_CSharpStringLiteral) && State.StartOfStringLiteral == 0) {
1707 } else if (Current.is(TT_TableGenMultiLineString) &&
1710 } else if (Current.isStringLiteral() && State.StartOfStringLiteral == 0) {
1712 } else if (!Current.isOneOf(tok::comment, tok::identifier, tok::hash) &&
1713 !Current.isStringLiteral()) {
1717 State.Column += Current.ColumnWidth;
1725 Keywords.isVerilogEndOfLabel(Current)) {
1731 handleEndOfLine(Current, State, DryRun, AllowBreak, Newline);
1733 if (Current.Role)
1734 Current.Role->formatFromToken(State, this, DryRun);
1748 const FormatToken &Current = *State.NextToken;
1749 if (Current.FakeLParens.empty())
1752 const FormatToken *Previous = Current.getPreviousNonComment();
1764 for (const auto &PrecedenceLevel : llvm::reverse(Current.FakeLParens)) {
1783 if (!Current.isTrailingComment() &&
1789 PrecedenceLevel > prec::Comma || Current.NestingLevel == 0) &&
1806 if ((shouldUnindentNextOperator(Current) ||
1829 Current.isNot(TT_UnaryOperator) &&
1841 &PrecedenceLevel == &Current.FakeLParens.back() &&
1847 !Current.isTrailingComment())) {
1877 const FormatToken &Current = *State.NextToken;
1878 if (!Current.opensScope())
1884 if (Current.isOneOf(tok::less, tok::l_paren) &&
1889 if (Current.MatchingParen && Current.is(BK_Block)) {
1900 if (Current.isOneOf(tok::l_brace, TT_ArrayInitializerLSquare) ||
1901 opensProtoMessageField(Current, Style)) {
1902 if (Current.opensBlockOrBlockTypeList(Style)) {
1905 } else if (Current.is(tok::l_brace)) {
1912 const FormatToken *NextNonComment = Current.getNextNonComment();
1913 bool EndsInComma = Current.MatchingParen &&
1914 Current.MatchingParen->Previous &&
1915 Current.MatchingParen->Previous->is(tok::comma);
1916 AvoidBinPacking = EndsInComma || Current.is(TT_DictLiteral) ||
1922 if (Current.ParameterCount > 1)
1929 if (Style.isTableGen() && Current.is(TT_TableGenDAGArgOpenerToBreak) &&
1935 const FormatToken *Next = Current.Next;
1944 if (Current.is(tok::less) && Current.ParentBracket == tok::l_paren) {
1950 Current.MatchingParen &&
1951 Current.MatchingParen->getPreviousNonComment() &&
1952 Current.MatchingParen->getPreviousNonComment()->is(tok::comma);
1967 Current.getPreviousNonComment() &&
1968 Current.getPreviousNonComment()->is(tok::kw__Generic);
1976 (Current.is(PPK_OnePerLine) ||
1977 (!BinPackInconclusiveFunctions && Current.is(PPK_Inconclusive))));
1979 if (Current.is(TT_ObjCMethodExpr) && Current.MatchingParen &&
1984 if (getLengthToMatchingParen(Current, State.Stack) + State.Column >
1991 for (const FormatToken *Tok = &Current;
1992 Tok && Tok != Current.MatchingParen; Tok = Tok->Next) {
2009 Current.Children.empty() &&
2010 !Current.isOneOf(TT_DictLiteral, TT_ArrayInitializerLSquare) &&
2012 (Current.is(TT_TemplateOpener) &&
2015 ParenState(&Current, NewIndent, LastSpace, AvoidBinPacking, NoLineBreak));
2019 NewState.HasMultipleNestedBlocks = (Current.BlockParameterCount > 1);
2021 if (Style.BraceWrapping.BeforeLambdaBody && Current.Next &&
2022 Current.is(tok::l_paren)) {
2024 FormatToken const *next = Current.Next;
2034 NewState.IsInsideObjCArrayLiteral = Current.is(TT_ArrayInitializerLSquare) &&
2035 Current.Previous &&
2036 Current.Previous->is(tok::at);
2040 const FormatToken &Current = *State.NextToken;
2041 if (!Current.closesScope())
2047 (Current.isOneOf(tok::r_paren, tok::r_square, TT_TemplateString) ||
2048 (Current.is(tok::r_brace) && State.NextToken != State.Line->First) ||
2051 (Current.is(tok::greater) && Current.is(TT_DictLiteral)))) {
2067 if (CurrentState.BreakBeforeParameter && Current.MatchingParen &&
2068 Current.MatchingParen->Previous) {
2069 const FormatToken &CurrentScopeOpener = *Current.MatchingParen->Previous;
2074 CurrentScopeOpener.TotalLength - Current.TotalLength - 1;
2075 if (State.Column + Current.ColumnWidth + NecessarySpaceInLine <=
2082 if (Current.is(tok::r_square)) {
2084 const FormatToken *NextNonComment = Current.getNextNonComment();
2132 const FormatToken &Current, LineState &State,
2134 unsigned StartColumn = State.Column - Current.ColumnWidth;
2135 StringRef OldDelimiter = *getRawStringDelimiter(Current.TokenText);
2147 Current.TokenText.substr(OldPrefixSize).drop_back(OldSuffixSize));
2171 bool ContentStartsOnNewline = Current.TokenText[OldPrefixSize] == '\n';
2194 (!Newline && Current.Next && Current.Next->is(tok::r_paren))
2210 Current.NewlinesBefore ? FirstStartColumn - NewPrefixSize : CurrentIndent;
2220 return addMultilineToken(Current, State);
2226 Current.Tok.getLocation().getLocWithOffset(2);
2237 Current.Tok.getLocation().getLocWithOffset(Current.TokenText.size() -
2248 Current.Tok.getLocation().getLocWithOffset(OldPrefixSize);
2279 unsigned ContinuationIndenter::addMultilineToken(const FormatToken &Current,
2288 State.Column = Current.LastLineColumnWidth;
2295 unsigned ContinuationIndenter::handleEndOfLine(const FormatToken &Current,
2301 auto RawStringStyle = getRawStringStyle(Current, State);
2302 if (RawStringStyle && !Current.Finalized) {
2303 Penalty = reformatRawStringLiteral(Current, State, *RawStringStyle, DryRun,
2305 } else if (Current.IsMultiline && Current.isNot(TT_BlockComment)) {
2308 Penalty = addMultilineToken(Current, State);
2320 Current, State, AllowBreak, /*DryRun=*/true, Strict);
2326 breakProtrudingToken(Current, StrictState, AllowBreak,
2338 breakProtrudingToken(Current, OriginalState, AllowBreak, /*DryRun=*/false,
2351 static StringRef getEnclosingFunctionName(const FormatToken &Current) {
2352 // Look for: 'function(' or 'function<templates>(' before Current.
2353 auto Tok = Current.getPreviousNonComment();
2370 ContinuationIndenter::getRawStringStyle(const FormatToken &Current,
2372 if (!Current.isStringLiteral())
2374 auto Delimiter = getRawStringDelimiter(Current.TokenText);
2380 getEnclosingFunctionName(Current));
2389 ContinuationIndenter::createBreakableToken(const FormatToken &Current,
2391 unsigned StartColumn = State.Column - Current.ColumnWidth;
2392 if (Current.isStringLiteral()) {
2409 if (Current.IsUnterminatedLiteral)
2420 if (Style.isVerilog() && Current.Previous &&
2421 Current.Previous->isOneOf(tok::kw_export, Keywords.kw_import)) {
2424 StringRef Text = Current.TokenText;
2428 // UnbreakableTailLength of Current is an overapproximation in that case and
2432 : Current.UnbreakableTailLength;
2449 Current, QuoteStyle,
2450 /*UnindentPlus=*/shouldUnindentNextOperator(Current), StartColumn,
2469 Current, StartColumn, Prefix, Postfix, UnbreakableTailLength,
2472 } else if (Current.is(TT_BlockComment)) {
2477 switchesFormatting(Current)) {
2481 Current, StartColumn, Current.OriginalColumn, !Current.Previous,
2483 } else if (Current.is(TT_LineComment) &&
2484 (!Current.Previous ||
2485 Current.Previous->isNot(TT_ImplicitStringLiteral))) {
2487 for (const FormatToken *T = &Current; T && T->is(TT_LineComment);
2495 CommentPragmasRegex.match(Current.TokenText.substr(2)) ||
2496 switchesFormatting(Current) || !RegularComments) {
2500 Current, StartColumn, /*InPPDirective=*/false, Encoding, Style);
2506 ContinuationIndenter::breakProtrudingToken(const FormatToken &Current,
2510 createBreakableToken(Current, State, AllowBreak);
2515 if (Current.is(TT_LineComment)) {
2524 if (Current.UnbreakableTailLength >= ColumnLimit)
2528 unsigned StartColumn = State.Column - Current.ColumnWidth;
2529 unsigned NewBreakPenalty = Current.isStringLiteral()
2865 Current.UnbreakableTailLength;
2874 if (Current.isNot(TT_LineComment))
2878 if (Current.is(TT_BlockComment))
2895 const FormatToken &Current = *State.NextToken;
2896 if (!Current.isStringLiteral() || Current.is(TT_ImplicitStringLiteral))
2901 if (Current.TokenText.starts_with("R\""))
2903 if (Current.IsMultiline)
2905 if (Current.getNextNonComment() &&
2906 Current.getNextNonComment()->isStringLiteral()) {
2910 State.Column + Current.ColumnWidth + Current.UnbreakableTailLength >