Skip to content

Commit 5ba008a

Browse files
authored
Merge pull request #79577 from dylansturg/index-missing-symbols
Discard non-indexed relations instead of entire references.
2 parents 4bb3cf1 + d21b7d6 commit 5ba008a

File tree

2 files changed

+69
-1
lines changed

2 files changed

+69
-1
lines changed

lib/Index/Index.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,9 @@ class IndexSwiftASTWalker : public SourceEntityWalker {
549549
assert(D);
550550
if (auto *VD = dyn_cast<ValueDecl>(D)) {
551551
if (!shouldIndex(VD, /*IsRef*/ true))
552-
return true;
552+
// Let the caller continue while discarding the relation to a symbol
553+
// that won't appear in the index.
554+
return false;
553555
}
554556
auto Match = std::find_if(Info.Relations.begin(), Info.Relations.end(),
555557
[D](IndexRelation R) { return R.decl == D; });
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %empty-directory(%t/SDK)
3+
// RUN: split-file %s %t
4+
//
5+
// RUN: mkdir -p %t/SDK/Frameworks/FakeSystem.framework/Modules/FakeSystem.swiftmodule
6+
// RUN: %target-swift-frontend \
7+
// RUN: -emit-module \
8+
// RUN: -module-name FakeSystem \
9+
// RUN: -o %t/SDK/Frameworks/FakeSystem.framework/Modules/FakeSystem.swiftmodule/%module-target-triple.swiftmodule \
10+
// RUN: -swift-version 5 \
11+
// RUN: %t/FakeSystem.swift
12+
//
13+
// RUN: %empty-directory(%t/idx)
14+
// RUN: %empty-directory(%t/modulecache)
15+
//
16+
// --- Built with indexing
17+
// RUN: %target-swift-frontend \
18+
// RUN: -typecheck \
19+
// RUN: -index-system-modules \
20+
// RUN: -index-ignore-stdlib \
21+
// RUN: -index-store-path %t/idx \
22+
// RUN: -sdk %t/SDK \
23+
// RUN: -Fsystem %t/SDK/Frameworks \
24+
// RUN: -module-cache-path %t/modulecache \
25+
// RUN: %t/view.swift
26+
//
27+
// --- Check the index.
28+
// RUN: c-index-test core -print-record %t/idx | %FileCheck %s
29+
//
30+
31+
//--- FakeSystem.swift
32+
public protocol View {
33+
}
34+
35+
public protocol ViewModifier {
36+
associatedtype Body: View
37+
typealias Content = _HiddenView<Self>
38+
func body(content: Self.Content) -> Self.Body
39+
}
40+
41+
public struct _HiddenView<M>: View where M: ViewModifier {
42+
init(m: M) {}
43+
}
44+
45+
public struct _HiddenModifier: ViewModifier {
46+
public func body(content: Content) -> some View {
47+
return _HiddenView(m: self)
48+
}
49+
}
50+
51+
extension View {
52+
public func background() -> some View {
53+
return _HiddenView(m: _HiddenModifier())
54+
}
55+
}
56+
57+
//--- view.swift
58+
import FakeSystem
59+
60+
private struct Mod: FakeSystem.ViewModifier {
61+
func body(content: Content) -> some View {
62+
content
63+
.background()
64+
// CHECK: 6:8 | instance-method/Swift | s:10FakeSystem4ViewPAAE10backgroundQryF | Ref,Call,Dyn{{.*}}
65+
}
66+
}

0 commit comments

Comments
 (0)