nickdesaulniers created this revision. nickdesaulniers added reviewers: dblaikie, jcranmer-intel. Herald added a project: All. nickdesaulniers requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
Looks like these DW_AT_language tags made it into the DWARFv5 spec. Let's emit them when -std=c++{20|17} or -std=c17. Link: https://dwarfstd.org/Languages.php Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D142675 Files: clang/lib/CodeGen/CGDebugInfo.cpp clang/test/CodeGen/debug-info-programming-language.c clang/test/CodeGenCXX/debug-info-artificial-arg.cpp clang/test/CodeGenCXX/debug-info-auto-return.cpp clang/test/CodeGenCXX/debug-info-enum.cpp clang/test/CodeGenCXX/debug-info-indirect-field-decl.cpp clang/test/CodeGenCXX/debug-info-ms-abi.cpp clang/test/CodeGenCXX/debug-info-programming-language.cpp clang/test/CodeGenCXX/debug-info-template-limit.cpp clang/test/CodeGenCXX/debug-info-template-member.cpp clang/test/CodeGenCXX/debug-info-template-partial-specialization.cpp clang/test/CodeGenCXX/debug-info-template.cpp clang/test/CodeGenCXX/debug-info-union-template.cpp clang/test/CodeGenCXX/debug-info.cpp
Index: clang/test/CodeGenCXX/debug-info.cpp =================================================================== --- clang/test/CodeGenCXX/debug-info.cpp +++ clang/test/CodeGenCXX/debug-info.cpp @@ -110,7 +110,6 @@ struct foo { // CHECK: ![[FOO:[0-9]+]] ={{.*}}!DICompositeType(tag: DW_TAG_structure_type, name: "foo" // CHECK-SAME: scope: [[PR14763]] -// CHECK-SAME: identifier: foo(const foo&); }; @@ -139,7 +138,6 @@ namespace pr16214 { // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "a" // CHECK-SAME: elements: [[A_MEM:![0-9]+]] -// CHECK-SAME: identifier: "_ZTSN7pr162141aE" // CHECK: [[A_MEM]] = !{[[A_I:![0-9]*]]} struct a { // CHECK: [[A_I]] = !DIDerivedType(tag: DW_TAG_member, name: "i" Index: clang/test/CodeGenCXX/debug-info-union-template.cpp =================================================================== --- clang/test/CodeGenCXX/debug-info-union-template.cpp +++ clang/test/CodeGenCXX/debug-info-union-template.cpp @@ -11,7 +11,6 @@ } // CHECK: !DICompositeType(tag: DW_TAG_union_type, name: "Value<float>", -// CHECK-SAME: templateParams: [[TTPARAM:![0-9]+]] -// CHECK-SAME: identifier: "_ZTSN7PR156375ValueIfEE" +// CHECK-SAME: templateParams: [[TTPARAM:![0-9]+]] // CHECK: [[TTPARAM]] = !{[[PARAMS:.*]]} // CHECK: [[PARAMS]] = !DITemplateTypeParameter(name: "T" Index: clang/test/CodeGenCXX/debug-info-template.cpp =================================================================== --- clang/test/CodeGenCXX/debug-info-template.cpp +++ clang/test/CodeGenCXX/debug-info-template.cpp @@ -51,7 +51,7 @@ // We could just emit a declaration of 'foo' here, rather than the entire // definition (same goes for any time we emit a member (function or data) // pointer type) -// CHECK: [[FOO]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "foo", {{.*}}identifier: "_ZTS3foo") +// CHECK: [[FOO]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "foo", {{.*}}) // CHECK: !DISubprogram(name: "f", linkageName: "_ZN3foo1fEv", {{.*}}type: [[FTYPE:![0-9]*]] // // Currently Clang emits the pointer-to-member-function value, but LLVM doesn't @@ -131,7 +131,6 @@ // CHECK: ![[NNT]] ={{.*}}!DICompositeType(tag: DW_TAG_structure_type, name: "NN<tmpl_impl, glb>", // CHECK-SAME: templateParams: [[NNARGS:![0-9]*]] -// CHECK-SAME: identifier: // CHECK: [[NNARGS]] = !{[[NNARG1:![0-9]*]], [[NNARG2:![0-9]*]]} // CHECK: [[NNARG1]] = !DITemplateValueParameter(tag: DW_TAG_GNU_template_template_param, name: "tmpl", value: !"tmpl_impl") // CHECK: [[NNARG2]] = !DITemplateValueParameter(name: "lvr", type: [[INTLVR:![0-9]*]], value: ptr @glb) @@ -165,7 +164,7 @@ static constexpr const ClassTemplateArg &Arg = A; }; -// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "ClassTemplateArgTemplate<ClassTemplateArg{1, 2.000000e+00}>", {{.*}}, templateParams: ![[CLASS_TEMP_ARGS:[0-9]*]], +// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "ClassTemplateArgTemplate<ClassTemplateArg{1, 2.000000e+00}>", {{.*}}, templateParams: ![[CLASS_TEMP_ARGS:[0-9]*]]) // CHECK: ![[CLASS_TEMP_ARG_CONST_REF_TYPE:[0-9]*]] = !DIDerivedType(tag: DW_TAG_reference_type, baseType: ![[CLASS_TEMP_ARG_CONST_TYPE:[0-9]*]], // CHECK: ![[CLASS_TEMP_ARG_CONST_TYPE]] = !DIDerivedType(tag: DW_TAG_const_type, baseType: ![[CLASS_TEMP_ARG_TYPE:[0-9]*]]) // CHECK: ![[CLASS_TEMP_ARG_TYPE]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "ClassTemplateArg", @@ -176,7 +175,7 @@ template<const ClassTemplateArg&> struct ClassTemplateArgRefTemplate {}; ClassTemplateArgRefTemplate<ClassTemplateArgObj.Arg> ClassTemplateArgRefObj; -// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "ClassTemplateArgRefTemplate<<template param ClassTemplateArg{1, 2.000000e+00}> >", {{.*}}, templateParams: ![[CLASS_TEMP_REF_ARGS:[0-9]*]], +// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "ClassTemplateArgRefTemplate<<template param ClassTemplateArg{1, 2.000000e+00}> >", {{.*}}, templateParams: ![[CLASS_TEMP_REF_ARGS:[0-9]*]]) // CHECK: ![[CLASS_TEMP_REF_ARGS]] = !{![[CLASS_TEMP_REF_ARG:[0-9]*]]} // CHECK: ![[CLASS_TEMP_REF_ARG]] = !DITemplateValueParameter(type: ![[CLASS_TEMP_ARG_CONST_REF_TYPE]], value: ptr @_ZTAXtl16ClassTemplateArgLi1ELf40000000EEE) Index: clang/test/CodeGenCXX/debug-info-template-partial-specialization.cpp =================================================================== --- clang/test/CodeGenCXX/debug-info-template-partial-specialization.cpp +++ clang/test/CodeGenCXX/debug-info-template-partial-specialization.cpp @@ -6,7 +6,6 @@ // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "__pointer_type1<C, default_delete<C>, false>", // CHECK-SAME: templateParams: ![[PARAMS:[0-9]+]] - // CHECK-SAME: identifier: "_ZTSN18__pointer_type_imp15__pointer_type1I1C14default_deleteIS1_ELb0EEE" template <class _Tp, class _Dp> struct __pointer_type1<_Tp, _Dp, false> { typedef _Tp* type; Index: clang/test/CodeGenCXX/debug-info-template-member.cpp =================================================================== --- clang/test/CodeGenCXX/debug-info-template-member.cpp +++ clang/test/CodeGenCXX/debug-info-template-member.cpp @@ -36,10 +36,9 @@ // CHECK-SAME: templateParams: {{![0-9]+}} // CHECK: !DITemplateValueParameter(name: "N", type: [[TY]], value: i32 1) -// CHECK: ![[OUTER_FOO_INNER_ID:[0-9]*]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "inner"{{.*}}, identifier: +// CHECK: ![[OUTER_FOO_INNER_ID:[0-9]*]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "inner"{{.*}}, // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "foo" // CHECK-SAME: elements: [[FOO_MEM:![0-9]*]] -// CHECK-SAME: identifier: "_ZTS3foo" // CHECK: [[FOO_MEM]] = !{[[FOO_FUNC:![0-9]*]]} // CHECK: [[FOO_FUNC]] = !DISubprogram(name: "func", linkageName: "_ZN3foo4funcEN5outerIS_E5innerE", // CHECK-SAME: type: [[FOO_FUNC_TYPE:![0-9]*]] @@ -49,7 +48,6 @@ // CHECK: [[C:![0-9]*]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "MyClass" // CHECK-SAME: elements: [[C_MEM:![0-9]*]] // CHECK-SAME: vtableHolder: [[C]] -// CHECK-SAME: identifier: "_ZTS7MyClass") // CHECK: [[C_MEM]] = !{[[C_VPTR:![0-9]*]], [[C_FUNC:![0-9]*]]} // CHECK: [[C_VPTR]] = !DIDerivedType(tag: DW_TAG_member, name: "_vptr$MyClass" @@ -62,11 +60,9 @@ // CHECK-SAME: elements: [[VIRT_MEM:![0-9]*]] // CHECK-SAME: vtableHolder: [[VIRT_TEMP]] // CHECK-SAME: templateParams: [[VIRT_TEMP_PARAM:![0-9]*]] -// CHECK-SAME: identifier: "_ZTS4virtI4elemE" // CHECK: [[ELEM:![0-9]+]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "elem" // CHECK-SAME: elements: [[ELEM_MEM:![0-9]*]] -// CHECK-SAME: identifier: "_ZTS4elem" // CHECK: [[ELEM_MEM]] = !{[[ELEM_X:![0-9]*]]} // CHECK: [[ELEM_X]] = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: [[ELEM]] // CHECK-SAME: baseType: [[VIRT_TEMP:![0-9]+]] Index: clang/test/CodeGenCXX/debug-info-template-limit.cpp =================================================================== --- clang/test/CodeGenCXX/debug-info-template-limit.cpp +++ clang/test/CodeGenCXX/debug-info-template-limit.cpp @@ -1,7 +1,7 @@ // RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited -triple %itanium_abi_triple %s -o - | FileCheck %s // Check that this pointer type is TC<int> -// CHECK: ![[LINE:[0-9]+]] = distinct !DICompositeType(tag: DW_TAG_class_type, name: "TC<int>"{{.*}}, identifier: "_ZTS2TCIiE") +// CHECK: ![[LINE:[0-9]+]] = distinct !DICompositeType(tag: DW_TAG_class_type, name: "TC<int>" // CHECK: !DIDerivedType(tag: DW_TAG_pointer_type, baseType: ![[LINE]] template<typename T> 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 @@ -20,15 +20,11 @@ return 0; } -// Update these tests once support for DW_LANG_C_plus_plus_17/20 is added - it's -// a complicated tradeoff. The language codes are already published/blessed by -// the DWARF committee, but haven't been released in a published standard yet, -// so consumers might not be ready for these codes & could regress functionality -// (because they wouldn't be able to identify that the language was C++). The -// DWARFv6 language encoding, separating language from language version, would -// remove this problem/not require new codes for new language versions and make -// it possible to identify the base language irrespective of the version. +// The DWARFv6 language encoding, separating language from language version, +// would remove this problem/not require new codes for new language versions +// and make it possible to identify the base language irrespective of the +// version. // CHECK-CPP14: distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, -// CHECK-CPP17: distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, -// CHECK-CPP20: 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/CodeGenCXX/debug-info-ms-abi.cpp =================================================================== --- clang/test/CodeGenCXX/debug-info-ms-abi.cpp +++ clang/test/CodeGenCXX/debug-info-ms-abi.cpp @@ -14,11 +14,9 @@ Foo::Nested n; // CHECK: ![[Nested:[0-9]+]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Nested", -// CHECK-SAME: identifier: ".?AUNested@Foo@@" // CHECK: ![[Foo:[^ ]*]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Foo", // CHECK-SAME: elements: ![[elements:[0-9]+]] -// CHECK-SAME: identifier: ".?AUFoo@@" // CHECK: ![[elements]] = !{![[vshape:[0-9]+]], ![[vptr:[0-9]+]], ![[Nested]], ![[f:[0-9]+]], ![[g:[0-9]+]], ![[h:[0-9]+]], ![[i:[0-9]+]]} Index: clang/test/CodeGenCXX/debug-info-indirect-field-decl.cpp =================================================================== --- clang/test/CodeGenCXX/debug-info-indirect-field-decl.cpp +++ clang/test/CodeGenCXX/debug-info-indirect-field-decl.cpp @@ -12,7 +12,7 @@ // CHECK-SAME: line: [[@LINE+4]] // CHECK-SAME: baseType: ![[UNION:[0-9]+]] // CHECK-SAME: size: 32, offset: 32 - // CHECK: ![[UNION]] = distinct !DICompositeType(tag: DW_TAG_union_type,{{.*}} identifier: "_ZTSN3BarUt_E") + // CHECK: ![[UNION]] = distinct !DICompositeType(tag: DW_TAG_union_type, union { // CHECK: !DIDerivedType(tag: DW_TAG_member, name: "i2", // CHECK-SAME: line: [[@LINE+5]] Index: clang/test/CodeGenCXX/debug-info-enum.cpp =================================================================== --- clang/test/CodeGenCXX/debug-info-enum.cpp +++ clang/test/CodeGenCXX/debug-info-enum.cpp @@ -14,7 +14,6 @@ // CHECK: [[E1]] = !DICompositeType(tag: DW_TAG_enumeration_type, name: "e" // CHECK-SAME: scope: [[TEST1:![0-9]*]] // CHECK-SAME: elements: [[TEST1_ENUMS:![0-9]*]] -// CHECK-SAME: identifier: "_ZTSN5test11eE" // CHECK: [[TEST1]] = !DINamespace(name: "test1" // CHECK: [[TEST1_ENUMS]] = !{[[TEST1_E:![0-9]*]]} // CHECK: [[TEST1_E]] = !DIEnumerator(name: "E", value: 0, isUnsigned: true) @@ -33,7 +32,6 @@ // CHECK: [[E2]] = !DICompositeType(tag: DW_TAG_enumeration_type, name: "e" // CHECK-SAME: scope: [[TEST2:![0-9]+]] // CHECK-SAME: elements: [[TEST1_ENUMS]] -// CHECK-SAME: identifier: "_ZTSN5test21eE" // CHECK: [[TEST2]] = !DINamespace(name: "test2" // MSVC: [[G2]] = !DIGlobalVariableExpression(var: [[VAR2:![0-9]*]], @@ -49,7 +47,6 @@ // CHECK: [[E3]] = !DICompositeType(tag: DW_TAG_enumeration_type, name: "e" // CHECK-SAME: scope: [[TEST3:![0-9]*]] // CHECK-SAME: elements: [[TEST3_ENUMS:![0-9]*]] -// CHECK-SAME: identifier: "_ZTSN5test31eE" // CHECK: [[TEST3]] = !DINamespace(name: "test3" // CHECK: [[TEST3_ENUMS]] = !{[[TEST3_E:![0-9]*]]} // CHECK: [[TEST3_E]] = !DIEnumerator(name: "E", value: -1) Index: clang/test/CodeGenCXX/debug-info-auto-return.cpp =================================================================== --- clang/test/CodeGenCXX/debug-info-auto-return.cpp +++ clang/test/CodeGenCXX/debug-info-auto-return.cpp @@ -7,7 +7,7 @@ // CHECK: !DISubprogram(name: "findMax",{{.*}}, type: [[FUN_TYPE:![0-9]+]], {{.*}}spFlags: DISPFlagDefinition, {{.*}} declaration: [[DECL:![0-9]+]] // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "myClass", -// CHECK-SAME: elements: [[MEMBERS:![0-9]+]], +// CHECK-SAME: elements: [[MEMBERS:![0-9]+]]) // CHECK: [[MEMBERS]] = !{} Index: clang/test/CodeGenCXX/debug-info-artificial-arg.cpp =================================================================== --- clang/test/CodeGenCXX/debug-info-artificial-arg.cpp +++ clang/test/CodeGenCXX/debug-info-artificial-arg.cpp @@ -23,7 +23,6 @@ } // CHECK: ![[CLASSTYPE:.*]] = distinct !DICompositeType(tag: DW_TAG_class_type, name: "A", -// CHECK-SAME: identifier: "_ZTS1A" // CHECK: ![[ARTARG:.*]] = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: ![[CLASSTYPE]],{{.*}} DIFlagArtificial // CHECK: !DISubprogram(name: "A", scope: ![[CLASSTYPE]] // CHECK-SAME: line: 12 Index: clang/test/CodeGen/debug-info-programming-language.c =================================================================== --- clang/test/CodeGen/debug-info-programming-language.c +++ clang/test/CodeGen/debug-info-programming-language.c @@ -5,6 +5,9 @@ // RUN: -x c -std=c17 -O0 -disable-llvm-passes -debug-info-kind=limited \ // RUN: | FileCheck --check-prefix=CHECK-C17 %s // RUN: %clang_cc1 -dwarf-version=3 -emit-llvm -triple %itanium_abi_triple %s -o - \ +// RUN: -x c -std=c2x -O0 -disable-llvm-passes -debug-info-kind=limited \ +// RUN: | FileCheck --check-prefix=CHECK-C2X %s +// 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: -gstrict-dwarf | FileCheck --check-prefix=CHECK-STRICT %s // RUN: %clang_cc1 -dwarf-version=5 -emit-llvm -triple %itanium_abi_triple %s -o - \ @@ -13,10 +16,10 @@ // CHECK-STRICT: !DICompileUnit(language: DW_LANG_C99 // CHECK-C11: !DICompileUnit(language: DW_LANG_C11 -// Update this check once support for DW_LANG_C17 is broadly supported/known in -// consumers. Maybe we'll skip this and go to the DWARFv6 language+version -// encoding that avoids the risk of regression when describing a language -// version newer than what the consumer is aware of. -// CHECK-C17: !DICompileUnit(language: DW_LANG_C11 +// CHECK-C17: !DICompileUnit(language: DW_LANG_C17 + +// Update this check once support for whichever DW_LANG_ tag gets added to +// https://dwarfstd.org/Languages.php for c2x in DWARFv6. +// CHECK-C2X: !DICompileUnit(language: DW_LANG_C17 void f1(void) { } Index: clang/lib/CodeGen/CGDebugInfo.cpp =================================================================== --- clang/lib/CodeGen/CGDebugInfo.cpp +++ clang/lib/CodeGen/CGDebugInfo.cpp @@ -565,10 +565,16 @@ LangTag = llvm::dwarf::DW_LANG_ObjC_plus_plus; 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) LangTag = llvm::dwarf::DW_LANG_C_plus_plus_11; + // CPlusPlus03 is emitted as llvm::dwarf::DW_LANG_C_plus_plus, not + // llvm::dwarf::DW_LANG_C_plus_plus_03. else LangTag = llvm::dwarf::DW_LANG_C_plus_plus; } else if (LO.ObjC) { @@ -578,6 +584,8 @@ LangTag = llvm::dwarf::DW_LANG_OpenCL; } else if (LO.RenderScript) { LangTag = llvm::dwarf::DW_LANG_GOOGLE_RenderScript; + } else if (LO.C17 && !(CGO.DebugStrictDwarf && CGO.DwarfVersion < 5)) { + LangTag = llvm::dwarf::DW_LANG_C17; } else if (LO.C11 && !(CGO.DebugStrictDwarf && CGO.DwarfVersion < 5)) { LangTag = llvm::dwarf::DW_LANG_C11; } else if (LO.C99) {
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits