[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

@@ -325,45 +325,6 @@ struct ModuleRebuildInfo {
return false;
}
const char *invalidModuleReason(serialization::Status status) {
using namespace serialization;
switch (status) {
case Status::FormatTooOld:
return "compiled with an older version of the compiler";
case Status::FormatTooNew:
return "compiled with a newer version of the compiler";
case Status::RevisionIncompatible:
return "compiled with a different version of the compiler";
case Status::ChannelIncompatible:
return "compiled for a different distribution channel";
case Status::NotInOSSA:
return "module was not built with OSSA";
case Status::MissingDependency:
return "missing dependency";
case Status::MissingUnderlyingModule:
return "missing underlying module";
case Status::CircularDependency:
return "circular dependency";
case Status::FailedToLoadBridgingHeader:
return "failed to load bridging header";
case Status::Malformed:
return "malformed";
case Status::MalformedDocumentation:
return "malformed documentation";
case Status::NameMismatch:
return "name mismatch";
case Status::TargetIncompatible:
return "compiled for a different target platform";
case Status::TargetTooNew:
return "target platform newer than current platform";
case Status::SDKMismatch:
return "SDK does not match";
case Status::Valid:
return nullptr;
}
llvm_unreachable("bad status");
}
/// Emits a diagnostic for all out-of-date compiled or forwarding modules
/// encountered while trying to load a module.
template<typename... DiagArgs>
@@ -406,9 +367,9 @@ struct ModuleRebuildInfo {
// If there was a compiled module that wasn't able to be read, diagnose
// the reason we couldn't read it.
if (auto status = mod.serializationStatus) {
if (auto reason = invalidModuleReason(*status)) {
if (auto reason = SerializedModuleLoaderBase::invalidModuleReason(*status)) {
diags.diagnose(loc, diag::compiled_module_invalid_reason,
mod.path, reason);
mod.path, reason.value());
} else {
diags.diagnose(loc, diag::compiled_module_invalid, mod.path);
}