[PATCH] D14484: [clang-format] Formatting constructor initializer lists by putting them always on different lines

Andrew Somerville via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 15 21:34:46 PDT 2020


catskul added a comment.

In D14484#2246171 <https://reviews.llvm.org/D14484#2246171>, @FStefanni wrote:

> Hi to all,
>
> I am also interested to this option, since match my personal style, but more important, in my experience, this kind of formatting is very used.
> I hope it will be implemented in a near future.
>
> Which is the current status? Is someone going to support this?
>
> Regards.

@FStefanni it seems `ConstructorInitializerAllOnOneLineOrOnePerLine =  false` may do the trick per @MyDeveloperDay .

I tried this and had success so far. Try it out and see if it resolves your use case.

In D14484#1689271 <https://reviews.llvm.org/D14484#1689271>, @MyDeveloperDay wrote:

> Looking at this I'm wondering if this Isn't at least partially handled by the `BreakConstructorInitializersStyle`  in combination with `ConstructorInitializerAllOnOneLineOrOnePerLine` style?
>
> I can't be exactly sure but I think BreakConstructorInitializersStyle  didn't exist before 2017 D32479: clang-format: Introduce BreakConstructorInitializers option <https://reviews.llvm.org/D32479> when this original patch was submitted
>
>   BreakConstructorInitializers: BeforeComma
>   ConstructorInitializerAllOnOneLineOrOnePerLine: true
>   
>   SomeClass::Constructor() : aaaaaa(aaaaaaa), bbbbbb(bbbbbbb), cc(cc) {}
>   
>   SomeClass::Constructor()
>       : aaaaaa(aaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaa,
>                aaaaaaaaaaaaaaaaaaa)
>       , bbbbbb(bbbbbbb)
>       , cc(cc) {}
>
>
>
>   BreakConstructorInitializers: BeforeComma
>   ConstructorInitializerAllOnOneLineOrOnePerLine: false
>   
>   SomeClass::Constructor()
>       : aaaaaa(aaaaaaa)
>       , bbbbbb(bbbbbbb)
>       , cc(cc) {}
>   
>   SomeClass::Constructor()
>       : aaaaaa(aaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaa,
>                aaaaaaaaaaaaaaaaaaa)
>       , bbbbbb(bbbbbbb)
>       , cc(cc) {}
>
> At least the unit tests appear to be covered by using those styles?
>
> Nit: At a minimum, this patch would need to be rebased and be a full context diff, can anyone see a  use case that can't be covered with what we have?
>
> Moving to "request changes" (really request to abandon if not necessary any longer)




Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D14484/new/

https://reviews.llvm.org/D14484



More information about the llvm-commits mailing list