Skip to content

Commit 9102c65

Browse files
authored
Merge pull request #84938 from artemcm/ShareCacheRefInScanner
[Dependency Scanning] Have `ModuleDependnecyScanner` hold a reference to a dependency cache, instead of passing it around
2 parents be3009d + 1584287 commit 9102c65

File tree

3 files changed

+123
-122
lines changed

3 files changed

+123
-122
lines changed

include/swift/DependencyScan/ModuleDependencyScanner.h

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -216,13 +216,14 @@ class ModuleDependencyIssueReporter {
216216
class ModuleDependencyScanner {
217217
public:
218218
ModuleDependencyScanner(SwiftDependencyScanningService &ScanningService,
219+
ModuleDependenciesCache &Cache,
219220
const CompilerInvocation &ScanCompilerInvocation,
220221
const SILOptions &SILOptions,
221222
ASTContext &ScanASTContext,
222223
DependencyTracker &DependencyTracker,
223224
std::shared_ptr<llvm::cas::ObjectStore> CAS,
224225
std::shared_ptr<llvm::cas::ActionCache> ActionCache,
225-
DiagnosticEngine &diags, bool ParallelScan);
226+
DiagnosticEngine &Diagnostics, bool ParallelScan);
226227

227228
/// Identify the scanner invocation's main module's dependencies
228229
llvm::ErrorOr<ModuleDependencyInfo>
@@ -231,8 +232,7 @@ class ModuleDependencyScanner {
231232
/// Resolve module dependencies of the given module, computing a full
232233
/// transitive closure dependency graph.
233234
std::vector<ModuleDependencyID>
234-
performDependencyScan(ModuleDependencyID rootModuleID,
235-
ModuleDependenciesCache &cache);
235+
performDependencyScan(ModuleDependencyID rootModuleID);
236236

237237
/// How many filesystem lookups were performed by the scanner
238238
unsigned getNumLookups() { return NumLookups; }
@@ -275,47 +275,46 @@ class ModuleDependencyScanner {
275275
/// that have one
276276
ModuleDependencyIDSetVector
277277
resolveImportedModuleDependencies(
278-
const ModuleDependencyID &rootModuleID, ModuleDependenciesCache &cache);
278+
const ModuleDependencyID &rootModuleID);
279279
void resolveSwiftModuleDependencies(
280-
const ModuleDependencyID &rootModuleID, ModuleDependenciesCache &cache,
280+
const ModuleDependencyID &rootModuleID,
281281
ModuleDependencyIDSetVector &discoveredSwiftModules);
282282
void resolveAllClangModuleDependencies(
283-
ArrayRef<ModuleDependencyID> swiftModules, ModuleDependenciesCache &cache,
283+
ArrayRef<ModuleDependencyID> swiftModules,
284284
ModuleDependencyIDSetVector &discoveredClangModules);
285285
void resolveHeaderDependencies(
286-
ArrayRef<ModuleDependencyID> swiftModules, ModuleDependenciesCache &cache,
286+
ArrayRef<ModuleDependencyID> swiftModules,
287287
ModuleDependencyIDSetVector &discoveredHeaderDependencyClangModules);
288288
void resolveSwiftOverlayDependencies(
289-
ArrayRef<ModuleDependencyID> swiftModules, ModuleDependenciesCache &cache,
289+
ArrayRef<ModuleDependencyID> swiftModules,
290290
ModuleDependencyIDSetVector &discoveredDependencies);
291291

292292
/// Resolve all of a given module's imports to a Swift module, if one exists.
293293
void resolveSwiftImportsForModule(
294-
const ModuleDependencyID &moduleID, ModuleDependenciesCache &cache,
294+
const ModuleDependencyID &moduleID,
295295
ModuleDependencyIDSetVector &importedSwiftDependencies);
296296

297297
/// If a module has a bridging header or other header inputs, execute a
298298
/// dependency scan on it and record the dependencies.
299299
void resolveHeaderDependenciesForModule(
300-
const ModuleDependencyID &moduleID, ModuleDependenciesCache &cache,
300+
const ModuleDependencyID &moduleID,
301301
ModuleDependencyIDSetVector &headerClangModuleDependencies);
302302

303303
/// Resolve all module dependencies comprised of Swift overlays
304304
/// of this module's Clang module dependencies.
305305
void resolveSwiftOverlayDependenciesForModule(
306-
const ModuleDependencyID &moduleID, ModuleDependenciesCache &cache,
306+
const ModuleDependencyID &moduleID,
307307
ModuleDependencyIDSetVector &swiftOverlayDependencies);
308308

309309
/// Identify all cross-import overlay module dependencies of the
310310
/// source module under scan and apply an action for each.
311311
void resolveCrossImportOverlayDependencies(
312-
StringRef mainModuleName, ModuleDependenciesCache &cache,
312+
StringRef mainModuleName,
313313
llvm::function_ref<void(ModuleDependencyID)> action);
314314

315315
/// Perform Bridging Header Chaining.
316316
llvm::Error
317317
performBridgingHeaderChaining(const ModuleDependencyID &rootModuleID,
318-
ModuleDependenciesCache &cache,
319318
ModuleDependencyIDSetVector &allModules);
320319

321320
/// Bridge Clang dependency scanner's dependency node
@@ -351,7 +350,6 @@ class ModuleDependencyScanner {
351350
void performParallelClangModuleLookup(
352351
const ImportStatementInfoMap &unresolvedImportsMap,
353352
const ImportStatementInfoMap &unresolvedOptionalImportsMap,
354-
ModuleDependenciesCache &cache,
355353
BatchClangModuleLookupResult &result);
356354

357355
/// Given a result of a batch Clang module dependency lookup,
@@ -371,7 +369,6 @@ class ModuleDependencyScanner {
371369
const ImportStatementInfoMap &unresolvedImportsMap,
372370
const ImportStatementInfoMap &unresolvedOptionalImportsMap,
373371
ArrayRef<ModuleDependencyID> swiftModuleDependents,
374-
ModuleDependenciesCache &cache,
375372
ModuleDependencyIDSetVector &allDiscoveredClangModules,
376373
std::vector<std::pair<ModuleDependencyID, ScannerImportStatementInfo>>
377374
&failedToResolveImports,
@@ -381,7 +378,6 @@ class ModuleDependencyScanner {
381378
/// Re-query some failed-to-resolve Clang imports from cache
382379
/// in chance they were brought in as transitive dependencies.
383380
void reQueryMissedModulesFromCache(
384-
ModuleDependenciesCache &cache,
385381
const std::vector<
386382
std::pair<ModuleDependencyID, ScannerImportStatementInfo>>
387383
&failedToResolveImports,
@@ -395,8 +391,7 @@ class ModuleDependencyScanner {
395391
/// the module, if one is found.
396392
std::optional<std::pair<ModuleDependencyID, std::string>>
397393
attemptToFindResolvingSerializedSearchPath(
398-
const ScannerImportStatementInfo &moduleImport,
399-
const ModuleDependenciesCache &cache);
394+
const ScannerImportStatementInfo &moduleImport);
400395

401396
private:
402397
const CompilerInvocation &ScanCompilerInvocation;
@@ -407,6 +402,9 @@ class ModuleDependencyScanner {
407402
std::string ModuleOutputPath;
408403
/// The location of where the explicitly-built SDK modules will be output to
409404
std::string SDKModuleOutputPath;
405+
406+
/// Reference to a module dependency cache
407+
ModuleDependenciesCache &DependencyCache;
410408

411409
/// The available pool of workers for filesystem module search
412410
unsigned NumThreads;

0 commit comments

Comments
 (0)