In C++20 some binary operations can be rewritten, e.g. a != b
can be rewritten to !(a == b) if != is not explicitly defined.
The TargetFinder hasn't considered the corresponding CXXRewrittenBinaryOperator yet. This resulted that the definition of such operators couldn't be found
when navigating to such a != operator, see https://github.com/clangd/clangd/issues/1476.
In this patch we add support of CXXRewrittenBinaryOperator in FindTarget.
In such a case we redirect to the inner binary operator of the decomposed form.
E.g. in case that a != b has been rewritten to !(a == b) we go to the
== operator. The == operator might be implicitly defined (e.g. by a <=>
operator), but this case is already handled, see the new test.
I'm not sure if I the hover test which is added in this patch is the right one,
but at least is passed with this patch and fails without it :)
Note, that it might be a bit missleading that hovering over a != refers to
"instance method operator==".
this template pattern vs instantiation is really surprising, but it's a reasonable analogy, I don't see any particular problems. (Also, operator<=> looks like a template over whatever = is!)
Do you know whether this means go-to-definition gives you two options to navigate to?
(No need to write a test, just curious)