This revision was automatically updated to reflect the committed changes.
Closed by commit rG939544add98e: [clangd] Handle the missing call expr in 
targetDecl. (authored by hokein).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D70773/new/

https://reviews.llvm.org/D70773

Files:
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp


Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ 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) {
Index: clang-tools-extra/clangd/FindTarget.cpp
===================================================================
--- clang-tools-extra/clangd/FindTarget.cpp
+++ 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.


Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ 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) {
Index: clang-tools-extra/clangd/FindTarget.cpp
===================================================================
--- clang-tools-extra/clangd/FindTarget.cpp
+++ 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.
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
  • [PATCH] D70773: [cl... Haojian Wu via Phabricator via cfe-commits
    • [PATCH] D70773... pre-merge checks [bot] via Phabricator via cfe-commits
    • [PATCH] D70773... Haojian Wu via Phabricator via cfe-commits

Reply via email to