Skip to content

[clang-format] Formatting regression in 17.0.0 introduces spacing around arrow operator in macros #66923

@sfc-gh-mheimel

Description

@sfc-gh-mheimel

It seems that there is a formatting regression in 17.0.0 that affects the spacing of the arrow operator in macros containing assignments. Here's a minimal example (with an empty clang format config) to reproduce the issue:

$ cat test.cpp
#define P(ptr) auto p = (ptr)->p

In version 16, this is correctly formatted:

$ clang-format-16 test.cpp
#define P(ptr) auto p = (ptr)->p
$ clang-format-16 --version
clang-format version 16.0.0

With version 17, clang-format (incorrectly) wants to add spacing around the arrow operator:

$ clang-format-17 test.cpp
#define P(ptr) auto p = (ptr) -> p
$ clang-format-17 --version
clang-format version 17.0.0

Interestingly, the behavior is switched when the macro is removed:

$ cat test.cpp
auto p = (ptr)->p;
$ clang-format-17 test.cpp
auto p = (ptr)->p;
$ clang-format-16 test.cpp
auto p = (ptr) -> p;

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions