From 53a522e1306aff01960a0249ffe8bbd704e7abbe Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Thu, 4 Oct 2018 11:03:55 +0000 Subject: [PATCH] [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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@343767 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Index/IndexTypeSourceInfo.cpp | 3 ++- test/Index/index-local-symbol.cpp | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 test/Index/index-local-symbol.cpp diff --git a/lib/Index/IndexTypeSourceInfo.cpp b/lib/Index/IndexTypeSourceInfo.cpp index 8342e93c15..85afc63450 100644 --- a/lib/Index/IndexTypeSourceInfo.cpp +++ b/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/test/Index/index-local-symbol.cpp b/test/Index/index-local-symbol.cpp new file mode 100644 index 0000000000..1ffc4ec89e --- /dev/null +++ b/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 -- 2.50.1