<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/69234>69234</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Clang-Format misformats Thread Safety Analysis annotations that include an arrow
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang-format
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
petrhosek
</td>
</tr>
</table>
<pre>
For the following snippet:
```cpp
#if __has_attribute(capability)
#define LOCKABLE(name) __attribute__((capability(name)))
#endif
#if __has_attribute(unlock_function)
#define UNLOCK_FUNCTION(...) __attribute__((unlock_function(__VA_ARGS__)))
#endif
struct LOCKABLE("M") M {
void unlock() UNLOCK_FUNCTION();
};
class L {
public:
void f() UNLOCK_FUNCTION(this->mutex_) { this->mutex_.unlock(); }
private:
M mutex_;
};
```
#67780 changed the behavior where it would insert extra spaces around the arrow in the annotation, so the following:
```cpp
void f() UNLOCK_FUNCTION(this->mutex_) { this->mutex_.unlock(); }
```
becomes:
```cpp
void f() UNLOCK_FUNCTION(this -> mutex_) { this->mutex_.unlock(); }
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0lFtvozwQhn-NuRkFEUMIXHCRQ_n0aXuQtu3eImOG4K2xkW2S5t-vIEmT9KC9qFayDFgz7_vYM4ZZKzYKMSOzJZmtPda7RpusQ2cabfHFK3W1z3JtwDUItZZS74TagFWi69CRcEGCNQlOcxwcBu-64woNRQ1F0TBbMOeMKHuHhCacdawUUrg9oelbaIW1UAi3D6sfi-XtDaGJYi0SmkJxzi4KQpN3Eqe44zjpoapEfQX4BU6vpOYvRd0r7oRWnzA93w9URf58v3r6_-Ge0MT3_S_IPqglRfFrUSx-_vc4hPyV0jrTc3d5DITSO0Lp4HcHZL48xAFstajgYDdGpZ9wDlbhMYPM1-f3ceaSWQu3Z9GuL6Xgb4U9etRfyrtG2AkJb9re4euwu0EKrlf9S0QSLmHguIDojNgyhxemd3DU-5T81GbvShvP50kAvGFqg9XYsCU2bCu0gV2DBkE42OleViCUReMAX51hYDvG0QIzuleHNGaM3oFQhw-ltGOHQq7A6uubcL4BH3r_Xx_d9SmUyHWL9rs8MFjDN4m8KgurNEyZh9k0TufRPJ2lsddkMZ-mPKmi2TASFs-ikvNqPi2TOkzjmHoiowENp8E0niZBHMY-RlHJprSqozKIZqwkUYAtE9KXctv62mw8YW2PWZzSMPIkK1Ha8WdGKZdMbSa1Ni1zw-WZrT2TDWmTst9YEgVSWGfPQk44idlqzMrHLGiFPeRbeGoMsgoeWY1uDwvF5N4Ke9EdFlzDHAjFZV8NbXNsI683Mmuc68ba0JzQfCNc05c-1y2h-eB_fEw6o38jd4Tm464sofm4sT8BAAD__58Krg0">