[ModuleLoader] Emit a better diagnostic for swiftinterfaces with wrong arch.

Before this change, we would emit the warning only for swiftmodules; however,
it may be the case that only a swiftinterface (of a different arch) is present
but no swiftmodule is present.

Fixes rdar://problem/50905075.
This commit is contained in:
Varun Gandhi
2020-04-21 20:18:03 -07:00
parent c4134ca452
commit 412ee0a922
4 changed files with 20 additions and 16 deletions

View File

@@ -405,8 +405,12 @@ bool SerializedModuleLoader::maybeDiagnoseTargetMismatch(
return false;
StringRef filePath = directoryIterator->path();
StringRef extension = llvm::sys::path::extension(filePath);
if (file_types::lookupTypeForExtension(extension) ==
file_types::TY_SwiftModuleFile) {
auto fileType = file_types::lookupTypeForExtension(extension);
// We also check for interfaces here, because the SerializedModuleLoader
// is invoked after the ModuleInterfaceLoader; if the ModuleInterfaceLoader
// handled interfaces separately, we could get duplicate diagnostics.
if (fileType == file_types::TY_SwiftModuleFile
|| fileType == file_types::TY_SwiftModuleInterfaceFile) {
if (!foundArchs.empty())
foundArchs += ", ";
foundArchs += llvm::sys::path::stem(filePath).str();
@@ -414,7 +418,7 @@ bool SerializedModuleLoader::maybeDiagnoseTargetMismatch(
}
if (foundArchs.empty()) {
// Maybe this swiftmodule directory only contains swiftinterfaces, or
// It is strange that there were no swiftmodules or swiftinterfaces here;
// maybe something else is going on. Regardless, we shouldn't emit a
// possibly incorrect diagnostic.
return false;