llvm / llvm/llvm-project

[clang-format] Option for putting `requires`-clause and `= default;` in one line

Open
#216,973 2 comments 0 reactions 0 assignees View on GitHub
clang-format
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

It seems that clang-format hasn't supported putting trailing `requires`-clause and `= default;` in one line. E.g. the following style isn't properly supported.
```C++
template
struct Foo {
Foo() requires Bar = default; // <- Currently clang-format puts this in more than one lines.
};
```

Such formatting style has been becoming more and more frequent in the C++ working draft/standard since [P2325R3](https://wg21.link/p2325r3). I guess clang-format should support it.

Contributor guide

Open the contributing guide

Research direction

Start by running clang-format on the C++ example in the issue and compare its output with the requested single-line form. Trace the formatting path that handles trailing requires-clauses and defaulted declarations, then add coverage showing the declaration remains on one line when it fits.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.