QualifierAlignment not working on top-level const + typenames
Example input:
$ cat /tmp/main.cpp
#include <cstdint>
void foo(const std::int32_t x,
const std::int32_t& y)
{}
Output:
$ ./clang-format --style="{QualifierAlignment: Right}" /tmp/main.cpp
#include <cstdint>
void foo(const std::int32_t x, std::int32_t const &y) {}
The correct alignment is applied for the reference parameter, but not for the first (value) parameter.
@llvm/issue-subscribers-clang-format
@mydeveloperday I'm looking a bit at the code. It seems the reason why this doesn't work is that clang-format will only fix it if the type is a pointer, reference or rvalue reference:
if (Next && Next->isOneOf(tok::star, tok::amp, tok::ampamp) &&
Why is that? Not even this code works then, even though it's documented
// The case `const Foo` -> `Foo const`
There's no unit tests for that case :(
maybe this was overlooked because const on "by-value" arguments is discouraged
Yes, I can understand that. There are however a number of guidelines that require const to be applied to value arguments as well, so it's a use case that should be supported.
@rymiel @mydeveloperday Do you have any input on this issue?