<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/56215>56215</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang-format: constructor initializers are not formatted after a requires clause
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
elevendroids
</td>
</tr>
</table>
<pre>
Hello again :grin:
Take a look at the following example:
```c++
template <typename T>
struct Foo {
constexpr Foo(int value_)
: value{value_}
{
do_magic();
do_more_magic();
}
template<typename U>
requires std::is_copy_constructible<T>
constexpr Foo(Foo<U> const & other)
: value{other.value}
{
do_magic();
do_more_magic();
}
constexpr Foo(Foo const & other) requires std::is_copy_constructible<T>
: value{other.value}
{
do_magic();
do_more_magic();
}
constexpr Foo(Foo const & other) requires (std::is_copy_constructible<T>)
: value{other.value}
{
do_magic();
do_more_magic();
}
int value;
};
```
Formatting this with `--style="{BasedOnStyle: llvm, BreakConstructorInitializers: BeforeColon, ConstructorInitializerIndentWidth: 4, PackConstructorInitializers: Never}"` produces this output:
```c++
template <typename T> struct Foo {
// OK
constexpr Foo(int value_)
: value{value_} {
do_magic();
do_more_magic();
}
// OK
template <typename U>
requires std::is_copy_constructible<T>
constexpr Foo(Foo<U> const &other)
: value{other.value} {
do_magic();
do_more_magic();
}
// Not OK - initializers list not indented
template <typename U>
constexpr Foo(Foo<U> const &other)
requires std::is_copy_constructible<T>
: value{other.value} {
do_magic();
do_more_magic();
}
// Not OK - initializers list not indented
constexpr Foo(Foo const &other)
requires std::is_copy_constructible<T>
: value{other.value} {
do_magic();
do_more_magic();
}
// Not OK - initializers list not indented
constexpr Foo(Foo const &other)
requires(std::is_copy_constructible<T>)
: value{other.value} {
do_magic();
do_more_magic();
}
int value;
};
```
Version tested:
clang-format version 15.0.0 (https://github.com/llvm/llvm-project.git 1f69f7ea9af4bd4e8001a25044aa026557f366f7)
Platform:
Arch Linux, x86_64
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJztVtuO0zAQ_Zr0xWqVOLf2IQ9tlwoEAiQWeKycZJKade1iO3vh6xknve3SLaULK5CIrKTxHE_OHI9nmqvyLnsJQijCasYl8cJxrbnEByGef-H540t2BYQRodQVYZbYBZBK4YIbLmsCt2y5EoDwDry-J343Co9O3GhnLSCUWcBvTO3dCiRbArn0whed2VjdFJbMlCJeOtl3R_AqlDQWblfaATw65NKSayYamHt0tIM53u00ulib04s988YxWV-lmi9ZzZHn0PkJD5iVhkcxW-e7qU2U-0F-3AbpEBq-NlyDIcaWTrhwzM28UKu7eRukU4HnTtPp5b11DyVw93DqfHcm4tGEKNwf_agkrXWwfnteXQ6wP0D7bHH-0SgRclqgf-GObo_gFuhA29-bGrC_bKb0klnrKoddcENuuF0QxPT7xt65YC88SpH6hBko38kP3eSYCHG99OiUTDSwq-lGH6VfSW45E_wbaONwE6gwiKkSSjr4YeQrWYK0n3lpF25N5JDvWXHM71u4xo1LW3aJT1ZalU2B29cGoRq7auzTSiA5WP3oDAd593qj-YlF8JEyeD8njuTD8VzYZcJDegej-x2175TK92PhO3ZQ_pAWb5VFPUgfz8YugYjgSFGiibeZB-XJgp0X-HkiP6NYT5DsaIH9L8UJUpzRcp5bj5_2lsc7zCeUjCuJR8s4qTZFuRBM1v2qbT_keo0J4oE_8F0PXli7coW-24gau1KTDwqFPWfWtZ720ce6_wUKO0AACapkVKXARqyK8jKCoe8HjMZ-FDHm0ySO0ypMkirdytjd3-N5dzS2zMa6WJA3XDa3rg_dDpN5EvXKLCxH4Yj1LLcCsn32bi-KXae6nytMQ5sqHRQFIKyyoPHv-_YgoK_GQK_RIvu1qPGVG9O4BJrFCQ3i3iJL_ZxCxYowZmXBIhpTf5imEQuSUZpTWvUEy0GYzIuxB1IJN6R14dpofNHjGfUp9RMaB1Ec0nQQB6zK8zxOkmBU5UHsRT4sGRcDx2OgdN3TWUspb2qDRnc0zM7IjOG1BGg_h_5ZYxdKZyCwe8tSK16aXvv9rOX_HbbmzcY">