Skip to content

clang-format 21 regression involving pointer arrow operator #160518

@JohnC32

Description

@JohnC32

Running clang-format 21.1.1 on the following which was indented using clang-format 19:

const char* Element::getName(std::size_t eIdx) {
    return (getStructType()->getElements())[eIdx]->getName();
}

using _clang-format:

---
BasedOnStyle: Google
IndentWidth: 4
...

results in the incorrect addition of spaces around the pointer arrow operator " -> ":

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.

Metadata

Metadata

Assignees

Type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions