[cfe-dev] clang-format: Multiple statements in line

Florian Lindner via cfe-dev cfe-dev at lists.llvm.org
Sun Aug 30 04:38:29 PDT 2015


Ok, I understand your reason, though I do not agree ;-)

Another question on clang-format regarding initializer lists:

I want my list to have one initializer per line, with the break after the comma.

ConstructorInitializerAllOnOneLineOrOnePerLine: true does this, but only if the unbroken list is longer than ColumnLimit

Is there a way to always break the initializer list after each entry? I understand the WebKit style guide to demand that:

> Constructors for C++ classes should initialize all of their members using
> C++ initializer syntax. Each member (and superclass) should be indented on
> a separate line, with the colon or comma preceding the member on that line.
http://www.webkit.org/coding/coding-style.html

Best Regards,
Florian

Am Mittwoch, 26. August 2015, 19:15:15 schrieb Daniel Jasper:
> On Wed, Aug 26, 2015 at 7:03 PM, Florian Lindner <mailinglists at xgm.de>
> wrote:
> 
> >
> > Am Mittwoch, 26. August 2015, 18:40:43 schrieb Daniel Jasper:
> > > Sure, there is bugs.llvm.org with a dedicated "Formatter" component.
> > >
> > > However, the bar for adding such features is:
> > > - Large project with open style guide recommending it.
> >
> > Why that? Of course, I'm not suggesting to change the default setting, but
> > I fail to understand how adding such a feature hurts if it doesn't change
> > the default.
> >
> 
> Every configuration flag has a certain cost. Among other things, this
> includes:
> - Style flags become less discoverable
> - Maintenance increases when ensuring that all combinations of flags work
> as expected
> 
> I'll try to put a more detailed explanation of the reasons on some
> documentation page.
> 
> In essence, we'd rather support a stricter set of rules really well instead
> trying to make clang-format work for everyone but doing a bad job of it.
> 
> > - Person willing to contribute an maintain a patch.
> >
> > Sure.
> >
> > Best Regards,
> > Florian
> >
> > >
> > >
> > > On Wed, Aug 26, 2015 at 5:40 PM, Florian Lindner <mailinglists at xgm.de>
> > > wrote:
> > >
> > > > Am Mittwoch, 26. August 2015, 13:11:32 schrieb Daniel Jasper:
> > > > > No, there isn't.
> > > >
> > > > Ok, thanks for that statement. Is this functionality planned somehow?
> > Is
> > > > there a bug tracker where I can file this as a wishlist item?
> > > >
> > > > Best Regards,
> > > > Florian
> > > >
> > > > >
> > > > > On Wed, Aug 26, 2015 at 11:23 AM, Florian Lindner via cfe-dev <
> > > > > cfe-dev at lists.llvm.org> wrote:
> > > > >
> > > > > > Hello,
> > > > > >
> > > > > > I have code like that:
> > > > > >
> > > > > > ierr = KSPDestroy(&ksp);CHKERRQ(ierr);
> > > > > >
> > > > > > clang-format introduces a linebreak between the two statements. Is
> > > > there a
> > > > > > possiblity to omit that?
> > > > > >
> > > > > > My configuration, based on style LLVM:
> > > > > >
> > > > > > AllowAllParametersOfDeclarationOnNextLine: true
> > > > > > AllowShortBlocksOnASingleLine: true
> > > > > > AllowShortCaseLabelsOnASingleLine: true
> > > > > > AllowShortIfStatementsOnASingleLine: true
> > > > > > AllowShortLoopsOnASingleLine: true
> > > > > > AllowShortFunctionsOnASingleLine: All
> > > > > > AlwaysBreakAfterDefinitionReturnType: false
> > > > > > AlwaysBreakTemplateDeclarations: false
> > > > > > AlwaysBreakBeforeMultilineStrings: false
> > > > > >
> > > > > > (I've just set every remotely related option to don't break)
> > > > > >
> > > > > > Thanks,
> > > > > > Florian
> > > > > > _______________________________________________
> > > > > > cfe-dev mailing list
> > > > > > cfe-dev at lists.llvm.org
> > > > > > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
> > > > > >
> > > >



More information about the cfe-dev mailing list