From 7d5062c6ac868537605dd0860b2714aba9ece90d Mon Sep 17 00:00:00 2001 From: Marek Kurdej Date: Sat, 12 Feb 2022 21:25:42 +0100 Subject: [PATCH] [clang-format] Remove unnecessary parentheses in return statements. NFC. --- clang/lib/Format/ContinuationIndenter.cpp | 4 +-- clang/lib/Format/FormatTokenLexer.cpp | 2 +- clang/lib/Format/NamespaceEndCommentsFixer.cpp | 2 +- clang/lib/Format/TokenAnnotator.cpp | 38 +++++++++++++------------- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp index 42c3d2e..23892be 100644 --- a/clang/lib/Format/ContinuationIndenter.cpp +++ b/clang/lib/Format/ContinuationIndenter.cpp @@ -331,7 +331,7 @@ bool ContinuationIndenter::mustBreak(const LineState &State) { if (Style.BraceWrapping.BeforeLambdaBody && Current.CanBreakBefore && Current.is(TT_LambdaLBrace) && Previous.isNot(TT_LineComment)) { auto LambdaBodyLength = getLengthToMatchingParen(Current, State.Stack); - return (LambdaBodyLength > getColumnLimit(State)); + return LambdaBodyLength > getColumnLimit(State); } if (Current.MustBreakBefore || Current.is(TT_InlineASMColon)) return true; @@ -1234,7 +1234,7 @@ static bool hasNestedBlockInlined(const FormatToken *Previous, return true; // Also a nested block if contains a lambda inside function with 1 parameter - return (Style.BraceWrapping.BeforeLambdaBody && Current.is(TT_LambdaLSquare)); + return Style.BraceWrapping.BeforeLambdaBody && Current.is(TT_LambdaLSquare); } unsigned ContinuationIndenter::moveStateToNextToken(LineState &State, diff --git a/clang/lib/Format/FormatTokenLexer.cpp b/clang/lib/Format/FormatTokenLexer.cpp index 0ecae6a..1540c14 100644 --- a/clang/lib/Format/FormatTokenLexer.cpp +++ b/clang/lib/Format/FormatTokenLexer.cpp @@ -500,7 +500,7 @@ bool FormatTokenLexer::canPrecedeRegexLiteral(FormatToken *Prev) { // `!` is an unary prefix operator, but also a post-fix operator that casts // away nullability, so the same check applies. if (Prev->isOneOf(tok::plusplus, tok::minusminus, tok::exclaim)) - return (Tokens.size() < 3 || precedesOperand(Tokens[Tokens.size() - 3])); + return Tokens.size() < 3 || precedesOperand(Tokens[Tokens.size() - 3]); // The previous token must introduce an operand location where regex // literals can occur. diff --git a/clang/lib/Format/NamespaceEndCommentsFixer.cpp b/clang/lib/Format/NamespaceEndCommentsFixer.cpp index 00d1618..65f9655 100644 --- a/clang/lib/Format/NamespaceEndCommentsFixer.cpp +++ b/clang/lib/Format/NamespaceEndCommentsFixer.cpp @@ -136,7 +136,7 @@ bool validEndComment(const FormatToken *RBraceTok, StringRef NamespaceName, return false; NamespaceNameInComment = Groups.size() > 2 ? Groups[2] : ""; - return (NamespaceNameInComment == NamespaceName); + return NamespaceNameInComment == NamespaceName; } void addEndComment(const FormatToken *RBraceTok, StringRef EndCommentText, diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index dabecbf..f1db522 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -1615,10 +1615,10 @@ private: PriorLeadingIdentifier->is(tok::kw_explicit)) PriorLeadingIdentifier = PriorLeadingIdentifier->Previous; - return (PriorLeadingIdentifier && - (PriorLeadingIdentifier->is(TT_TemplateCloser) || - PriorLeadingIdentifier->ClosesRequiresClause) && - LeadingIdentifier->TokenText == Current.Next->TokenText); + return PriorLeadingIdentifier && + (PriorLeadingIdentifier->is(TT_TemplateCloser) || + PriorLeadingIdentifier->ClosesRequiresClause) && + LeadingIdentifier->TokenText == Current.Next->TokenText; } } } @@ -1868,7 +1868,7 @@ private: return true; // const a = in JavaScript. - return (Style.isJavaScript() && PreviousNotConst->is(tok::kw_const)); + return Style.isJavaScript() && PreviousNotConst->is(tok::kw_const); } /// Determine whether ')' is ending a cast. @@ -3085,12 +3085,12 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line, Right.Next->Next->is(TT_RangeBasedForLoopColon)) return getTokenPointerOrReferenceAlignment(Right) != FormatStyle::PAS_Left; - return ( - (!Left.isOneOf(TT_PointerOrReference, tok::l_paren) && - (getTokenPointerOrReferenceAlignment(Right) != FormatStyle::PAS_Left || - (Line.IsMultiVariableDeclStmt && - (Left.NestingLevel == 0 || - (Left.NestingLevel == 1 && Line.First->is(tok::kw_for))))))); + return !Left.isOneOf(TT_PointerOrReference, tok::l_paren) && + (getTokenPointerOrReferenceAlignment(Right) != + FormatStyle::PAS_Left || + (Line.IsMultiVariableDeclStmt && + (Left.NestingLevel == 0 || + (Left.NestingLevel == 1 && Line.First->is(tok::kw_for))))); } if (Right.is(TT_FunctionTypeLParen) && Left.isNot(tok::l_paren) && (!Left.is(TT_PointerOrReference) || @@ -3172,7 +3172,7 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line, // dependent on PointerAlignment style. if (Previous) { if (Previous->endsSequence(tok::kw_operator)) - return (Style.PointerAlignment != FormatStyle::PAS_Left); + return Style.PointerAlignment != FormatStyle::PAS_Left; if (Previous->is(tok::kw_const) || Previous->is(tok::kw_volatile)) return (Style.PointerAlignment != FormatStyle::PAS_Left) || (Style.SpaceAroundPointerQualifiers == @@ -3237,11 +3237,11 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line, (Left.is(tok::r_square) && Left.is(TT_AttributeSquare))) return true; if (Left.is(TT_ForEachMacro)) - return (Style.SpaceBeforeParensOptions.AfterForeachMacros || - spaceRequiredBeforeParens(Right)); + return Style.SpaceBeforeParensOptions.AfterForeachMacros || + spaceRequiredBeforeParens(Right); if (Left.is(TT_IfMacro)) - return (Style.SpaceBeforeParensOptions.AfterIfMacros || - spaceRequiredBeforeParens(Right)); + return Style.SpaceBeforeParensOptions.AfterIfMacros || + spaceRequiredBeforeParens(Right); if (Line.Type == LT_ObjCDecl) return true; if (Left.is(tok::semi)) @@ -3764,8 +3764,8 @@ isItAnEmptyLambdaAllowed(const FormatToken &Tok, } static bool isAllmanLambdaBrace(const FormatToken &Tok) { - return (Tok.is(tok::l_brace) && Tok.is(BK_Block) && - !Tok.isOneOf(TT_ObjCBlockLBrace, TT_DictLiteral)); + return Tok.is(tok::l_brace) && Tok.is(BK_Block) && + !Tok.isOneOf(TT_ObjCBlockLBrace, TT_DictLiteral); } // Returns the first token on the line that is not a comment. @@ -3938,7 +3938,7 @@ bool TokenAnnotator::mustBreakBefore(const AnnotatedLine &Line, // concept ... if (Right.is(tok::kw_concept)) return Style.BreakBeforeConceptDeclarations == FormatStyle::BBCDS_Always; - return (Style.AlwaysBreakTemplateDeclarations == FormatStyle::BTDS_Yes); + return Style.AlwaysBreakTemplateDeclarations == FormatStyle::BTDS_Yes; } if (Left.ClosesRequiresClause) { switch (Style.RequiresClausePosition) { -- 2.7.4