Skip to content

[clang-format] mistaking reference for binary operator in macro with clang-format 19 #100304

Closed
@rmarker

Description

@rmarker

While trying out clang-format on the new 19.x branch, I discovered an issue with the formatting in macros.
It is incorrectly treating the rvalue reference as a binary operator.

In clang-format 18.1.7 with the default LLVM style:

#define RVALUE_COPY(CLASS)                                                     \
  CLASS(CLASS &&That) : my(std::move(That.my)) {}

In clang-format 19.1.0 (183e8ec)

#define RVALUE_COPY(CLASS)                                                     \
  CLASS(CLASS && That) : my(std::move(That.my)) {}

I also discovered that a similar thing happens with * and & as well. I.e.

#define PTR_COPY(CLASS)                                                     \
  CLASS(CLASS * That) : my(That->my) {}
#define REF_COPY(CLASS)                                                     \
  CLASS(CLASS & That) : my(That.my) {}

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions