Clang-format Adds Space in Placement New Expression with Setting SpaceBeforeParens: ControlStatements #41501
Closed
Description
| Bugzilla Link | 42156 |
| Version | 8.0 |
| OS | Windows NT |
| Reporter | LLVM Bugzilla Contributor |
Extended Description
.clang-format file:
Language: Cpp
SpaceBeforeParens: ControlStatements
ColumnLimit: 0
After running clang-format the code is formatted as follows:
void Foo() {
new (place) Bar;
}
The new expression is not a control statement (the docs name for/if/while as examples). Instead, it works and feels much more like a function call. The parentheses are enclosing a parameter list, not a control expression. So this parameter list should be formatted like the one of a function call, like so:
void Foo() {
new(place) Bar;
}
Note the missing space before the parameter list.
Activity