@@ -1152,7 +1152,8 @@ static Language getLanguageFromOptions(const LangOptions &LangOpts) {
1152
1152
1153
1153
std::unique_ptr<CompilerInstance> CompilerInstance::cloneForModuleCompileImpl (
1154
1154
SourceLocation ImportLoc, StringRef ModuleName, FrontendInputFile Input,
1155
- StringRef OriginalModuleMapFile, StringRef ModuleFileName) {
1155
+ StringRef OriginalModuleMapFile, StringRef ModuleFileName,
1156
+ IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS) {
1156
1157
// Construct a compiler invocation for creating this module.
1157
1158
auto Invocation = std::make_shared<CompilerInvocation>(getInvocation ());
1158
1159
@@ -1212,19 +1213,21 @@ std::unique_ptr<CompilerInstance> CompilerInstance::cloneForModuleCompileImpl(
1212
1213
auto &Inv = *Invocation;
1213
1214
Instance.setInvocation (std::move (Invocation));
1214
1215
1216
+ if (VFS) {
1217
+ Instance.createFileManager (std::move (VFS));
1218
+ } else if (FrontendOpts.ModulesShareFileManager ) {
1219
+ Instance.setFileManager (&getFileManager ());
1220
+ } else {
1221
+ Instance.createFileManager (&getVirtualFileSystem ());
1222
+ }
1223
+
1215
1224
Instance.createDiagnostics (
1216
- getVirtualFileSystem (),
1225
+ Instance. getVirtualFileSystem (),
1217
1226
new ForwardingDiagnosticConsumer (getDiagnosticClient ()),
1218
1227
/* ShouldOwnClient=*/ true );
1219
-
1220
1228
if (llvm::is_contained (DiagOpts.SystemHeaderWarningsModules , ModuleName))
1221
1229
Instance.getDiagnostics ().setSuppressSystemWarnings (false );
1222
1230
1223
- if (FrontendOpts.ModulesShareFileManager ) {
1224
- Instance.setFileManager (&getFileManager ());
1225
- } else {
1226
- Instance.createFileManager (&getVirtualFileSystem ());
1227
- }
1228
1231
Instance.createSourceManager (Instance.getFileManager ());
1229
1232
SourceManager &SourceMgr = Instance.getSourceManager ();
1230
1233
@@ -1318,7 +1321,8 @@ static OptionalFileEntryRef getPublicModuleMap(FileEntryRef File,
1318
1321
}
1319
1322
1320
1323
std::unique_ptr<CompilerInstance> CompilerInstance::cloneForModuleCompile (
1321
- SourceLocation ImportLoc, Module *Module, StringRef ModuleFileName) {
1324
+ SourceLocation ImportLoc, Module *Module, StringRef ModuleFileName,
1325
+ IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS) {
1322
1326
StringRef ModuleName = Module->getTopLevelModuleName ();
1323
1327
1324
1328
InputKind IK (getLanguageFromOptions (getLangOpts ()), InputKind::ModuleMap);
@@ -1363,7 +1367,8 @@ std::unique_ptr<CompilerInstance> CompilerInstance::cloneForModuleCompile(
1363
1367
return cloneForModuleCompileImpl (
1364
1368
ImportLoc, ModuleName,
1365
1369
FrontendInputFile (ModuleMapFilePath, IK, IsSystem),
1366
- ModMap.getModuleMapFileForUniquing (Module)->getName (), ModuleFileName);
1370
+ ModMap.getModuleMapFileForUniquing (Module)->getName (), ModuleFileName,
1371
+ std::move (VFS));
1367
1372
}
1368
1373
1369
1374
// FIXME: We only need to fake up an input file here as a way of
@@ -1380,7 +1385,8 @@ std::unique_ptr<CompilerInstance> CompilerInstance::cloneForModuleCompile(
1380
1385
auto Instance = cloneForModuleCompileImpl (
1381
1386
ImportLoc, ModuleName,
1382
1387
FrontendInputFile (FakeModuleMapFile, IK, +Module->IsSystem ),
1383
- ModMap.getModuleMapFileForUniquing (Module)->getName (), ModuleFileName);
1388
+ ModMap.getModuleMapFileForUniquing (Module)->getName (), ModuleFileName,
1389
+ std::move (VFS));
1384
1390
1385
1391
std::unique_ptr<llvm::MemoryBuffer> ModuleMapBuffer =
1386
1392
llvm::MemoryBuffer::getMemBufferCopy (InferredModuleMapContent);
0 commit comments