[Dependency Scanning] Refactor primary scan operations into 'ModuleDependencyScanner' class

From being a scattered collection of 'static' methods in ScanDependencies.cpp
and member methods of ASTContext. This makes 'ScanDependencies.cpp' much easier
to read, and abstracts the actual scanning logic away to a place with common
state which will make it easier to reason about in the future.
This commit is contained in:
Artem Chikin
2023-08-28 16:11:48 -07:00
parent ea0e5c3a3e
commit 6e3f896962
25 changed files with 1480 additions and 1372 deletions

View File

@@ -28,6 +28,7 @@
#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/StringSet.h"
#include "llvm/ADT/TinyPtrVector.h"
#include "llvm/ADT/IntrusiveRefCntPtr.h"
#include "llvm/Support/VersionTuple.h"
#include <system_error>
@@ -36,10 +37,19 @@ class FileCollectorBase;
namespace vfs {
class OutputBackend;
}
namespace cas {
class CachingOnDiskFileSystem;
}
}
namespace clang {
class DependencyCollector;
namespace tooling {
namespace dependencies {
struct ModuleID;
class DependencyScanningTool;
}
}
}
namespace swift {
@@ -51,6 +61,7 @@ class ClassDecl;
class FileUnit;
class ModuleDecl;
class ModuleDependencyInfo;
struct ModuleDependencyID;
class ModuleDependenciesCache;
class NominalTypeDecl;
class SourceFile;
@@ -327,8 +338,12 @@ public:
/// Retrieve the dependencies for the given, named module, or \c None
/// if no such module exists.
virtual llvm::Optional<const ModuleDependencyInfo *>
getModuleDependencies(StringRef moduleName, ModuleDependenciesCache &cache,
virtual llvm::SmallVector<std::pair<ModuleDependencyID, ModuleDependencyInfo>, 1>
getModuleDependencies(StringRef moduleName,
StringRef moduleOutputPath,
llvm::IntrusiveRefCntPtr<llvm::cas::CachingOnDiskFileSystem> CacheFS,
const llvm::DenseSet<clang::tooling::dependencies::ModuleID> &alreadySeenClangModules,
clang::tooling::dependencies::DependencyScanningTool &clangScanningTool,
InterfaceSubContextDelegate &delegate,
bool isTestableImport = false) = 0;
};