Skip to content

Commit 198d2ff

Browse files
committed
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 llvm/llvm-project#67744 this will allow for setting the compilation directory of pcm files using the -file-compilation-dir flag.
1 parent 1611ca0 commit 198d2ff

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

lib/Frontend/CompilerInvocation.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1553,6 +1553,13 @@ static bool ParseClangImporterArgs(ClangImporterOptions &Opts, ArgList &Args,
15531553
Opts.ExtraArgs.push_back("-fdebug-prefix-map=" + Val);
15541554
}
15551555

1556+
if (auto *A = Args.getLastArg(OPT_file_compilation_dir)) {
1557+
// Forward the -file-compilation-dir flag to correctly set the
1558+
// debug compilation directory.
1559+
std::string Val(A->getValue());
1560+
Opts.ExtraArgs.push_back("-ffile-compilation-dir=" + Val);
1561+
}
1562+
15561563
if (FrontendOpts.CASFSRootIDs.empty() &&
15571564
FrontendOpts.ClangIncludeTrees.empty()) {
15581565
if (!workingDirectory.empty()) {
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Emit the explicit module.
2+
// RUN: %empty-directory(%t)
3+
// RUN: %target-swift-emit-pcm -g -module-name Macro -o %t/Macro.pcm -file-compilation-dir /compdir %S/Inputs/module.modulemap
4+
// RUN: %llvm-dwarfdump %t/Macro.pcm | %FileCheck %s
5+
6+
// CHECK: DW_AT_comp_dir ("/compdir")

0 commit comments

Comments
 (0)