<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/130359>130359</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Clang-format-20.1 incorrectly formats variadic pack expansions with assignments
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang-format
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
lamarrr
</td>
</tr>
</table>
<pre>
Clang-format on the recent 20.1 release now incorrectly formats variadic pack expansions that have assignments in them.
A test-case is a hash-combine function:
```cpp
constexpr unsigned long long hash_combine(unsigned long long hash_a, unsigned long long hash_b)
{
hash_a ^= hash_b + 0x9e37'79b9 + (hash_a << 6) + (hash_a >> 2);
return hash_a;
}
template <typename... H>
constexpr unsigned long long hash_combine_n(unsigned long long hash_a, H... hash_b)
{
((hash_a = hash_combine(hash_a, hash_b)), ...);
return hash_a;
}
```
It formats `hash_combine_n` to:
```cpp
constexpr unsigned long long hash_combine(unsigned long long hash_a,
unsigned long long hash_b)
{
hash_a ^= hash_b + 0x9e37'79b9 + (hash_a << 6) + (hash_a >> 2);
return hash_a;
}
template <typename... H>
constexpr unsigned long long hash_combine_n(unsigned long long hash_a,
H... hash_b)
{
(hash_a = hash_combine(hash_a, hash_b), ...);
return hash_a;
}
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzsVN1yozwMfRpxowlj5ISfCy7SpJl-T9ExoAR_CzZjm7R9-x0gbbPd7W5zsXfLeGBGSEc64nCU9_pkmEvY3MFmH6kxtNaVneqVcy6qbPNS7jplTqujdb0KaA2GltFxzSYgiThBxx0rz2jsE2pTW-e4Dt0LLhUez8pp1egaB1V_Q34elPHaGo-hVQFbdWZcxujZBI967tDHILYgtlsM7MOqnhpojwpb5dtVbftKG8bjaOqgrQG5XdIhFcuphwHEtrbGB34eHI5mJtpgZ81puU1IjxckoPyzDAW0-7S8AiqmttkdiC1eChA29yD3lwwEukPxXLDMgLKsqIo5ApS_ZssdyB2mQD-_uQd5jzQ1kUsHx2F05nWyOQjZfiEfuB86FXhCDC8DG9VzHMf4MOHcsIxH86d1PEywv1oAUH49_v7jkt8h3quns8M4jr9I8_ozv0X-C296g1R8YJMKDPZva2Se-6vXPz19XN3vJHWjnm4S06sYoqaUTSELFXGZZOtE5mmeJFFbiiZbr9epkJTItUj4SFXOfKxlkTWskiLSJQnaCCkyIimliHOVNpyyzFkKOlYEa8G90l3cdec-tu4Uae9HLhMp5KaIOlVx52cHJqqvzBaIJk925VS3qsaTh7XotA_-HSno0PEPFr2aTfkmI37Sob324Gh0XdmGMPjpp6ED0OGkQztWcW17oMPU_fJYDc7-z3UAOsykPNDhwutc0vcAAAD__9_y-C0">