Skip to content

[clang-format] no space in cdtor declaration with SpaceBeforeParensOptions: AfterFunctionDeclarationName: true #98812

Closed
@urnathan

Description

@urnathan

It seems that cdtors (as they pedantically have no name?) do not pay attention to AfterFunctionDeclarationName: true or AfterFunctionDefinitionName: true with SpaceBeforeParens: custom style options. Aesthetically this is undesired -- the space in the declaration/definition makes the name stand out more.

/*
.clang-format contents:
BasedOnStyle: LLVM
SpaceBeforeParens: Custom
SpaceBeforeParensOptions:
  AfterFunctionDeclarationName: true
  AfterFunctionDefinitionName: true
*/

struct A {
  // space before (, as expected
  void frob();     // void frob ();

  // no space before (, unexpected
  A (int);   // A(int);
  A (int) {} // A(int) {}
  ~A ();     // ~A();
  ~A ();     // ~A() {}
};

void fn (A &a) 
{
  // no space before (, expected
  (void)A (); // (void)A();
  a.frob ();  // a.frob();
  a.~A ();    // a.~A();
}

Perhaps the type should be considered the name in these cases? or a new cdtor-specific spacing option?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions