mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[AST] Treat platform modules as non-user
Modules defined within the SDK are considered non-user modules, extend this to any module found within the parent platform directory if there is one. This ensures we include modules such as XCTest and Testing. rdar://131854240
This commit is contained in:
@@ -4009,7 +4009,8 @@ FrontendStatsTracer::getTraceFormatter<const SourceFile *>() {
|
||||
bool IsNonUserModuleRequest::evaluate(Evaluator &evaluator, ModuleDecl *mod) const {
|
||||
// If there's no SDK path, fallback to checking whether the module was
|
||||
// in the system search path or a clang system module
|
||||
SearchPathOptions &searchPathOpts = mod->getASTContext().SearchPathOpts;
|
||||
auto &ctx = mod->getASTContext();
|
||||
SearchPathOptions &searchPathOpts = ctx.SearchPathOpts;
|
||||
StringRef sdkPath = searchPathOpts.getSDKPath();
|
||||
if (sdkPath.empty() && mod->isSystemModule())
|
||||
return true;
|
||||
@@ -4028,9 +4029,14 @@ bool IsNonUserModuleRequest::evaluate(Evaluator &evaluator, ModuleDecl *mod) con
|
||||
if (modulePath.empty())
|
||||
return false;
|
||||
|
||||
// If we have a platform path, check against that as it will be a parent of
|
||||
// the SDK path.
|
||||
auto *FS = ctx.SourceMgr.getFileSystem().get();
|
||||
auto sdkOrPlatform = searchPathOpts.getSDKPlatformPath(FS).value_or(sdkPath);
|
||||
|
||||
StringRef runtimePath = searchPathOpts.RuntimeResourcePath;
|
||||
return (!runtimePath.empty() && pathStartsWith(runtimePath, modulePath)) ||
|
||||
(!sdkPath.empty() && pathStartsWith(sdkPath, modulePath));
|
||||
(!sdkOrPlatform.empty() && pathStartsWith(sdkOrPlatform, modulePath));
|
||||
}
|
||||
|
||||
version::Version ModuleDecl::getLanguageVersionBuiltWith() const {
|
||||
|
||||
Reference in New Issue
Block a user