@@ -1089,32 +1089,33 @@ forEachBatchEntry(CompilerInstance &invocationInstance,
1089
1089
1090
1090
// Create a new instance by the arguments and save it in the map.
1091
1091
auto newGlobalCache = std::make_unique<GlobalModuleDependenciesCache>();
1092
- subInstanceMap->insert (
1093
- {entry.arguments ,
1094
- std::make_tuple (std::make_unique<CompilerInstance>(),
1095
- std::move (newGlobalCache),
1096
- std::make_unique<ModuleDependenciesCache>(*newGlobalCache))});
1092
+ auto newInstance = std::make_unique<CompilerInstance>();
1097
1093
1098
- pInstance = std::get<0 >((*subInstanceMap)[entry.arguments ]).get ();
1099
- auto globalCache = std::get<1 >((*subInstanceMap)[entry.arguments ]).get ();
1100
- pCache = std::get<2 >((*subInstanceMap)[entry.arguments ]).get ();
1101
1094
SmallVector<const char *, 4 > args;
1102
1095
llvm::cl::TokenizeGNUCommandLine (entry.arguments , saver, args);
1103
1096
CompilerInvocation subInvoke = invoke;
1104
- pInstance ->addDiagnosticConsumer (&FDC);
1097
+ newInstance ->addDiagnosticConsumer (&FDC);
1105
1098
if (subInvoke.parseArgs (args, diags)) {
1106
1099
invocationInstance.getDiags ().diagnose (
1107
1100
SourceLoc (), diag::scanner_arguments_invalid, entry.arguments );
1108
1101
return true ;
1109
1102
}
1110
1103
std::string InstanceSetupError;
1111
- if (pInstance ->setup (subInvoke, InstanceSetupError)) {
1104
+ if (newInstance ->setup (subInvoke, InstanceSetupError)) {
1112
1105
invocationInstance.getDiags ().diagnose (
1113
1106
SourceLoc (), diag::scanner_arguments_invalid, entry.arguments );
1114
1107
return true ;
1115
1108
}
1116
- globalCache->configureForTriple (pInstance->getInvocation ()
1117
- .getLangOptions ().Target .str ());
1109
+ newGlobalCache->configureForTriple (
1110
+ newInstance->getInvocation ().getLangOptions ().Target .str ());
1111
+ auto newLocalCache = std::make_unique<ModuleDependenciesCache>(
1112
+ *newGlobalCache, newInstance->getMainModule ()->getNameStr ());
1113
+ pInstance = newInstance.get ();
1114
+ pCache = newLocalCache.get ();
1115
+ subInstanceMap->insert (
1116
+ {entry.arguments ,
1117
+ std::make_tuple (std::move (newInstance), std::move (newGlobalCache),
1118
+ std::move (newLocalCache))});
1118
1119
}
1119
1120
assert (pInstance);
1120
1121
assert (pCache);
@@ -1252,7 +1253,8 @@ bool swift::dependencies::scanDependencies(CompilerInstance &instance) {
1252
1253
if (opts.ReuseDependencyScannerCache )
1253
1254
deserializeDependencyCache (instance, globalCache);
1254
1255
1255
- ModuleDependenciesCache cache (globalCache);
1256
+ ModuleDependenciesCache cache (globalCache,
1257
+ instance.getMainModule ()->getNameStr ());
1256
1258
1257
1259
// Execute scan
1258
1260
auto dependenciesOrErr = performModuleScan (instance, cache);
@@ -1287,7 +1289,8 @@ bool swift::dependencies::prescanDependencies(CompilerInstance &instance) {
1287
1289
GlobalModuleDependenciesCache singleUseGlobalCache;
1288
1290
singleUseGlobalCache.configureForTriple (instance.getInvocation ()
1289
1291
.getLangOptions ().Target .str ());
1290
- ModuleDependenciesCache cache (singleUseGlobalCache);
1292
+ ModuleDependenciesCache cache (singleUseGlobalCache,
1293
+ instance.getMainModule ()->getNameStr ());
1291
1294
if (out.has_error () || EC) {
1292
1295
Context.Diags .diagnose (SourceLoc (), diag::error_opening_output, path,
1293
1296
EC.message ());
@@ -1318,7 +1321,8 @@ bool swift::dependencies::batchScanDependencies(
1318
1321
GlobalModuleDependenciesCache singleUseGlobalCache;
1319
1322
singleUseGlobalCache.configureForTriple (instance.getInvocation ()
1320
1323
.getLangOptions ().Target .str ());
1321
- ModuleDependenciesCache cache (singleUseGlobalCache);
1324
+ ModuleDependenciesCache cache (singleUseGlobalCache,
1325
+ instance.getMainModule ()->getNameStr ());
1322
1326
(void )instance.getMainModule ();
1323
1327
llvm::BumpPtrAllocator alloc;
1324
1328
llvm::StringSaver saver (alloc);
@@ -1353,7 +1357,8 @@ bool swift::dependencies::batchPrescanDependencies(
1353
1357
GlobalModuleDependenciesCache singleUseGlobalCache;
1354
1358
singleUseGlobalCache.configureForTriple (instance.getInvocation ()
1355
1359
.getLangOptions ().Target .str ());
1356
- ModuleDependenciesCache cache (singleUseGlobalCache);
1360
+ ModuleDependenciesCache cache (singleUseGlobalCache,
1361
+ instance.getMainModule ()->getNameStr ());
1357
1362
(void )instance.getMainModule ();
1358
1363
llvm::BumpPtrAllocator alloc;
1359
1364
llvm::StringSaver saver (alloc);
0 commit comments