Skip to content

Commit ddc0e21

Browse files
committed
[clang] set DebugCompilationDir in PCHContainer (llvm#67744)
This change sets the debug compilation directory when generating debug information for PCH object containers. This allows for overriding the compilation directory in debug information in precompiled pcm files.
1 parent 09de80c commit ddc0e21

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,8 @@ class PCHContainerGenerator : public ASTConsumer {
163163
CodeGenOpts.setDebugInfo(llvm::codegenoptions::FullDebugInfo);
164164
CodeGenOpts.setDebuggerTuning(CI.getCodeGenOpts().getDebuggerTuning());
165165
CodeGenOpts.DwarfVersion = CI.getCodeGenOpts().DwarfVersion;
166+
CodeGenOpts.DebugCompilationDir =
167+
CI.getInvocation().getCodeGenOpts().DebugCompilationDir;
166168
CodeGenOpts.DebugPrefixMap =
167169
CI.getInvocation().getCodeGenOpts().DebugPrefixMap;
168170
CodeGenOpts.DebugStrictDwarf = CI.getCodeGenOpts().DebugStrictDwarf;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// UNSUPPORTED: target={{.*}}-zos{{.*}}, target={{.*}}-aix{{.*}}
2+
// REQUIRES: asserts
3+
4+
// Modules:
5+
// RUN: rm -rf %t
6+
// RUN: %clang_cc1 -x objective-c -fmodules -fmodule-format=obj \
7+
// RUN: -fdebug-compilation-dir=/OVERRIDE \
8+
// RUN: -fimplicit-module-maps -DMODULES -fmodules-cache-path=%t %s \
9+
// RUN: -I %S/Inputs -I %t -emit-llvm -o %t.ll \
10+
// RUN: -mllvm -debug-only=pchcontainer &>%t-mod.ll
11+
// RUN: cat %t-mod.ll | FileCheck %s
12+
13+
// PCH:
14+
// RUN: %clang_cc1 -x objective-c -emit-pch -fmodule-format=obj -I %S/Inputs \
15+
// RUN: -fdebug-compilation-dir=/OVERRIDE \
16+
// RUN: -o %t.pch %S/Inputs/DebugObjC.h \
17+
// RUN: -mllvm -debug-only=pchcontainer &>%t-pch.ll
18+
// RUN: cat %t-pch.ll | FileCheck %s
19+
20+
#ifdef MODULES
21+
@import DebugObjC;
22+
#endif
23+
24+
// CHECK: !DIFile(filename: "{{.*}}DebugObjC{{(\.h)?}}", directory: "/OVERRIDE")

0 commit comments

Comments
 (0)