diff options
author | Tom <pottagetom@gmail.com> | 2024-08-23 05:42:22 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-22 21:42:22 -0700 |
commit | 7c3237d778572931ff097e81df43d0bce9d1d4f8 (patch) | |
tree | 0864b8c8c74d39c9743cc43f987058edfd4b38ff /clang/lib/Format/ContinuationIndenter.cpp | |
parent | fdaaa878443285e47a2cbc1b641ac04e2efa7881 (diff) | |
download | llvm-7c3237d778572931ff097e81df43d0bce9d1d4f8.zip llvm-7c3237d778572931ff097e81df43d0bce9d1d4f8.tar.gz llvm-7c3237d778572931ff097e81df43d0bce9d1d4f8.tar.bz2 |
[clang-format] Change BinPackParameters to enum and add AlwaysOnePerLine (#101882)
Related issues that have requested this feature:
#51833
#23796
#53190 Partially solves - this issue requests is for both arguments and
parameters
Diffstat (limited to 'clang/lib/Format/ContinuationIndenter.cpp')
-rw-r--r-- | clang/lib/Format/ContinuationIndenter.cpp | 27 |
1 files changed, 5 insertions, 22 deletions
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp index 46dafad..4fcb776 100644 --- a/clang/lib/Format/ContinuationIndenter.cpp +++ b/clang/lib/Format/ContinuationIndenter.cpp @@ -128,25 +128,6 @@ static bool startsSegmentOfBuilderTypeCall(const FormatToken &Tok) { return Tok.isMemberAccess() && Tok.Previous && Tok.Previous->closesScope(); } -// Returns \c true if \c Current starts a new parameter. -static bool startsNextParameter(const FormatToken &Current, - const FormatStyle &Style) { - assert(Current.Previous); - const auto &Previous = *Current.Previous; - if (Current.is(TT_CtorInitializerComma) && - Style.BreakConstructorInitializers == FormatStyle::BCIS_BeforeComma) { - return true; - } - if (Style.Language == FormatStyle::LK_Proto && Current.is(TT_SelectorName)) - return true; - return Previous.is(tok::comma) && !Current.isTrailingComment() && - ((Previous.isNot(TT_CtorInitializerComma) || - Style.BreakConstructorInitializers != - FormatStyle::BCIS_BeforeComma) && - (Previous.isNot(TT_InheritanceComma) || - Style.BreakInheritanceList != FormatStyle::BILS_BeforeComma)); -} - // Returns \c true if \c Token in an alignable binary operator static bool isAlignableBinaryOperator(const FormatToken &Token) { // No need to align binary operators that only have two operands. @@ -437,7 +418,8 @@ bool ContinuationIndenter::mustBreak(const LineState &State) { // sets BreakBeforeParameter to avoid bin packing and this creates a // completely unnecessary line break after a template type that isn't // line-wrapped. - (Previous.NestingLevel == 1 || Style.BinPackParameters)) || + (Previous.NestingLevel == 1 || + Style.BinPackParameters == FormatStyle::BPPS_BinPack)) || (Style.BreakBeforeTernaryOperators && Current.is(TT_ConditionalExpr) && Previous.isNot(tok::question)) || (!Style.BreakBeforeTernaryOperators && @@ -1951,11 +1933,12 @@ void ContinuationIndenter::moveStatePastScopeOpener(LineState &State, // for backwards compatibility. bool ObjCBinPackProtocolList = (Style.ObjCBinPackProtocolList == FormatStyle::BPS_Auto && - Style.BinPackParameters) || + Style.BinPackParameters == FormatStyle::BPPS_BinPack) || Style.ObjCBinPackProtocolList == FormatStyle::BPS_Always; bool BinPackDeclaration = - (State.Line->Type != LT_ObjCDecl && Style.BinPackParameters) || + (State.Line->Type != LT_ObjCDecl && + Style.BinPackParameters == FormatStyle::BPPS_BinPack) || (State.Line->Type == LT_ObjCDecl && ObjCBinPackProtocolList); bool GenericSelection = |