[PATCH] D87257: [clang] Traverse init-captures while indexing

Nathan Ridge via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 7 17:11:52 PDT 2020


nridge created this revision.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, jkorous.
Herald added a project: clang.
nridge requested review of this revision.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87257

Files:
  clang-tools-extra/clangd/unittests/XRefsTests.cpp
  clang/lib/Index/IndexBody.cpp


Index: clang/lib/Index/IndexBody.cpp
===================================================================
--- clang/lib/Index/IndexBody.cpp
+++ clang/lib/Index/IndexBody.cpp
@@ -391,11 +391,13 @@
     if (C->capturesThis() || C->capturesVLAType())
       return true;
 
+    // if (!base::TraverseStmt(Init))
+    //  return false;
+
     if (C->capturesVariable() && IndexCtx.shouldIndexFunctionLocalSymbols())
       return IndexCtx.handleReference(C->getCapturedVar(), C->getLocation(),
                                       Parent, ParentDC, SymbolRoleSet());
 
-    // FIXME: Lambda init-captures.
     return true;
   }
 
Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -1589,6 +1589,12 @@
         [[Vector]]<int> x2;
         Vector<double> y;
       )cpp",
+      R"cpp(// Lambda capture initializer
+        void foo() {
+          int [[w^aldo]] = 42;
+          auto lambda = [x = [[waldo]]](){};
+        }
+      )cpp",
   };
   for (const char *Test : Tests) {
     Annotations T(Test);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87257.290378.patch
Type: text/x-patch
Size: 1190 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200908/81ed4a06/attachment.bin>


More information about the cfe-commits mailing list