https://github.com/HazardyKnusperkeks updated https://github.com/llvm/llvm-project/pull/161021
From 4c5525b88a4f191270fa363a2c62699fd5c1fa27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Sch=C3=A4pers?= <[email protected]> Date: Sat, 27 Sep 2025 22:32:12 +0200 Subject: [PATCH] [clang-format][NFC] Introduce isNotOneOf And apply throughout the code base. --- clang/lib/Format/ContinuationIndenter.cpp | 34 ++++----- clang/lib/Format/FormatToken.h | 12 ++- .../lib/Format/NamespaceEndCommentsFixer.cpp | 2 +- clang/lib/Format/TokenAnnotator.cpp | 76 +++++++++---------- clang/lib/Format/UnwrappedLineFormatter.cpp | 8 +- clang/lib/Format/UnwrappedLineParser.cpp | 40 +++++----- clang/lib/Format/WhitespaceManager.cpp | 4 +- 7 files changed, 90 insertions(+), 86 deletions(-) diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp index 9413c13a4137e..21e1856e639d7 100644 --- a/clang/lib/Format/ContinuationIndenter.cpp +++ b/clang/lib/Format/ContinuationIndenter.cpp @@ -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, - Keywords.kw_dollar) && - !Previous.isOneOf(TT_InlineASMColon, TT_ConditionalExpr) && + Previous.isNotOneOf(tok::kw_return, tok::lessless, tok::at, + Keywords.kw_dollar) && + Previous.isNotOneOf(TT_InlineASMColon, TT_ConditionalExpr) && nextIsMultilineString(State)) { 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->isNotOneOf(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.isNotOneOf(tok::l_paren, TT_TemplateOpener, tok::l_square) && !IsStartOfBracedList()) { return false; } @@ -843,8 +843,8 @@ 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, - tok::kw_switch) && + return Tok.Previous->isNotOneOf(TT_CastRParen, tok::kw_for, tok::kw_while, + tok::kw_switch) && !(Style.isJavaScript() && Tok.Previous->is(Keywords.kw_await)); }; auto IsFunctionCallParen = [](const FormatToken &Tok) { @@ -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.isNotOneOf(TT_ObjCMethodExpr, TT_RequiresClause, + TT_TableGenDAGArgOpener, + TT_TableGenDAGArgOpenerToBreak) && !(Current.MacroParent && Previous.MacroParent) && (Current.isNot(TT_LineComment) || Previous.isOneOf(BK_BracedInit, TT_VerilogMultiLineListLParen)) && @@ -1239,11 +1239,11 @@ unsigned ContinuationIndenter::addTokenOnNewLine(LineState &State, } if (PreviousNonComment && - !PreviousNonComment->isOneOf(tok::comma, tok::colon, tok::semi) && + PreviousNonComment->isNotOneOf(tok::comma, tok::colon, tok::semi) && ((PreviousNonComment->isNot(TT_TemplateCloser) && !PreviousNonComment->ClosesRequiresClause) || Current.NestingLevel != 0) && - !PreviousNonComment->isOneOf( + PreviousNonComment->isNotOneOf( 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.isNotOneOf(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.isNotOneOf(tok::colon, tok::comment)) { return ContinuationIndent; } if (Current.is(TT_ProtoExtensionLSquare)) @@ -1734,8 +1734,8 @@ 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, - TT_CtorInitializerColon)))) { + Previous->isNotOneOf(TT_DictLiteral, TT_ObjCMethodExpr, + TT_CtorInitializerColon)))) { CurrentState.NestedBlockInlined = !Newline && hasNestedBlockInlined(Previous, Current, Style); } diff --git a/clang/lib/Format/FormatToken.h b/clang/lib/Format/FormatToken.h index e04b0e7af10c0..e69091e72bbc3 100644 --- a/clang/lib/Format/FormatToken.h +++ b/clang/lib/Format/FormatToken.h @@ -645,6 +645,9 @@ struct FormatToken { return is(K1) || isOneOf(K2, Ks...); } template <typename T> bool isNot(T Kind) const { return !is(Kind); } + template <typename... Ts> bool isNotOneOf(Ts... Ks) const { + return !isOneOf(Ks...); + } bool isIf(bool AllowConstexprMacro = true) const { return is(tok::kw_if) || endsSequence(tok::kw_constexpr, tok::kw_if) || @@ -748,8 +751,8 @@ struct FormatToken { /// Returns \c true if this is a "." or "->" accessing a member. bool isMemberAccess() const { return isOneOf(tok::arrow, tok::period, tok::arrowstar) && - !isOneOf(TT_DesignatedInitializerPeriod, TT_TrailingReturnArrow, - TT_LambdaArrow, TT_LeadingJavaAnnotation); + isNotOneOf(TT_DesignatedInitializerPeriod, TT_TrailingReturnArrow, + TT_LambdaArrow, TT_LeadingJavaAnnotation); } bool isPointerOrReference() const { @@ -1877,8 +1880,9 @@ struct AdditionalKeywords { // In Verilog the colon in a default label is optional. return Tok.is(TT_CaseLabelColon) || (Tok.is(tok::kw_default) && - !(Next && Next->isOneOf(tok::colon, tok::semi, kw_clocking, kw_iff, - kw_input, kw_output, kw_sequence))); + (!Next || + Next->isNotOneOf(tok::colon, tok::semi, kw_clocking, kw_iff, + kw_input, kw_output, kw_sequence))); } /// Returns whether \p Tok is a Verilog keyword that starts a diff --git a/clang/lib/Format/NamespaceEndCommentsFixer.cpp b/clang/lib/Format/NamespaceEndCommentsFixer.cpp index 08f8d6840fe00..6ecd09428da09 100644 --- a/clang/lib/Format/NamespaceEndCommentsFixer.cpp +++ b/clang/lib/Format/NamespaceEndCommentsFixer.cpp @@ -85,7 +85,7 @@ std::string computeName(const FormatToken *NamespaceTok) { // one token before that up until the '{'. A '(' might be a macro with // arguments. const FormatToken *FirstNSTok = nullptr; - while (Tok && !Tok->isOneOf(tok::l_brace, tok::coloncolon, tok::l_paren)) { + while (Tok && Tok->isNotOneOf(tok::l_brace, tok::coloncolon, tok::l_paren)) { if (FirstNSTok) FirstNSName += FirstNSTok->TokenText; FirstNSTok = Tok; diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 6a8286da73442..8235f357af74f 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -577,7 +577,7 @@ class AnnotatingParser { if (IsIf && CurrentToken->is(tok::semi)) { for (auto *Tok = OpeningParen.Next; Tok != CurrentToken && - !Tok->isOneOf(tok::equal, tok::l_paren, tok::l_brace); + Tok->isNotOneOf(tok::equal, tok::l_paren, tok::l_brace); Tok = Tok->Next) { if (Tok->isPointerOrReference()) Tok->setFinalizedType(TT_PointerOrReference); @@ -1430,8 +1430,8 @@ class AnnotatingParser { Scopes.back() == ST_Class)) { Tok->setType(TT_BitFieldColon); } else if (Contexts.size() == 1 && - !Line.getFirstNonComment()->isOneOf(tok::kw_enum, tok::kw_case, - tok::kw_default) && + Line.getFirstNonComment()->isNotOneOf( + tok::kw_enum, tok::kw_case, tok::kw_default) && !Line.startsWith(tok::kw_typedef, tok::kw_enum)) { if (Prev->isOneOf(tok::r_paren, tok::kw_noexcept) || Prev->ClosesRequiresClause) { @@ -1570,8 +1570,8 @@ class AnnotatingParser { !Tok->isOneOf(TT_TypeDeclarationParen, TT_RequiresExpressionLParen)) { if (!Prev || (!Prev->isAttribute() && - !Prev->isOneOf(TT_RequiresClause, TT_LeadingJavaAnnotation, - TT_BinaryOperator))) { + Prev->isNotOneOf(TT_RequiresClause, TT_LeadingJavaAnnotation, + TT_BinaryOperator))) { Line.MightBeFunctionDecl = true; Tok->MightBeFunctionDeclParen = true; } @@ -1669,7 +1669,7 @@ class AnnotatingParser { } } while (CurrentToken && - !CurrentToken->isOneOf(tok::l_paren, tok::semi, tok::r_paren)) { + CurrentToken->isNotOneOf(tok::l_paren, tok::semi, tok::r_paren)) { if (CurrentToken->isOneOf(tok::star, tok::amp)) CurrentToken->setType(TT_PointerOrReference); auto Next = CurrentToken->getNextNonComment(); @@ -2099,7 +2099,7 @@ class AnnotatingParser { // Reset token type in case we have already looked at it and then // recovered from an error (e.g. failure to find the matching >). if (!CurrentToken->isTypeFinalized() && - !CurrentToken->isOneOf( + CurrentToken->isNotOneOf( TT_LambdaLSquare, TT_LambdaLBrace, TT_AttributeMacro, TT_IfMacro, TT_ForEachMacro, TT_TypenameMacro, TT_FunctionLBrace, TT_ImplicitStringLiteral, TT_InlineASMBrace, TT_FatArrow, @@ -2516,7 +2516,7 @@ class AnnotatingParser { Current.setType(TT_CastRParen); if (Current.MatchingParen && Current.Next && !Current.Next->isBinaryOperator() && - !Current.Next->isOneOf( + Current.Next->isNotOneOf( tok::semi, tok::colon, tok::l_brace, tok::l_paren, tok::comma, tok::period, tok::arrow, tok::coloncolon, tok::kw_noexcept)) { if (FormatToken *AfterParen = Current.MatchingParen->Next; @@ -2574,9 +2574,9 @@ class AnnotatingParser { } else if (Current.isOneOf(tok::identifier, tok::kw_const, tok::kw_noexcept, tok::kw_requires) && Current.Previous && - !Current.Previous->isOneOf(tok::equal, tok::at, - TT_CtorInitializerComma, - TT_CtorInitializerColon) && + Current.Previous->isNotOneOf(tok::equal, tok::at, + TT_CtorInitializerComma, + TT_CtorInitializerColon) && Line.MightBeFunctionDecl && Contexts.size() == 1) { // Line.MightBeFunctionDecl can only be true after the parentheses of a // function declaration have been found. @@ -2785,8 +2785,8 @@ class AnnotatingParser { // If there is an identifier (or with a few exceptions a keyword) right // before the parentheses, this is unlikely to be a cast. if (LeftOfParens->Tok.getIdentifierInfo() && - !LeftOfParens->isOneOf(Keywords.kw_in, tok::kw_return, tok::kw_case, - tok::kw_delete, tok::kw_throw)) { + LeftOfParens->isNotOneOf(Keywords.kw_in, tok::kw_return, tok::kw_case, + tok::kw_delete, tok::kw_throw)) { return false; } @@ -2953,7 +2953,7 @@ class AnnotatingParser { // Search for unexpected tokens. for (Prev = BeforeRParen; Prev != LParen; Prev = Prev->Previous) - if (!Prev->isOneOf(tok::kw_const, tok::identifier, tok::coloncolon)) + if (Prev->isNotOneOf(tok::kw_const, tok::identifier, tok::coloncolon)) return false; return true; @@ -3745,8 +3745,8 @@ void TokenAnnotator::annotate(AnnotatedLine &Line) { const bool InRequiresExpression = Line.Type == LT_RequiresExpression; for (auto &Child : Line.Children) { if (InRequiresExpression && - !Child->First->isOneOf(tok::kw_typename, tok::kw_requires, - TT_CompoundRequirementLBrace)) { + Child->First->isNotOneOf(tok::kw_typename, tok::kw_requires, + TT_CompoundRequirementLBrace)) { Child->Type = LT_SimpleRequirement; } annotate(*Child); @@ -4329,9 +4329,9 @@ unsigned TokenAnnotator::splitPenalty(const AnnotatedLine &Line, // Slightly prefer formatting local lambda definitions like functions. if (Right.is(TT_LambdaLSquare) && Left.is(tok::equal)) return 35; - if (!Right.isOneOf(TT_ObjCMethodExpr, TT_LambdaLSquare, - TT_ArrayInitializerLSquare, - TT_DesignatedInitializerLSquare, TT_AttributeSquare)) { + if (Right.isNotOneOf(TT_ObjCMethodExpr, TT_LambdaLSquare, + TT_ArrayInitializerLSquare, + TT_DesignatedInitializerLSquare, TT_AttributeSquare)) { return 500; } } @@ -4520,7 +4520,7 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line, const FormatToken &Left, const FormatToken &Right) const { if (Left.is(tok::kw_return) && - !Right.isOneOf(tok::semi, tok::r_paren, tok::hashhash)) { + Right.isNotOneOf(tok::semi, tok::r_paren, tok::hashhash)) { return true; } if (Left.is(tok::kw_throw) && Right.is(tok::l_paren) && Right.MatchingParen && @@ -4809,10 +4809,10 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line, TT_LambdaLSquare))); } if (Right.is(tok::l_square) && - !Right.isOneOf(TT_ObjCMethodExpr, TT_LambdaLSquare, - TT_DesignatedInitializerLSquare, - TT_StructuredBindingLSquare, TT_AttributeSquare) && - !Left.isOneOf(tok::numeric_constant, TT_DictLiteral) && + Right.isNotOneOf(TT_ObjCMethodExpr, TT_LambdaLSquare, + TT_DesignatedInitializerLSquare, + TT_StructuredBindingLSquare, TT_AttributeSquare) && + Left.isNotOneOf(tok::numeric_constant, TT_DictLiteral) && !(Left.isNot(tok::r_square) && Style.SpaceBeforeSquareBrackets && Right.is(TT_ArraySubscriptLSquare))) { return false; @@ -4918,7 +4918,7 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line, if (Left.is(tok::at) && Right.isNot(tok::objc_not_keyword)) return false; if (Right.is(TT_UnaryOperator)) { - return !Left.isOneOf(tok::l_paren, tok::l_square, tok::at) && + return Left.isNotOneOf(tok::l_paren, tok::l_square, tok::at) && (Left.isNot(tok::colon) || Left.isNot(TT_ObjCMethodExpr)); } // No space between the variable name and the initializer list. @@ -5261,8 +5261,8 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line, if (Left.is(tok::ellipsis)) return false; if (Left.is(TT_TemplateCloser) && - !Right.isOneOf(tok::equal, tok::l_brace, tok::comma, tok::l_square, - Keywords.kw_implements, Keywords.kw_extends)) { + Right.isNotOneOf(tok::equal, tok::l_brace, tok::comma, tok::l_square, + Keywords.kw_implements, Keywords.kw_extends)) { // Type assertions ('<type>expr') are not followed by whitespace. Other // locations that should have whitespace following are identified by the // above set of follower tokens. @@ -5550,14 +5550,14 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line, return Right.hasWhitespaceBefore(); } if (Right.is(tok::coloncolon) && - !Left.isOneOf(tok::l_brace, tok::comment, tok::l_paren)) { + Left.isNotOneOf(tok::l_brace, tok::comment, tok::l_paren)) { // Put a space between < and :: in vector< ::std::string > return (Left.is(TT_TemplateOpener) && ((Style.Standard < FormatStyle::LS_Cpp11) || ShouldAddSpacesInAngles())) || - !(Left.isOneOf(tok::l_paren, tok::r_paren, tok::l_square, - tok::kw___super, TT_TemplateOpener, - TT_TemplateCloser)) || + Left.isNotOneOf(tok::l_paren, tok::r_paren, tok::l_square, + tok::kw___super, TT_TemplateOpener, + TT_TemplateCloser) || (Left.is(tok::l_paren) && Style.SpacesInParensOptions.Other); } if ((Left.is(TT_TemplateOpener)) != (Right.is(TT_TemplateCloser))) @@ -5600,7 +5600,7 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line, // Returns 'true' if 'Tok' is a brace we'd want to break before in Allman style. static bool isAllmanBrace(const FormatToken &Tok) { return Tok.is(tok::l_brace) && Tok.is(BK_Block) && - !Tok.isOneOf(TT_ObjCBlockLBrace, TT_LambdaLBrace, TT_DictLiteral); + Tok.isNotOneOf(TT_ObjCBlockLBrace, TT_LambdaLBrace, TT_DictLiteral); } // Returns 'true' if 'Tok' is a function argument. @@ -6207,8 +6207,8 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line, return false; // Avoid to break after '(' in the cases that is in bang operators. if (Right.is(tok::l_paren)) { - return !Left.isOneOf(TT_TableGenBangOperator, TT_TableGenCondOperator, - TT_TemplateCloser); + return Left.isNotOneOf(TT_TableGenBangOperator, TT_TableGenCondOperator, + TT_TemplateCloser); } // Avoid to break between the value and its suffix part. if (Left.is(TT_TableGenValueSuffix)) @@ -6295,8 +6295,8 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line, } if (Right.is(tok::colon) && - !Right.isOneOf(TT_CtorInitializerColon, TT_InlineASMColon, - TT_BitFieldColon)) { + Right.isNotOneOf(TT_CtorInitializerColon, TT_InlineASMColon, + TT_BitFieldColon)) { return false; } if (Left.is(tok::colon) && Left.isOneOf(TT_DictLiteral, TT_ObjCMethodExpr)) { @@ -6406,8 +6406,8 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line, // Allow breaking after a trailing annotation, e.g. after a method // declaration. if (Left.is(TT_TrailingAnnotation)) { - return !Right.isOneOf(tok::l_brace, tok::semi, tok::equal, tok::l_paren, - tok::less, tok::coloncolon); + return Right.isNotOneOf(tok::l_brace, tok::semi, tok::equal, tok::l_paren, + tok::less, tok::coloncolon); } if (Right.isAttribute()) diff --git a/clang/lib/Format/UnwrappedLineFormatter.cpp b/clang/lib/Format/UnwrappedLineFormatter.cpp index ac9d147defc13..95135d77a1523 100644 --- a/clang/lib/Format/UnwrappedLineFormatter.cpp +++ b/clang/lib/Format/UnwrappedLineFormatter.cpp @@ -506,8 +506,8 @@ class LineJoiner { (NextLine.First->is(tok::r_brace) && !Style.BraceWrapping.SplitEmptyRecord); } else if (TheLine->InPPDirective || - !TheLine->First->isOneOf(tok::kw_class, tok::kw_enum, - tok::kw_struct)) { + TheLine->First->isNotOneOf(tok::kw_class, tok::kw_enum, + tok::kw_struct)) { // Try to merge a block with left brace unwrapped that wasn't yet // covered. ShouldMerge = !Style.BraceWrapping.AfterFunction || @@ -686,8 +686,8 @@ class LineJoiner { } Limit = limitConsideringMacros(I + 1, E, Limit); AnnotatedLine &Line = **I; - if (Line.First->isNot(tok::kw_do) && Line.First->isNot(tok::kw_else) && - Line.Last->isNot(tok::kw_else) && Line.Last->isNot(tok::r_paren)) { + if (Line.First->isNotOneOf(tok::kw_do, tok::kw_else) && + Line.Last->isNotOneOf(tok::kw_else, tok::r_paren)) { return 0; } // Only merge `do while` if `do` is the only statement on the line. diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index 2c9766c9b7bc0..e5759eb100ded 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -584,7 +584,7 @@ void UnwrappedLineParser::calculateBraceTypes(bool ExpectClassBody) { ProbablyBracedList = ProbablyBracedList || (NextTok->is(tok::identifier) && - !PrevTok->isOneOf(tok::semi, tok::r_brace, tok::l_brace)); + PrevTok->isNotOneOf(tok::semi, tok::r_brace, tok::l_brace)); ProbablyBracedList = ProbablyBracedList || (NextTok->is(tok::semi) && @@ -607,7 +607,7 @@ void UnwrappedLineParser::calculateBraceTypes(bool ExpectClassBody) { // A statement can end with only `;` (simple statement), a block // closing brace (compound statement), or `:` (label statement). // If PrevTok is a block opening brace, Tok ends an empty block. - !PrevTok->isOneOf(tok::semi, BK_Block, tok::colon)) { + PrevTok->isNotOneOf(tok::semi, BK_Block, tok::colon)) { ProbablyBracedList = true; } } @@ -1233,22 +1233,22 @@ void UnwrappedLineParser::parsePPUnknown() { static bool tokenCanStartNewLine(const FormatToken &Tok) { // Semicolon can be a null-statement, l_square can be a start of a macro or // a C++11 attribute, but this doesn't seem to be common. - return !Tok.isOneOf(tok::semi, tok::l_brace, - // Tokens that can only be used as binary operators and a - // part of overloaded operator names. - tok::period, tok::periodstar, tok::arrow, tok::arrowstar, - tok::less, tok::greater, tok::slash, tok::percent, - tok::lessless, tok::greatergreater, tok::equal, - tok::plusequal, tok::minusequal, tok::starequal, - tok::slashequal, tok::percentequal, tok::ampequal, - tok::pipeequal, tok::caretequal, tok::greatergreaterequal, - tok::lesslessequal, - // Colon is used in labels, base class lists, initializer - // lists, range-based for loops, ternary operator, but - // should never be the first token in an unwrapped line. - tok::colon, - // 'noexcept' is a trailing annotation. - tok::kw_noexcept); + return Tok.isNotOneOf( + tok::semi, tok::l_brace, + // Tokens that can only be used as binary operators and a + // part of overloaded operator names. + tok::period, tok::periodstar, tok::arrow, tok::arrowstar, tok::less, + tok::greater, tok::slash, tok::percent, tok::lessless, + tok::greatergreater, tok::equal, tok::plusequal, tok::minusequal, + tok::starequal, tok::slashequal, tok::percentequal, tok::ampequal, + tok::pipeequal, tok::caretequal, tok::greatergreaterequal, + tok::lesslessequal, + // Colon is used in labels, base class lists, initializer lists, + // range-based for loops, ternary operator, but should never be the first + // token in an unwrapped line. + tok::colon, + // 'noexcept' is a trailing annotation. + tok::kw_noexcept); } static bool mustBeJSIdent(const AdditionalKeywords &Keywords, @@ -4885,8 +4885,8 @@ void UnwrappedLineParser::readToken(int LevelDifference) { const auto *Next = Tokens->peekNextToken(); if ((Style.isVerilog() && !Keywords.isVerilogPPDirective(*Next)) || (Style.isTableGen() && - !Next->isOneOf(tok::kw_else, tok::pp_define, tok::pp_ifdef, - tok::pp_ifndef, tok::pp_endif))) { + Next->isNotOneOf(tok::kw_else, tok::pp_define, tok::pp_ifdef, + tok::pp_ifndef, tok::pp_endif))) { break; } distributeComments(Comments, FormatTok); diff --git a/clang/lib/Format/WhitespaceManager.cpp b/clang/lib/Format/WhitespaceManager.cpp index 30c06bbb4d071..4be3f61bc05c1 100644 --- a/clang/lib/Format/WhitespaceManager.cpp +++ b/clang/lib/Format/WhitespaceManager.cpp @@ -462,8 +462,8 @@ AlignTokenSequence(const FormatStyle &Style, unsigned Start, unsigned End, if ((Style.PointerAlignment == FormatStyle::PAS_Right || Style.ReferenceAlignment == FormatStyle::RAS_Right) && CurrentChange.Spaces != 0 && - !CurrentChange.Tok->isOneOf(tok::equal, tok::r_paren, - TT_TemplateCloser)) { + CurrentChange.Tok->isNotOneOf(tok::equal, tok::r_paren, + TT_TemplateCloser)) { const bool ReferenceNotRightAligned = Style.ReferenceAlignment != FormatStyle::RAS_Right && Style.ReferenceAlignment != FormatStyle::RAS_Pointer; _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
