Skip to content

Commit

Permalink
[clang] set DebugCompilationDir in PCHContainer (#67744)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rmaz committed Sep 29, 2023
1 parent ce38cbb commit c14ca4c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
2 changes: 2 additions & 0 deletions clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ class PCHContainerGenerator : public ASTConsumer {
CodeGenOpts.setDebugInfo(llvm::codegenoptions::FullDebugInfo);
CodeGenOpts.setDebuggerTuning(CI.getCodeGenOpts().getDebuggerTuning());
CodeGenOpts.DwarfVersion = CI.getCodeGenOpts().DwarfVersion;
CodeGenOpts.DebugCompilationDir =
CI.getInvocation().getCodeGenOpts().DebugCompilationDir;
CodeGenOpts.DebugPrefixMap =
CI.getInvocation().getCodeGenOpts().DebugPrefixMap;
CodeGenOpts.DebugStrictDwarf = CI.getCodeGenOpts().DebugStrictDwarf;
Expand Down
24 changes: 24 additions & 0 deletions clang/test/Modules/module-debuginfo-compdir.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// UNSUPPORTED: target={{.*}}-zos{{.*}}, target={{.*}}-aix{{.*}}
// REQUIRES: asserts

// Modules:
// RUN: rm -rf %t
// RUN: %clang_cc1 -x objective-c -fmodules -fmodule-format=obj \
// RUN: -fdebug-compilation-dir=/OVERRIDE \
// RUN: -fimplicit-module-maps -DMODULES -fmodules-cache-path=%t %s \
// RUN: -I %S/Inputs -I %t -emit-llvm -o %t.ll \
// RUN: -mllvm -debug-only=pchcontainer &>%t-mod.ll
// RUN: cat %t-mod.ll | FileCheck %s

// PCH:
// RUN: %clang_cc1 -x objective-c -emit-pch -fmodule-format=obj -I %S/Inputs \
// RUN: -fdebug-compilation-dir=/OVERRIDE \
// RUN: -o %t.pch %S/Inputs/DebugObjC.h \
// RUN: -mllvm -debug-only=pchcontainer &>%t-pch.ll
// RUN: cat %t-pch.ll | FileCheck %s

#ifdef MODULES
@import DebugObjC;
#endif

// CHECK: !DIFile(filename: "{{.*}}DebugObjC{{(\.h)?}}", directory: "/OVERRIDE")

0 comments on commit c14ca4c

Please sign in to comment.