@@ -46,7 +46,7 @@ class ModuleDependencyScanningWorker {
4646 &alreadySeenModules);
4747
4848 // / Retrieve the module dependencies for the Swift module with the given name.
49- ModuleDependencyVector scanFilesystemForSwiftModuleDependency (
49+ SwiftModuleScannerQueryResult scanFilesystemForSwiftModuleDependency (
5050 Identifier moduleName, bool isTestableImport = false );
5151
5252 // / Query dependency information for header dependencies
@@ -122,27 +122,67 @@ class SwiftDependencyTracker {
122122 SwiftDependencyTracker (std::shared_ptr<llvm::cas::ObjectStore> CAS,
123123 llvm::PrefixMapper *Mapper,
124124 const CompilerInvocation &CI);
125-
125+
126126 void startTracking (bool includeCommonDeps = true );
127127 void trackFile (const Twine &path);
128128 llvm::Expected<llvm::cas::ObjectProxy> createTreeFromDependencies ();
129-
129+
130130private:
131131 llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS;
132132 std::shared_ptr<llvm::cas::ObjectStore> CAS;
133133 llvm::PrefixMapper *Mapper;
134-
134+
135135 struct FileEntry {
136136 llvm::cas::ObjectRef FileRef;
137137 size_t Size;
138-
138+
139139 FileEntry (llvm::cas::ObjectRef FileRef, size_t Size)
140- : FileRef(FileRef), Size(Size) {}
140+ : FileRef(FileRef), Size(Size) {}
141141 };
142142 llvm::StringMap<FileEntry> CommonFiles;
143143 std::map<std::string, FileEntry> TrackedFiles;
144144};
145145
146+ class ModuleDependencyIssueReporter {
147+ private:
148+ ModuleDependencyIssueReporter (DiagnosticEngine &Diagnostics)
149+ : Diagnostics(Diagnostics) {}
150+
151+ // / Diagnose scanner failure and attempt to reconstruct the dependency
152+ // / path from the main module to the missing dependency
153+ void diagnoseModuleNotFoundFailure (
154+ const ScannerImportStatementInfo &moduleImport,
155+ const ModuleDependenciesCache &cache,
156+ std::optional<ModuleDependencyID> dependencyOf,
157+ std::optional<std::pair<ModuleDependencyID, std::string>>
158+ resolvingSerializedSearchPath,
159+ std::optional<
160+ std::vector<SwiftModuleScannerQueryResult::IncompatibleCandidate>>
161+ foundIncompatibleCandidates = std::nullopt );
162+
163+ // / Upon query failure, if incompatible binary module
164+ // / candidates were found, emit a failure diagnostic
165+ void diagnoseFailureOnOnlyIncompatibleCandidates (
166+ const ScannerImportStatementInfo &moduleImport,
167+ const std::vector<SwiftModuleScannerQueryResult::IncompatibleCandidate>
168+ &candidates,
169+ const ModuleDependenciesCache &cache,
170+ std::optional<ModuleDependencyID> dependencyOf);
171+
172+ // / Emit warnings for each discovered binary Swift module
173+ // / which was incompatible with the current compilation
174+ // / when querying \c moduleName
175+ void warnOnIncompatibleCandidates (
176+ StringRef moduleName,
177+ const std::vector<SwiftModuleScannerQueryResult::IncompatibleCandidate>
178+ &candidates);
179+
180+ DiagnosticEngine &Diagnostics;
181+ std::unordered_set<std::string> ReportedMissing;
182+ // Restrict access to the parent scanner class.
183+ friend class ModuleDependencyScanner ;
184+ };
185+
146186class ModuleDependencyScanner {
147187public:
148188 ModuleDependencyScanner (SwiftDependencyScanningService &ScanningService,
@@ -246,7 +286,7 @@ class ModuleDependencyScanner {
246286 StringRef mainModuleName, ModuleDependenciesCache &cache,
247287 llvm::function_ref<void (ModuleDependencyID)> action);
248288
249- // / Performance BridgingHeader Chaining.
289+ // / Perform Bridging Header Chaining.
250290 llvm::Error
251291 performBridgingHeaderChaining (const ModuleDependencyID &rootModuleID,
252292 ModuleDependenciesCache &cache,
@@ -261,12 +301,6 @@ class ModuleDependencyScanner {
261301 // / for a given module name.
262302 Identifier getModuleImportIdentifier (StringRef moduleName);
263303
264- // / Diagnose scanner failure and attempt to reconstruct the dependency
265- // / path from the main module to the missing dependency.
266- void diagnoseScannerFailure (const ScannerImportStatementInfo &moduleImport,
267- const ModuleDependenciesCache &cache,
268- std::optional<ModuleDependencyID> dependencyOf);
269-
270304 // / Assuming the \c `moduleImport` failed to resolve,
271305 // / iterate over all binary Swift module dependencies with serialized
272306 // / search paths and attempt to diagnose if the failed-to-resolve module
@@ -275,12 +309,12 @@ class ModuleDependencyScanner {
275309 std::optional<std::pair<ModuleDependencyID, std::string>>
276310 attemptToFindResolvingSerializedSearchPath (
277311 const ScannerImportStatementInfo &moduleImport,
278- const ModuleDependenciesCache &cache, const SourceLoc &importLoc );
312+ const ModuleDependenciesCache &cache);
279313
280314private:
281315 const CompilerInvocation &ScanCompilerInvocation;
282316 ASTContext &ScanASTContext;
283- DiagnosticEngine &Diagnostics ;
317+ ModuleDependencyIssueReporter IssueReporter ;
284318
285319 // / The available pool of workers for filesystem module search
286320 unsigned NumThreads;
0 commit comments