[Dependency Scanning] Add import statement source locations to the dependency scanner cache serialization format

This commit is contained in:
Artem Chikin
2024-12-05 10:41:30 -08:00
parent 8399267785
commit 25d32fc7a3
5 changed files with 577 additions and 307 deletions

View File

@@ -176,13 +176,6 @@ class ModuleDependencyInfoStorageBase {
public:
const ModuleDependencyKind dependencyKind;
ModuleDependencyInfoStorageBase(ModuleDependencyKind dependencyKind,
ArrayRef<LinkLibrary> linkLibraries,
StringRef moduleCacheKey = "")
: dependencyKind(dependencyKind), linkLibraries(linkLibraries),
moduleCacheKey(moduleCacheKey.str()),
finalized(false) {}
ModuleDependencyInfoStorageBase(
ModuleDependencyKind dependencyKind,
ArrayRef<ScannerImportStatementInfo> moduleImports,
@@ -303,11 +296,14 @@ public:
SwiftInterfaceModuleDependenciesStorage(
StringRef moduleOutputPath, StringRef swiftInterfaceFile,
ArrayRef<StringRef> compiledModuleCandidates,
ArrayRef<ScannerImportStatementInfo> moduleImports,
ArrayRef<ScannerImportStatementInfo> optionalModuleImports,
ArrayRef<StringRef> buildCommandLine, ArrayRef<LinkLibrary> linkLibraries,
ArrayRef<StringRef> extraPCMArgs, StringRef contextHash, bool isFramework,
bool isStatic, StringRef RootID, StringRef moduleCacheKey,
StringRef userModuleVersion)
: ModuleDependencyInfoStorageBase(ModuleDependencyKind::SwiftInterface,
moduleImports, optionalModuleImports,
linkLibraries, moduleCacheKey),
moduleOutputPath(moduleOutputPath),
swiftInterfaceFile(swiftInterfaceFile),
@@ -350,9 +346,12 @@ public:
SwiftSourceModuleDependenciesStorage(
StringRef RootID, ArrayRef<StringRef> buildCommandLine,
ArrayRef<ScannerImportStatementInfo> moduleImports,
ArrayRef<ScannerImportStatementInfo> optionalModuleImports,
ArrayRef<StringRef> bridgingHeaderBuildCommandLine,
ArrayRef<StringRef> extraPCMArgs)
: ModuleDependencyInfoStorageBase(ModuleDependencyKind::SwiftSource, {}),
: ModuleDependencyInfoStorageBase(ModuleDependencyKind::SwiftSource,
moduleImports, optionalModuleImports, {}),
textualModuleDetails(extraPCMArgs, buildCommandLine, RootID),
testableImports(llvm::StringSet<>()),
bridgingHeaderBuildCommandLine(bridgingHeaderBuildCommandLine.begin(),
@@ -500,6 +499,7 @@ public:
StringRef clangIncludeTreeRoot,
StringRef moduleCacheKey, bool IsSystem)
: ModuleDependencyInfoStorageBase(ModuleDependencyKind::Clang,
{}, {},
linkLibraries, moduleCacheKey),
pcmOutputPath(pcmOutputPath), mappedPCMPath(mappedPCMPath),
moduleMapFile(moduleMapFile), contextHash(contextHash),
@@ -531,7 +531,7 @@ public:
SwiftPlaceholderModuleDependencyStorage(StringRef compiledModulePath,
StringRef moduleDocPath,
StringRef sourceInfoPath)
: ModuleDependencyInfoStorageBase(ModuleDependencyKind::SwiftPlaceholder,
: ModuleDependencyInfoStorageBase(ModuleDependencyKind::SwiftPlaceholder, {}, {},
{}),
compiledModulePath(compiledModulePath), moduleDocPath(moduleDocPath),
sourceInfoPath(sourceInfoPath) {}
@@ -586,6 +586,8 @@ public:
static ModuleDependencyInfo forSwiftInterfaceModule(
StringRef moduleOutputPath, StringRef swiftInterfaceFile,
ArrayRef<StringRef> compiledCandidates, ArrayRef<StringRef> buildCommands,
ArrayRef<ScannerImportStatementInfo> moduleImports,
ArrayRef<ScannerImportStatementInfo> optionalModuleImports,
ArrayRef<LinkLibrary> linkLibraries, ArrayRef<StringRef> extraPCMArgs,
StringRef contextHash, bool isFramework, bool isStatic,
StringRef CASFileSystemRootID, StringRef moduleCacheKey,
@@ -593,6 +595,7 @@ public:
return ModuleDependencyInfo(
std::make_unique<SwiftInterfaceModuleDependenciesStorage>(
moduleOutputPath, swiftInterfaceFile, compiledCandidates,
moduleImports, optionalModuleImports,
buildCommands, linkLibraries, extraPCMArgs, contextHash,
isFramework, isStatic, CASFileSystemRootID, moduleCacheKey,
userModuleVersion));
@@ -619,11 +622,14 @@ public:
static ModuleDependencyInfo
forSwiftSourceModule(const std::string &CASFileSystemRootID,
ArrayRef<StringRef> buildCommands,
ArrayRef<ScannerImportStatementInfo> moduleImports,
ArrayRef<ScannerImportStatementInfo> optionalModuleImports,
ArrayRef<StringRef> bridgingHeaderBuildCommands,
ArrayRef<StringRef> extraPCMArgs) {
return ModuleDependencyInfo(
std::make_unique<SwiftSourceModuleDependenciesStorage>(
CASFileSystemRootID, buildCommands, bridgingHeaderBuildCommands,
CASFileSystemRootID, buildCommands, moduleImports,
optionalModuleImports, bridgingHeaderBuildCommands,
extraPCMArgs));
}