Skip to content

Commit 0a859b8

Browse files
committed
[llvm][DebugInfo] DW_AT_language_version
1 parent 8a0b6a0 commit 0a859b8

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

llvm/include/llvm/BinaryFormat/Dwarf.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,7 @@ HANDLE_DW_AT(0x8b, defaulted, 5, DWARF)
426426
HANDLE_DW_AT(0x8c, loclists_base, 5, DWARF)
427427
// New in Dwarf v6:
428428
HANDLE_DW_AT(0x90, language_name, 6, DWARF)
429+
HANDLE_DW_AT(0x91, language_version, 6, DWARF)
429430

430431
// Vendor extensions:
431432
HANDLE_DW_AT(0x806, GHS_namespace_alias, 0, GHS)

llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,12 +1039,18 @@ void DwarfDebug::finishUnitAttributes(const DICompileUnit *DIUnit,
10391039
} else
10401040
NewCU.addString(Die, dwarf::DW_AT_producer, Producer);
10411041

1042-
if (auto Lang = DIUnit->getSourceLanguage(); Lang.hasVersionedName())
1042+
if (auto Lang = DIUnit->getSourceLanguage(); Lang.hasVersionedName()) {
10431043
NewCU.addUInt(Die, dwarf::DW_AT_language_name, dwarf::DW_FORM_data2,
10441044
Lang.getName());
1045-
else
1045+
1046+
if (uint32_t LangVersion = Lang.getVersion();
1047+
LangVersion != 0)
1048+
NewCU.addUInt(Die, dwarf::DW_AT_language_version, /*Form=*/std::nullopt,
1049+
LangVersion);
1050+
} else {
10461051
NewCU.addUInt(Die, dwarf::DW_AT_language, dwarf::DW_FORM_data2,
10471052
Lang.getName());
1053+
}
10481054

10491055
NewCU.addString(Die, dwarf::DW_AT_name, FN);
10501056
StringRef SysRoot = DIUnit->getSysRoot();

0 commit comments

Comments
 (0)