Issue 160518
Summary clang-format 21 regression involving pointer arrow operator
Labels clang-format
Assignees
Reporter JohnC32
    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.

_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to