@@ -844,8 +844,8 @@ class ModuleInterfaceLoaderImpl {
844
844
}
845
845
InterfaceSubContextDelegateImpl astDelegate (ctx.SourceMgr , ctx.Diags ,
846
846
ctx.SearchPathOpts , ctx.LangOpts ,
847
+ ctx.ClangImporterOpts ,
847
848
Opts,
848
- ctx.getClangModuleLoader (),
849
849
/* buildModuleCacheDirIfAbsent*/ true ,
850
850
cacheDir,
851
851
prebuiltCacheDir,
@@ -1084,20 +1084,12 @@ bool ModuleInterfaceLoader::buildSwiftModuleFromSwiftInterface(
1084
1084
bool SerializeDependencyHashes, bool TrackSystemDependencies,
1085
1085
ModuleInterfaceLoaderOptions LoaderOpts) {
1086
1086
InterfaceSubContextDelegateImpl astDelegate (SourceMgr, Diags,
1087
- SearchPathOpts, LangOpts,
1087
+ SearchPathOpts, LangOpts, ClangOpts,
1088
1088
LoaderOpts,
1089
- /* clangImporter*/ nullptr ,
1090
1089
/* CreateCacheDirIfAbsent*/ true ,
1091
1090
CacheDir, PrebuiltCacheDir,
1092
1091
SerializeDependencyHashes,
1093
1092
TrackSystemDependencies);
1094
- // At this point we don't have an ClangImporter instance because the instance
1095
- // is created later when we create a new ASTContext to build the interface.
1096
- // Thus, we have to add these extra clang flags manually here to ensure explict
1097
- // module building works.
1098
- for (auto &Arg: ClangOpts.ExtraArgs ) {
1099
- astDelegate.addExtraClangArg (Arg);
1100
- }
1101
1093
ModuleInterfaceBuilder builder (SourceMgr, Diags, astDelegate, InPath,
1102
1094
ModuleName, CacheDir, PrebuiltCacheDir,
1103
1095
LoaderOpts.disableInterfaceLock );
@@ -1238,19 +1230,13 @@ bool InterfaceSubContextDelegateImpl::extractSwiftInterfaceVersionAndArgs(
1238
1230
return false ;
1239
1231
}
1240
1232
1241
- void InterfaceSubContextDelegateImpl::addExtraClangArg (StringRef arg) {
1242
- genericSubInvocation.getClangImporterOptions ().ExtraArgs .push_back (arg);
1243
- GenericArgs.push_back (" -Xcc" );
1244
- GenericArgs.push_back (ArgSaver.save (arg));
1245
- }
1246
-
1247
1233
InterfaceSubContextDelegateImpl::InterfaceSubContextDelegateImpl (
1248
1234
SourceManager &SM,
1249
1235
DiagnosticEngine &Diags,
1250
1236
const SearchPathOptions &searchPathOpts,
1251
1237
const LangOptions &langOpts,
1238
+ const ClangImporterOptions &clangImporterOpts,
1252
1239
ModuleInterfaceLoaderOptions LoaderOpts,
1253
- ClangModuleLoader *clangImporter,
1254
1240
bool buildModuleCacheDirIfAbsent,
1255
1241
StringRef moduleCachePath,
1256
1242
StringRef prebuiltCachePath,
@@ -1288,22 +1274,21 @@ InterfaceSubContextDelegateImpl::InterfaceSubContextDelegateImpl(
1288
1274
StringRef explictSwiftModuleMap = searchPathOpts.ExplicitSwiftModuleMap ;
1289
1275
genericSubInvocation.getSearchPathOptions ().ExplicitSwiftModuleMap =
1290
1276
explictSwiftModuleMap;
1291
- if (clangImporter) {
1292
- // We need to add these extra clang flags because explict module building
1293
- // related flags are all there: -fno-implicit-modules, -fmodule-map-file=,
1294
- // and -fmodule-file=.
1295
- // If we don't add these flags, the interface will be built with implicit
1296
- // PCMs.
1297
- for (auto arg: static_cast <ClangImporter*>(clangImporter)->getExtraClangArgs ()) {
1298
- addExtraClangArg (arg);
1299
- }
1300
- // Respect the detailed-record preprocessor setting of the parent context.
1301
- // This, and the "raw" clang module format it implicitly enables, are
1302
- // required by sourcekitd.
1303
- auto &Opts = clangImporter->getClangInstance ().getPreprocessorOpts ();
1304
- if (Opts.DetailedRecord ) {
1305
- genericSubInvocation.getClangImporterOptions ().DetailedPreprocessingRecord = true ;
1306
- }
1277
+ auto &subClangImporterOpts = genericSubInvocation.getClangImporterOptions ();
1278
+ // Respect the detailed-record preprocessor setting of the parent context.
1279
+ // This, and the "raw" clang module format it implicitly enables, are
1280
+ // required by sourcekitd.
1281
+ subClangImporterOpts.DetailedPreprocessingRecord =
1282
+ clangImporterOpts.DetailedPreprocessingRecord ;
1283
+ // We need to add these extra clang flags because explict module building
1284
+ // related flags are all there: -fno-implicit-modules, -fmodule-map-file=,
1285
+ // and -fmodule-file=.
1286
+ // If we don't add these flags, the interface will be built with implicit
1287
+ // PCMs.
1288
+ subClangImporterOpts.ExtraArgs = clangImporterOpts.ExtraArgs ;
1289
+ for (auto arg: subClangImporterOpts.ExtraArgs ) {
1290
+ GenericArgs.push_back (" -Xcc" );
1291
+ GenericArgs.push_back (ArgSaver.save (arg));
1307
1292
}
1308
1293
1309
1294
// Tell the genericSubInvocation to serialize dependency hashes if asked to do so.
0 commit comments