Skip to content

[clang-format] There is no option to disable BreakInheritanceList and BreakConstructorInitializers #61156

@nebraszka

Description

@nebraszka

Hi,
I want to achieve this formatting effect:

class D : public A, public B, public C
{
public:
  int id_c;
}; 

typedef enum : int
{
  ALL = 0,
  DEBUG = 1,
  INFO = 2,
  WARN = 3,
  ERROR = 4,
} log_level_t;

I want to use Mozilla style, so I generated .clang-format with Mozilla style parameters:

clang-format -style=mozilla -dump-config > .clang-format

After formatting using this .clang-format file, I got the following:

class D
  : public A
  , public B
  , public C
{
public:
  int id_c;
};

typedef enum
  : int
{
  ALL = 0,
  DEBUG = 1,
  INFO = 2,
  WARN = 3,
  ERROR = 4,
} log_level_t;

Trying to achieve my formatting goal, I found those values in the .clang-format file:

# BasedOnStyle:  Mozilla
BreakBeforeInheritanceComma: false
BreakInheritanceList: BeforeComma
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeComma

I want to disable line breaks, but there's no false value for those parameters:

# It doesn't work
BasedOnStyle:  Mozilla
BreakConstructorInitializers: false
BreakConstructorInitializers: false

I was only able to get the effect I wanted by commenting on the relevant parameters:

# BasedOnStyle:  Mozilla
BreakBeforeInheritanceComma: false
#BreakInheritanceList: BeforeComma
BreakConstructorInitializersBeforeComma: false
#BreakConstructorInitializers: BeforeComma

However, with this solution, I have to copy all the parameters from the Mozilla style instead of using BasedOnStyle: Mozilla.
Shouldn't there be an option to disable those parameters connected with breaks?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions