<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/139717>139717</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang-format]: Feature Request add option to ReferenceAlignment when using east-const
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang-format
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
LucHermitte
</td>
</tr>
</table>
<pre>
It would be nice to have a way to have an extra option to `ReferenceAlignment` (and `PointerAlignment` I guess) when `QualifierAlignment` is set to `Right` in order to remove any space between `const` and `&`, and still add spaces before `&` the rest of the time.
AFAIK, it is currently (*) impossible to format in the following way:
```c++
SomeType & lvref; // space before "&"
SomeType && rvref; // space before "&&"
SomeType const& cref; // no-space before "&", but before "const&"
SomeType const&& crvref // same thing
```
Indeed, if we select `Middle` for `ReferenceAlignment`, an extra space will be added to `const &`
(*) tested with clang-format 19, and the documentation of clang-format-21 shows no difference on the topic.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJx8VNGOqzYQ_RrzMkoEJkB44IHdVdSordRu-wMGD-DK2Kk9hObvKwObbPZqb4SSMPYcn5lzxsJ71RvEimUvLHuLxESDddVvU_sLulERYdRYeavOBLOdtIQGwagWgSwM4oogYBa3x5sB_I-cAHshZU2Iszx-xw4dmhZrrXozoiGWx8D4URgZ1v-wyhC6p9Uz9BN6z3gJ84AmbPtzElp16stG5cEjfZyk-mGNGrBOogtxh6NduN3AX0SL0CDNuGK21vglYaPCeL58vy4BT0prEFKuiR4a7KzDx0agAcGhJ7Dd8p_UiHsW1yyu61N9_jUgKQok28k5NKRvoXDG61AZqPFivVeNXhraWTcKCtwDVGe1trMyfegwS-sVNRy9PC3jL-GJ67_siH_fLgiM56CvDjuWvsD6YfzE-Ole98qe88Ce8y-5Id09pf8s-yvA2kmeQ3tH2NKN3X1zPn-FZqJP8Q-Qb7BX-EDxTk2MCDQo03_uzdqqs5GIclGggxnBo8aWgni_Kyk1Bv0667516OqCzdBrBXPwQ4PBEig3zy3kYDPOqtFdYEJPKGFWNECrhel3m8ZJ-eGxILW07RQOFcvQ2O5p744n4Ac7ezAWpOo2pmBXm5C9qHYfySqVZVqKCKukOBRJejyUeTRUbSfEMRcCseCdwLjEMimL8lgUMhcywUhVPOZZnCVpwpNDlu9TkcUNj5uiyNOuExk7xDgKpfdaX8e9dX2kvJ-wStKySIpIiwa1X-4Pzj_zDhpmb5GrQt6umXrPDrFWnvwDiRTp5e55SszeWFrDCQVNDuEd_53ChIUxfFwrPyq23hOTDxODwtNuESaanK4GoosPI7SYplc0TM2-tSPjp0Bl-9ldnP0HW2L8tFToGT9tRV4r_n8AAAD__-vhog8">