Skip to content

Commit f6931c8

Browse files
committed
[Index] Test records of extensions in sources and modules
1 parent b87fd12 commit f6931c8

File tree

2 files changed

+75
-1
lines changed

2 files changed

+75
-1
lines changed

test/Index/Store/record-sourcefile.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
// CHECK: type-alias/Swift | TA | s:{{.*}} | <no-cgname> | Def,RelChild -
3131
// CHECK: class/Swift | C1 | s:{{.*}} | <no-cgname> | Def,Ref,RelBase,RelCont -
3232
// CHECK: instance-method/Swift | method() | s:{{.*}} | <no-cgname> | Def,Ref,Call,Dyn,RelChild,RelRec,RelCall,RelCont -
33-
// CHECK: class/Swift | C2 | s:{{.*}} | <no-cgname> | Def -
33+
// CHECK: class/Swift | C2 | s:{{.*}} | <no-cgname> | Def,Ref - RelChild,RelBase
3434
// CHECK: instance-method/Swift | method() | s:{{.*}} | <no-cgname> | Def,Dyn,RelChild,RelOver -
3535
// CHECK: function/Swift | takeC1(x:) | s:{{.*}} | <no-cgname> | Def -
3636
// CHECK: instance-method(test)/Swift | testFoo() | s:{{.*}} | <no-cgname> | Def,Dyn,RelChild -
@@ -151,3 +151,6 @@ class MyTestCase: XCTestCase {
151151
// CHECK-NEXT: RelChild | s:4file10MyTestCaseC
152152
func testFoo() { test1() }
153153
}
154+
155+
// CHECK: [[@LINE+1]]:11 | class/Swift | s:4file2C2C | Ref | rel: 0
156+
extension C2 {}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
// --- Prepare SDK (.swiftmodule).
2+
// RUN: %empty-directory(%t)
3+
// RUN: %empty-directory(%t/SDK)
4+
// RUN: mkdir -p %t/SDK/Frameworks/SomeModule.framework/Modules/SomeModule.swiftmodule
5+
// RUN: %target-swift-frontend \
6+
// RUN: -emit-module \
7+
// RUN: -module-name SomeModule \
8+
// RUN: -o %t/SDK/Frameworks/SomeModule.framework/Modules/SomeModule.swiftmodule/%module-target-triple.swiftmodule \
9+
// RUN: -swift-version 5 \
10+
// RUN: -D SOME_MODULE \
11+
// RUN: %s
12+
13+
#if SOME_MODULE
14+
15+
public func someFunc() {}
16+
17+
public class C2 {}
18+
19+
extension C2 {
20+
public func publicFunc() {}
21+
}
22+
23+
// Don't record extensions with nothing to index.
24+
extension C2 {}
25+
26+
extension C2 {
27+
internal func SECRET() {}
28+
private func SECRET1() {}
29+
fileprivate func SECRET2() {}
30+
}
31+
32+
internal protocol SECRETProto {}
33+
extension C2: SECRETProto {}
34+
35+
// -----------------------------------------------------------------------------
36+
// Test-1 - '.swiftmodule' - Normal index-while-building.
37+
//
38+
// RUN: %empty-directory(%t/idx)
39+
// RUN: %empty-directory(%t/modulecache)
40+
//
41+
// --- Built with indexing
42+
// RUN: %target-swift-frontend \
43+
// RUN: -typecheck \
44+
// RUN: -index-system-modules \
45+
// RUN: -index-ignore-stdlib \
46+
// RUN: -index-store-path %t/idx \
47+
// RUN: -sdk %t/SDK \
48+
// RUN: -Fsystem %t/SDK/Frameworks \
49+
// RUN: -module-cache-path %t/modulecache \
50+
// RUN: -D CLIENT \
51+
// RUN: %s
52+
53+
#elseif CLIENT
54+
55+
import SomeModule
56+
print(someFunc())
57+
58+
#endif
59+
60+
// -----------------------------------------------------------------------------
61+
// --- Check the records.
62+
// RUN: c-index-test core -print-record %t/idx | %FileCheck %s
63+
64+
// CHECK: 0:0 | function/Swift | s:10SomeModule8someFuncyyF | Def | rel: 0
65+
// CHECK-NEXT: 0:0 | class/Swift | [[class_USR:s:10SomeModule2C2C]] | Def | rel: 0
66+
// CHECK-NEXT: 0:0 | class/Swift | [[class_USR]] | Ref,RelExt | rel: 1
67+
// CHECK-NEXT: RelExt | s:e:[[publicFunc_USR:s:10SomeModule2C2C10publicFuncyyF]]
68+
// CHECK-NEXT: 0:0 | instance-method/Swift | [[publicFunc_USR]] | Def,Dyn,RelChild | rel: 1
69+
// CHECK-NEXT: RelChild | s:e:[[publicFunc_USR]]
70+
// CHECK-NEXT: 0:0 | extension/ext-class/Swift | s:e:[[publicFunc_USR]] | Def | rel: 0
71+
// CHECK-NOT: SECRET

0 commit comments

Comments
 (0)