@@ -550,7 +550,7 @@ std::error_code ImplicitSerializedModuleLoader::findModuleFilesInDirectory(
550
550
std::unique_ptr<llvm::MemoryBuffer> *ModuleBuffer,
551
551
std::unique_ptr<llvm::MemoryBuffer> *ModuleDocBuffer,
552
552
std::unique_ptr<llvm::MemoryBuffer> *ModuleSourceInfoBuffer,
553
- bool skipBuildingInterface , bool IsFramework, bool IsTestableDependencyLookup) {
553
+ bool IsCanImportLookup , bool IsFramework, bool IsTestableDependencyLookup) {
554
554
if (LoadMode == ModuleLoadingMode::OnlyInterface ||
555
555
Ctx.IgnoreAdjacentModules )
556
556
return std::make_error_code (std::errc::not_supported);
@@ -579,7 +579,8 @@ std::error_code ImplicitSerializedModuleLoader::findModuleFilesInDirectory(
579
579
580
580
bool ImplicitSerializedModuleLoader::maybeDiagnoseTargetMismatch (
581
581
SourceLoc sourceLocation, StringRef moduleName,
582
- const SerializedModuleBaseName &absoluteBaseName) {
582
+ const SerializedModuleBaseName &absoluteBaseName,
583
+ bool isCanImportLookup) {
583
584
llvm::vfs::FileSystem &fs = *Ctx.SourceMgr .getFileSystem ();
584
585
585
586
// Get the last component of the base name, which is the target-specific one.
@@ -614,9 +615,11 @@ bool ImplicitSerializedModuleLoader::maybeDiagnoseTargetMismatch(
614
615
return false ;
615
616
}
616
617
617
- Ctx.Diags .diagnose (sourceLocation, diag::sema_no_import_target, moduleName,
618
- target, foundArchs, dir);
619
- return true ;
618
+ Ctx.Diags
619
+ .diagnose (sourceLocation, diag::sema_no_import_target, moduleName, target,
620
+ foundArchs, dir)
621
+ .limitBehaviorIf (isCanImportLookup, DiagnosticBehavior::Warning);
622
+ return !isCanImportLookup;
620
623
}
621
624
622
625
SerializedModuleBaseName::SerializedModuleBaseName (
@@ -720,7 +723,7 @@ bool SerializedModuleLoaderBase::findModule(
720
723
std::unique_ptr<llvm::MemoryBuffer> *moduleBuffer,
721
724
std::unique_ptr<llvm::MemoryBuffer> *moduleDocBuffer,
722
725
std::unique_ptr<llvm::MemoryBuffer> *moduleSourceInfoBuffer,
723
- bool skipBuildingInterface , bool isTestableDependencyLookup,
726
+ bool isCanImportLookup , bool isTestableDependencyLookup,
724
727
bool &isFramework, bool &isSystemModule) {
725
728
// Find a module with an actual, physical name on disk, in case
726
729
// -module-alias is used (otherwise same).
@@ -766,7 +769,7 @@ bool SerializedModuleLoaderBase::findModule(
766
769
auto result = findModuleFilesInDirectory (
767
770
moduleID, absoluteBaseName, moduleInterfacePath,
768
771
moduleInterfaceSourcePath, moduleBuffer, moduleDocBuffer,
769
- moduleSourceInfoBuffer, skipBuildingInterface , IsFramework,
772
+ moduleSourceInfoBuffer, isCanImportLookup , IsFramework,
770
773
isTestableDependencyLookup);
771
774
if (!result)
772
775
return SearchResult::Found;
@@ -780,7 +783,7 @@ bool SerializedModuleLoaderBase::findModule(
780
783
// 'std::errc::no_such_file_or_directory'.
781
784
if (firstAbsoluteBaseName &&
782
785
maybeDiagnoseTargetMismatch (moduleID.Loc , moduleName,
783
- *firstAbsoluteBaseName))
786
+ *firstAbsoluteBaseName, isCanImportLookup ))
784
787
return SearchResult::Error;
785
788
786
789
return SearchResult::NotFound;
@@ -838,7 +841,7 @@ bool SerializedModuleLoaderBase::findModule(
838
841
auto result = findModuleFilesInDirectory (
839
842
moduleID, absoluteBaseName, moduleInterfacePath,
840
843
moduleInterfaceSourcePath, moduleBuffer, moduleDocBuffer,
841
- moduleSourceInfoBuffer, skipBuildingInterface , isFramework,
844
+ moduleSourceInfoBuffer, isCanImportLookup , isFramework,
842
845
isTestableDependencyLookup);
843
846
if (!result)
844
847
return true ;
@@ -1512,7 +1515,7 @@ bool SerializedModuleLoaderBase::canImportModule(
1512
1515
mID , /* moduleInterfacePath=*/ nullptr , &moduleInterfaceSourcePath,
1513
1516
&moduleInputBuffer,
1514
1517
/* moduleDocBuffer=*/ nullptr , /* moduleSourceInfoBuffer=*/ nullptr ,
1515
- /* skipBuildingInterface =*/ true , isTestableDependencyLookup,
1518
+ /* isCanImportLookup =*/ true , isTestableDependencyLookup,
1516
1519
isFramework, isSystemModule);
1517
1520
// If we cannot find the module, don't continue.
1518
1521
if (!found)
@@ -1607,7 +1610,7 @@ SerializedModuleLoaderBase::loadModule(SourceLoc importLoc,
1607
1610
if (!findModule (moduleID, &moduleInterfacePath, &moduleInterfaceSourcePath,
1608
1611
&moduleInputBuffer, &moduleDocInputBuffer,
1609
1612
&moduleSourceInfoInputBuffer,
1610
- /* skipBuildingInterface =*/ false ,
1613
+ /* isCanImportLookup =*/ false ,
1611
1614
/* isTestableDependencyLookup=*/ false ,
1612
1615
isFramework,
1613
1616
isSystemModule)) {
@@ -1747,7 +1750,7 @@ std::error_code MemoryBufferSerializedModuleLoader::findModuleFilesInDirectory(
1747
1750
std::unique_ptr<llvm::MemoryBuffer> *ModuleBuffer,
1748
1751
std::unique_ptr<llvm::MemoryBuffer> *ModuleDocBuffer,
1749
1752
std::unique_ptr<llvm::MemoryBuffer> *ModuleSourceInfoBuffer,
1750
- bool skipBuildingInterface , bool IsFramework,
1753
+ bool isCanImportLookup , bool IsFramework,
1751
1754
bool isTestableDependencyLookup) {
1752
1755
// This is a soft error instead of an llvm_unreachable because this API is
1753
1756
// primarily used by LLDB which makes it more likely that unwitting changes to
@@ -1756,12 +1759,6 @@ std::error_code MemoryBufferSerializedModuleLoader::findModuleFilesInDirectory(
1756
1759
return std::make_error_code (std::errc::not_supported);
1757
1760
}
1758
1761
1759
- bool MemoryBufferSerializedModuleLoader::maybeDiagnoseTargetMismatch (
1760
- SourceLoc sourceLocation, StringRef moduleName,
1761
- const SerializedModuleBaseName &absoluteBaseName) {
1762
- return false ;
1763
- }
1764
-
1765
1762
void SerializedModuleLoaderBase::verifyAllModules () {
1766
1763
#ifndef NDEBUG
1767
1764
for (const LoadedModulePair &loaded : LoadedModuleFiles)
0 commit comments