Lines Matching refs:Current
934 void updateParameterCount(FormatToken *Left, FormatToken *Current) { in updateParameterCount() argument
938 if (Current->is(tok::l_brace) && Current->is(BK_Block)) in updateParameterCount()
940 if (Current->is(tok::comma)) { in updateParameterCount()
944 Left->Role->CommaFound(Current); in updateParameterCount()
945 } else if (Left->ParameterCount == 0 && Current->isNot(tok::comment)) { in updateParameterCount()
1807 void modifyContext(const FormatToken &Current) { in modifyContext() argument
1809 if (Current.getPrecedence() != prec::Assignment) in modifyContext()
1815 assert(Current.Previous); in modifyContext()
1816 if (Current.Previous->is(tok::kw_operator)) { in modifyContext()
1832 assert(Current.Previous->Previous); in modifyContext()
1833 return !Current.Previous->Previous->isOneOf(tok::kw_typename, in modifyContext()
1861 return !Current.Previous || Current.Previous->isNot(tok::kw_operator); in modifyContext()
1867 for (FormatToken *Previous = Current.Previous; in modifyContext()
1885 } else if (Current.is(tok::lessless) && in modifyContext()
1886 (!Current.Previous || in modifyContext()
1887 Current.Previous->isNot(tok::kw_operator))) { in modifyContext()
1889 } else if (Current.isOneOf(tok::kw_return, tok::kw_throw)) { in modifyContext()
1891 } else if (Current.is(TT_TrailingReturnArrow)) { in modifyContext()
1893 } else if (Current.is(Keywords.kw_assert)) { in modifyContext()
1895 } else if (Current.Previous && in modifyContext()
1896 Current.Previous->is(TT_CtorInitializerColon)) { in modifyContext()
1899 } else if (Current.Previous && Current.Previous->is(TT_InheritanceColon)) { in modifyContext()
1901 } else if (Current.isOneOf(tok::r_paren, tok::greater, tok::comma)) { in modifyContext()
1902 for (FormatToken *Previous = Current.Previous; in modifyContext()
1911 } else if (Current.is(tok::kw_new)) { in modifyContext()
1913 } else if (Current.is(tok::semi) || in modifyContext()
1914 (Current.is(tok::exclaim) && Current.Previous && in modifyContext()
1915 Current.Previous->isNot(tok::kw_operator))) { in modifyContext()
1923 static FormatToken *untilMatchingParen(FormatToken *Current) { in untilMatchingParen() argument
1926 while (Current) { in untilMatchingParen()
1927 if (Current->is(tok::l_paren)) in untilMatchingParen()
1929 if (Current->is(tok::r_paren)) in untilMatchingParen()
1933 Current = Current->Next; in untilMatchingParen()
1935 return Current; in untilMatchingParen()
1938 static bool isDeductionGuide(FormatToken &Current) { in isDeductionGuide() argument
1940 if (Current.Previous && Current.Previous->is(tok::r_paren) && in isDeductionGuide()
1941 Current.startsSequence(tok::arrow, tok::identifier, tok::less)) { in isDeductionGuide()
1943 FormatToken *TemplateCloser = Current.Next->Next; in isDeductionGuide()
1965 Current.Previous->MatchingParen) { in isDeductionGuide()
1969 Current.Previous->MatchingParen->Previous; in isDeductionGuide()
1972 LeadingIdentifier->TokenText == Current.Next->TokenText; in isDeductionGuide()
1978 void determineTokenType(FormatToken &Current) { in determineTokenType() argument
1979 if (Current.isNot(TT_Unknown)) { in determineTokenType()
1985 Current.is(tok::exclaim)) { in determineTokenType()
1986 if (Current.Previous) { in determineTokenType()
1990 *Current.Previous, /* AcceptIdentifierName= */ true) in determineTokenType()
1991 : Current.Previous->is(tok::identifier); in determineTokenType()
1993 Current.Previous->isOneOf( in determineTokenType()
1997 Current.Previous->Tok.isLiteral()) { in determineTokenType()
1998 Current.setType(TT_NonNullAssertion); in determineTokenType()
2002 if (Current.Next && in determineTokenType()
2003 Current.Next->isOneOf(TT_BinaryOperator, Keywords.kw_as)) { in determineTokenType()
2004 Current.setType(TT_NonNullAssertion); in determineTokenType()
2012 if (Current.is(Keywords.kw_instanceof)) { in determineTokenType()
2013 Current.setType(TT_BinaryOperator); in determineTokenType()
2014 } else if (isStartOfName(Current) && in determineTokenType()
2015 (!Line.MightBeFunctionDecl || Current.NestingLevel != 0)) { in determineTokenType()
2016 Contexts.back().FirstStartOfName = &Current; in determineTokenType()
2017 Current.setType(TT_StartOfName); in determineTokenType()
2018 } else if (Current.is(tok::semi)) { in determineTokenType()
2023 } else if (Current.isOneOf(tok::kw_auto, tok::kw___auto_type)) { in determineTokenType()
2025 } else if (Current.is(tok::arrow) && in determineTokenType()
2027 Current.setType(TT_TrailingReturnArrow); in determineTokenType()
2028 } else if (Current.is(tok::arrow) && Style.isVerilog()) { in determineTokenType()
2030 Current.setType(TT_BinaryOperator); in determineTokenType()
2031 } else if (Current.is(tok::arrow) && AutoFound && in determineTokenType()
2032 Line.MightBeFunctionDecl && Current.NestingLevel == 0 && in determineTokenType()
2033 !Current.Previous->isOneOf(tok::kw_operator, tok::identifier)) { in determineTokenType()
2035 Current.setType(TT_TrailingReturnArrow); in determineTokenType()
2036 } else if (Current.is(tok::arrow) && Current.Previous && in determineTokenType()
2037 Current.Previous->is(tok::r_brace)) { in determineTokenType()
2040 Current.setType(TT_TrailingReturnArrow); in determineTokenType()
2041 } else if (isDeductionGuide(Current)) { in determineTokenType()
2043 Current.setType(TT_TrailingReturnArrow); in determineTokenType()
2044 } else if (Current.isPointerOrReference()) { in determineTokenType()
2045 Current.setType(determineStarAmpUsage( in determineTokenType()
2046 Current, in determineTokenType()
2049 } else if (Current.isOneOf(tok::minus, tok::plus, tok::caret) || in determineTokenType()
2050 (Style.isVerilog() && Current.is(tok::pipe))) { in determineTokenType()
2051 Current.setType(determinePlusMinusCaretUsage(Current)); in determineTokenType()
2052 if (Current.is(TT_UnaryOperator) && Current.is(tok::caret)) in determineTokenType()
2054 } else if (Current.isOneOf(tok::minusminus, tok::plusplus)) { in determineTokenType()
2055 Current.setType(determineIncrementUsage(Current)); in determineTokenType()
2056 } else if (Current.isOneOf(tok::exclaim, tok::tilde)) { in determineTokenType()
2057 Current.setType(TT_UnaryOperator); in determineTokenType()
2058 } else if (Current.is(tok::question)) { in determineTokenType()
2063 Current.setType(TT_JsTypeOptionalQuestion); in determineTokenType()
2065 Current.setType(TT_ConditionalExpr); in determineTokenType()
2067 } else if (Current.isBinaryOperator() && in determineTokenType()
2068 (!Current.Previous || Current.Previous->isNot(tok::l_square)) && in determineTokenType()
2069 (Current.isNot(tok::greater) && in determineTokenType()
2072 if (Current.is(tok::lessequal) && Contexts.size() == 1 && in determineTokenType()
2076 Current.ForcedPrecedence = prec::Assignment; in determineTokenType()
2077 Current.setFinalizedType(TT_BinaryOperator); in determineTokenType()
2079 if (Current.getPrecedence() == prec::Assignment) in determineTokenType()
2082 Current.setType(TT_BinaryOperator); in determineTokenType()
2083 } else if (Current.is(tok::comment)) { in determineTokenType()
2084 if (Current.TokenText.starts_with("/*")) { in determineTokenType()
2085 if (Current.TokenText.ends_with("*/")) { in determineTokenType()
2086 Current.setType(TT_BlockComment); in determineTokenType()
2090 Current.Tok.setKind(tok::unknown); in determineTokenType()
2093 Current.setType(TT_LineComment); in determineTokenType()
2095 } else if (Current.is(tok::string_literal)) { in determineTokenType()
2097 Current.getPreviousNonComment() && in determineTokenType()
2098 Current.getPreviousNonComment()->isOneOf(tok::comma, tok::l_brace) && in determineTokenType()
2099 Current.getNextNonComment() && in determineTokenType()
2100 Current.getNextNonComment()->isOneOf(tok::comma, tok::r_brace)) { in determineTokenType()
2101 Current.setType(TT_StringInConcatenation); in determineTokenType()
2103 } else if (Current.is(tok::l_paren)) { in determineTokenType()
2104 if (lParenStartsCppCast(Current)) in determineTokenType()
2105 Current.setType(TT_CppCastLParen); in determineTokenType()
2106 } else if (Current.is(tok::r_paren)) { in determineTokenType()
2107 if (rParenEndsCast(Current)) in determineTokenType()
2108 Current.setType(TT_CastRParen); in determineTokenType()
2109 if (Current.MatchingParen && Current.Next && in determineTokenType()
2110 !Current.Next->isBinaryOperator() && in determineTokenType()
2111 !Current.Next->isOneOf(tok::semi, tok::colon, tok::l_brace, in determineTokenType()
2114 if (FormatToken *AfterParen = Current.MatchingParen->Next; in determineTokenType()
2117 if (FormatToken *BeforeParen = Current.MatchingParen->Previous; in determineTokenType()
2124 Current.setType(TT_FunctionAnnotationRParen); in determineTokenType()
2128 } else if (Current.is(tok::at) && Current.Next && !Style.isJavaScript() && in determineTokenType()
2132 switch (Current.Next->Tok.getObjCKeywordID()) { in determineTokenType()
2136 Current.setType(TT_ObjCDecl); in determineTokenType()
2139 Current.setType(TT_ObjCProperty); in determineTokenType()
2144 } else if (Current.is(tok::period)) { in determineTokenType()
2145 FormatToken *PreviousNoComment = Current.getPreviousNonComment(); in determineTokenType()
2148 Current.setType(TT_DesignatedInitializerPeriod); in determineTokenType()
2149 } else if (Style.Language == FormatStyle::LK_Java && Current.Previous && in determineTokenType()
2150 Current.Previous->isOneOf(TT_JavaAnnotation, in determineTokenType()
2152 Current.setType(Current.Previous->getType()); in determineTokenType()
2154 } else if (canBeObjCSelectorComponent(Current) && in determineTokenType()
2157 Current.Previous && Current.Previous->is(TT_CastRParen) && in determineTokenType()
2158 Current.Previous->MatchingParen && in determineTokenType()
2159 Current.Previous->MatchingParen->Previous && in determineTokenType()
2160 Current.Previous->MatchingParen->Previous->is( in determineTokenType()
2165 Current.setType(TT_SelectorName); in determineTokenType()
2166 } else if (Current.isOneOf(tok::identifier, tok::kw_const, tok::kw_noexcept, in determineTokenType()
2168 Current.Previous && in determineTokenType()
2169 !Current.Previous->isOneOf(tok::equal, tok::at, in determineTokenType()
2175 Current.setType(TT_TrailingAnnotation); in determineTokenType()
2178 Current.Previous) { in determineTokenType()
2179 if (Current.Previous->is(tok::at) && in determineTokenType()
2180 Current.isNot(Keywords.kw_interface)) { in determineTokenType()
2181 const FormatToken &AtToken = *Current.Previous; in determineTokenType()
2184 Current.setType(TT_LeadingJavaAnnotation); in determineTokenType()
2186 Current.setType(TT_JavaAnnotation); in determineTokenType()
2187 } else if (Current.Previous->is(tok::period) && in determineTokenType()
2188 Current.Previous->isOneOf(TT_JavaAnnotation, in determineTokenType()
2190 Current.setType(Current.Previous->getType()); in determineTokenType()
2732 : Style(Style), Keywords(Keywords), Line(Line), Current(Line.First) {} in ExpressionParser()
2738 while (Current && (Current->is(tok::kw_return) || in parse()
2739 (Current->is(tok::colon) && in parse()
2740 Current->isOneOf(TT_ObjCMethodExpr, TT_DictLiteral)))) { in parse()
2744 if (!Current || Precedence > PrecedenceArrowAndPeriod) in parse()
2760 FormatToken *Start = Current; in parse()
2766 while (Current) { in parse()
2783 if (Precedence == CurrentPrecedence && Current && in parse()
2784 Current->is(TT_SelectorName)) { in parse()
2787 Start = Current; in parse()
2792 Precedence == prec::Additive && Current) { in parse()
2795 FormatToken *Prev = Current->getPreviousNonComment(); in parse()
2805 if (!Current || in parse()
2806 (Current->closesScope() && in parse()
2807 (Current->MatchingParen || Current->is(TT_TemplateString))) || in parse()
2810 Precedence == prec::Assignment && Current->is(tok::colon))) { in parse()
2817 if (Current->opensScope() || in parse()
2818 Current->isOneOf(TT_RequiresClause, in parse()
2822 while (Current && (!Current->closesScope() || Current->opensScope())) { in parse()
2831 LatestOperator->NextOperator = Current; in parse()
2832 LatestOperator = Current; in parse()
2833 Current->OperatorIndex = OperatorIndex; in parse()
2844 if (LatestOperator && (Current || Precedence > 0)) { in parse()
2853 auto Ret = Current ? Current : Line.Last; in parse()
2873 if (Current) { in getCurrentPrecedence()
2874 const FormatToken *NextNonComment = Current->getNextNonComment(); in getCurrentPrecedence()
2875 if (Current->is(TT_ConditionalExpr)) in getCurrentPrecedence()
2877 if (NextNonComment && Current->is(TT_SelectorName) && in getCurrentPrecedence()
2882 if (Current->is(TT_JsComputedPropertyName)) in getCurrentPrecedence()
2884 if (Current->is(TT_TrailingReturnArrow)) in getCurrentPrecedence()
2886 if (Current->is(TT_FatArrow)) in getCurrentPrecedence()
2888 if (Current->isOneOf(tok::semi, TT_InlineASMColon, TT_SelectorName) || in getCurrentPrecedence()
2889 (Current->is(tok::comment) && NextNonComment && in getCurrentPrecedence()
2893 if (Current->is(TT_RangeBasedForLoopColon)) in getCurrentPrecedence()
2896 Current->is(Keywords.kw_instanceof)) { in getCurrentPrecedence()
2900 Current->isOneOf(Keywords.kw_in, Keywords.kw_as)) { in getCurrentPrecedence()
2903 if (Current->is(TT_BinaryOperator) || Current->is(tok::comma)) in getCurrentPrecedence()
2904 return Current->getPrecedence(); in getCurrentPrecedence()
2905 if (Current->isOneOf(tok::period, tok::arrow) && in getCurrentPrecedence()
2906 Current->isNot(TT_TrailingReturnArrow)) { in getCurrentPrecedence()
2910 Current->isOneOf(Keywords.kw_extends, Keywords.kw_implements, in getCurrentPrecedence()
2916 if (Style.isVerilog() && Current->is(tok::colon)) in getCurrentPrecedence()
2934 if (!End && Current) in addFakeParenthesis()
2935 End = Current->getPreviousNonComment(); in addFakeParenthesis()
2947 while (Current && Current->is(TT_UnaryOperator)) { in parseUnaryOperator()
2948 Tokens.push_back(Current); in parseUnaryOperator()
2959 while (Current && Current->isTrailingComment()) in parseConditionalExpr()
2961 FormatToken *Start = Current; in parseConditionalExpr()
2963 if (!Current || Current->isNot(tok::question)) in parseConditionalExpr()
2967 if (!Current || Current->isNot(TT_ConditionalExpr)) in parseConditionalExpr()
2975 if (Current) in next()
2976 Current = Current->Next; in next()
2977 while (Current && in next()
2978 (Current->NewlinesBefore == 0 || SkipPastLeadingComments) && in next()
2979 Current->isTrailingComment()) { in next()
2980 Current = Current->Next; in next()
2988 if (!Current) in verilogGroupDecl()
2991 FormatToken *Start = Current; in verilogGroupDecl()
3106 while (Current && Current != FirstOfType) { in verilogGroupDecl()
3107 if (Current->opensScope()) { in verilogGroupDecl()
3121 FormatToken *Current; member in clang::format::__anon9257c8bf0111::ExpressionParser
3286 static bool isFunctionDeclarationName(bool IsCpp, const FormatToken &Current, in isFunctionDeclarationName() argument
3289 assert(Current.Previous); in isFunctionDeclarationName()
3291 if (Current.is(TT_FunctionDeclarationName)) in isFunctionDeclarationName()
3294 if (!Current.Tok.getIdentifierInfo()) in isFunctionDeclarationName()
3333 const FormatToken *Next = Current.Next; in isFunctionDeclarationName()
3334 if (Current.is(tok::kw_operator)) { in isFunctionDeclarationName()
3335 const auto *Previous = Current.Previous; in isFunctionDeclarationName()
3350 if (Current.isNot(TT_StartOfName) || Current.NestingLevel != 0) in isFunctionDeclarationName()
3457 FormatToken *Current = First->Next; in calculateFormattingInformation() local
3471 for (auto *Tok = Current; Tok; Tok = Tok->Next) { in calculateFormattingInformation()
3553 while (Current) { in calculateFormattingInformation()
3554 const FormatToken *Prev = Current->Previous; in calculateFormattingInformation()
3555 if (Current->is(TT_LineComment)) { in calculateFormattingInformation()
3557 Current->SpacesRequiredBefore = in calculateFormattingInformation()
3562 Current->SpacesRequiredBefore = 0; in calculateFormattingInformation()
3564 Current->SpacesRequiredBefore = Style.SpacesBeforeTrailingComments; in calculateFormattingInformation()
3574 if (!Current->HasUnescapedNewline) { in calculateFormattingInformation()
3575 for (FormatToken *Parameter = Current->Previous; Parameter; in calculateFormattingInformation()
3588 } else if (!Current->Finalized && Current->SpacesRequiredBefore == 0 && in calculateFormattingInformation()
3589 spaceRequiredBefore(Line, *Current)) { in calculateFormattingInformation()
3590 Current->SpacesRequiredBefore = 1; in calculateFormattingInformation()
3595 Current->MustBreakBefore = true; in calculateFormattingInformation()
3597 Current->MustBreakBefore = in calculateFormattingInformation()
3598 Current->MustBreakBefore || mustBreakBefore(Line, *Current); in calculateFormattingInformation()
3599 if (!Current->MustBreakBefore && InFunctionDecl && in calculateFormattingInformation()
3600 Current->is(TT_FunctionDeclarationName)) { in calculateFormattingInformation()
3601 Current->MustBreakBefore = mustBreakForReturnType(Line); in calculateFormattingInformation()
3605 Current->CanBreakBefore = in calculateFormattingInformation()
3606 Current->MustBreakBefore || canBreakBefore(Line, *Current); in calculateFormattingInformation()
3613 if (Current->MustBreakBefore || Prev->Children.size() > 1 || in calculateFormattingInformation()
3616 Current->IsMultiline) { in calculateFormattingInformation()
3617 Current->TotalLength = Prev->TotalLength + Style.ColumnLimit; in calculateFormattingInformation()
3619 Current->TotalLength = Prev->TotalLength + Current->ColumnWidth + in calculateFormattingInformation()
3620 ChildSize + Current->SpacesRequiredBefore; in calculateFormattingInformation()
3623 if (Current->is(TT_CtorInitializerColon)) in calculateFormattingInformation()
3635 Current->SplitPenalty = splitPenalty(Line, *Current, InFunctionDecl); in calculateFormattingInformation()
3637 Current->is(TT_SelectorName) && Current->ParameterIndex > 0) { in calculateFormattingInformation()
3638 if (Current->ParameterIndex == 1) in calculateFormattingInformation()
3639 Current->SplitPenalty += 5 * Current->BindingStrength; in calculateFormattingInformation()
3641 Current->SplitPenalty += 20 * Current->BindingStrength; in calculateFormattingInformation()
3644 Current = Current->Next; in calculateFormattingInformation()
3649 for (Current = First; Current; Current = Current->Next) { in calculateFormattingInformation()
3650 if (Current->Role) in calculateFormattingInformation()
3651 Current->Role->precomputeFormattingInfos(Current); in calculateFormattingInformation()
3652 if (Current->MatchingParen && in calculateFormattingInformation()
3653 Current->MatchingParen->opensBlockOrBlockTypeList(Style) && in calculateFormattingInformation()
3657 Current->IndentLevel = IndentLevel; in calculateFormattingInformation()
3658 if (Current->opensBlockOrBlockTypeList(Style)) in calculateFormattingInformation()
3668 FormatToken *Current = Line.Last; in calculateUnbreakableTailLengths() local
3669 while (Current) { in calculateUnbreakableTailLengths()
3670 Current->UnbreakableTailLength = UnbreakableTailLength; in calculateUnbreakableTailLengths()
3671 if (Current->CanBreakBefore || in calculateUnbreakableTailLengths()
3672 Current->isOneOf(tok::comment, tok::string_literal)) { in calculateUnbreakableTailLengths()
3676 Current->ColumnWidth + Current->SpacesRequiredBefore; in calculateUnbreakableTailLengths()
3678 Current = Current->Previous; in calculateUnbreakableTailLengths()