From: Haojian Wu Date: Thu, 4 Oct 2018 11:03:55 +0000 (+0000) Subject: [Index] Respect "IndexFunctionLocals" option for type loc. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=53a522e1306aff01960a0249ffe8bbd704e7abbe;p=clang [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 --- 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