Skip to content

Commit 62fa9b9

Browse files
author
Esme-Yi
committed
[DebugInfo] Fix the mismatching between C++ language tags and Dwarf versions.
Summary: The tags DW_LANG_C_plus_plus_14 and DW_LANG_C_plus_plus_11, introduced in Dwarf-5, are unexpected in previous versions. Fixing the mismathing doesn't have any drawbacks for any other debuggers, but helps dbx. Reviewed By: aprantl, shchenz Differential Revision: https://reviews.llvm.org/D99250
1 parent 6e51991 commit 62fa9b9

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

clang/lib/CodeGen/CGDebugInfo.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -568,9 +568,9 @@ void CGDebugInfo::CreateCompileUnit() {
568568
if (LO.CPlusPlus) {
569569
if (LO.ObjC)
570570
LangTag = llvm::dwarf::DW_LANG_ObjC_plus_plus;
571-
else if (LO.CPlusPlus14)
571+
else if (LO.CPlusPlus14 && CGM.getCodeGenOpts().DwarfVersion >= 5)
572572
LangTag = llvm::dwarf::DW_LANG_C_plus_plus_14;
573-
else if (LO.CPlusPlus11)
573+
else if (LO.CPlusPlus11 && CGM.getCodeGenOpts().DwarfVersion >= 5)
574574
LangTag = llvm::dwarf::DW_LANG_C_plus_plus_11;
575575
else
576576
LangTag = llvm::dwarf::DW_LANG_C_plus_plus;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// RUN: %clang_cc1 -dwarf-version=5 -emit-llvm -triple %itanium_abi_triple %s -o - \
2+
// RUN: -x c++ -std=c++14 -O0 -disable-llvm-passes -debug-info-kind=limited \
3+
// RUN: | FileCheck --check-prefix=CHECK-DWARF5 %s
4+
// RUN: %clang_cc1 -dwarf-version=3 -emit-llvm -triple %itanium_abi_triple %s -o - \
5+
// RUN: -x c++ -std=c++14 -O0 -disable-llvm-passes -debug-info-kind=limited \
6+
// RUN: | FileCheck --check-prefix=CHECK-DWARF3 %s
7+
8+
int main() {
9+
return 0;
10+
}
11+
12+
// CHECK-DWARF5: distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14,
13+
// CHECK-DWARF3: distinct !DICompileUnit(language: DW_LANG_C_plus_plus,

clang/test/Modules/ModuleDebugInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
// CHECK-MOD: distinct !DICompileUnit(language: DW_LANG_{{.*}}C_plus_plus,
2424

2525
// CHECK: distinct !DICompileUnit(language: DW_LANG_{{.*}}C_plus_plus,
26-
// CHECK-CXX: distinct !DICompileUnit(language: DW_LANG_C_plus_plus_11,
26+
// CHECK-CXX: distinct !DICompileUnit(language: DW_LANG_C_plus_plus,
2727
// CHECK-SAME: isOptimized: false,
2828
// CHECK-NOT: splitDebugFilename:
2929
// CHECK-SAME: dwoId:

0 commit comments

Comments
 (0)