|
| 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