Pass through file-compilation-dir to the ClangImporter.

This change passes through the -file-compilation-dir flag to the
ClangImporter instance as -ffile-compilation-dir. When used in
conjunction with https://github.com/llvm/llvm-project/pull/67744
this will allow for setting the compilation directory of pcm
files using the -file-compilation-dir flag.
This commit is contained in:
Richard Howell
2023-09-28 15:20:56 -07:00
parent 1611ca07aa
commit 198d2ff2ca
2 changed files with 13 additions and 0 deletions

View File

@@ -1553,6 +1553,13 @@ static bool ParseClangImporterArgs(ClangImporterOptions &Opts, ArgList &Args,
Opts.ExtraArgs.push_back("-fdebug-prefix-map=" + Val);
}
if (auto *A = Args.getLastArg(OPT_file_compilation_dir)) {
// Forward the -file-compilation-dir flag to correctly set the
// debug compilation directory.
std::string Val(A->getValue());
Opts.ExtraArgs.push_back("-ffile-compilation-dir=" + Val);
}
if (FrontendOpts.CASFSRootIDs.empty() &&
FrontendOpts.ClangIncludeTrees.empty()) {
if (!workingDirectory.empty()) {

View File

@@ -0,0 +1,6 @@
// Emit the explicit module.
// RUN: %empty-directory(%t)
// RUN: %target-swift-emit-pcm -g -module-name Macro -o %t/Macro.pcm -file-compilation-dir /compdir %S/Inputs/module.modulemap
// RUN: %llvm-dwarfdump %t/Macro.pcm | %FileCheck %s
// CHECK: DW_AT_comp_dir ("/compdir")