[clang] c14ca4c - [clang] set DebugCompilationDir in PCHContainer (#67744)

via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 29 11:30:38 PDT 2023


Author: Richard Howell
Date: 2023-09-29T11:30:33-07:00
New Revision: c14ca4c16c22b4b018f0fe60b4c656d37f4a76dc

URL: https://github.com/llvm/llvm-project/commit/c14ca4c16c22b4b018f0fe60b4c656d37f4a76dc
DIFF: https://github.com/llvm/llvm-project/commit/c14ca4c16c22b4b018f0fe60b4c656d37f4a76dc.diff

LOG: [clang] set DebugCompilationDir in PCHContainer (#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.

Added: 
    clang/test/Modules/module-debuginfo-compdir.m

Modified: 
    clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp b/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
index 9ffeef026bd1b76..ee543e40b46099d 100644
--- a/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
+++ b/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
@@ -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;

diff  --git a/clang/test/Modules/module-debuginfo-compdir.m b/clang/test/Modules/module-debuginfo-compdir.m
new file mode 100644
index 000000000000000..fced242624f75b3
--- /dev/null
+++ b/clang/test/Modules/module-debuginfo-compdir.m
@@ -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
+ at import DebugObjC;
+#endif
+
+// CHECK: !DIFile(filename: "{{.*}}DebugObjC{{(\.h)?}}", directory: "/OVERRIDE")


        


More information about the cfe-commits mailing list