Add support for C++20 operator rewriting
Overview
We can't find the != operator because it's not there. In C++20, a new comparison operator was introduced, called the spaceship operator. Along with this came the compiler's ability to rewrite other operators to just use == or <=> (spaceship). So, in C++20 mode, there is no != defined for std::vector<int>::iterator. In fact, if you write this out:
std::vector<int>::iterator a, b;
auto r{ a != b };
And then you use LSP to jump to the != function used, it'll jump you to the == function instead. This is because the != has been rewitten to use == followed by a unary !, so it's actually doing !(a == b). This throws a huge wrench into how we handle things, since in every other scenario we can just have a single function to call. Now we need to figure out how Clang rewrote our operator and apply the rewrite on jank's side, too.
The new <=> operator is meant to encompass <, <=, ==, !=, >, >= . But clearly rewriting can also be done not to <=> but to ==. So we'll need to know which operator we're trying to find and then have some fallbacks to find instead. If we find a fallback (like == instead of != ), we need also to then support adding the ! on there.
It's a whole feature on its own.
Test case
(let [a ((cpp/type "std::vector<int>::iterator"))
_ (cpp/!= a a)]
)
This ticket is weird.
- It doesn't describe a bug.
- It overlaps with #414.
- It treats #414 as a sub task, when that its own standalone feature.
If this is a bug ticket for the reason I needed the it_neq, let's actually make a bug ticket for that. That bug ticket says that cpp/!= doesn't work on two references to iterators.
Let's not conflate bug tickets with feature tickets.
Fair enough, updated the issue 👍.