<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/54620>54620</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
ReferenceAlignment is affected by PointerAlignment the presence of AlignConsecutiveDeclarations
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Arkadiy-bb
</td>
</tr>
</table>
<pre>
When `AlignConsecutiveDeclarations` is true, the way `ReferenceAlignment` works changes depending on `PointerAlignment`:
```bash
$ echo "struct Test { ShortType& v1; SomeLongerType& v2; MuchMuchLongerType& v3;};" | clang-format-13 --style "{AlignConsecutiveDeclarations: true, PointerAlignment: Right, ReferenceAlignment: Left}"
struct Test {
ShortType & v1;
SomeLongerType & v2;
MuchMuchLongerType& v3;
};
$ echo "struct Test { ShortType& v1; SomeLongerType& v2; MuchMuchLongerType& v3;};" | clang-format-13 --style "{AlignConsecutiveDeclarations: true, PointerAlignment: Left, ReferenceAlignment: Left}"
struct Test {
ShortType& v1;
SomeLongerType& v2;
MuchMuchLongerType& v3;
};
$ echo "struct Test { ShortType& v1; SomeLongerType& v2; MuchMuchLongerType& v3;};" | clang-format-13 --style "{AlignConsecutiveDeclarations: true, PointerAlignment: Left, ReferenceAlignment: Right}"
struct Test {
ShortType & v1;
SomeLongerType & v2;
MuchMuchLongerType &v3;
};
$ echo "struct Test { ShortType& v1; SomeLongerType& v2; MuchMuchLongerType& v3;};" | clang-format-13 --style "{AlignConsecutiveDeclarations: true, PointerAlignment: Right, ReferenceAlignment: Right}"
struct Test {
ShortType &v1;
SomeLongerType &v2;
MuchMuchLongerType &v3;
};
```
In other words, when the alignments for pointer and reference are different, we get some "hybrid"of left and right, with spaces to the left or to the right of the `&`.
Is this expected behavior? Or a bug? I would expect that the reference alignment should be independent of pointer alignment...
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJztVk2PmzAQ_TVwGQWBgXwcOKQbrbTSVq22K_VsYAB3CUa2SZp_37FJUtJdJd0e20aEYM8b5s0b25Nclofsa4MdePNw3Yq6u5OdxmIwYocbLFquuBE0RWYQGowa0GN3YBqEPT9YryesUGFXoHPfYmcsdi_Vi4ai4V2NGkrssStFV4N0kT5L0RlUUw8vXnvhxgtPd5pxV851c5xiCWDRSPAY00SkMPCM2oC3-ADwpZHKPB96YjeH82cXebE1yi0-SmKipogdc0b4OBSN_V4idjFZvcXG3hmjIHdAanT1rJJqy80simE20-bQouVDHK6qF6_P0r3KnWxPom6MNb4hJpkfsTKWCsWZSPSLBuPkRImzCi4dq8QZcqHHGcImkGuijBxGaf72yjjpf7swt0ryWoK3S3IhxP-SvKck41Z6R01gKsK1bXLE3aiJhf17NblxgL2_KNPD68bZ5SB_XpRTo5kerQ8dSGpxyraxUtu89rZH2q7HT3lpICGhH8UA3pWgTrkDVwilqNzQybJHqNGAJvJW7eaQK1HSg6ygpeU8up803AvTgO55QZ3TSBfVgSjcceigQM52YLmzOd2DixTIt6GOjd97LAyWkGPDd0IqL76HT0QY8qG2zw-U5NCWRyA5cTPG-JnNKWXQjYPmCKIbe7qdJR5nGU7QIAj8MovLVbzivhGmxeyNtWH_UnCSaSR4eLW0HJFeoXY8KM61NeoPqs0aY3q7Wj12T1dNSg55UMgtDdp2d_qZ9Up-o6g0FFoPSCW-T5M5C_0mwyRZhWm6nCdhFCd5nCdxzjiWUbqYl2xR-S3PsdWZl9p91eEe3Cvs0k43vshYyFgYs1W0CBMWBdUyWsTpKl0iWyZVEXlJiFsu2sDyCKSqfZU5SlQOTcZWaKN_GrnWlDGiC0fv54OhPZKt1QsvxWGW576Lnjn2PwBbywmV">