[Dependency Scanning] Add support for diagnosing invalid architecture swift binary module candidates

Refactor 'maybeDiagnoseTargetMismatch' to separately collect mismatching target variant modules in 'identifyArchitectureVariants' and rename it to 'handlePossibleTargetMismatch'.

Prior uses of 'maybeDiagnoseTargetMismatch' will continue diagnosing errors/warnings on only discovering incompatible swift binary module target variants.

A new overload of 'handlePossibleTargetMismatch', in 'SwiftModuleScanner', instead collects it as a discovered incompatible candidate, for diagnosis downstream.
This commit is contained in:
Artem Chikin
2025-09-23 15:36:11 -07:00
parent c73869e479
commit 48c2a328ec
5 changed files with 76 additions and 23 deletions

View File

@@ -151,14 +151,23 @@ protected:
/// to list the architectures that \e are present.
///
/// \returns true if an error diagnostic was emitted
virtual bool maybeDiagnoseTargetMismatch(
virtual bool handlePossibleTargetMismatch(
SourceLoc sourceLocation,
StringRef moduleName,
const SerializedModuleBaseName &BaseName,
const SerializedModuleBaseName &baseName,
bool isCanImportLookup) {
return false;
}
/// Assuming the \c baseName is a target-specific Swift module path,
/// for a missing target variant, collect all adjacent binary module
/// files to build a list of discovered modules for incompatible
/// architectures.
static void identifyArchitectureVariants(
ASTContext &Ctx,
const SerializedModuleBaseName &baseName,
std::vector<std::string> &incompatibleArchModules);
/// Determines if the provided path is a cached artifact for dependency
/// tracking purposes.
virtual bool isCached(StringRef DepPath) {
@@ -282,7 +291,7 @@ class ImplicitSerializedModuleLoader : public SerializedModuleLoaderBase {
bool IsCanImportLookup, bool IsFramework,
bool IsTestableDependencyLookup = false) override;
bool maybeDiagnoseTargetMismatch(
bool handlePossibleTargetMismatch(
SourceLoc sourceLocation,
StringRef moduleName,
const SerializedModuleBaseName &BaseName,