<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/160518>160518</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang-format 21 regression involving pointer arrow operator
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang-format
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
JohnC32
</td>
</tr>
</table>
<pre>
Running clang-format 21.1.1 on the following which was indented using clang-format 19:
```c++
const char* Element::getName(std::size_t eIdx) {
return (getStructType()->getElements())[eIdx]->getName();
}
```
using `_clang-format`:
```yaml
---
BasedOnStyle: Google
IndentWidth: 4
ColumnLimit: 100
AlignConsecutiveDeclarations: Consecutive
...
```
results in the incorrect addition of spaces around the pointer arrow operator " -> ":
```c++
const char* Element::getName(std::size_t eIdx) {
return (getStructType()->getElements())[eIdx] -> getName();
}
```
clang-format 19 does not add the whitespace around the pointer arrow operator.
Note, I'm upgrading from clang-format 19 to 21 and I did not try 20, so not sure when the behavior regressed.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzMVEGL6zYQ_jXyZYiRZDuxDz54d1_KlvIKfYUeF0Wa2CqyFKRx0vTXF9kp3e4W2mNhwGY0881830ijUrKjR-xZ88Sal0ItNIXYfx8m_1zJ4hTMvf9p8d76EbRTftydQ5wVgRSlKAUEDzQhnINz4ZaDbpPVE9xUAusNekIDS_qULTpWDYyvtuebaSafsvFBB58I9KQikwN8cTijp5xQDSPSVzUjk20is7mS_R3fCPDV_MZkB-yQIQAAItISPTDZjkjfKC6afr5fci6T3Y5VX0akB3janNmapxWpeXlEPMrloyojs8PL-643EhtFtudv72nm408072p2jA-73Y7x4UklND_6b3R3yKoBvgthdMj48LqK94s1NGV_zfjwHNwy-x_sbLMWIHiuPTg7-ufgE-qF7BVfUDsVFdngU456d8T4UJbl594jpsVRntc6Sut1iBE1gTLGZiAIZ0gXpTGBimHxZo27BOsJI6gYww3CBaOiEIFJCVm5_PP_n_HW6n-d8ocrDCZgAh9WpVZNbpMlXKX6d6XKDfNrIGTyGV6ZPMywXMaoTL5L5xjmj28GKIAUoLyBVzDWrLUp3kHyDJHC6khLzJ3gNs4TTupqQ4SIY8SU0OTChekr01WdKrAXh6Y9iE6Iupj6Q1Vxud-fhUJe7YVuO2xOe6lrrCpxatvC9pLLhneyFhVvRF0eVM0R26oRjVL6ULOa46ysK527zmWIY2FTWrAXe96ItnDqhC6t60bKvz0WKfMCin3O252WMbGaO5so_YVElhz2H_bQn8zyTbX-Gtw16_fPohdLdP1EdMmPg8kjk8fR0rScSh1mJo-50uOzu8TwK2pi8rgSSEweHxyuvfwjAAD__9TSoEo">