[PATCH] D96262: [clang][index] report references from unreslovedLookupExpr.
Haojian Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 11 02:07:34 PST 2021
hokein updated this revision to Diff 322927.
hokein added a comment.
address comment, add more tests.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D96262/new/
https://reviews.llvm.org/D96262
Files:
clang-tools-extra/clangd/unittests/XRefsTests.cpp
clang/lib/Index/IndexBody.cpp
clang/test/Index/Core/index-dependent-source.cpp
Index: clang/test/Index/Core/index-dependent-source.cpp
===================================================================
--- clang/test/Index/Core/index-dependent-source.cpp
+++ clang/test/Index/Core/index-dependent-source.cpp
@@ -224,3 +224,10 @@
// CHECK: [[@LINE+1]]:9 | struct(Gen)/C++ | UsingD | c:@ST>1#T at UsingD | <no-cgname> | Ref,RelCont | rel: 1
using UsingD<U>::foo;
};
+
+template <typename T> void foo();
+// CHECK: [[@LINE-1]]:28 | function/C | foo | c:@FT@>1#Tfoo#v# | <no-cgname> | Decl | rel: 0
+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
+}
Index: clang/lib/Index/IndexBody.cpp
===================================================================
--- clang/lib/Index/IndexBody.cpp
+++ clang/lib/Index/IndexBody.cpp
@@ -466,6 +466,15 @@
}
return true;
}
+
+ bool VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) {
+ SmallVector<SymbolRelation, 4> Relations;
+ SymbolRoleSet Roles = getRolesForRef(E, Relations);
+ for (auto *D : E->decls())
+ IndexCtx.handleReference(D, E->getNameLoc(), Parent, ParentDC, Roles,
+ Relations, E);
+ return true;
+ }
};
} // anonymous namespace
Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -1863,6 +1863,26 @@
Vector<int> x2;
Vector<double> y;
)cpp",
+ R"cpp(// Dependent code
+ template <typename T> void $decl[[foo]](T t);
+ template <typename T> void bar(T t) { [[foo]](t); } // foo in bar is uninstantiated.
+ void baz(int x) { [[f^oo]](x); }
+ )cpp",
+ R"cpp(
+ namespace ns {
+ struct S{};
+ void $decl[[foo]](S s);
+ } // namespace ns
+ template <typename T> void foo(T t);
+ // FIXME: Maybe report this foo as a ref to ns::foo (because of ADL)
+ // when bar<ns::S> is instantiated?
+ template <typename T> void bar(T t) { foo(t); }
+ void baz(int x) {
+ ns::S s;
+ bar<ns::S>(s);
+ [[f^oo]](s);
+ }
+ )cpp",
};
for (const char *Test : Tests)
checkFindRefs(Test);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D96262.322927.patch
Type: text/x-patch
Size: 2377 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210211/a6b0eaa4/attachment-0001.bin>
More information about the cfe-commits
mailing list