Index: clang-tools-extra/trunk/clangd/FindTarget.cpp =================================================================== --- clang-tools-extra/trunk/clangd/FindTarget.cpp +++ clang-tools-extra/trunk/clangd/FindTarget.cpp @@ -16,6 +16,7 @@ #include "clang/AST/DeclVisitor.h" #include "clang/AST/DeclarationName.h" #include "clang/AST/Expr.h" +#include "clang/AST/ExprCXX.h" #include "clang/AST/ExprObjC.h" #include "clang/AST/NestedNameSpecifier.h" #include "clang/AST/PrettyPrinter.h" @@ -449,6 +450,12 @@ E->getMemberNameInfo().getLoc(), {E->getFoundDecl()}}; } + + void VisitOverloadExpr(const OverloadExpr *E) { + Ref = ReferenceLoc{E->getQualifierLoc(), E->getNameInfo().getLoc(), + llvm::SmallVector( + E->decls().begin(), E->decls().end())}; + } }; Visitor V; Index: clang-tools-extra/trunk/clangd/unittests/FindTargetTests.cpp =================================================================== --- clang-tools-extra/trunk/clangd/unittests/FindTargetTests.cpp +++ clang-tools-extra/trunk/clangd/unittests/FindTargetTests.cpp @@ -10,8 +10,10 @@ #include "Selection.h" #include "TestTU.h" #include "clang/AST/Decl.h" +#include "clang/AST/DeclTemplate.h" #include "clang/Basic/SourceLocation.h" #include "llvm/ADT/StringRef.h" +#include "llvm/Support/Casting.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Testing/Support/Annotations.h" #include "gmock/gmock.h" @@ -482,7 +484,11 @@ TU.Code = Code; auto AST = TU.build(); - auto &Func = llvm::cast(findDecl(AST, "foo")); + + auto *TestDecl = &findDecl(AST, "foo"); + if (auto *T = llvm::dyn_cast(TestDecl)) + TestDecl = T->getTemplatedDecl(); + auto &Func = llvm::cast(*TestDecl); std::vector Refs; findExplicitReferences(Func.getBody(), [&Refs](ReferenceLoc R) { @@ -671,6 +677,35 @@ )cpp", "0: targets = {vector}\n" "1: targets = {x}\n"}, + // Handle UnresolvedLookupExpr. + {R"cpp( + namespace ns1 { void func(char*); } + namespace ns2 { void func(int*); } + using namespace ns1; + using namespace ns2; + + template + void foo(T t) { + $0^func($1^t); + } + )cpp", + "0: targets = {ns1::func, ns2::func}\n" + "1: targets = {t}\n"}, + // Handle UnresolvedMemberExpr. + {R"cpp( + struct X { + void func(char*); + void func(int*); + }; + + template + void foo(X x, T t) { + $0^x.$1^func($2^t); + } + )cpp", + "0: targets = {x}\n" + "1: targets = {X::func, X::func}\n" + "2: targets = {t}\n"}, }; for (const auto &C : Cases) {