<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/111011>111011</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang-format adds unnecessary space before & when :: operator is used
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
mkaz101
</td>
</tr>
</table>
<pre>
I experienced a strange bug in clang-format in version 19.1.1.
I have a setting to keep reference (&) signs glued to the type on the left side. This formatting works for most functions, however if the function is in global scope (prepended with ::) clang-format is adding additional space between the type and &.
Here is the small code snippet that I used for testing.
```
class test {
friend std::ostream& ::operator<<(std::ostream & lhs,
const ::test_1::test2 &
rhs);
friend std::ostream& operator<<(std::ostream& lhs,
const ::test_1::test2& rhs);
}
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMU11v4yoQ_TX4ZVQLcGLHD37oh6Lb9_t-hWFsc4vBYnCy3V-_wknbbVZqFyHz4cOZc4ZBEdnRI3Zs_8D2T4Va0xRiN7-on4KLog_mtXsG_LFgtOg1GlBAKSo_IvTrCNaDdsqPd0OIs0p5fcJINngQbSlKUTL-xPj9M0zqhPkwpmT9CCnAC-ICEQeMmRmYPDBZM9lClkQwuhVNxqUJIb0uCMFvc4dDArIGS_h3sgSX0BvrOcSXbQPmQAmG1etkgycmH2EKZzxhBDtsLG__wFJWPbrQKwekw7JJWSIu6A0aONs0Aavuc5ftjV0CZUyOnIdMlzkWpRF6TGdE_6FeeQNM1teEXL7_YMRMkkE0K-dAB4NA3i4LJkiTSvAMK6HZTCWkbPMTBav5tW9L7RTRBgTWPFz2AIZ8ewYomYuRQCmimpmsr87CglGlEFn1mLs83EKzdHBTzuQb6fdNB591bDxZ0n_iYy4z499T5RZz-JZVD7_7_8rbt67-MPWl4oy-1dA83VxDYbrKtFWrCuxEI5u2EbIWxdTpmmMjDvu-Ubv9Yd82hg9Cil1jdvpw0H1hO8nlTnBeiZoLLkpd9fu26qt2JyuO2LMdx1lZVzp3mssQx8ISrdgJIbgQhVM9Onp7ybHLqLt-HYntuLOU6ONcsslh96mUlTEEq_eokUjF1_cyHkLE7fbPE_prat4zm4s3l2exRtdNKS20PZMjk8fRpmntSx1mJo858nW4W2L4H3Vi8rjJJyaPVwenTv4KAAD__8ugY-w">