summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaojian Wu <hokein@google.com>2018-10-04 11:03:55 +0000
committerHaojian Wu <hokein@google.com>2018-10-04 11:03:55 +0000
commitcd499ff2cdeda65ce41c011e706f6b75f7dfe6f9 (patch)
treec691ac062f5f4a9ec565c70d6cacfe541738aa1b
parent7ade4bf8f1842561747f22c053714c727541834a (diff)
[Index] Respect "IndexFunctionLocals" option for type loc.
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
-rw-r--r--clang/lib/Index/IndexTypeSourceInfo.cpp3
-rw-r--r--clang/test/Index/index-local-symbol.cpp6
2 files changed, 8 insertions, 1 deletions
diff --git a/clang/lib/Index/IndexTypeSourceInfo.cpp b/clang/lib/Index/IndexTypeSourceInfo.cpp
index 8342e93c156..85afc634505 100644
--- a/clang/lib/Index/IndexTypeSourceInfo.cpp
+++ b/clang/lib/Index/IndexTypeSourceInfo.cpp
@@ -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/clang/test/Index/index-local-symbol.cpp b/clang/test/Index/index-local-symbol.cpp
new file mode 100644
index 00000000000..1ffc4ec89ed
--- /dev/null
+++ b/clang/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