@@ -280,7 +280,6 @@ static Optional<StringRef> getRelativeDepPath(StringRef DepPath,
280
280
// / output path.
281
281
// / \note Needs to be in the swift namespace so CompilerInvocation can see it.
282
282
class swift ::ParseableInterfaceBuilder {
283
- ASTContext &ctx;
284
283
llvm::vfs::FileSystem &fs;
285
284
DiagnosticEngine &diags;
286
285
const StringRef interfacePath;
@@ -307,10 +306,9 @@ class swift::ParseableInterfaceBuilder {
307
306
.setMainAndSupplementaryOutputs ({MainOut}, {SOPs});
308
307
}
309
308
310
- void configureSubInvocation () {
311
- auto &SearchPathOpts = ctx.SearchPathOpts ;
312
- auto &LangOpts = ctx.LangOpts ;
313
-
309
+ void configureSubInvocation (const SearchPathOptions &SearchPathOpts,
310
+ const LangOptions &LangOpts,
311
+ ClangModuleLoader *ClangLoader) {
314
312
// Start with a SubInvocation that copies various state from our
315
313
// invoking ASTContext.
316
314
subInvocation.setImportSearchPaths (SearchPathOpts.ImportSearchPaths );
@@ -329,7 +327,7 @@ class swift::ParseableInterfaceBuilder {
329
327
// Respect the detailed-record preprocessor setting of the parent context.
330
328
// This, and the "raw" clang module format it implicitly enables, are
331
329
// required by sourcekitd.
332
- if (auto * ClangLoader = ctx. getClangModuleLoader () ) {
330
+ if (ClangLoader) {
333
331
auto &Opts = ClangLoader->getClangInstance ().getPreprocessorOpts ();
334
332
if (Opts.DetailedRecord ) {
335
333
subInvocation.getClangImporterOptions ().DetailedPreprocessingRecord = true ;
@@ -472,7 +470,10 @@ class swift::ParseableInterfaceBuilder {
472
470
}
473
471
474
472
public:
475
- ParseableInterfaceBuilder (ASTContext &ctx,
473
+ ParseableInterfaceBuilder (SourceManager &sourceMgr, DiagnosticEngine &diags,
474
+ const SearchPathOptions &searchPathOpts,
475
+ const LangOptions &langOpts,
476
+ ClangModuleLoader *clangImporter,
476
477
StringRef interfacePath,
477
478
StringRef moduleName,
478
479
StringRef moduleCachePath,
@@ -482,14 +483,14 @@ class swift::ParseableInterfaceBuilder {
482
483
bool remarkOnRebuildFromInterface = false ,
483
484
SourceLoc diagnosticLoc = SourceLoc(),
484
485
DependencyTracker *tracker = nullptr )
485
- : ctx(ctx), fs(*ctx.SourceMgr. getFileSystem()), diags(ctx.Diags ),
486
- interfacePath (interfacePath), moduleName(moduleName),
487
- moduleCachePath(moduleCachePath), prebuiltCachePath(prebuiltCachePath),
488
- serializeDependencyHashes(serializeDependencyHashes),
489
- trackSystemDependencies(trackSystemDependencies),
490
- remarkOnRebuildFromInterface(remarkOnRebuildFromInterface),
491
- diagnosticLoc(diagnosticLoc), dependencyTracker(tracker) {
492
- configureSubInvocation ();
486
+ : fs(*sourceMgr. getFileSystem()), diags(diags ),
487
+ interfacePath (interfacePath), moduleName(moduleName),
488
+ moduleCachePath(moduleCachePath), prebuiltCachePath(prebuiltCachePath),
489
+ serializeDependencyHashes(serializeDependencyHashes),
490
+ trackSystemDependencies(trackSystemDependencies),
491
+ remarkOnRebuildFromInterface(remarkOnRebuildFromInterface),
492
+ diagnosticLoc(diagnosticLoc), dependencyTracker(tracker) {
493
+ configureSubInvocation (searchPathOpts, langOpts, clangImporter );
493
494
}
494
495
495
496
const CompilerInvocation &getSubInvocation () const {
@@ -1236,9 +1237,11 @@ class ParseableInterfaceModuleLoaderImpl {
1236
1237
// Set up a builder if we need to build the module. It'll also set up
1237
1238
// the subinvocation we'll need to use to compute the cache paths.
1238
1239
ParseableInterfaceBuilder builder (
1239
- ctx, interfacePath, moduleName, cacheDir, prebuiltCacheDir,
1240
- /* serializeDependencyHashes*/ false , trackSystemDependencies,
1241
- remarkOnRebuildFromInterface, diagnosticLoc, dependencyTracker);
1240
+ ctx.SourceMgr , ctx.Diags , ctx.SearchPathOpts , ctx.LangOpts ,
1241
+ ctx.getClangModuleLoader (), interfacePath, moduleName, cacheDir,
1242
+ prebuiltCacheDir, /* serializeDependencyHashes*/ false ,
1243
+ trackSystemDependencies, remarkOnRebuildFromInterface, diagnosticLoc,
1244
+ dependencyTracker);
1242
1245
auto &subInvocation = builder.getSubInvocation ();
1243
1246
1244
1247
// Compute the output path if we're loading or emitting a cached module.
@@ -1373,12 +1376,15 @@ std::error_code ParseableInterfaceModuleLoader::findModuleFilesInDirectory(
1373
1376
1374
1377
1375
1378
bool ParseableInterfaceModuleLoader::buildSwiftModuleFromSwiftInterface (
1376
- ASTContext &Ctx, StringRef CacheDir, StringRef PrebuiltCacheDir,
1377
- StringRef ModuleName, StringRef InPath, StringRef OutPath,
1378
- bool SerializeDependencyHashes, bool TrackSystemDependencies,
1379
- bool RemarkOnRebuildFromInterface) {
1380
- ParseableInterfaceBuilder builder (Ctx, InPath, ModuleName,
1381
- CacheDir, PrebuiltCacheDir,
1379
+ SourceManager &SourceMgr, DiagnosticEngine &Diags,
1380
+ const SearchPathOptions &SearchPathOpts, const LangOptions &LangOpts,
1381
+ StringRef CacheDir, StringRef PrebuiltCacheDir,
1382
+ StringRef ModuleName, StringRef InPath, StringRef OutPath,
1383
+ bool SerializeDependencyHashes, bool TrackSystemDependencies,
1384
+ bool RemarkOnRebuildFromInterface) {
1385
+ ParseableInterfaceBuilder builder (SourceMgr, Diags, SearchPathOpts, LangOpts,
1386
+ /* clangImporter*/ nullptr , InPath,
1387
+ ModuleName, CacheDir, PrebuiltCacheDir,
1382
1388
SerializeDependencyHashes,
1383
1389
TrackSystemDependencies,
1384
1390
RemarkOnRebuildFromInterface);
0 commit comments