From: Ben Langmuir Date: Thu, 14 Jul 2016 18:51:55 +0000 (+0000) Subject: [index] Index system ImportDecls even when there is a DeclarationsOnly filter X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=56d0aaf1e7d97762d51581c51853006c85cd2be1;p=clang [index] Index system ImportDecls even when there is a DeclarationsOnly filter Whether we call an ImportDecl a decl or a reference symbol role is somewhat academic, but in practice it's more like a declaration because it is interesting even to consumers who wouldn't care about references. Most importantly, we want to report the module dependencies of system modules even when we have declaration-only filtering. rdar://problem/27134855 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@275454 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Index/IndexingContext.cpp b/lib/Index/IndexingContext.cpp index 424c1034ae..bcc367c662 100644 --- a/lib/Index/IndexingContext.cpp +++ b/lib/Index/IndexingContext.cpp @@ -83,14 +83,14 @@ bool IndexingContext::importedModule(const ImportDecl *ImportD) { if (SEntry.getFile().getFileCharacteristic() != SrcMgr::C_User) { switch (IndexOpts.SystemSymbolFilter) { case IndexingOptions::SystemSymbolFilterKind::None: - case IndexingOptions::SystemSymbolFilterKind::DeclarationsOnly: return true; + case IndexingOptions::SystemSymbolFilterKind::DeclarationsOnly: case IndexingOptions::SystemSymbolFilterKind::All: break; } } - SymbolRoleSet Roles = (unsigned)SymbolRole::Reference; + SymbolRoleSet Roles = (unsigned)SymbolRole::Declaration; if (ImportD->isImplicit()) Roles |= (unsigned)SymbolRole::Implicit; diff --git a/test/Index/Core/index-with-module.m b/test/Index/Core/index-with-module.m index 646a48a2c9..03fd5cd5b8 100644 --- a/test/Index/Core/index-with-module.m +++ b/test/Index/Core/index-with-module.m @@ -1,12 +1,12 @@ // RUN: rm -rf %t.mcp // RUN: c-index-test core -print-source-symbols -- %s -I %S/Inputs/module -fmodules -fmodules-cache-path=%t.mcp | FileCheck %s -// CHECK: [[@LINE+1]]:9 | module/C | ModA | Ref | +// CHECK: [[@LINE+1]]:9 | module/C | ModA | Decl | @import ModA; -// CHECK: [[@LINE+1]]:1 | module/C | ModA | Ref,Impl | +// CHECK: [[@LINE+1]]:1 | module/C | ModA | Decl,Impl | #include "ModA.h" void foo() { // CHECK: [[@LINE+1]]:3 | function/C | ModA_func | c:@F@ModA_func | {{.*}} | Ref,Call,RelCall | rel: 1 ModA_func(); -} \ No newline at end of file +} diff --git a/test/Index/index-module.m b/test/Index/index-module.m index ff512592b6..1175ae376d 100644 --- a/test/Index/index-module.m +++ b/test/Index/index-module.m @@ -6,6 +6,8 @@ int glob; // RUN: rm -rf %t.cache // RUN: c-index-test -index-file %s -fmodules-cache-path=%t.cache -fmodules -F %S/../Modules/Inputs \ // RUN: -Xclang -fdisable-module-hash | FileCheck %s +// RUN: c-index-test -index-file %s -fmodules-cache-path=%t.cache.sys -fmodules -iframework %S/../Modules/Inputs \ +// RUN: -Xclang -fdisable-module-hash | FileCheck %s // RUN: c-index-test -index-file %s -fmodules-cache-path=%t.cache -fmodules -gmodules -F %S/../Modules/Inputs \ // RUN: -Xclang -fdisable-module-hash | FileCheck %s @@ -18,6 +20,7 @@ int glob; // CHECK-NOT: [indexDeclaration] // RUN: c-index-test -index-tu %t.cache/DependsOnModule.pcm | FileCheck %s -check-prefix=CHECK-DMOD +// RUN: c-index-test -index-tu %t.cache.sys/DependsOnModule.pcm | FileCheck %s -check-prefix=CHECK-DMOD // CHECK-DMOD: [startedTranslationUnit] // CHECK-DMOD-NEXT: [ppIncludedFile]: [[DMOD_MODULE_H:.*/Modules/Inputs/DependsOnModule\.framework[/\\]Headers[/\\]DependsOnModule\.h]] | {{.*}} | hash loc: | {{.*}} | module: DependsOnModule @@ -27,7 +30,8 @@ int glob; // CHECK-DMOD-NEXT: [ppIncludedFile]: [[DMOD_SUB_H:.*/Modules/Inputs/DependsOnModule\.framework[/\\]Frameworks[/\\]SubFramework\.framework[/\\]Headers[/\\]SubFramework\.h]] | {{.*}} | hash loc: | {{.*}} | module: DependsOnModule.SubFramework // CHECK-DMOD-NEXT: [ppIncludedFile]: [[DMOD_SUB_OTHER_H:.*/Modules/Inputs/DependsOnModule.framework[/\\]Frameworks/SubFramework\.framework/Headers/Other\.h]] | name: "SubFramework/Other.h" | hash loc: [[DMOD_SUB_H]]:1:1 | isImport: 0 | isAngled: 0 | isModule: 0 | module: DependsOnModule.SubFramework.Other // CHECK-DMOD-NEXT: [ppIncludedFile]: [[DMOD_PRIVATE_H:.*/Modules/Inputs/DependsOnModule.framework[/\\]PrivateHeaders[/\\]DependsOnModulePrivate.h]] | {{.*}} | hash loc: | {{.*}} | module: DependsOnModule.Private.DependsOnModule -// CHECK-DMOD-NEXT: [importedASTFile]: {{.*}}.cache{{[/\\]}}Module.pcm | loc: [[DMOD_MODULE_H]]:1:1 | name: "Module" | isImplicit: 1 +// CHECK-DMOD-NEXT: [importedASTFile]: {{.*}}.cache{{(.sys)?[/\\]}}Module.pcm | loc: [[DMOD_MODULE_H]]:1:1 | name: "Module" | isImplicit: 1 +// // CHECK-DMOD-NEXT: [indexDeclaration]: kind: variable | name: depends_on_module_other | {{.*}} | loc: [[DMOD_OTHER_H]]:1:5 // CHECK-DMOD-NEXT: [indexDeclaration]: kind: variable | name: template | {{.*}} | loc: [[DMOD_NOT_CXX_H]]:1:12 // CHECK-DMOD-NEXT: [indexDeclaration]: kind: variable | name: sub_framework | {{.*}} | loc: [[DMOD_SUB_H]]:2:8