diff --git a/clang-tools-extra/clangd/FindTarget.cpp b/clang-tools-extra/clangd/FindTarget.cpp --- a/clang-tools-extra/clangd/FindTarget.cpp +++ b/clang-tools-extra/clangd/FindTarget.cpp @@ -175,6 +175,9 @@ RelSet Flags; Visitor(TargetFinder &Outer, RelSet Flags) : Outer(Outer), Flags(Flags) {} + void VisitCallExpr(const CallExpr *CE) { + Outer.add(CE->getCalleeDecl(), Flags); + } void VisitDeclRefExpr(const DeclRefExpr *DRE) { const Decl *D = DRE->getDecl(); // UsingShadowDecl allows us to record the UsingDecl. diff --git a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp --- a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp +++ b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp @@ -114,6 +114,23 @@ auto X = S() [[+]] S(); )cpp"; EXPECT_DECLS("DeclRefExpr", "S operator+(S) const"); + + Code = R"cpp( + int foo(); + int s = foo[[()]]; + )cpp"; + EXPECT_DECLS("CallExpr", "int foo()"); + + Code = R"cpp( + struct X { + void operator()(int n); + }; + void test() { + X x; + x[[(123)]]; + } + )cpp"; + EXPECT_DECLS("CXXOperatorCallExpr", "void operator()(int n)"); } TEST_F(TargetDeclTest, UsingDecl) {