Skip to content

[clang-format] Option to place names of functions, constructors and destructors on a new line #161730

@chghehe

Description

@chghehe

I would like to place names of functions, constructors and destructors (declarations and inline definitions) on a new line and leave all possible specifiers (such as explicit, constexpr, attributes and so on) on a separate line before the function name.

Currently it is possible only for function names using BreakAfterReturnType: All, but constructors and destructors have no return type.

Input:

class SomeClass {
public:
  constexpr SomeClass() noexcept = default;

  constexpr explicit SomeClass(int x);

  [[nodiscard]] std::shared_ptr<void> foo();
};

Desired output:

class SomeClass {
public:
  constexpr 
  SomeClass() noexcept = default;

  constexpr explicit 
  SomeClass(int x);

  [[nodiscard]] std::shared_ptr<void>  //< Formatted by BreakAfterReturnType: All
  foo();                               //<
};

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions