Clang-format 10.0 vs. 5.0 const member fuction is formated differently

Viewed 254

We are updating our clang-format from 5.0 to 10.0 (yes, I know that this is a big jump :-)) The file .clang-format is kept constant.

With the 5.0 version we get a format like this

virtual Composite *copy_composite_tree(Composite *parent  // parent of copied tree
                                      ) const;

With the 10.0 version this changes to

virtual Composite *copy_composite_tree(Composite *parent  // parent of copied tree
) const;

Is there an option to keep the 5.0 formatting style?

2 Answers

I consider this to be a bug, which was introduced with clang-format 9.0.1, since all buildin styles, such as LLVM, Google, ... show the very same behaviour.

I reported this bug to the llvm project.

https://bugs.llvm.org/show_bug.cgi?id=46509

I'd assume this is simply governed by bracket alignment just like everything else, quoting clang documentation:

AlignAfterOpenBracket (BracketAlignmentStyle) If true, horizontally aligns arguments after an open bracket. This applies to round brackets (parentheses), angle brackets and square brackets.

Possible values:

BAS_Align (in configuration: Align) Align parameters on the open bracket, e.g.:

someLongFunction(argument1,
                 argument2);

BAS_DontAlign (in configuration: DontAlign) Don’t align, instead use ContinuationIndentWidth, e.g.:

someLongFunction(argument1,
    argument2);

BAS_AlwaysBreak (in configuration: AlwaysBreak) Always break after an open bracket, if the parameters don’t fit on a single line, e.g.:

someLongFunction(
    argument1, argument2);
Related