<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/140664>140664</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
ReferenceAlignment does NOT work properly (depends on the content of the file being formated)
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
huweiATgithub
</td>
</tr>
</table>
<pre>
The clang-format behaves differently on `Reference Alignment` for different inputs.
```yaml
Language: Cpp
BasedOnStyle: Google
ColumnLimit: 120
SortIncludes: Never
IndentPPDirectives: BeforeHash
InsertNewlineAtEOF: true
ReferenceAlignment: Left
```
## Case 1
When all references are right-aligned initially, it is not being formatted.
input:
```cpp
int f(int &a, int &b) { return a + b; }
```
output:
```cpp
int f(int &a, int &b) { return a + b; }
```
## Case 2
When one reference is left-aligned initially, the other also got formatted.
input:
```cpp
int f(int &a, int& b) { return a + b; }
```
output:
```cpp
int f(int& a, int& b) { return a + b; }
```
## Other info
If use command-line option `--style="{ReferenceAlignment: Left}"`, both cases got formatted correctly.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJy8lN2K6zYQx59GvhkSFNmWkwtfOJumXVh2Dz0LvZbtka1Wlow0zpK3L3L2NN0uLf2AgkD2aDSa_4-ZUTGawSHWrDyy8pSphUYf6nF5Q9O8DobGpc1a31_r1xGhs8oNG-3DpAhaHNUFI_RGawzoyF7BO2CS_4iroUNorBnchI6Y5KB9uDuDcfNCcct4k5bkt3VVk2W8eVJuWNSALG_gYZ4Zb44qYv_ivtLVrtbvvR8sMt48eLtM7slMhpJ9JzjjzVcf6NF1dukxJuszXjAw3jy6Hh19-XIyATsyl9vpEbUP-IOK4-oSMdAzvlnjsKHvXs7JhcKSHvtN2V1Y3sATavq9iHdNImcihwcVEXaMNz-N6EBZC-FbkAgqIAQzjLRRKSD2YJwho6y9MvEAhsBEcD7BNm6AG3nC_h3bypDlHwh2Ky7jCDQT-7QzIdUa7fbdMnEAVh0hIC3BgQImjtCy_AisOn3W4Rf6H175AzDxDZh3eAeWaFjUf0KLRgRPIwZQNnoYPP13YExI-EdS_h6tFPZfP3FH9bKqNU77m_lRwxIROj9NyvWbVMHgZzK3ttxs4q17TkwIVh3_opir1UXylGLraYRORYwfkULnQ-oie01ws77O-0N-UBnWu6qoqh3f5yIb672UUuu9lPv-UMoKZbnT8iCqCttDoQ86M7XgouSl4Dzf5aXYllq2rd6Jsii6viwkKzhOytittZdp68OQmRgXrHcFl7LIrGrRxnWACeHwDdbTlH95ykKdLm3aZYis4NZEivcwZMhi_RkD9B4jPL-8wpsPv8Ac_IzBXoGJfY8zuj6mQZfKrfOO0gWv119tLH5oVeyZOGRLsPVINKdhw8SZifNtsG47PzFxTvm8b5s5-J-xIybOq4rIxPld5qUWvwYAAP__yGO9qQ">