@@ -35,6 +35,7 @@ class ClangModuleDependenciesCacheImpl;
35
35
class SourceFile ;
36
36
class ASTContext ;
37
37
class Identifier ;
38
+ class CompilerInstance ;
38
39
39
40
// / Which kind of module dependencies we are looking for.
40
41
enum class ModuleDependenciesKind : int8_t {
@@ -501,34 +502,40 @@ class GlobalModuleDependenciesCache {
501
502
std::vector<ModuleDependencyID> AllModules;
502
503
503
504
// / Dependencies for modules that have already been computed.
504
- // / This maps a dependency kind to a map of a module's name to a Dependency object
505
+ // / This maps a dependency kind to a map of a module's name to a Dependency
506
+ // / object
505
507
ModuleDependenciesKindMap ModuleDependenciesMap;
506
508
};
507
509
508
- // / The 'persistent' Clang dependency scanner service
509
- clang::tooling::dependencies::DependencyScanningService clangScanningService;
510
+ // / The persistent Clang dependency scanner service
511
+ clang::tooling::dependencies::DependencyScanningService ClangScanningService;
512
+ // / The global file system cache.
513
+ Optional<
514
+ clang::tooling::dependencies::DependencyScanningFilesystemSharedCache>
515
+ SharedFilesystemCache;
510
516
511
- // / All cached Swift source module dependencies, in the order in which they were encountered
517
+ // / All cached Swift source module dependencies, in the order in which they
518
+ // / were encountered
512
519
std::vector<ModuleDependencyID> AllSourceModules;
513
-
514
- // / Dependencies for all Swift source-based modules discovered. Each one is the main
515
- // / module of a prior invocation of the scanner.
520
+ // / Dependencies for all Swift source-based modules discovered. Each one is
521
+ // / the main module of a prior invocation of the scanner.
516
522
ModuleNameToDependencyMap SwiftSourceModuleDependenciesMap;
517
523
518
- // / A map from a String representing the target triple of a scanner invocation to the corresponding
519
- // / cached dependencies discovered so far when using this triple.
520
- llvm::StringMap<std::unique_ptr<ContextSpecificGlobalCacheState>> ContextSpecificCacheMap;
524
+ // / A map from a String representing the target triple of a scanner invocation
525
+ // / to the corresponding cached dependencies discovered so far when using this
526
+ // / triple.
527
+ llvm::StringMap<std::unique_ptr<ContextSpecificGlobalCacheState>>
528
+ ContextSpecificCacheMap;
521
529
522
530
// / The current context hash configuration
523
531
Optional<std::string> CurrentContextHash;
524
-
525
- // / The context hashes used by scanners using this cache, in the order in which they were used
532
+ // / The context hashes used by scanners using this cache, in the order in
533
+ // / which they were used
526
534
std::vector<std::string> AllContextHashes;
527
535
528
536
// / Retrieve the dependencies map that corresponds to the given dependency
529
537
// / kind.
530
- ModuleNameToDependencyMap &
531
- getDependenciesMap (ModuleDependenciesKind kind);
538
+ ModuleNameToDependencyMap &getDependenciesMap (ModuleDependenciesKind kind);
532
539
const ModuleNameToDependencyMap &
533
540
getDependenciesMap (ModuleDependenciesKind kind) const ;
534
541
@@ -539,6 +546,16 @@ class GlobalModuleDependenciesCache {
539
546
operator =(const GlobalModuleDependenciesCache &) = delete ;
540
547
virtual ~GlobalModuleDependenciesCache () {}
541
548
549
+ // / Query the service's filesystem cache
550
+ clang::tooling::dependencies::DependencyScanningFilesystemSharedCache &
551
+ getSharedFilesystemCache () {
552
+ assert (SharedFilesystemCache && " Expected a shared cache" );
553
+ return *SharedFilesystemCache;
554
+ }
555
+
556
+ // / Wrap the filesystem on the specified `CompilerInstance` with a
557
+ // / caching `DependencyScanningWorkerFilesystem`
558
+ void overlaySharedFilesystemCacheForCompilation (CompilerInstance &Instance);
542
559
private:
543
560
// / Enforce clients not being allowed to query this cache directly, it must be
544
561
// / wrapped in an instance of `ModuleDependenciesCache`.
@@ -552,19 +569,21 @@ class GlobalModuleDependenciesCache {
552
569
553
570
// / Return context hashes of all scanner invocations that have used
554
571
// / this cache instance.
555
- const std::vector<std::string>& getAllContextHashes () const {
572
+ const std::vector<std::string> & getAllContextHashes () const {
556
573
return AllContextHashes;
557
574
}
558
575
559
576
// / Whether we have cached dependency information for the given module.
560
577
bool hasDependencies (StringRef moduleName,
561
578
Optional<ModuleDependenciesKind> kind) const ;
562
579
563
- // / Return a pointer to the context-specific cache state of the current scanning action.
564
- ContextSpecificGlobalCacheState* getCurrentCache () const ;
580
+ // / Return a pointer to the context-specific cache state of the current
581
+ // / scanning action.
582
+ ContextSpecificGlobalCacheState *getCurrentCache () const ;
565
583
566
584
// / Return a pointer to the cache state of the specified context hash.
567
- ContextSpecificGlobalCacheState* getCacheForScanningContextHash (StringRef scanningContextHash) const ;
585
+ ContextSpecificGlobalCacheState *
586
+ getCacheForScanningContextHash (StringRef scanningContextHash) const ;
568
587
569
588
// / Look for source-based module dependency details
570
589
Optional<ModuleDependencies>
@@ -585,10 +604,13 @@ class GlobalModuleDependenciesCache {
585
604
const ModuleDependencies *updateDependencies (ModuleDependencyID moduleID,
586
605
ModuleDependencies dependencies);
587
606
588
- // / Reference the list of all module dependencies that are not source-based modules
589
- // / (i.e. interface dependencies, binary dependencies, clang dependencies).
590
- const std::vector<ModuleDependencyID> &getAllNonSourceModules (StringRef scanningContextHash) const {
591
- auto contextSpecificCache = getCacheForScanningContextHash (scanningContextHash);
607
+ // / Reference the list of all module dependencies that are not source-based
608
+ // / modules (i.e. interface dependencies, binary dependencies, clang
609
+ // / dependencies).
610
+ const std::vector<ModuleDependencyID> &
611
+ getAllNonSourceModules (StringRef scanningContextHash) const {
612
+ auto contextSpecificCache =
613
+ getCacheForScanningContextHash (scanningContextHash);
592
614
return contextSpecificCache->AllModules ;
593
615
}
594
616
0 commit comments