diff options
Diffstat (limited to 'clang/lib/Format/ContinuationIndenter.cpp')
-rw-r--r-- | clang/lib/Format/ContinuationIndenter.cpp | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp index 9413c13..cd4c1aa 100644 --- a/clang/lib/Format/ContinuationIndenter.cpp +++ b/clang/lib/Format/ContinuationIndenter.cpp @@ -368,7 +368,7 @@ bool ContinuationIndenter::canBreak(const LineState &State) { // If binary operators are moved to the next line (including commas for some // styles of constructor initializers), that's always ok. - if (!Current.isOneOf(TT_BinaryOperator, tok::comma) && + if (Current.isNoneOf(TT_BinaryOperator, tok::comma) && // Allow breaking opening brace of lambdas (when passed as function // arguments) to a new line when BeforeLambdaBody brace wrapping is // enabled. @@ -445,7 +445,7 @@ bool ContinuationIndenter::mustBreak(const LineState &State) { (!Style.BreakBeforeTernaryOperators && Previous.is(TT_ConditionalExpr))) && CurrentState.BreakBeforeParameter && !Current.isTrailingComment() && - !Current.isOneOf(tok::r_paren, tok::r_brace)) { + Current.isNoneOf(tok::r_paren, tok::r_brace)) { return true; } if (CurrentState.IsChainedConditional && @@ -523,9 +523,9 @@ bool ContinuationIndenter::mustBreak(const LineState &State) { if (Style.AlwaysBreakBeforeMultilineStrings && (NewLineColumn == State.FirstIndent + Style.ContinuationIndentWidth || Previous.is(tok::comma) || Current.NestingLevel < 2) && - !Previous.isOneOf(tok::kw_return, tok::lessless, tok::at, + Previous.isNoneOf(tok::kw_return, tok::lessless, tok::at, Keywords.kw_dollar) && - !Previous.isOneOf(TT_InlineASMColon, TT_ConditionalExpr) && + Previous.isNoneOf(TT_InlineASMColon, TT_ConditionalExpr) && nextIsMultilineString(State)) { return true; } @@ -648,7 +648,7 @@ bool ContinuationIndenter::mustBreak(const LineState &State) { // into the ColumnLimit, they are checked here in the ContinuationIndenter. if (Style.ColumnLimit != 0 && Previous.is(BK_Block) && Previous.is(tok::l_brace) && - !Current.isOneOf(tok::r_brace, tok::comment)) { + Current.isNoneOf(tok::r_brace, tok::comment)) { return true; } @@ -752,7 +752,7 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun, return false; const auto *Next = Comma->getNextNonComment(); - return Next && !Next->isOneOf(TT_LambdaLSquare, tok::l_brace, tok::caret); + return Next && Next->isNoneOf(TT_LambdaLSquare, tok::l_brace, tok::caret); }; if (DisallowLineBreaks()) @@ -835,7 +835,7 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun, return Tok.is(tok::l_brace) && Tok.isNot(BK_Block) && Style.Cpp11BracedListStyle; }; - if (!Tok.isOneOf(tok::l_paren, TT_TemplateOpener, tok::l_square) && + if (Tok.isNoneOf(tok::l_paren, TT_TemplateOpener, tok::l_square) && !IsStartOfBracedList()) { return false; } @@ -843,7 +843,7 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun, return true; if (Tok.Previous->isIf()) return Style.AlignAfterOpenBracket == FormatStyle::BAS_AlwaysBreak; - return !Tok.Previous->isOneOf(TT_CastRParen, tok::kw_for, tok::kw_while, + return Tok.Previous->isNoneOf(TT_CastRParen, tok::kw_for, tok::kw_while, tok::kw_switch) && !(Style.isJavaScript() && Tok.Previous->is(Keywords.kw_await)); }; @@ -882,8 +882,8 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun, Tok.isOneOf(tok::ellipsis, Keywords.kw_await))) { return true; } - const auto *Previous = Tok.Previous; - if (!Previous || (!Previous->isOneOf(TT_FunctionDeclarationLParen, + if (const auto *Previous = Tok.Previous; + !Previous || (Previous->isNoneOf(TT_FunctionDeclarationLParen, TT_LambdaDefinitionLParen) && !IsFunctionCallParen(*Previous))) { return true; @@ -920,9 +920,9 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun, // align the commas with the opening paren. if (Style.AlignAfterOpenBracket != FormatStyle::BAS_DontAlign && !CurrentState.IsCSharpGenericTypeConstraint && Previous.opensScope() && - Previous.isNot(TT_ObjCMethodExpr) && Previous.isNot(TT_RequiresClause) && - Previous.isNot(TT_TableGenDAGArgOpener) && - Previous.isNot(TT_TableGenDAGArgOpenerToBreak) && + Previous.isNoneOf(TT_ObjCMethodExpr, TT_RequiresClause, + TT_TableGenDAGArgOpener, + TT_TableGenDAGArgOpenerToBreak) && !(Current.MacroParent && Previous.MacroParent) && (Current.isNot(TT_LineComment) || Previous.isOneOf(BK_BracedInit, TT_VerilogMultiLineListLParen)) && @@ -962,7 +962,7 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun, if (Current.isNot(tok::comment) && P && (P->isOneOf(TT_BinaryOperator, tok::comma) || (P->is(TT_ConditionalExpr) && P->is(tok::colon))) && - !P->isOneOf(TT_OverloadedOperator, TT_CtorInitializerComma) && + P->isNoneOf(TT_OverloadedOperator, TT_CtorInitializerComma) && P->getPrecedence() != prec::Assignment && P->getPrecedence() != prec::Relational && P->getPrecedence() != prec::Spaceship) { @@ -992,7 +992,7 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun, // parameter, i.e. let nested calls have a continuation indent. CurrentState.LastSpace = State.Column; CurrentState.NestedBlockIndent = State.Column; - } else if (!Current.isOneOf(tok::comment, tok::caret) && + } else if (Current.isNoneOf(tok::comment, tok::caret) && ((Previous.is(tok::comma) && Previous.isNot(TT_OverloadedOperator)) || (Previous.is(tok::colon) && Previous.is(TT_ObjCMethodExpr)))) { @@ -1099,7 +1099,7 @@ unsigned ContinuationIndenter::addTokenOnNewLine(LineState &State, if (Current.isNot(TT_LambdaArrow) && (!Style.isJavaScript() || Current.NestingLevel != 0 || !PreviousNonComment || PreviousNonComment->isNot(tok::equal) || - !Current.isOneOf(Keywords.kw_async, Keywords.kw_function))) { + Current.isNoneOf(Keywords.kw_async, Keywords.kw_function))) { CurrentState.NestedBlockIndent = State.Column; } @@ -1239,11 +1239,11 @@ unsigned ContinuationIndenter::addTokenOnNewLine(LineState &State, } if (PreviousNonComment && - !PreviousNonComment->isOneOf(tok::comma, tok::colon, tok::semi) && + PreviousNonComment->isNoneOf(tok::comma, tok::colon, tok::semi) && ((PreviousNonComment->isNot(TT_TemplateCloser) && !PreviousNonComment->ClosesRequiresClause) || Current.NestingLevel != 0) && - !PreviousNonComment->isOneOf( + PreviousNonComment->isNoneOf( TT_BinaryOperator, TT_FunctionAnnotationRParen, TT_JavaAnnotation, TT_LeadingJavaAnnotation) && Current.isNot(TT_BinaryOperator) && !PreviousNonComment->opensScope() && @@ -1281,8 +1281,8 @@ unsigned ContinuationIndenter::addTokenOnNewLine(LineState &State, bool AllowAllConstructorInitializersOnNextLine = Style.PackConstructorInitializers == FormatStyle::PCIS_NextLine || Style.PackConstructorInitializers == FormatStyle::PCIS_NextLineOnly; - if (!(Previous.isOneOf(tok::l_paren, tok::l_brace, TT_BinaryOperator) || - PreviousIsBreakingCtorInitializerColon) || + if ((Previous.isNoneOf(tok::l_paren, tok::l_brace, TT_BinaryOperator) && + !PreviousIsBreakingCtorInitializerColon) || (!Style.AllowAllParametersOfDeclarationOnNextLine && State.Line->MustBeDeclaration) || (!Style.AllowAllArgumentsOnNextLine && @@ -1576,7 +1576,7 @@ unsigned ContinuationIndenter::getNewLineColumn(const LineState &State) { if (Previous.is(tok::r_paren) && Previous.isNot(TT_TableGenDAGArgOperatorToBreak) && !Current.isBinaryOperator() && - !Current.isOneOf(tok::colon, tok::comment)) { + Current.isNoneOf(tok::colon, tok::comment)) { return ContinuationIndent; } if (Current.is(TT_ProtoExtensionLSquare)) @@ -1591,7 +1591,7 @@ unsigned ContinuationIndenter::getNewLineColumn(const LineState &State) { NextNonComment->SpacesRequiredBefore; } if (CurrentState.Indent == State.FirstIndent && PreviousNonComment && - !PreviousNonComment->isOneOf(tok::r_brace, TT_CtorInitializerComma)) { + PreviousNonComment->isNoneOf(tok::r_brace, TT_CtorInitializerComma)) { // Ensure that we fall back to the continuation indent width instead of // just flushing continuations left. return CurrentState.Indent + Style.ContinuationIndentWidth; @@ -1734,7 +1734,7 @@ unsigned ContinuationIndenter::moveStateToNextToken(LineState &State, } if (Previous && (Previous->isOneOf(TT_BinaryOperator, TT_ConditionalExpr) || (Previous->isOneOf(tok::l_paren, tok::comma, tok::colon) && - !Previous->isOneOf(TT_DictLiteral, TT_ObjCMethodExpr, + Previous->isNoneOf(TT_DictLiteral, TT_ObjCMethodExpr, TT_CtorInitializerColon)))) { CurrentState.NestedBlockInlined = !Newline && hasNestedBlockInlined(Previous, Current, Style); @@ -1758,7 +1758,7 @@ unsigned ContinuationIndenter::moveStateToNextToken(LineState &State, State.StartOfStringLiteral = State.Column + 1; } else if (Current.isStringLiteral() && State.StartOfStringLiteral == 0) { State.StartOfStringLiteral = State.Column; - } else if (!Current.isOneOf(tok::comment, tok::identifier, tok::hash) && + } else if (Current.isNoneOf(tok::comment, tok::identifier, tok::hash) && !Current.isStringLiteral()) { State.StartOfStringLiteral = 0; } @@ -2057,7 +2057,7 @@ void ContinuationIndenter::moveStatePastScopeOpener(LineState &State, // array literals as these follow different indentation rules. bool NoLineBreak = Current.Children.empty() && - !Current.isOneOf(TT_DictLiteral, TT_ArrayInitializerLSquare) && + Current.isNoneOf(TT_DictLiteral, TT_ArrayInitializerLSquare) && (CurrentState.NoLineBreak || CurrentState.NoLineBreakInOperand || (Current.is(TT_TemplateOpener) && CurrentState.ContainsUnwrappedBuilder)); |