Skip to content

Commit 8c7f331

Browse files
authored
Merge pull request #63339 from bnbarham/wd-hack
[Frontend] Split -working-directory<path>
2 parents 7a81eb3 + b5caa97 commit 8c7f331

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

lib/Frontend/CompilerInvocation.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,6 +1247,16 @@ static bool ParseClangImporterArgs(ClangImporterOptions &Opts,
12471247
Opts.IndexStorePath = A->getValue();
12481248

12491249
for (const Arg *A : Args.filtered(OPT_Xcc)) {
1250+
StringRef clangArg = A->getValue();
1251+
if (clangArg.consume_front("-working-directory")) {
1252+
if (!clangArg.empty() && clangArg.front() != '=') {
1253+
// Have an old -working-directory<path> argument. Convert it into
1254+
// two separate arguments as Clang no longer supports that format.
1255+
Opts.ExtraArgs.push_back("-working-directory");
1256+
Opts.ExtraArgs.push_back(clangArg.str());
1257+
continue;
1258+
}
1259+
}
12501260
Opts.ExtraArgs.push_back(A->getValue());
12511261
}
12521262

test/ClangImporter/working-directory.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck -Xcc -I -Xcc %S/Inputs/custom-modules -module-cache-path %t/mcp %s
66
// RUN: find %t/mcp -name "ObjCParseExtras-*.pcm" | count 1
77

8+
// Check that the old working directory argument is mapped to the new format
9+
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck -Xcc -I -Xcc custom-modules %s -dump-clang-diagnostics -module-cache-path %t/mcp -Xcc -working-directory%S/Inputs 2>&1 | %FileCheck %s
10+
811
// Check that the working directory is set to the CWD if not explicitly passed
912
// RUN: cd %S/Inputs/ && %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck -Xcc -I -Xcc custom-modules %s -dump-clang-diagnostics -module-cache-path %t/mcp 2>&1 | %FileCheck %s
1013

@@ -15,4 +18,4 @@ import ObjCParseExtras
1518
print(SomeImageName)
1619

1720
// CHECK: clang
18-
// CHECK: '-working-directory' '{{[^"]+}}/Inputs'
21+
// CHECK: '-working-directory' 'SOURCE_DIR/test/ClangImporter/Inputs'

0 commit comments

Comments
 (0)