Skip to content

[clang-format] Awkward requires formatting with RequiresClausePosition: OwnLine #101550

Closed
@urnathan

Description

@urnathan

I think this counts as a defect report, rather than a feature request. With RequiresClausePosition: OwnLine, a function's open paren is placed at the beginning of a line, which is inconsistent with the underlying style of putting at the end of the preceding line.

Here's a formatting with that option. As you can see, in a declaration, the ending semicolon occupies the same line as the requires clause, but in a function definition, the opening brace does not.

// BasedOnStyle: LLVM
// RequiresClausePosition: OwnLine
// AlwaysBreakTemplateDeclarations: Yes

template <typename T>
int frob()
  requires(true); // semicolon at EOL, expected

template <typename T>
int Frob(T)
  requires(true)
{ // brace at SOL, unexpected
  return 00000000000000000000000000000000000000000;
}

template <typename T>
  requires(true)
class X; // class at SOL, expected

IMHO that definition would be better formatted as:

template <typename T>
int Frob(T)
  requires(true) {
  return 00000000000000000000000000000000000000000;
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions