@@ -211,30 +211,27 @@ void ClangImporter::recordModuleDependencies(
211211 fileDeps.push_back (fileDep.getKey ().str ());
212212 }
213213 // Inherit all Clang driver args when creating the clang importer.
214- std::vector <std::string> allArgs = Impl.ClangArgs ;
214+ ArrayRef <std::string> allArgs = Impl.ClangArgs ;
215215 ClangImporterOptions Opts;
216- std::vector<std::string> cc1Args;
217216
218- // Calling this to convert driver args to CC1 args.
219- createClangInvocation (this , Opts, allArgs, &cc1Args);
217+ // Ensure the arguments we collected is sufficient to create a Clang
218+ // invocation.
219+ assert (createClangInvocation (this , Opts, allArgs));
220+
220221 std::vector<std::string> swiftArgs;
221222 // We are using Swift frontend mode.
222223 swiftArgs.push_back (" -frontend" );
224+ // We pass the entire argument list via -Xcc, so the invocation should
225+ // use extra clang options alone.
226+ swiftArgs.push_back (" -only-use-extra-clang-opts" );
223227 auto addClangArg = [&](StringRef arg) {
224- swiftArgs.push_back (" -Xcc" );
225- swiftArgs.push_back (" -Xclang" );
226228 swiftArgs.push_back (" -Xcc" );
227229 swiftArgs.push_back (arg.str ());
228230 };
229231 // Add all args inheritted from creating the importer.
230- for (auto arg: cc1Args ) {
232+ for (auto arg: allArgs ) {
231233 addClangArg (arg);
232234 }
233- // Add all args reported from the Clang dependencies scanner.
234- for (auto arg: clangModuleDep.NonPathCommandLine ) {
235- addClangArg (arg);
236- }
237-
238235 // Swift frontend action: -emit-pcm
239236 swiftArgs.push_back (" -emit-pcm" );
240237 swiftArgs.push_back (" -module-name" );
0 commit comments