mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[ScanDependency] Do not use public/private swiftinterface in the same package
When scanning finds a dependency in the same package, do not load public/private swiftinterface since they do not have the package level decl to compile the current module. Always prefer package module (if enabled), or use binary module, unless it is building a public/private swiftinterface file in which case the interface file is preferred. This also does some clean up to sync up the code path between implicit and explicit module finding path. rdar://122356964
This commit is contained in:
@@ -1244,8 +1244,8 @@ std::error_code ModuleInterfaceLoader::findModuleFilesInDirectory(
|
||||
|
||||
// First check to see if the .swiftinterface exists at all. Bail if not.
|
||||
auto &fs = *Ctx.SourceMgr.getFileSystem();
|
||||
std::string InPath = BaseName.findInterfacePath(fs, Ctx).value_or("");
|
||||
if (InPath.empty()) {
|
||||
auto InPath = BaseName.findInterfacePath(fs, Ctx);
|
||||
if (!InPath) {
|
||||
if (fs.exists(ModPath)) {
|
||||
LLVM_DEBUG(llvm::dbgs()
|
||||
<< "No .swiftinterface file found adjacent to module file "
|
||||
@@ -1256,7 +1256,7 @@ std::error_code ModuleInterfaceLoader::findModuleFilesInDirectory(
|
||||
}
|
||||
|
||||
if (ModuleInterfaceSourcePath)
|
||||
ModuleInterfaceSourcePath->assign(InPath.begin(), InPath.end());
|
||||
ModuleInterfaceSourcePath->assign(InPath->begin(), InPath->end());
|
||||
|
||||
// If we've been told to skip building interfaces, we are done here and do
|
||||
// not need to have the module actually built. For example, if we are
|
||||
@@ -1264,14 +1264,14 @@ std::error_code ModuleInterfaceLoader::findModuleFilesInDirectory(
|
||||
// the interface.
|
||||
if (skipBuildingInterface) {
|
||||
if (ModuleInterfacePath)
|
||||
ModuleInterfacePath->assign(InPath.begin(), InPath.end());
|
||||
ModuleInterfacePath->assign(InPath->begin(), InPath->end());
|
||||
return std::error_code();
|
||||
}
|
||||
|
||||
// Create an instance of the Impl to do the heavy lifting.
|
||||
auto ModuleName = ModuleID.Item.str();
|
||||
ModuleInterfaceLoaderImpl Impl(
|
||||
Ctx, ModPath, InPath, ModuleName, InterfaceChecker.CacheDir,
|
||||
Ctx, ModPath, *InPath, ModuleName, InterfaceChecker.CacheDir,
|
||||
InterfaceChecker.PrebuiltCacheDir, InterfaceChecker.BackupInterfaceDir,
|
||||
ModuleID.Loc, InterfaceChecker.Opts,
|
||||
InterfaceChecker.RequiresOSSAModules,
|
||||
@@ -1290,7 +1290,7 @@ std::error_code ModuleInterfaceLoader::findModuleFilesInDirectory(
|
||||
if (ModuleBuffer) {
|
||||
*ModuleBuffer = std::move(*ModuleBufferOrErr);
|
||||
if (ModuleInterfacePath)
|
||||
ModuleInterfacePath->assign(InPath.begin(), InPath.end());
|
||||
ModuleInterfacePath->assign(InPath->begin(), InPath->end());
|
||||
}
|
||||
|
||||
// Open .swiftsourceinfo file if it's present.
|
||||
|
||||
Reference in New Issue
Block a user