r343767 - [Index] Respect "IndexFunctionLocals" option for type loc.

Haojian Wu via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 4 04:03:56 PDT 2018


Author: hokein
Date: Thu Oct  4 04:03:55 2018
New Revision: 343767

URL: http://llvm.org/viewvc/llvm-project?rev=343767&view=rev
Log:
[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

Added:
    cfe/trunk/test/Index/index-local-symbol.cpp
Modified:
    cfe/trunk/lib/Index/IndexTypeSourceInfo.cpp

Modified: cfe/trunk/lib/Index/IndexTypeSourceInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexTypeSourceInfo.cpp?rev=343767&r1=343766&r2=343767&view=diff
==============================================================================
--- cfe/trunk/lib/Index/IndexTypeSourceInfo.cpp (original)
+++ cfe/trunk/lib/Index/IndexTypeSourceInfo.cpp Thu Oct  4 04:03:55 2018
@@ -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()) {

Added: cfe/trunk/test/Index/index-local-symbol.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/index-local-symbol.cpp?rev=343767&view=auto
==============================================================================
--- cfe/trunk/test/Index/index-local-symbol.cpp (added)
+++ cfe/trunk/test/Index/index-local-symbol.cpp Thu Oct  4 04:03:55 2018
@@ -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




More information about the cfe-commits mailing list