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()) {


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()) {
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to