Skip to content

Commit

Permalink
[index] Index system ImportDecls even when there is a DeclarationsOnl…
Browse files Browse the repository at this point in the history
…y 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
  • Loading branch information
benlangmuir committed Jul 14, 2016
1 parent 93765ed commit 56d0aaf
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/Index/IndexingContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
6 changes: 3 additions & 3 deletions test/Index/Core/index-with-module.m
Original file line number Diff line number Diff line change
@@ -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();
}
}
6 changes: 5 additions & 1 deletion test/Index/index-module.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
// 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

Expand All @@ -18,6 +20,7 @@
// 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: <invalid> | {{.*}} | module: DependsOnModule
Expand All @@ -27,7 +30,8 @@
// CHECK-DMOD-NEXT: [ppIncludedFile]: [[DMOD_SUB_H:.*/Modules/Inputs/DependsOnModule\.framework[/\\]Frameworks[/\\]SubFramework\.framework[/\\]Headers[/\\]SubFramework\.h]] | {{.*}} | hash loc: <invalid> | {{.*}} | 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: <invalid> | {{.*}} | 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
Expand Down

0 comments on commit 56d0aaf

Please sign in to comment.