[PATCH] D138597: DebugInfo: Add/support new DW_LANG codes for recent C and C++ versions
David Blaikie via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 5 17:33:07 PST 2022
dblaikie updated this revision to Diff 480292.
dblaikie added a comment.
Rebase on top of committed LLVM changes
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D138597/new/
https://reviews.llvm.org/D138597
Files:
clang/lib/CodeGen/CGDebugInfo.cpp
clang/test/CodeGen/debug-info-programming-language.c
clang/test/CodeGenCXX/debug-info-programming-language.cpp
Index: clang/test/CodeGenCXX/debug-info-programming-language.cpp
===================================================================
--- clang/test/CodeGenCXX/debug-info-programming-language.cpp
+++ clang/test/CodeGenCXX/debug-info-programming-language.cpp
@@ -4,6 +4,12 @@
// 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-CPP14 %s
+// RUN: %clang_cc1 -dwarf-version=3 -emit-llvm -triple %itanium_abi_triple %s -o - \
+// RUN: -x c++ -std=c++17 -O0 -disable-llvm-passes -debug-info-kind=limited \
+// RUN: | FileCheck --check-prefix=CHECK-CPP17 %s
+// RUN: %clang_cc1 -dwarf-version=3 -emit-llvm -triple %itanium_abi_triple %s -o - \
+// RUN: -x c++ -std=c++20 -O0 -disable-llvm-passes -debug-info-kind=limited \
+// RUN: | FileCheck --check-prefix=CHECK-CPP20 %s
// RUN: %clang_cc1 -dwarf-version=3 -gstrict-dwarf -emit-llvm -triple %itanium_abi_triple %s -o - \
// RUN: -x c++ -std=c++14 -O0 -disable-llvm-passes -debug-info-kind=limited | FileCheck %s
// RUN: %clang_cc1 -dwarf-version=5 -gstrict-dwarf -emit-llvm -triple %itanium_abi_triple %s -o - \
@@ -15,4 +21,6 @@
}
// CHECK-CPP14: distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14,
+// CHECK-CPP17: distinct !DICompileUnit(language: DW_LANG_C_plus_plus_17,
+// CHECK-CPP20: distinct !DICompileUnit(language: DW_LANG_C_plus_plus_20,
// CHECK: distinct !DICompileUnit(language: DW_LANG_C_plus_plus,
Index: clang/test/CodeGen/debug-info-programming-language.c
===================================================================
--- /dev/null
+++ clang/test/CodeGen/debug-info-programming-language.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -dwarf-version=3 -emit-llvm -triple %itanium_abi_triple %s -o - \
+// RUN: -x c -std=c11 -O0 -disable-llvm-passes -debug-info-kind=limited \
+// RUN: | FileCheck --check-prefix=CHECK-C11 %s
+// RUN: %clang_cc1 -dwarf-version=3 -emit-llvm -triple %itanium_abi_triple %s -o - \
+// RUN: -x c -std=c17 -O0 -disable-llvm-passes -debug-info-kind=limited \
+// RUN: | FileCheck --check-prefix=CHECK-C17 %s
+
+// CHECK-C11: !DICompileUnit(language: DW_LANG_C11
+// CHECK-C17: !DICompileUnit(language: DW_LANG_C17
+
+void f1(void) { }
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===================================================================
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -526,7 +526,8 @@
// Get absolute path name.
SourceManager &SM = CGM.getContext().getSourceManager();
- std::string MainFileName = CGM.getCodeGenOpts().MainFileName;
+ auto &CGO = CGM.getCodeGenOpts();
+ std::string MainFileName = CGO.MainFileName;
if (MainFileName.empty())
MainFileName = "<stdin>";
@@ -562,11 +563,15 @@
if (LO.CPlusPlus) {
if (LO.ObjC)
LangTag = llvm::dwarf::DW_LANG_ObjC_plus_plus;
- else if (LO.CPlusPlus14 && (!CGM.getCodeGenOpts().DebugStrictDwarf ||
- CGM.getCodeGenOpts().DwarfVersion >= 5))
+ else if (CGO.DebugStrictDwarf && CGO.DwarfVersion < 5)
+ LangTag = llvm::dwarf::DW_LANG_C_plus_plus;
+ else if (LO.CPlusPlus20)
+ LangTag = llvm::dwarf::DW_LANG_C_plus_plus_20;
+ else if (LO.CPlusPlus17)
+ LangTag = llvm::dwarf::DW_LANG_C_plus_plus_17;
+ else if (LO.CPlusPlus14)
LangTag = llvm::dwarf::DW_LANG_C_plus_plus_14;
- else if (LO.CPlusPlus11 && (!CGM.getCodeGenOpts().DebugStrictDwarf ||
- CGM.getCodeGenOpts().DwarfVersion >= 5))
+ else if (LO.CPlusPlus11)
LangTag = llvm::dwarf::DW_LANG_C_plus_plus_11;
else
LangTag = llvm::dwarf::DW_LANG_C_plus_plus;
@@ -577,6 +582,10 @@
LangTag = llvm::dwarf::DW_LANG_OpenCL;
} else if (LO.RenderScript) {
LangTag = llvm::dwarf::DW_LANG_GOOGLE_RenderScript;
+ } else if (LO.C17) {
+ LangTag = llvm::dwarf::DW_LANG_C17;
+ } else if (LO.C11) {
+ LangTag = llvm::dwarf::DW_LANG_C11;
} else if (LO.C99) {
LangTag = llvm::dwarf::DW_LANG_C99;
} else {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D138597.480292.patch
Type: text/x-patch
Size: 4109 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221206/524b8f69/attachment.bin>
More information about the llvm-commits
mailing list