Issue 79132
Summary [feature request] [clang-format] Put brace on new line in constructor after multi-line member initializer list
Labels clang-format
Assignees
Reporter flyx
    To separate a constructor's member initializer list from its body, I'd like to use this style:

```c++
// short, all in one line, currently possible.
MyClass::MyClass(int val): val{val} {
    // body
}

// member initializers don't fit on one line.
// separate initializers from body by putting
// brace on new line, currently not possible.
MyClass::MyClass(int someValue, int anotherValue):
 some_value{some_value}, another_value{another_value}
{
    // body
}

// multi-line arguments, but inline initializers.
// currently possible.
MyClass::MyClass(
    int argumentWithVeryDetailedName
): val{argumentWithVeryDetailedName} {
 // body
}

// both multi-line arguments and multi-line initializers.
// as before, the brace on a new line is not possible.
MyClass::MyCLass(
    int argumentWithVeryDetailedName
):
 fieldWithVeryDetailedName{argumentWithVeryDetailedName}
{
    // body
}
```

So, the `{` should be on a new line if and only the member initializers are not inline. Currently, clang-format always puts it at the end of the line of the last initializer.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to