[Dependency Scanning] Emit a warning when failing to load a binary module of a non-resilient dependency

This failure will most-likely result in the dependency query failure which will fail the scan. It will be helpful if the scanner emitted diagnostic for each such module it rejected to explain the reason why.

Resolves rdar://142906530
This commit is contained in:
Artem Chikin
2025-01-15 16:53:05 -08:00
parent f7fb0991b7
commit 550538f3b5
6 changed files with 89 additions and 51 deletions

View File

@@ -18,6 +18,7 @@
#include "swift/AST/ModuleDependencies.h"
#include "swift/AST/ModuleLoader.h"
#include "swift/AST/SearchPathOptions.h"
#include "swift/Serialization/Validation.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/PrefixMapper.h"
#include "llvm/TargetParser/Triple.h"
@@ -165,7 +166,8 @@ protected:
/// Scan the given serialized module file to determine dependencies.
llvm::ErrorOr<ModuleDependencyInfo>
scanModuleFile(Twine modulePath, bool isFramework, bool isTestableImport);
scanModuleFile(Twine modulePath, bool isFramework,
bool isTestableImport, bool isCandidateForTextualModule);
struct BinaryModuleImports {
llvm::StringSet<> moduleImports;
@@ -267,6 +269,10 @@ public:
InterfaceSubContextDelegate &delegate,
llvm::PrefixMapper *mapper,
bool isTestableImport) override;
/// A textual reason why the compiler rejected a binary module load
/// attempt with a given status, to be used for diagnostic output.
static std::optional<std::string> invalidModuleReason(serialization::Status status);
};
/// Imports serialized Swift modules into an ASTContext.