[Dependency Scanning] Refactor Swift Scanner loader to be standalone

- 'SwiftModuleScanner' will now be owned directly by the 'ModuleDependencyScanningWorker' and will contain all the necessary custom logic, instead of being instantiated by the module interface loader for each query
- Moves ownership over module output path and sdk module output path directly into the scanning worker, instead of the cache
This commit is contained in:
Artem Chikin
2025-06-18 16:38:32 -07:00
parent 5eb85acad5
commit 68883a1014
16 changed files with 447 additions and 539 deletions

View File

@@ -15,7 +15,7 @@
#include "swift/AST/Identifier.h"
#include "swift/AST/ModuleDependencies.h"
#include "swift/Frontend/ModuleInterfaceLoader.h"
#include "swift/Serialization/SerializedModuleLoader.h"
#include "swift/Serialization/ScanningLoaders.h"
#include "llvm/CAS/CASReference.h"
#include "llvm/Support/ThreadPool.h"
@@ -38,17 +38,14 @@ public:
private:
/// Retrieve the module dependencies for the Clang module with the given name.
ModuleDependencyVector scanFilesystemForClangModuleDependency(
Identifier moduleName, StringRef moduleOutputPath,
StringRef sdkModuleOutputPath,
Identifier moduleName,
const llvm::DenseSet<clang::tooling::dependencies::ModuleID>
&alreadySeenModules,
llvm::PrefixMapper *prefixMapper);
/// Retrieve the module dependencies for the Swift module with the given name.
ModuleDependencyVector scanFilesystemForSwiftModuleDependency(
Identifier moduleName, StringRef moduleOutputPath,
StringRef sdkModuleOutputPath, llvm::PrefixMapper *prefixMapper,
bool isTestableImport = false);
Identifier moduleName, bool isTestableImport = false);
/// Query dependency information for header dependencies
/// of a binary Swift module.
@@ -90,7 +87,7 @@ private:
// The Clang scanner tool used by this worker.
clang::tooling::dependencies::DependencyScanningTool clangScanningTool;
// Swift and Clang module loaders acting as scanners.
std::unique_ptr<ModuleInterfaceLoader> swiftScannerModuleLoader;
std::unique_ptr<SwiftModuleScanner> swiftModuleScannerLoader;
// Base command line invocation for clang scanner queries (both module and header)
std::vector<std::string> clangScanningBaseCommandLineArgs;
@@ -102,6 +99,11 @@ private:
// Working directory for clang module lookup queries
std::string clangScanningWorkingDirectoryPath;
/// The location of where the explicitly-built modules will be output to
std::string moduleOutputPath;
/// The location of where the explicitly-built SDK modules will be output to
std::string sdkModuleOutputPath;
// CAS instance.
std::shared_ptr<llvm::cas::ObjectStore> CAS;
std::shared_ptr<llvm::cas::ActionCache> ActionCache;