summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEsme-Yi <esme.yi@ibm.com>2021-04-12 07:42:54 +0000
committerEsme-Yi <esme.yi@ibm.com>2021-04-12 07:42:54 +0000
commit62fa9b9388aa114e3b1a58bbdbcd966ae3492ba5 (patch)
tree173bb0ef9f2c45bfce2278f27c75c6d30eceb1cb
parent6e5199104914c2415092315388ed09fbd9d629f7 (diff)
downloadllvm-62fa9b9388aa114e3b1a58bbdbcd966ae3492ba5.tar.gz
[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
-rw-r--r--clang/lib/CodeGen/CGDebugInfo.cpp4
-rw-r--r--clang/test/CodeGenCXX/debug-info-programming-language.cpp13
-rw-r--r--clang/test/Modules/ModuleDebugInfo.cpp2
3 files changed, 16 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index d20b309b476d..290cdbf8c4e3 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -568,9 +568,9 @@ void CGDebugInfo::CreateCompileUnit() {
if (LO.CPlusPlus) {
if (LO.ObjC)
LangTag = llvm::dwarf::DW_LANG_ObjC_plus_plus;
- else if (LO.CPlusPlus14)
+ else if (LO.CPlusPlus14 && CGM.getCodeGenOpts().DwarfVersion >= 5)
LangTag = llvm::dwarf::DW_LANG_C_plus_plus_14;
- else if (LO.CPlusPlus11)
+ else if (LO.CPlusPlus11 && CGM.getCodeGenOpts().DwarfVersion >= 5)
LangTag = llvm::dwarf::DW_LANG_C_plus_plus_11;
else
LangTag = llvm::dwarf::DW_LANG_C_plus_plus;
diff --git a/clang/test/CodeGenCXX/debug-info-programming-language.cpp b/clang/test/CodeGenCXX/debug-info-programming-language.cpp
new file mode 100644
index 000000000000..82a6db6445f3
--- /dev/null
+++ b/clang/test/CodeGenCXX/debug-info-programming-language.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -dwarf-version=5 -emit-llvm -triple %itanium_abi_triple %s -o - \
+// RUN: -x c++ -std=c++14 -O0 -disable-llvm-passes -debug-info-kind=limited \
+// RUN: | FileCheck --check-prefix=CHECK-DWARF5 %s
+// RUN: %clang_cc1 -dwarf-version=3 -emit-llvm -triple %itanium_abi_triple %s -o - \
+// RUN: -x c++ -std=c++14 -O0 -disable-llvm-passes -debug-info-kind=limited \
+// RUN: | FileCheck --check-prefix=CHECK-DWARF3 %s
+
+int main() {
+ return 0;
+}
+
+// CHECK-DWARF5: distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14,
+// CHECK-DWARF3: distinct !DICompileUnit(language: DW_LANG_C_plus_plus,
diff --git a/clang/test/Modules/ModuleDebugInfo.cpp b/clang/test/Modules/ModuleDebugInfo.cpp
index 3121719e55a6..836f0d28fb2a 100644
--- a/clang/test/Modules/ModuleDebugInfo.cpp
+++ b/clang/test/Modules/ModuleDebugInfo.cpp
@@ -23,7 +23,7 @@
// CHECK-MOD: distinct !DICompileUnit(language: DW_LANG_{{.*}}C_plus_plus,
// CHECK: distinct !DICompileUnit(language: DW_LANG_{{.*}}C_plus_plus,
-// CHECK-CXX: distinct !DICompileUnit(language: DW_LANG_C_plus_plus_11,
+// CHECK-CXX: distinct !DICompileUnit(language: DW_LANG_C_plus_plus,
// CHECK-SAME: isOptimized: false,
// CHECK-NOT: splitDebugFilename:
// CHECK-SAME: dwoId: