Skip to content

clang-format AlwaysBreakConstructorInitializers #43246

@llvmbot

Description

@llvmbot
Bugzilla Link 43901
Version unspecified
OS Windows NT
Reporter LLVM Bugzilla Contributor
CC @mydeveloperday

Extended Description

I was wondering if it would be possible to add an option to always break constructor initializers. For example:

AlwaysBreakConstructorInitializers (booL)

if true, always break the constructor initializer list, regardless if they can all fit on a single line (the style is dictated by BreakConstructorInitializers:

true:
Constructor() :
initializer1(),
initializer2()

false:
Constructor() : initializer1(), initializer2()

IMO... clang-format works too hard to get everything to fit on a single line, but this specific instance really makes the code hard to read. It also makes it had to add // NOLINT tags as clang-format will move the comment around. For example:

Constructor() : // NOLINT
initializer1(),
initializer2()

becomes

Constructor() :
// NOLINT
initializer1(),
initializer2()

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions