[ScanDependency] Allow importing binary testable module when no interface

Follow-up adjustment for binary module selection in dependency scanning
time. If a testable binary module doesn't have an interface file, it
should be used even it might pull in more dependencies.
This commit is contained in:
Steven Wu
2024-04-08 10:26:15 -07:00
parent bdb32c92c6
commit 90a1586c3c
4 changed files with 17 additions and 9 deletions

View File

@@ -431,7 +431,8 @@ SerializedModuleLoaderBase::getImportsOfModule(
llvm::ErrorOr<ModuleDependencyInfo>
SerializedModuleLoaderBase::scanModuleFile(Twine modulePath, bool isFramework,
bool isTestableImport) {
bool isTestableImport,
bool hasInterface) {
const std::string moduleDocPath;
const std::string sourceInfoPath;
@@ -455,7 +456,10 @@ SerializedModuleLoaderBase::scanModuleFile(Twine modulePath, bool isFramework,
return std::make_error_code(std::errc::no_such_file_or_directory);
}
if (loadedModuleFile->isTestable() && !isTestableImport) {
// If the module file has interface file and not testable imported, don't
// import the testable module because it contains more interfaces than
// needed and can pull in more dependencies.
if (loadedModuleFile->isTestable() && !isTestableImport && hasInterface) {
if (Ctx.LangOpts.EnableModuleLoadingRemarks)
Ctx.Diags.diagnose(SourceLoc(), diag::skip_module_testable,
modulePath.str());