@@ -213,22 +213,29 @@ void ClangImporter::recordModuleDependencies(
213213 swiftArgs.push_back (" -Xcc" );
214214 swiftArgs.push_back (arg.str ());
215215 };
216- // Add all args inheritted from creating the importer.
216+
217+ // Add all args inherited from creating the importer.
217218 auto It = allArgs.begin ();
219+
220+ {
221+ StringRef arg = *It;
222+ if (arg == " clang" ||
223+ arg.endswith (llvm::sys::path::get_separator ().str () + " clang" )) {
224+ // Remove the initial path to clang executable argument, to avoid
225+ // treating it as an executable input to compilation. It is not needed
226+ // because the consumer of this command-line will invoke the emit-PCM
227+ // action via swift-frontend.
228+ It += 1 ;
229+ }
230+ }
231+
218232 while (It != allArgs.end ()) {
219233 StringRef arg = *It;
220234 // Remove the -target arguments because we should use the target triple
221235 // specified with `-clang-target` on the scanner invocation, or
222236 // from the depending Swift modules.
223237 if (arg == " -target" ) {
224238 It += 2 ;
225- } else if (arg == " clang" ||
226- arg.endswith (llvm::sys::path::get_separator ().str () + " clang" )) {
227- // Remove the initial path to clang executable argument, to avoid
228- // treating it as an executable input to compilation. It is not needed
229- // because the consumer of this command-line will invoke the emit-PCM
230- // action via swift-frontend.
231- It += 1 ;
232239 } else if (arg.startswith (" -fapinotes-swift-version=" )) {
233240 // Remove the apinotes version because we should use the language version
234241 // specified in the interface file.
0 commit comments