]> granicus.if.org Git - clang/commitdiff
[Index] Respect "IndexFunctionLocals" option for type loc.
authorHaojian Wu <hokein@google.com>
Thu, 4 Oct 2018 11:03:55 +0000 (11:03 +0000)
committerHaojian Wu <hokein@google.com>
Thu, 4 Oct 2018 11:03:55 +0000 (11:03 +0000)
Summary:
Previously, clang index ignored local symbols defined in the function body even
IndexFunctionLocals is true.

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: ilya-biryukov, ioeric, arphaman, kadircet, cfe-commits

Differential Revision: https://reviews.llvm.org/D52877

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@343767 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Index/IndexTypeSourceInfo.cpp
test/Index/index-local-symbol.cpp [new file with mode: 0644]

index 8342e93c156d885e60fea8b3db71c1ac819a90ea..85afc6345053894c6dbe5dcdb7f51670f5ff5eed 100644 (file)
@@ -100,7 +100,8 @@ public:
 
   bool VisitTagTypeLoc(TagTypeLoc TL) {
     TagDecl *D = TL.getDecl();
-    if (D->getParentFunctionOrMethod())
+    if (!IndexCtx.shouldIndexFunctionLocalSymbols() &&
+        D->getParentFunctionOrMethod())
       return true;
 
     if (TL.isDefinition()) {
diff --git a/test/Index/index-local-symbol.cpp b/test/Index/index-local-symbol.cpp
new file mode 100644 (file)
index 0000000..1ffc4ec
--- /dev/null
@@ -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