Skip to content

Commit a06b86b

Browse files
authored
Merge pull request #62559 from xymus/index-system-modules-without-sdk
[Index] Index any system module when no SDK path is defined
2 parents b6d0986 + 82486f2 commit a06b86b

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

lib/Index/IndexRecord.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,8 @@ static void addModuleDependencies(ArrayRef<ImportedModule> imports,
451451
// We don't officially support binary swift modules, so normally
452452
// the index data for user modules would get generated while
453453
// building them.
454-
bool isDistributedModule = mod->isSDKModule();
454+
bool isDistributedModule = mod->isSDKModule() ||
455+
mod->getASTContext().SearchPathOpts.getSDKPath().empty();
455456
if (mod->isSystemModule() && indexSystemModules &&
456457
(isDistributedModule || mod->isStdlibModule()) &&
457458
(!skipStdlib || !mod->isStdlibModule())) {

test/Index/index_swift_only_systemmodule.swift

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import SomeModule
22
print(someFunc())
33

44
// UNIT: Record | system | SomeModule |
5+
// SKIP-NOT: Record | system | SomeModule |
56

67
// RUN: %empty-directory(%t)
78
//
@@ -43,6 +44,38 @@ print(someFunc())
4344
//
4445
// --- Check the index.
4546
// RUN: c-index-test core -print-unit %t/idx | %FileCheck -check-prefix=UNIT %s
47+
//
48+
// --- Built with indexing, SomeModule is outside of the SDK so it's skipped.
49+
// RUN: %empty-directory(%t/idx)
50+
// RUN: %empty-directory(%t/modulecache)
51+
// RUN: %target-swift-frontend \
52+
// RUN: -typecheck \
53+
// RUN: -index-system-modules \
54+
// RUN: -index-ignore-stdlib \
55+
// RUN: -index-store-path %t/idx \
56+
// RUN: -sdk %t/NotTheActualSDK \
57+
// RUN: -Fsystem %t/SDK/Frameworks \
58+
// RUN: -module-cache-path %t/modulecache \
59+
// RUN: %s
60+
//
61+
// --- Check the index.
62+
// RUN: c-index-test core -print-unit %t/idx | %FileCheck -check-prefix=SKIP %s
63+
64+
// --- Built with indexing, without an SDK path SomeModule is indexed.
65+
// RUN: %empty-directory(%t/idx)
66+
// RUN: %empty-directory(%t/modulecache)
67+
// RUN: %target-swift-frontend \
68+
// RUN: -typecheck \
69+
// RUN: -index-system-modules \
70+
// RUN: -index-ignore-stdlib \
71+
// RUN: -index-store-path %t/idx \
72+
// RUN: -sdk "" \
73+
// RUN: -Fsystem %t/SDK/Frameworks \
74+
// RUN: -module-cache-path %t/modulecache \
75+
// RUN: %s
76+
//
77+
// --- Check the index.
78+
// RUN: c-index-test core -print-unit %t/idx | %FileCheck -check-prefix=UNIT %s
4679

4780
// -----------------------------------------------------------------------------
4881
// --- Prepare SDK (.swiftinterface).

0 commit comments

Comments
 (0)