[clang-tools-extra] ee648c0 - [clang][index] Index unresolved member expression as reference
Aleksandr Platonov via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 19 09:03:36 PDT 2022
Author: Denis Fatkulin
Date: 2022-08-19T19:02:42+03:00
New Revision: ee648c0ce09b1edcee65407041eab38228f4b042
URL: https://github.com/llvm/llvm-project/commit/ee648c0ce09b1edcee65407041eab38228f4b042
DIFF: https://github.com/llvm/llvm-project/commit/ee648c0ce09b1edcee65407041eab38228f4b042.diff
LOG: [clang][index] Index unresolved member expression as reference
Unresolved member expressions aren't indexed as references.
Example code:
```
struct Foo {
template <typename T> void bar(T t);
};
template <typename T> void test(Foo F, T t) {
F.bar(t); // Not indexed
}
```
Reviewed By: hokein
Differential Revision: https://reviews.llvm.org/D131091
Added:
Modified:
clang-tools-extra/clangd/unittests/XRefsTests.cpp
clang/lib/Index/IndexBody.cpp
clang/test/Index/Core/index-dependent-source.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clangd/unittests/XRefsTests.cpp b/clang-tools-extra/clangd/unittests/XRefsTests.cpp
index 40650c36046cb..e9e6b6f79a2d5 100644
--- a/clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ b/clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -2090,6 +2090,14 @@ TEST(FindReferences, WithinAST) {
[[f^oo]](s);
}
)cpp",
+ R"cpp(// unresolved member expression
+ struct Foo {
+ template <typename T> void $decl[[b^ar]](T t);
+ };
+ template <typename T> void test(Foo F, T t) {
+ F.[[bar]](t);
+ }
+ )cpp",
// Enum base
R"cpp(
diff --git a/clang/lib/Index/IndexBody.cpp b/clang/lib/Index/IndexBody.cpp
index eb8905a7459cd..8b8235c133023 100644
--- a/clang/lib/Index/IndexBody.cpp
+++ b/clang/lib/Index/IndexBody.cpp
@@ -468,7 +468,7 @@ class BodyIndexer : public RecursiveASTVisitor<BodyIndexer> {
return true;
}
- bool VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) {
+ bool VisitOverloadExpr(OverloadExpr *E) {
SmallVector<SymbolRelation, 4> Relations;
SymbolRoleSet Roles = getRolesForRef(E, Relations);
for (auto *D : E->decls())
diff --git a/clang/test/Index/Core/index-dependent-source.cpp b/clang/test/Index/Core/index-dependent-source.cpp
index 8832edefd5bf9..8fec9abd1e926 100644
--- a/clang/test/Index/Core/index-dependent-source.cpp
+++ b/clang/test/Index/Core/index-dependent-source.cpp
@@ -231,3 +231,12 @@ template <typename T> void bar() {
foo<T>();
// CHECK: [[@LINE-1]]:3 | function/C | foo | c:@FT@>1#Tfoo#v# | <no-cgname> | Ref,Call,RelCall,RelCont | rel: 1
}
+
+struct Foo {
+ template <typename T> void bar();
+ // CHECK: [[@LINE-1]]:30 | instance-method/C++ | bar | c:@S at Foo@FT@>1#Tbar#v# | <no-cgname> | Decl,RelChild | rel: 1
+};
+template <typename T> void baz(Foo f) {
+ f.bar<T>();
+ // CHECK: [[@LINE-1]]:5 | instance-method/C++ | bar | c:@S at Foo@FT@>1#Tbar#v# | <no-cgname> | Ref,Call,RelCall,RelCont | rel: 1
+}
More information about the cfe-commits
mailing list