diff --git a/clang-tools-extra/clangd/unittests/XRefsTests.cpp b/clang-tools-extra/clangd/unittests/XRefsTests.cpp --- a/clang-tools-extra/clangd/unittests/XRefsTests.cpp +++ b/clang-tools-extra/clangd/unittests/XRefsTests.cpp @@ -2090,6 +2090,14 @@ [[f^oo]](s); } )cpp", + R"cpp(// unresolved member expression + struct Foo { + template void $decl[[bar]](T t); + }; + template void test(Foo F, T t) { + F.[[b^ar]](t); + } + )cpp", // Enum base R"cpp( diff --git a/clang/lib/Index/IndexBody.cpp b/clang/lib/Index/IndexBody.cpp --- a/clang/lib/Index/IndexBody.cpp +++ b/clang/lib/Index/IndexBody.cpp @@ -468,7 +468,7 @@ return true; } - bool VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) { + bool VisitOverloadExpr(OverloadExpr *E) { SmallVector 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 --- a/clang/test/Index/Core/index-dependent-source.cpp +++ b/clang/test/Index/Core/index-dependent-source.cpp @@ -231,3 +231,12 @@ foo(); // CHECK: [[@LINE-1]]:3 | function/C | foo | c:@FT@>1#Tfoo#v# | | Ref,Call,RelCall,RelCont | rel: 1 } + +struct Foo { + template void bar(); + // CHECK: [[@LINE-1]]:30 | instance-method/C++ | bar | c:@S@Foo@FT@>1#Tbar#v# | | Decl,RelChild | rel: 1 +}; +template void baz(Foo f) { + f.bar(); + // CHECK: [[@LINE-1]]:5 | instance-method/C++ | bar | c:@S@Foo@FT@>1#Tbar#v# | | Ref,Call,RelCall,RelCont | rel: 1 +} diff --git a/clang/unittests/Index/IndexTests.cpp b/clang/unittests/Index/IndexTests.cpp --- a/clang/unittests/Index/IndexTests.cpp +++ b/clang/unittests/Index/IndexTests.cpp @@ -392,6 +392,36 @@ Contains(AllOf(QName("MyTypedef"), HasRole(SymbolRole::Reference), WrittenAt(Position(4, 16)))))); } + +TEST(IndexTest, UnresolvedLookupExpr) { + std::string Code = R"cpp( + template void foo(T t); + template void test(T t) { + foo(t); + } + )cpp"; + auto Index = std::make_shared(); + tooling::runToolOnCode(std::make_unique(Index), Code); + EXPECT_THAT(Index->Symbols, + Contains(AllOf(QName("foo"), HasRole(SymbolRole::Reference), + WrittenAt(Position(4, 7))))); +} + +TEST(IndexTest, UnresolvedMemberExpr) { + std::string Code = R"cpp( + struct Foo { + template void bar(T t); + }; + template void test(Foo F, T t) { + F.bar(t); + } + )cpp"; + auto Index = std::make_shared(); + tooling::runToolOnCode(std::make_unique(Index), Code); + EXPECT_THAT(Index->Symbols, + Contains(AllOf(QName("Foo::bar"), HasRole(SymbolRole::Reference), + WrittenAt(Position(6, 9))))); +} } // namespace } // namespace index } // namespace clang