[clang] 167acac - Propagate the DWARF version from the main compiler invocation to PCHC… (#66032)

via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 12 08:31:32 PDT 2023


Author: Adrian Prantl
Date: 2023-09-12T08:31:27-07:00
New Revision: 167acac417254d85a1eb36d3a2479b50cedef271

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

LOG: Propagate the DWARF version from the main compiler invocation to PCHC… (#66032)

…ontainerGenerator

Currently it remains uninitialized and thus always uses the LLVM default
of 4.

Added: 
    

Modified: 
    clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
    clang/test/Modules/ModuleDebugInfo.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp b/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
index 114a9c1e2eac121..9ffeef026bd1b76 100644
--- a/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
+++ b/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
@@ -160,6 +160,7 @@ class PCHContainerGenerator : public ASTConsumer {
         LangOpts.CurrentModule.empty() ? MainFileName : LangOpts.CurrentModule;
     CodeGenOpts.setDebugInfo(llvm::codegenoptions::FullDebugInfo);
     CodeGenOpts.setDebuggerTuning(CI.getCodeGenOpts().getDebuggerTuning());
+    CodeGenOpts.DwarfVersion = CI.getCodeGenOpts().DwarfVersion;
     CodeGenOpts.DebugPrefixMap =
         CI.getInvocation().getCodeGenOpts().DebugPrefixMap;
     CodeGenOpts.DebugStrictDwarf = CI.getCodeGenOpts().DebugStrictDwarf;

diff  --git a/clang/test/Modules/ModuleDebugInfo.cpp b/clang/test/Modules/ModuleDebugInfo.cpp
index 8f7fa22bcb0b001..4d78324867bcb81 100644
--- a/clang/test/Modules/ModuleDebugInfo.cpp
+++ b/clang/test/Modules/ModuleDebugInfo.cpp
@@ -6,10 +6,11 @@
 
 // Modules:
 // RUN: rm -rf %t
-// RUN: %clang_cc1 -triple %itanium_abi_triple -x objective-c++ -std=c++11 -debugger-tuning=lldb -debug-info-kind=limited -fmodules -fmodule-format=obj -fimplicit-module-maps -DMODULES -fmodules-cache-path=%t %s -I %S/Inputs -I %t -emit-llvm -o %t.ll -mllvm -debug-only=pchcontainer &>%t-mod.ll
+// RUN: %clang_cc1 -triple %itanium_abi_triple -x objective-c++ -std=c++11 -debugger-tuning=lldb -debug-info-kind=limited -dwarf-version=5 -fmodules -fmodule-format=obj -fimplicit-module-maps -DMODULES -fmodules-cache-path=%t %s -I %S/Inputs -I %t -emit-llvm -o %t.ll -mllvm -debug-only=pchcontainer &>%t-mod.ll
 // RUN: cat %t-mod.ll | FileCheck %s
 // RUN: cat %t-mod.ll | FileCheck --check-prefix=CHECK-NEG %s
 // RUN: cat %t-mod.ll | FileCheck --check-prefix=CHECK-MOD %s
+// RUN: cat %t-mod.ll | FileCheck --check-prefix=CHECK-MOD-DWARF %s
 
 // PCH:
 // RUN: %clang_cc1 -triple %itanium_abi_triple -x c++ -std=c++11  -debugger-tuning=lldb -emit-pch -fmodule-format=obj -I %S/Inputs -o %t.pch %S/Inputs/DebugCXX.h -mllvm -debug-only=pchcontainer &>%t-pch.ll
@@ -20,6 +21,8 @@
 @import DebugCXX;
 #endif
 
+// CHECK-MOD-DWARF: !"Dwarf Version", i32 5
+
 // CHECK-MOD: distinct !DICompileUnit(language: DW_LANG_{{.*}}C_plus_plus,
 // CHECK-MOD: distinct !DICompileUnit(language: DW_LANG_{{.*}}C_plus_plus,
 


        


More information about the cfe-commits mailing list