@@ -386,7 +386,8 @@ bool ModuleDependenciesCacheDeserializer::readGraph(SwiftDependencyScanningServi
386
386
for (const auto &mod : *bridgingModuleDeps)
387
387
moduleDep.addBridgingModuleDependency (mod, alreadyAdded);
388
388
389
- cache.recordSourceDependency (currentModuleName, std::move (moduleDep));
389
+ cache.recordDependency (currentModuleName, std::move (moduleDep),
390
+ getContextHash ());
390
391
hasCurrentModule = false ;
391
392
break ;
392
393
}
@@ -991,37 +992,9 @@ unsigned ModuleDependenciesCacheSerializer::getArrayID(ModuleDependencyID module
991
992
992
993
void ModuleDependenciesCacheSerializer::collectStringsAndArrays (
993
994
const SwiftDependencyScanningService &cache) {
994
- for (auto &moduleID : cache.getAllSourceModules ()) {
995
- assert (moduleID.second == ModuleDependencyKind::SwiftSource &&
996
- " Expected source-based dependency" );
997
- auto optionalDependencyInfo =
998
- cache.findSourceModuleDependency (moduleID.first );
999
- assert (optionalDependencyInfo.has_value () && " Expected dependency info." );
1000
- auto dependencyInfo = optionalDependencyInfo.value ();
1001
- // Add the module's name
1002
- addIdentifier (moduleID.first );
1003
- // Add the module's dependencies
1004
- addStringArray (moduleID, ModuleIdentifierArrayKind::DependencyImports,
1005
- dependencyInfo->getModuleImports ());
1006
- addDependencyIDArray (moduleID, ModuleIdentifierArrayKind::QualifiedModuleDependencyIDs,
1007
- dependencyInfo->getModuleDependencies ());
1008
- auto swiftSourceDeps = dependencyInfo->getAsSwiftSourceModule ();
1009
- assert (swiftSourceDeps);
1010
- addStringArray (moduleID, ModuleIdentifierArrayKind::ExtraPCMArgs,
1011
- swiftSourceDeps->textualModuleDetails .extraPCMArgs );
1012
- if (swiftSourceDeps->textualModuleDetails .bridgingHeaderFile .has_value ())
1013
- addIdentifier (swiftSourceDeps->textualModuleDetails .bridgingHeaderFile .value ());
1014
- addStringArray (moduleID, ModuleIdentifierArrayKind::SourceFiles,
1015
- swiftSourceDeps->sourceFiles );
1016
- addStringArray (moduleID, ModuleIdentifierArrayKind::BridgingSourceFiles,
1017
- swiftSourceDeps->textualModuleDetails .bridgingSourceFiles );
1018
- addStringArray (moduleID, ModuleIdentifierArrayKind::BridgingModuleDependencies,
1019
- swiftSourceDeps->textualModuleDetails .bridgingModuleDependencies );
1020
- }
1021
-
1022
995
for (auto &contextHash : cache.getAllContextHashes ()) {
1023
996
addIdentifier (contextHash);
1024
- for (auto &moduleID : cache.getAllNonSourceModules (contextHash)) {
997
+ for (auto &moduleID : cache.getAllModules (contextHash)) {
1025
998
auto optionalDependencyInfo = cache.findDependency (moduleID.first ,
1026
999
moduleID.second ,
1027
1000
contextHash);
@@ -1078,6 +1051,21 @@ void ModuleDependenciesCacheSerializer::collectStringsAndArrays(
1078
1051
addIdentifier (swiftPHDeps->sourceInfoPath );
1079
1052
break ;
1080
1053
}
1054
+ case swift::ModuleDependencyKind::SwiftSource: {
1055
+ auto swiftSourceDeps = dependencyInfo->getAsSwiftSourceModule ();
1056
+ assert (swiftSourceDeps);
1057
+ addStringArray (moduleID, ModuleIdentifierArrayKind::ExtraPCMArgs,
1058
+ swiftSourceDeps->textualModuleDetails .extraPCMArgs );
1059
+ if (swiftSourceDeps->textualModuleDetails .bridgingHeaderFile .has_value ())
1060
+ addIdentifier (swiftSourceDeps->textualModuleDetails .bridgingHeaderFile .value ());
1061
+ addStringArray (moduleID, ModuleIdentifierArrayKind::SourceFiles,
1062
+ swiftSourceDeps->sourceFiles );
1063
+ addStringArray (moduleID, ModuleIdentifierArrayKind::BridgingSourceFiles,
1064
+ swiftSourceDeps->textualModuleDetails .bridgingSourceFiles );
1065
+ addStringArray (moduleID, ModuleIdentifierArrayKind::BridgingModuleDependencies,
1066
+ swiftSourceDeps->textualModuleDetails .bridgingModuleDependencies );
1067
+ break ;
1068
+ }
1081
1069
case swift::ModuleDependencyKind::Clang: {
1082
1070
auto clangDeps = dependencyInfo->getAsClangModule ();
1083
1071
assert (clangDeps);
@@ -1135,17 +1123,8 @@ void ModuleDependenciesCacheSerializer::writeInterModuleDependenciesCache(
1135
1123
writeArraysOfIdentifiers ();
1136
1124
1137
1125
// Write the core graph
1138
- // First, write the source modules we've encountered
1139
- for (auto &moduleID : cache.getAllSourceModules ()) {
1140
- auto dependencyInfo = cache.findSourceModuleDependency (moduleID.first );
1141
- assert (dependencyInfo.has_value () && " Expected dependency info." );
1142
- writeModuleInfo (moduleID, llvm::Optional<std::string>(), **dependencyInfo);
1143
- }
1144
-
1145
- // Write all non-source modules, for each of the context hashes this scanner
1146
- // has been used with
1147
1126
for (auto &contextHash : cache.getAllContextHashes ()) {
1148
- for (auto &moduleID : cache.getAllNonSourceModules (contextHash)) {
1127
+ for (auto &moduleID : cache.getAllModules (contextHash)) {
1149
1128
auto dependencyInfo = cache.findDependency (moduleID.first ,
1150
1129
moduleID.second ,
1151
1130
contextHash);
0 commit comments