@@ -46,7 +46,7 @@ class ModuleDependencyScanningWorker {
46
46
&alreadySeenModules);
47
47
48
48
// / Retrieve the module dependencies for the Swift module with the given name.
49
- ModuleDependencyVector scanFilesystemForSwiftModuleDependency (
49
+ SwiftModuleScannerQueryResult scanFilesystemForSwiftModuleDependency (
50
50
Identifier moduleName, bool isTestableImport = false );
51
51
52
52
// / Query dependency information for header dependencies
@@ -122,27 +122,67 @@ class SwiftDependencyTracker {
122
122
SwiftDependencyTracker (std::shared_ptr<llvm::cas::ObjectStore> CAS,
123
123
llvm::PrefixMapper *Mapper,
124
124
const CompilerInvocation &CI);
125
-
125
+
126
126
void startTracking (bool includeCommonDeps = true );
127
127
void trackFile (const Twine &path);
128
128
llvm::Expected<llvm::cas::ObjectProxy> createTreeFromDependencies ();
129
-
129
+
130
130
private:
131
131
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS;
132
132
std::shared_ptr<llvm::cas::ObjectStore> CAS;
133
133
llvm::PrefixMapper *Mapper;
134
-
134
+
135
135
struct FileEntry {
136
136
llvm::cas::ObjectRef FileRef;
137
137
size_t Size;
138
-
138
+
139
139
FileEntry (llvm::cas::ObjectRef FileRef, size_t Size)
140
- : FileRef(FileRef), Size(Size) {}
140
+ : FileRef(FileRef), Size(Size) {}
141
141
};
142
142
llvm::StringMap<FileEntry> CommonFiles;
143
143
std::map<std::string, FileEntry> TrackedFiles;
144
144
};
145
145
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
+
146
186
class ModuleDependencyScanner {
147
187
public:
148
188
ModuleDependencyScanner (SwiftDependencyScanningService &ScanningService,
@@ -246,7 +286,7 @@ class ModuleDependencyScanner {
246
286
StringRef mainModuleName, ModuleDependenciesCache &cache,
247
287
llvm::function_ref<void (ModuleDependencyID)> action);
248
288
249
- // / Performance BridgingHeader Chaining.
289
+ // / Perform Bridging Header Chaining.
250
290
llvm::Error
251
291
performBridgingHeaderChaining (const ModuleDependencyID &rootModuleID,
252
292
ModuleDependenciesCache &cache,
@@ -261,12 +301,6 @@ class ModuleDependencyScanner {
261
301
// / for a given module name.
262
302
Identifier getModuleImportIdentifier (StringRef moduleName);
263
303
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
-
270
304
// / Assuming the \c `moduleImport` failed to resolve,
271
305
// / iterate over all binary Swift module dependencies with serialized
272
306
// / search paths and attempt to diagnose if the failed-to-resolve module
@@ -275,12 +309,12 @@ class ModuleDependencyScanner {
275
309
std::optional<std::pair<ModuleDependencyID, std::string>>
276
310
attemptToFindResolvingSerializedSearchPath (
277
311
const ScannerImportStatementInfo &moduleImport,
278
- const ModuleDependenciesCache &cache, const SourceLoc &importLoc );
312
+ const ModuleDependenciesCache &cache);
279
313
280
314
private:
281
315
const CompilerInvocation &ScanCompilerInvocation;
282
316
ASTContext &ScanASTContext;
283
- DiagnosticEngine &Diagnostics ;
317
+ ModuleDependencyIssueReporter IssueReporter ;
284
318
285
319
// / The available pool of workers for filesystem module search
286
320
unsigned NumThreads;
0 commit comments