@@ -844,8 +844,8 @@ class ModuleInterfaceLoaderImpl {
844844 }
845845 InterfaceSubContextDelegateImpl astDelegate (ctx.SourceMgr , ctx.Diags ,
846846 ctx.SearchPathOpts , ctx.LangOpts ,
847+ ctx.ClangImporterOpts ,
847848 Opts,
848- ctx.getClangModuleLoader (),
849849 /* buildModuleCacheDirIfAbsent*/ true ,
850850 cacheDir,
851851 prebuiltCacheDir,
@@ -1084,20 +1084,12 @@ bool ModuleInterfaceLoader::buildSwiftModuleFromSwiftInterface(
10841084 bool SerializeDependencyHashes, bool TrackSystemDependencies,
10851085 ModuleInterfaceLoaderOptions LoaderOpts) {
10861086 InterfaceSubContextDelegateImpl astDelegate (SourceMgr, Diags,
1087- SearchPathOpts, LangOpts,
1087+ SearchPathOpts, LangOpts, ClangOpts,
10881088 LoaderOpts,
1089- /* clangImporter*/ nullptr ,
10901089 /* CreateCacheDirIfAbsent*/ true ,
10911090 CacheDir, PrebuiltCacheDir,
10921091 SerializeDependencyHashes,
10931092 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- }
11011093 ModuleInterfaceBuilder builder (SourceMgr, Diags, astDelegate, InPath,
11021094 ModuleName, CacheDir, PrebuiltCacheDir,
11031095 LoaderOpts.disableInterfaceLock );
@@ -1238,19 +1230,13 @@ bool InterfaceSubContextDelegateImpl::extractSwiftInterfaceVersionAndArgs(
12381230 return false ;
12391231}
12401232
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-
12471233InterfaceSubContextDelegateImpl::InterfaceSubContextDelegateImpl (
12481234 SourceManager &SM,
12491235 DiagnosticEngine &Diags,
12501236 const SearchPathOptions &searchPathOpts,
12511237 const LangOptions &langOpts,
1238+ const ClangImporterOptions &clangImporterOpts,
12521239 ModuleInterfaceLoaderOptions LoaderOpts,
1253- ClangModuleLoader *clangImporter,
12541240 bool buildModuleCacheDirIfAbsent,
12551241 StringRef moduleCachePath,
12561242 StringRef prebuiltCachePath,
@@ -1288,22 +1274,21 @@ InterfaceSubContextDelegateImpl::InterfaceSubContextDelegateImpl(
12881274 StringRef explictSwiftModuleMap = searchPathOpts.ExplicitSwiftModuleMap ;
12891275 genericSubInvocation.getSearchPathOptions ().ExplicitSwiftModuleMap =
12901276 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));
13071292 }
13081293
13091294 // Tell the genericSubInvocation to serialize dependency hashes if asked to do so.
0 commit comments