<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/109925>109925</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang-format] Regression in formatting of explicit NTTPs with bitwise operators.
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang-format
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Jhuighuy
</td>
</tr>
</table>
<pre>
Hi everyone,
The latest released `clang-format` (19.1.0) cannot properly format nested calls, when the inner call contains explicit non-type template parameter expressions, containing bitwise operations. Expressions with arithmetic operations are formatted correctly.
`clang-format` 18 produces correct results.
The problem can be reproduced regardless of the presence or contents of `.clang-format`.
Example:
```sh
~ » cat a.cpp
void main() {
// Bitwise operations.
f(g<flag_1 | flag_2>());
f(g<flag_1 & flag_2>());
f(g<flag_1 ^ flag_2>());
f(g<flag_1 & ~flag_2>());
// Arithmetic operations.
f(g<flag_1 + flag_2>());
f(g<flag_1 - flag_2>());
f(g<flag_1 * flag_2>());
f(g<flag_1 / flag_2>());
}
~ » clang-format a.cpp
void main() {
// Bitwise operations.
f(g < flag_1 | flag_2 > ());
f(g < flag_1 & flag_2 > ());
f(g < flag_1 ^ flag_2 > ());
f(g < flag_1 & ~flag_2 > ());
// Arithmetic operations.
f(g<flag_1 + flag_2>());
f(g<flag_1 - flag_2>());
f(g<flag_1 * flag_2>());
f(g<flag_1 / flag_2>());
}
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzkVU2PmzAQ_TXmMgoiQwhw4LD5UtVDVVV7rwwM4MrYyDbZzWV_ewUhm2S7uxJSe2qEksh-b_xmePLj1opaEWUs2rBo5_HeNdpkX5te1E1_8nJdnrIvAuhI5qQVMdyyYMeCh_P3Y0MguSPrwJAkbqkEtg4KyVW9qLRpuWPrABgmy9Rf-gHDFAqulHbQGd2RkSc4w0CRdVRCwaW0DLfw1JAC1xAIpciM61Bo5bhQFui5k6IQDpRWC3fqCBy13aAEOm54S47MADJkrdBqLDiRhaohF-5JWIJBAXcDwIf9FQ1PwjXAjXBNS04UNzjghibFo1ptDBVOnvzbqbwzgWUyNFz2BdkLCQzZXjrrvx1oZ3QuqR0GBTmBoYlZgqGam1KStaCrcTiDZlIFgTZjg6TcuMfWgf9Gw905-2fedpJYeJV8fmxzXngBtkW22UDBHXC_6Lpb-lGLElouFMNkeKcs3pw3ABgeGB5g8-eIL4iKYVKzcFtJXv9cAou3MP5FFu7P9YYn3HyEx_U8fLSfXf_lE8KbRh_es8mHveJmlpbFTOUPM_GHz_As3t12fHXEja_O1oB_-_m7zgMWToa79R6wcA8fzuyO8-q_GZxXD8475-VT0n_oxMs15ZVZWKZhyj3KljHGGGG4Rq_Jomodx5iHPK3ipAyrVR5GcVilPF0nq1USeiLDAFdBilGQLFNEv-QxVWWSJEmMqzjP2SqglgvpS3lsfW1qT1jbU7YM0hQjT_KcpB3zEvHuikUcEtRkA2-R97Vlq0AK6-y1khNOjll7R4x28IPqKX1AqEvADFGlq2vYfXt8_D6F032CaWN9rzcya5zr7HCpj46ohWv63C90y_AwaJh-Fp3Rv6hwDA9ja5bhYerumOHvAAAA___WPUet">