[cfe-dev] clang-format: Proposal for a new style for constructor and initializers line break.

Daniel Jasper djasper at google.com
Sun Sep 14 02:34:09 PDT 2014


Not entirely sure what advise you are looking for.
My thoughts:
- I am happy to accept a patch provided is has sufficient unit tests
- I think this should go in as a single patch, I don't see a need for "a
set of small patches"
- Personally, I think this style is bad as it makes it harder to
distinguish wrapped constructor arguments from initializers
- In particular, how do you indent:

Constructor( // Arguments too long to fit on the same line
    SomeArgument some_argument,
    SomeOtherArgument some_other_argument) :
    some_argument_(some_argument),
    some_other_argument_(some_other_argument) {
}

Is this style used in any large project or widely used style guide?

Cheers,
Daniel


On Sun, Sep 14, 2014 at 10:34 AM, Jean-philippe Dufraigne <
j.dufraigne at gmail.com> wrote:

> Hello,
>
> I'm interested in adding support for another style for constructor colon
> and initializer.
> An example of the style is above the value BCIS_AfterColonAndComma bellow.
>
> BreakConstructorInitializers would replace 'bool
> BreakConstructorInitializersBeforeComma;' while maintaining backward
> compatibility, in a similar fashion it was done before.
>
> I have the prototype for the code and would be really happy to finalize it
> and contribute a set of small patches.
>
> Please let me know if this something that fits with the project and if you
> have any advice.
> Best Regards,
> Jean-Philippe
>
>   /// \brief Different ways to break initializers.
>   enum BreakConstructorInitializersStyle
>   {
>     /// Constructor()
>     ///     : initializer1(),
>     ///       initializer2()
>     BCIS_BeforeColonAfterComma,
>     /// Constructor()
>     ///     : initializer1()
>     ///     , initializer2()
>     BCIS_BeforeColonAndComma,
>     /// Constructor() :
>     ///     initializer1(),
>     ///     initializer2()
>     BCIS_AfterColonAndComma
>   };
>
>   /// \brief Breaking and alignment style for constructor initializers
>   BreakConstructorInitializersStyle BreakConstructorInitializers;
>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140914/c0c7e10a/attachment.html>


More information about the cfe-dev mailing list