[PATCH] D96262: [clang][index] report references from unreslovedLookupExpr.

Haojian Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 8 06:24:20 PST 2021


hokein created this revision.
hokein added a reviewer: usaxena95.
Herald added subscribers: kadircet, arphaman.
hokein requested review of this revision.
Herald added a subscriber: ilya-biryukov.
Herald added a project: clang.

Fix https://github.com/clangd/clangd/issues/675


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D96262

Files:
  clang/lib/Index/IndexBody.cpp
  clang/test/Index/Core/index-dependent-source.cpp


Index: clang/test/Index/Core/index-dependent-source.cpp
===================================================================
--- clang/test/Index/Core/index-dependent-source.cpp
+++ clang/test/Index/Core/index-dependent-source.cpp
@@ -224,3 +224,10 @@
 // CHECK: [[@LINE+1]]:9 | struct(Gen)/C++ | UsingD | c:@ST>1#T at UsingD | <no-cgname> | Ref,RelCont | rel: 1
   using UsingD<U>::foo;
 };
+
+template <typename T> void foo();
+// CHECK: [[@LINE-1]]:28 | function/C | foo | c:@FT@>1#Tfoo#v# | <no-cgname> | Decl | rel: 0
+template <typename T> void bar() {
+  foo<T>();
+// CHECK: [[@LINE-1]]:3 | function/C | foo | c:@FT@>1#Tfoo#v# | <no-cgname> | Ref,Call,RelCall,RelCont | rel: 1
+}
Index: clang/lib/Index/IndexBody.cpp
===================================================================
--- clang/lib/Index/IndexBody.cpp
+++ clang/lib/Index/IndexBody.cpp
@@ -466,6 +466,15 @@
     }
     return true;
   }
+
+  bool VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) {
+    SmallVector<SymbolRelation, 4> Relations;
+    SymbolRoleSet Roles = getRolesForRef(E, Relations);
+    for (auto *D : E->decls())
+      IndexCtx.handleReference(D, E->getNameLoc(), Parent, ParentDC, Roles,
+                               Relations, E);
+    return true;
+  }
 };
 
 } // anonymous namespace


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D96262.322096.patch
Type: text/x-patch
Size: 1286 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210208/9e8dc845/attachment.bin>


More information about the cfe-commits mailing list