Skip to content

[Index] Index any system module when no SDK path is defined #62559

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/Index/IndexRecord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,8 @@ static void addModuleDependencies(ArrayRef<ImportedModule> imports,
// We don't officially support binary swift modules, so normally
// the index data for user modules would get generated while
// building them.
bool isDistributedModule = mod->isSDKModule();
bool isDistributedModule = mod->isSDKModule() ||
mod->getASTContext().SearchPathOpts.getSDKPath().empty();
if (mod->isSystemModule() && indexSystemModules &&
(isDistributedModule || mod->isStdlibModule()) &&
(!skipStdlib || !mod->isStdlibModule())) {
Expand Down
33 changes: 33 additions & 0 deletions test/Index/index_swift_only_systemmodule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import SomeModule
print(someFunc())

// UNIT: Record | system | SomeModule |
// SKIP-NOT: Record | system | SomeModule |

// RUN: %empty-directory(%t)
//
Expand Down Expand Up @@ -43,6 +44,38 @@ print(someFunc())
//
// --- Check the index.
// RUN: c-index-test core -print-unit %t/idx | %FileCheck -check-prefix=UNIT %s
//
// --- Built with indexing, SomeModule is outside of the SDK so it's skipped.
// RUN: %empty-directory(%t/idx)
// RUN: %empty-directory(%t/modulecache)
// RUN: %target-swift-frontend \
// RUN: -typecheck \
// RUN: -index-system-modules \
// RUN: -index-ignore-stdlib \
// RUN: -index-store-path %t/idx \
// RUN: -sdk %t/NotTheActualSDK \
// RUN: -Fsystem %t/SDK/Frameworks \
// RUN: -module-cache-path %t/modulecache \
// RUN: %s
//
// --- Check the index.
// RUN: c-index-test core -print-unit %t/idx | %FileCheck -check-prefix=SKIP %s

// --- Built with indexing, without an SDK path SomeModule is indexed.
// RUN: %empty-directory(%t/idx)
// RUN: %empty-directory(%t/modulecache)
// RUN: %target-swift-frontend \
// RUN: -typecheck \
// RUN: -index-system-modules \
// RUN: -index-ignore-stdlib \
// RUN: -index-store-path %t/idx \
// RUN: -sdk "" \
// RUN: -Fsystem %t/SDK/Frameworks \
// RUN: -module-cache-path %t/modulecache \
// RUN: %s
//
// --- Check the index.
// RUN: c-index-test core -print-unit %t/idx | %FileCheck -check-prefix=UNIT %s

// -----------------------------------------------------------------------------
// --- Prepare SDK (.swiftinterface).
Expand Down