Skip to content

clang-format 16 doesn't respect BreakAfterAttributes option for constructors #63046

Closed
@calcmogul

Description

@calcmogul

When the BreakAfterAttributes option in clang-format 16 is set to Always, it introduces a newline after attributes for member functions, but not for constructors. It seems like it should break after attributes for constructors as well.

Example input in a file called Test.cpp:

class Test {
public:
  [[deprecated]] Test(int);

  [[deprecated("msg")]] Test(double);

  [[deprecated]] void Func1();

  [[deprecated("msg")]] void Func2();
};

Command:

clang-format --style="{BreakAfterAttributes: Always}" Test.cpp

Expected output:

class Test {
public:
  [[deprecated]]
  Test(int);

  [[deprecated("msg")]]
  Test(double);

  [[deprecated]]
  void Func1();

  [[deprecated("msg")]]
  void Func2();
};

Actual output:

class Test {
public:
  [[deprecated]] Test(int);

  [[deprecated("msg")]] Test(double);

  [[deprecated]]
  void Func1();

  [[deprecated("msg")]]
  void Func2();
};

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions