Skip to content

Clang-format Adds Space in Placement New Expression with Setting SpaceBeforeParens: ControlStatements #41501

@llvmbot

Description

@llvmbot
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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillaclang-formatenhancementImproving things as opposed to bug fixing, e.g. new or missing featuregood first issuehttps://github.com/llvm/llvm-project/contribute

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions