Skip to content

Commit c8a3383

Browse files
authored
Merge pull request #60776 from artemcm/ClangCacheNoPreserve
[Dependency Scanner] Move the Clang scanning shared state out into local (per-scan) cache.
2 parents 1bba62e + 1f3600a commit c8a3383

File tree

1 file changed

+19
-29
lines changed

1 file changed

+19
-29
lines changed

include/swift/AST/ModuleDependencies.h

Lines changed: 19 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -515,18 +515,6 @@ class GlobalModuleDependenciesCache {
515515
/// The triples used by scanners using this cache, in the order in which they were used
516516
std::vector<std::string> AllTriples;
517517

518-
/// Additional information needed for Clang dependency scanning.
519-
ClangModuleDependenciesCacheImpl *clangImpl = nullptr;
520-
521-
/// Function that will delete \c clangImpl properly.
522-
void (*clangImplDeleter)(ClangModuleDependenciesCacheImpl *) = nullptr;
523-
524-
/// Free up the storage associated with the Clang implementation.
525-
void destroyClangImpl() {
526-
if (this->clangImplDeleter)
527-
this->clangImplDeleter(this->clangImpl);
528-
}
529-
530518
/// Retrieve the dependencies map that corresponds to the given dependency
531519
/// kind.
532520
llvm::StringMap<ModuleDependenciesVector> &
@@ -540,7 +528,7 @@ class GlobalModuleDependenciesCache {
540528
GlobalModuleDependenciesCache &
541529
operator=(const GlobalModuleDependenciesCache &) = delete;
542530

543-
virtual ~GlobalModuleDependenciesCache() { destroyClangImpl(); }
531+
virtual ~GlobalModuleDependenciesCache() {}
544532

545533
void configureForTriple(std::string triple);
546534

@@ -553,19 +541,6 @@ class GlobalModuleDependenciesCache {
553541
/// wrapped in an instance of `ModuleDependenciesCache`.
554542
friend class ModuleDependenciesCache;
555543

556-
/// Set the Clang-specific implementation data.
557-
virtual void
558-
setClangImpl(ClangModuleDependenciesCacheImpl *clangImpl,
559-
void (*clangImplDeleter)(ClangModuleDependenciesCacheImpl *)) {
560-
destroyClangImpl();
561-
562-
this->clangImpl = clangImpl;
563-
this->clangImplDeleter = clangImplDeleter;
564-
}
565-
566-
/// Retrieve the Clang-specific implementation data;
567-
ClangModuleDependenciesCacheImpl *getClangImpl() const { return clangImpl; }
568-
569544
/// Whether we have cached dependency information for the given module.
570545
bool hasDependencies(StringRef moduleName,
571546
ModuleLookupSpecifics details) const;
@@ -632,6 +607,18 @@ class ModuleDependenciesCache {
632607
/// the current scanning action.
633608
ModuleDependenciesKindRefMap ModuleDependenciesMap;
634609

610+
/// Additional information needed for Clang dependency scanning.
611+
ClangModuleDependenciesCacheImpl *clangImpl = nullptr;
612+
613+
/// Function that will delete \c clangImpl properly.
614+
void (*clangImplDeleter)(ClangModuleDependenciesCacheImpl *) = nullptr;
615+
616+
/// Free up the storage associated with the Clang implementation.
617+
void destroyClangImpl() {
618+
if (this->clangImplDeleter)
619+
this->clangImplDeleter(this->clangImpl);
620+
}
621+
635622
/// Retrieve the dependencies map that corresponds to the given dependency
636623
/// kind.
637624
llvm::StringMap<const ModuleDependencies *> &
@@ -654,19 +641,22 @@ class ModuleDependenciesCache {
654641
ModuleDependenciesCache(GlobalModuleDependenciesCache &globalCache);
655642
ModuleDependenciesCache(const ModuleDependenciesCache &) = delete;
656643
ModuleDependenciesCache &operator=(const ModuleDependenciesCache &) = delete;
657-
virtual ~ModuleDependenciesCache() {}
644+
virtual ~ModuleDependenciesCache() { destroyClangImpl(); }
658645

659646
public:
660647
/// Set the Clang-specific implementation data.
661648
void
662649
setClangImpl(ClangModuleDependenciesCacheImpl *clangImpl,
663650
void (*clangImplDeleter)(ClangModuleDependenciesCacheImpl *)) {
664-
globalCache.setClangImpl(clangImpl, clangImplDeleter);
651+
destroyClangImpl();
652+
653+
this->clangImpl = clangImpl;
654+
this->clangImplDeleter = clangImplDeleter;
665655
}
666656

667657
/// Retrieve the Clang-specific implementation data;
668658
ClangModuleDependenciesCacheImpl *getClangImpl() const {
669-
return globalCache.getClangImpl();
659+
return clangImpl;
670660
}
671661

672662
/// Whether we have cached dependency information for the given module.

0 commit comments

Comments
 (0)