[Clang] Fix incorrectly places missing 'const' in defaulted member operator overload
For a defaulted member operator overload that is not const-qualified:
std::partial_ordering operator<=>(const Box& other) = default;
clang fixes it by inserting 'const' in the wrong position, at the end instead of after the argument list:
std::partial_ordering operator<=>(const Box& other const) = default;
Simple reproducer: Box.cpp
Building with clang -Xclang -fixit <other args> reproduces the issue.
This is with:
Debian clang version 21.1.8 (3+b1)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/lib/llvm-21/bin
Please see also: https://github.com/clangd/clangd/issues/2625#issuecomment-4104351161
For convenience, here is a slightly simplified version of the reproducer:
#include <compare>
struct Box {
std::partial_ordering operator<=>(const Box& other) = default;
int size;
};
Running clang-22 -std=c++23 -Xclang -fixit test.cpp on this produces the incorrect result from the issue description.
(Occurs with trunk as well.)
I would like to work on this!