Skip to content

Commit 1d96cdc

Browse files
committed
[Index] Avoid forming relations to non-indexed decls
If we shouldn't index the related decl, don't record it as a relation.
1 parent cd480a9 commit 1d96cdc

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

lib/Index/Index.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,10 @@ class IndexSwiftASTWalker : public SourceEntityWalker {
543543

544544
bool addRelation(IndexSymbol &Info, SymbolRoleSet RelationRoles, Decl *D) {
545545
assert(D);
546+
if (auto *VD = dyn_cast<ValueDecl>(D)) {
547+
if (!shouldIndex(VD, /*IsRef*/ true))
548+
return true;
549+
}
546550
auto Match = std::find_if(Info.Relations.begin(), Info.Relations.end(),
547551
[D](IndexRelation R) { return R.decl == D; });
548552
if (Match != Info.Relations.end()) {
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// RUN: %empty-directory(%t)
2+
//
3+
// RUN: %target-swift-frontend -emit-module -emit-module-path %t/Mod.swiftmodule -module-name Mod %s
4+
// RUN: %target-swift-ide-test -print-indexed-symbols -module-to-print Mod -source-filename %s -I %t | %FileCheck %s
5+
6+
public class C {
7+
fileprivate func foo() {}
8+
}
9+
public class D: C {
10+
public override func foo() {}
11+
}
12+
13+
// Make sure we don't report the override of the private member in the base class.
14+
//CHECK: instance-method/Swift | foo() | s:3Mod1DC3fooyyF | Def,Dyn,RelChild | rel: 1
15+
//CHECK-NEXT: RelChild | class/Swift | D | s:3Mod1DC

0 commit comments

Comments
 (0)