Skip to content

Commit 167acac

Browse files
Propagate the DWARF version from the main compiler invocation to PCHC… (llvm#66032)
…ontainerGenerator Currently it remains uninitialized and thus always uses the LLVM default of 4.
1 parent c8d4053 commit 167acac

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ class PCHContainerGenerator : public ASTConsumer {
160160
LangOpts.CurrentModule.empty() ? MainFileName : LangOpts.CurrentModule;
161161
CodeGenOpts.setDebugInfo(llvm::codegenoptions::FullDebugInfo);
162162
CodeGenOpts.setDebuggerTuning(CI.getCodeGenOpts().getDebuggerTuning());
163+
CodeGenOpts.DwarfVersion = CI.getCodeGenOpts().DwarfVersion;
163164
CodeGenOpts.DebugPrefixMap =
164165
CI.getInvocation().getCodeGenOpts().DebugPrefixMap;
165166
CodeGenOpts.DebugStrictDwarf = CI.getCodeGenOpts().DebugStrictDwarf;

clang/test/Modules/ModuleDebugInfo.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@
66

77
// Modules:
88
// RUN: rm -rf %t
9-
// 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
9+
// 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
1010
// RUN: cat %t-mod.ll | FileCheck %s
1111
// RUN: cat %t-mod.ll | FileCheck --check-prefix=CHECK-NEG %s
1212
// RUN: cat %t-mod.ll | FileCheck --check-prefix=CHECK-MOD %s
13+
// RUN: cat %t-mod.ll | FileCheck --check-prefix=CHECK-MOD-DWARF %s
1314

1415
// PCH:
1516
// 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 @@
2021
@import DebugCXX;
2122
#endif
2223

24+
// CHECK-MOD-DWARF: !"Dwarf Version", i32 5
25+
2326
// CHECK-MOD: distinct !DICompileUnit(language: DW_LANG_{{.*}}C_plus_plus,
2427
// CHECK-MOD: distinct !DICompileUnit(language: DW_LANG_{{.*}}C_plus_plus,
2528

0 commit comments

Comments
 (0)