@@ -1153,7 +1153,7 @@ static Language getLanguageFromOptions(const LangOptions &LangOpts) {
1153
1153
std::unique_ptr<CompilerInstance> CompilerInstance::cloneForModuleCompileImpl (
1154
1154
SourceLocation ImportLoc, StringRef ModuleName, FrontendInputFile Input,
1155
1155
StringRef OriginalModuleMapFile, StringRef ModuleFileName,
1156
- IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS ) {
1156
+ std::optional<ThreadSafeCloneConfig> ThreadSafeConfig ) {
1157
1157
// Construct a compiler invocation for creating this module.
1158
1158
auto Invocation = std::make_shared<CompilerInvocation>(getInvocation ());
1159
1159
@@ -1213,18 +1213,24 @@ std::unique_ptr<CompilerInstance> CompilerInstance::cloneForModuleCompileImpl(
1213
1213
auto &Inv = *Invocation;
1214
1214
Instance.setInvocation (std::move (Invocation));
1215
1215
1216
- if (VFS ) {
1217
- Instance.createFileManager (std::move (VFS ));
1216
+ if (ThreadSafeConfig ) {
1217
+ Instance.createFileManager (ThreadSafeConfig-> getVFS ( ));
1218
1218
} else if (FrontendOpts.ModulesShareFileManager ) {
1219
1219
Instance.setFileManager (&getFileManager ());
1220
1220
} else {
1221
1221
Instance.createFileManager (&getVirtualFileSystem ());
1222
1222
}
1223
1223
1224
- Instance.createDiagnostics (
1225
- Instance.getVirtualFileSystem (),
1226
- new ForwardingDiagnosticConsumer (getDiagnosticClient ()),
1227
- /* ShouldOwnClient=*/ true );
1224
+ if (ThreadSafeConfig) {
1225
+ Instance.createDiagnostics (Instance.getVirtualFileSystem (),
1226
+ &ThreadSafeConfig->getDiagConsumer (),
1227
+ /* ShouldOwnClient=*/ false );
1228
+ } else {
1229
+ Instance.createDiagnostics (
1230
+ Instance.getVirtualFileSystem (),
1231
+ new ForwardingDiagnosticConsumer (getDiagnosticClient ()),
1232
+ /* ShouldOwnClient=*/ true );
1233
+ }
1228
1234
if (llvm::is_contained (DiagOpts.SystemHeaderWarningsModules , ModuleName))
1229
1235
Instance.getDiagnostics ().setSuppressSystemWarnings (false );
1230
1236
@@ -1322,7 +1328,7 @@ static OptionalFileEntryRef getPublicModuleMap(FileEntryRef File,
1322
1328
1323
1329
std::unique_ptr<CompilerInstance> CompilerInstance::cloneForModuleCompile (
1324
1330
SourceLocation ImportLoc, Module *Module, StringRef ModuleFileName,
1325
- IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS ) {
1331
+ std::optional<ThreadSafeCloneConfig> ThreadSafeConfig ) {
1326
1332
StringRef ModuleName = Module->getTopLevelModuleName ();
1327
1333
1328
1334
InputKind IK (getLanguageFromOptions (getLangOpts ()), InputKind::ModuleMap);
@@ -1368,7 +1374,7 @@ std::unique_ptr<CompilerInstance> CompilerInstance::cloneForModuleCompile(
1368
1374
ImportLoc, ModuleName,
1369
1375
FrontendInputFile (ModuleMapFilePath, IK, IsSystem),
1370
1376
ModMap.getModuleMapFileForUniquing (Module)->getName (), ModuleFileName,
1371
- std::move (VFS ));
1377
+ std::move (ThreadSafeConfig ));
1372
1378
}
1373
1379
1374
1380
// FIXME: We only need to fake up an input file here as a way of
@@ -1386,7 +1392,7 @@ std::unique_ptr<CompilerInstance> CompilerInstance::cloneForModuleCompile(
1386
1392
ImportLoc, ModuleName,
1387
1393
FrontendInputFile (FakeModuleMapFile, IK, +Module->IsSystem ),
1388
1394
ModMap.getModuleMapFileForUniquing (Module)->getName (), ModuleFileName,
1389
- std::move (VFS ));
1395
+ std::move (ThreadSafeConfig ));
1390
1396
1391
1397
std::unique_ptr<llvm::MemoryBuffer> ModuleMapBuffer =
1392
1398
llvm::MemoryBuffer::getMemBufferCopy (InferredModuleMapContent);
0 commit comments