[all-commits] [llvm/llvm-project] 6f065b: [clangd][c++20]Consider rewritten binary operators...
jensmassberg via All-commits
all-commits at lists.llvm.org
Mon Jun 26 02:29:25 PDT 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 6f065bfd633d7ca006f62b894108d5369dc46836
https://github.com/llvm/llvm-project/commit/6f065bfd633d7ca006f62b894108d5369dc46836
Author: Jens Massberg <massberg at google.com>
Date: 2023-06-26 (Mon, 26 Jun 2023)
Changed paths:
M clang-tools-extra/clangd/FindTarget.cpp
M clang-tools-extra/clangd/unittests/FindTargetTests.cpp
M clang-tools-extra/clangd/unittests/HoverTests.cpp
Log Message:
-----------
[clangd][c++20]Consider rewritten binary operators in TargetFinder
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==".
Differential Revision: https://reviews.llvm.org/D153331
More information about the All-commits
mailing list