diff --git a/clang-tools-extra/clangd/FindTarget.cpp b/clang-tools-extra/clangd/FindTarget.cpp index 08bdf977d166..5c99ac9569ef 100644 --- a/clang-tools-extra/clangd/FindTarget.cpp +++ b/clang-tools-extra/clangd/FindTarget.cpp @@ -189,6 +189,10 @@ public: D = USD; Outer.add(D, Flags); } + void VisitOverloadExpr(const OverloadExpr *OE) { + for (auto *D : OE->decls()) + Outer.add(D, Flags); + } void VisitCXXConstructExpr(const CXXConstructExpr *CCE) { Outer.add(CCE->getConstructor(), Flags); } diff --git a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp index 91f78e304f88..af69e0b62757 100644 --- a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp +++ b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp @@ -393,6 +393,32 @@ TEST_F(TargetDeclTest, Lambda) { EXPECT_DECLS("DeclRefExpr", "auto int x = 1"); } +TEST_F(TargetDeclTest, OverloadExpr) { + Code = R"cpp( + void func(int*); + void func(char*); + + template + void foo(T t) { + [[func]](t); + }; + )cpp"; + EXPECT_DECLS("UnresolvedLookupExpr", "void func(int *)", "void func(char *)"); + + Code = R"cpp( + struct X { + void func(int*); + void func(char*); + }; + + template + void foo(X x, T t) { + x.[[func]](t); + }; + )cpp"; + EXPECT_DECLS("UnresolvedMemberExpr", "void func(int *)", "void func(char *)"); +} + TEST_F(TargetDeclTest, ObjC) { Flags = {"-xobjective-c"}; Code = R"cpp(