[PATCH] D32479: clang-format: Introduce BreakConstructorInitializers option
Francois Ferrand via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue May 23 00:32:54 PDT 2017
Typz added inline comments.
================
Comment at: lib/Format/ContinuationIndenter.cpp:196
+ FormatStyle::BCIS_AfterColonAndComma) &&
+ (State.Column + State.Line->Last->TotalLength - Previous.TotalLength >
+ getColumnLimit(State) ||
----------------
djasper wrote:
> Why can you drop the "+2" here?
>
> Also, I'd like to structure this so we have to duplicate less of the logic. But I am not really sure it's possible.
the +2 here was needed to keep identifiers aligned when breaking after colon but before the command (e.g. the 4th combination, not defined anymore):
Foo() :
field(1)
, field(2)
================
Comment at: lib/Format/ContinuationIndenter.cpp:196
+ FormatStyle::BCIS_AfterColonAndComma) &&
+ (State.Column + State.Line->Last->TotalLength - Previous.TotalLength >
+ getColumnLimit(State) ||
----------------
Typz wrote:
> djasper wrote:
> > Why can you drop the "+2" here?
> >
> > Also, I'd like to structure this so we have to duplicate less of the logic. But I am not really sure it's possible.
> the +2 here was needed to keep identifiers aligned when breaking after colon but before the command (e.g. the 4th combination, not defined anymore):
>
> Foo() :
> field(1)
> , field(2)
I can avoid some duplication like this,m but i am not convinced it helps :
const FormatToken &ColonToken =
Style.BreakConstructorInitializers != FormatStyle::BCIS_AfterColon
? Current : Previous;
if (ColonToken.is(TT_CtorInitializerColon) &&
(State.Column + State.Line->Last->TotalLength - ColonToken.TotalLength +
(Style.BreakConstructorInitializers !=
FormatStyle::BCIS_AfterColon ? 2 : 0) >
getColumnLimit(State) ||
State.Stack.back().BreakBeforeParameter) &&
(Style.AllowShortFunctionsOnASingleLine != FormatStyle::SFS_All ||
Style.BreakConstructorInitializers != FormatStyle::BCIS_BeforeColon ||
Style.ColumnLimit != 0))
return true;
what do you think?
https://reviews.llvm.org/D32479
More information about the cfe-commits
mailing list