@@ -1335,23 +1335,15 @@ static OptionalFileEntryRef getPublicModuleMap(FileEntryRef File,
1335
1335
return FileMgr.getOptionalFileRef (PublicFilename);
1336
1336
}
1337
1337
1338
- // / Creates a \c CompilerInstance for compiling a module.
1339
- // /
1340
- // / This takes care of creating appropriate \c FrontendInputFile for
1341
- // / public/private frameworks, inferred modules and such.
1342
- static std::unique_ptr<CompilerInstance>
1343
- createCompilerInstanceForModuleCompile (CompilerInstance &ImportingInstance,
1344
- SourceLocation ImportLoc, Module *Module,
1345
- StringRef ModuleFileName) {
1338
+ std::unique_ptr<CompilerInstance> CompilerInstance::cloneForModuleCompile (
1339
+ SourceLocation ImportLoc, Module *Module, StringRef ModuleFileName) {
1346
1340
StringRef ModuleName = Module->getTopLevelModuleName ();
1347
1341
1348
- InputKind IK (getLanguageFromOptions (ImportingInstance.getLangOpts ()),
1349
- InputKind::ModuleMap);
1342
+ InputKind IK (getLanguageFromOptions (getLangOpts ()), InputKind::ModuleMap);
1350
1343
1351
1344
// Get or create the module map that we'll use to build this module.
1352
- ModuleMap &ModMap =
1353
- ImportingInstance.getPreprocessor ().getHeaderSearchInfo ().getModuleMap ();
1354
- SourceManager &SourceMgr = ImportingInstance.getSourceManager ();
1345
+ ModuleMap &ModMap = getPreprocessor ().getHeaderSearchInfo ().getModuleMap ();
1346
+ SourceManager &SourceMgr = getSourceManager ();
1355
1347
1356
1348
if (FileID ModuleMapFID = ModMap.getContainingModuleMapFileID (Module);
1357
1349
ModuleMapFID.isValid ()) {
@@ -1372,8 +1364,8 @@ createCompilerInstanceForModuleCompile(CompilerInstance &ImportingInstance,
1372
1364
// Canonicalize compilation to start with the public module map. This is
1373
1365
// vital for submodules declarations in the private module maps to be
1374
1366
// correctly parsed when depending on a top level module in the public one.
1375
- if (OptionalFileEntryRef PublicMMFile = getPublicModuleMap (
1376
- *ModuleMapFile, ImportingInstance. getFileManager ()))
1367
+ if (OptionalFileEntryRef PublicMMFile =
1368
+ getPublicModuleMap ( *ModuleMapFile, getFileManager ()))
1377
1369
ModuleMapFile = PublicMMFile;
1378
1370
1379
1371
StringRef ModuleMapFilePath = ModuleMapFile->getNameAsRequested ();
@@ -1387,7 +1379,7 @@ createCompilerInstanceForModuleCompile(CompilerInstance &ImportingInstance,
1387
1379
1388
1380
// Use the module map where this module resides.
1389
1381
return createCompilerInstanceForModuleCompileImpl (
1390
- ImportingInstance , ImportLoc, ModuleName,
1382
+ * this , ImportLoc, ModuleName,
1391
1383
FrontendInputFile (ModuleMapFilePath, IK, IsSystem),
1392
1384
ModMap.getModuleMapFileForUniquing (Module)->getName (), ModuleFileName);
1393
1385
}
@@ -1404,7 +1396,7 @@ createCompilerInstanceForModuleCompile(CompilerInstance &ImportingInstance,
1404
1396
Module->print (OS);
1405
1397
1406
1398
auto Instance = createCompilerInstanceForModuleCompileImpl (
1407
- ImportingInstance , ImportLoc, ModuleName,
1399
+ * this , ImportLoc, ModuleName,
1408
1400
FrontendInputFile (FakeModuleMapFile, IK, +Module->IsSystem ),
1409
1401
ModMap.getModuleMapFileForUniquing (Module)->getName (), ModuleFileName);
1410
1402
@@ -1465,8 +1457,8 @@ static bool compileModuleAndReadASTImpl(CompilerInstance &ImportingInstance,
1465
1457
SourceLocation ModuleNameLoc,
1466
1458
Module *Module,
1467
1459
StringRef ModuleFileName) {
1468
- auto Instance = createCompilerInstanceForModuleCompile (
1469
- ImportingInstance, ModuleNameLoc, Module, ModuleFileName);
1460
+ auto Instance = ImportingInstance. cloneForModuleCompile (ModuleNameLoc, Module,
1461
+ ModuleFileName);
1470
1462
1471
1463
if (!compileModule (ImportingInstance, ModuleNameLoc,
1472
1464
Module->getTopLevelModuleName (), ModuleFileName,
0 commit comments