mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Dependency Scanning] Add import statement source locations to the dependency scanner cache serialization format
This commit is contained in:
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
@@ -58,6 +58,8 @@ using IsSystemField = BCFixed<1>;
|
||||
using IsStaticField = BCFixed<1>;
|
||||
/// A bit taht indicates whether or not a link library is a force-load one
|
||||
using IsForceLoadField = BCFixed<1>;
|
||||
/// A bit taht indicates whether or not an import statement is optional
|
||||
using IsOptionalImport = BCFixed<1>;
|
||||
|
||||
/// Source location fields
|
||||
using LineNumberField = BCFixed<32>;
|
||||
@@ -97,8 +99,9 @@ enum {
|
||||
LINK_LIBRARY_ARRAY_NODE,
|
||||
MACRO_DEPENDENCY_NODE,
|
||||
MACRO_DEPENDENCY_ARRAY_NODE,
|
||||
SOURCE_LOCATION_NODE,
|
||||
IMPORT_STATEMENT_NODE,
|
||||
IMPORT_STATEMENT_ARRAY_NODE,
|
||||
OPTIONAL_IMPORT_STATEMENT_ARRAY_NODE,
|
||||
SWIFT_INTERFACE_MODULE_DETAILS_NODE,
|
||||
SWIFT_SOURCE_MODULE_DETAILS_NODE,
|
||||
SWIFT_PLACEHOLDER_MODULE_DETAILS_NODE,
|
||||
@@ -158,19 +161,19 @@ using MacroDependencyArrayLayout =
|
||||
BCRecordLayout<MACRO_DEPENDENCY_ARRAY_NODE, IdentifierIDArryField>;
|
||||
|
||||
// ACTODO: Comment
|
||||
using SourceLocationLayout =
|
||||
BCRecordLayout<LINK_LIBRARY_NODE, // ID
|
||||
using ImportStatementLayout =
|
||||
BCRecordLayout<IMPORT_STATEMENT_NODE, // ID
|
||||
IdentifierIDField, // importIdentifier
|
||||
IdentifierIDField, // bufferIdentifier
|
||||
LineNumberField, // lineNumber
|
||||
ColumnNumberField // columnNumber
|
||||
ColumnNumberField, // columnNumber
|
||||
IsOptionalImport // isOptional
|
||||
>;
|
||||
|
||||
// ACTODO: Comment
|
||||
using ImportStatementLayout =
|
||||
BCRecordLayout<LINK_LIBRARY_NODE, // ID
|
||||
IdentifierIDField, // importIdentifier
|
||||
SourceLocationIDArrayIDField // importLocations
|
||||
>;
|
||||
using ImportStatementArrayLayout =
|
||||
BCRecordLayout<IMPORT_STATEMENT_ARRAY_NODE, IdentifierIDArryField>;
|
||||
using OptionalImportStatementArrayLayout =
|
||||
BCRecordLayout<OPTIONAL_IMPORT_STATEMENT_ARRAY_NODE, IdentifierIDArryField>;
|
||||
|
||||
// After the array records, we have a sequence of Module info
|
||||
// records, each of which is followed by one of:
|
||||
@@ -182,8 +185,8 @@ using ImportStatementLayout =
|
||||
using ModuleInfoLayout =
|
||||
BCRecordLayout<MODULE_NODE, // ID
|
||||
IdentifierIDField, // moduleName
|
||||
ImportArrayIDField, // moduleImports
|
||||
ImportArrayIDField, // optionalModuleImports
|
||||
ImportArrayIDField, // imports
|
||||
ImportArrayIDField, // optionalImports
|
||||
LinkLibrariesArrayIDField, // linkLibraries
|
||||
MacroDependenciesArrayIDField, // macroDependencies
|
||||
DependencyIDArrayIDField, // importedSwiftModules
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -355,7 +355,7 @@ ModuleDependencyScanner::getMainModuleDependencyInfo(ModuleDecl *mainModule) {
|
||||
});
|
||||
|
||||
auto mainDependencies = ModuleDependencyInfo::forSwiftSourceModule(
|
||||
{}, buildCommands, {}, ExtraPCMArgs);
|
||||
{}, buildCommands, {}, {}, {}, ExtraPCMArgs);
|
||||
|
||||
if (ScanASTContext.CASOpts.EnableCaching) {
|
||||
std::vector<std::string> clangDependencyFiles;
|
||||
@@ -1166,7 +1166,7 @@ void ModuleDependencyScanner::discoverCrossImportOverlayDependencies(
|
||||
auto actualMainID = ModuleDependencyID{mainModuleName.str(),
|
||||
ModuleDependencyKind::SwiftSource};
|
||||
auto dummyMainDependencies =
|
||||
ModuleDependencyInfo::forSwiftSourceModule({}, {}, {}, {});
|
||||
ModuleDependencyInfo::forSwiftSourceModule({}, {}, {}, {}, {}, {});
|
||||
std::for_each(newOverlays.begin(), newOverlays.end(),
|
||||
[&](Identifier modName) {
|
||||
dummyMainDependencies.addModuleImport(modName.str());
|
||||
|
||||
@@ -246,8 +246,8 @@ SwiftModuleScanner::scanInterfaceFile(Twine moduleInterfacePath,
|
||||
|
||||
Result = ModuleDependencyInfo::forSwiftInterfaceModule(
|
||||
outputPathBase.str().str(), InPath, compiledCandidatesRefs,
|
||||
ArgsRefs, linkLibraries, PCMArgs, Hash, isFramework, isStatic, {},
|
||||
/*module-cache-key*/ "", UserModVer);
|
||||
ArgsRefs, {}, {}, linkLibraries, PCMArgs, Hash, isFramework,
|
||||
isStatic, {}, /*module-cache-key*/ "", UserModVer);
|
||||
|
||||
if (Ctx.CASOpts.EnableCaching) {
|
||||
std::vector<std::string> clangDependencyFiles;
|
||||
|
||||
Reference in New Issue
Block a user