[PATCH] D52877: [Index] Respect "IndexFunctionLocals" option during index.

Haojian Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 4 03:46:22 PDT 2018


hokein created this revision.
hokein added a reviewer: sammccall.
Herald added subscribers: kadircet, arphaman, ioeric, ilya-biryukov.

Previously, clangd index ignored symbols defined in the function body even
IndexFunctionLocals is true.


Repository:
  rC Clang

https://reviews.llvm.org/D52877

Files:
  lib/Index/IndexTypeSourceInfo.cpp
  test/Index/index-local-symbol.cpp


Index: test/Index/index-local-symbol.cpp
===================================================================
--- /dev/null
+++ test/Index/index-local-symbol.cpp
@@ -0,0 +1,6 @@
+void ff() {
+  struct Foo {};
+}
+
+// RUN: env CINDEXTEST_INDEXLOCALSYMBOLS=1 c-index-test -index-file %s | FileCheck %s
+// CHECK: [indexDeclaration]: kind: struct | name: Foo | {{.*}} | loc: 2:10
\ No newline at end of file
Index: lib/Index/IndexTypeSourceInfo.cpp
===================================================================
--- lib/Index/IndexTypeSourceInfo.cpp
+++ lib/Index/IndexTypeSourceInfo.cpp
@@ -100,7 +100,8 @@
 
   bool VisitTagTypeLoc(TagTypeLoc TL) {
     TagDecl *D = TL.getDecl();
-    if (D->getParentFunctionOrMethod())
+    if (!IndexCtx.shouldIndexFunctionLocalSymbols() &&
+        D->getParentFunctionOrMethod())
       return true;
 
     if (TL.isDefinition()) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52877.168261.patch
Type: text/x-patch
Size: 875 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181004/12e04675/attachment.bin>


More information about the cfe-commits mailing list