Skip to content

Commit d71d31c

Browse files
authored
Merge pull request #39945 from bnbarham/do-not-remove-resource-dir
[DepScanner] Do not remove the resource directory path
2 parents 0336167 + 5e43702 commit d71d31c

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

lib/ClangImporter/ClangModuleDependencyScanner.cpp

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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.

test/ScanDependencies/module_deps.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,11 @@ import SubE
126126
// CHECK: "commandLine": [
127127
// CHECK-NEXT: "-frontend"
128128
// CHECK-NEXT: "-only-use-extra-clang-opts"
129-
// CHECK-NOT: "BUILD_DIR/bin/clang"
129+
// CHECK-NOT: "BUILD_DIR/bin/clang"
130+
// CHECK: "-Xcc"
131+
// CHECK-NEXT: "-resource-dir"
132+
// CHECK-NEXT: "-Xcc"
133+
// CHECK-NEXT: "BUILD_DIR/lib/swift/clang"
130134
// CHECK: "-fsystem-module",
131135
// CHECK-NEXT: "-emit-pcm",
132136
// CHECK-NEXT: "-module-name",

0 commit comments

Comments
 (0)