Skip to content

[clang-format]: Feature Request add option to ReferenceAlignment when using east-const #139717

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
LucHermitte opened this issue May 13, 2025 · 1 comment

Comments

@LucHermitte
Copy link

It would be nice to have a way to have an extra option to ReferenceAlignment (and PointerAlignment I guess) when QualifierAlignment is set to Right in order to remove any space between const and &, and still add spaces before & the rest of the time.

AFAIK, it is currently (*) impossible to format in the following way:

SomeType & lvref;       // space before "&"
SomeType && rvref;      // space before "&&"
SomeType const& cref;   // no-space before "&", but before "const&"
SomeType const&& crvref // same thing

Indeed, if we select Middle for ReferenceAlignment, an extra space will be added to const &

(*) tested with clang-format 19, and the documentation of clang-format-21 shows no difference on the topic.

@llvmbot
Copy link
Member

llvmbot commented May 13, 2025

@llvm/issue-subscribers-clang-format

Author: Luc Hermitte (LucHermitte)

It would be nice to have a way to have an extra option to `ReferenceAlignment` (and `PointerAlignment` I guess) when `QualifierAlignment` is set to `Right` in order to remove any space between `const` and `&`, and still add spaces before `&` the rest of the time.

AFAIK, it is currently (*) impossible to format in the following way:

SomeType & lvref;       // space before "&"
SomeType && rvref;      // space before "&&"
SomeType const& cref;   // no-space before "&", but before "const&"
SomeType const&& crvref // same thing

Indeed, if we select Middle for ReferenceAlignment, an extra space will be added to const &

(*) tested with clang-format 19, and the documentation of clang-format-21 shows no difference on the topic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants