<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/61270>61270</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang-format messes up the formatting of constrained templates
</td>
</tr>
<tr>
<th>Labels</th>
<td>
c++20,
clang-format,
concepts
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
usx95
</td>
</tr>
</table>
<pre>
Some, but not all, C++20 requires expressions are severely mangled. This seems to be much more likely when ref qualifications are involved. Examples:
1. This:
```c++
template <typename F>
auto Bind (F f) && requires true;
```
is turned into this:
```c++
template <typename F>
auto Bind(F f) &&
requires true;
```
2. This:
```c++
template <internal::coroutine_result T>
template <typename F>
auto CoFuture<T>::Bind(F f) &&
requires true {
return 0;
}
```
is turned into this:
```c++
template <internal::coroutine_result T>
template <typename F>
auto CoFuture<T>::Bind(F f) &&
requires true
{
return 0;
}
```
3. This:
```cpp
template <typename T>
int foofoofoofoofoofoofoo(T t) &&
requires { abcdabcdabcdabcdabcd;abcdabcdabcdabcdabcd; }
{
return 0;
}
```
is turned into this:
```cpp
template <typename T>
int foofoofoofoofoofoofoo(T t) && requires {
abcdabcdabcdabcdabcd;
abcdabcdabcdabcdabcd;
} {
return 0;
}
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzElctyozoQhp9GbLriAslgWLAIdniBk_0pAY3RjJCILp7k7afAicGXmdwW48LYNE3r__5uFdxasVeIOYkLEu8C7l2nTe7tcxYHlW5e8v90j4RuofIOlHbApRwvt4QWhBY0BINPXhi0gM-DQWuFVha4QbB4QIPyBXqu9hKbFTx2woJF7C04DRVC7-sOem0QpPg5pv7qUIHBFp48l6IVNXenekIdtDyMdR6eeT9ItITdk3BHwtdzdFzhIgoAQJLweNRH2fMdh_0guUMgbOteBlS8RygJe5hTuHcaCqEaIDQtoSU0A0ITQpOZ3RmPhBU3VlyETv-EBeeNwgaEchrcUvQi81uqz5RfCn9N-7D845mu4JMGL3UK5dAoLsen2X2tjfZOKPzfoPXSweOZ-vcAJ7KtLr3zBgnbTk9Phf-CO33OmIFsivObY18gPPdis_sXff2UX58dii9Zd2Xf0qPv-cgut-7JomE4Rm7SzSYI5aDV-vogNH0Edw10AiGbAnhVN5dfwoo_hGeSGfuKeM45J709I_BF7GnqPop-xvy2kW4jLpv5bgrZ7JYD8GErgiZnTcYyHmAeJZuUheuIJUGXpxilvFqzDJOoSbOmoi2rm5rGaV1lTcgDkdOQspCFaZSxmCWrKmyjuNmwquaYxFFI1iH2XMiVlId-pc0-ENZ6zJOIbsJA8gqlnd55lNZvbzJCKaHbMSK52t-12vTczUGtahycHQPxLjD5WPmu8ntL1qEU1tl5LSecxHxZBnq0Fi34AVyHcAw6ofagW6i1ss5wMQ7FW79t4I3MO-eGaVPQktByL1znq1Wte0LLcbHXn7vB6B9YO0LLidISWk6gvwMAAP__Oeo74A">