-
Notifications
You must be signed in to change notification settings - Fork 15k
[llvm][Dwarf] Create re-usable constants for C-language DWARFv6 language codes #163199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -66,6 +66,22 @@ enum LLVMConstants : uint32_t { | |
| DW_ARANGES_VERSION = 2, ///< Section version number for .debug_aranges. | ||
| /// \} | ||
|
|
||
| /// DWARFv6 DW_AT_language_version constants: | ||
| /// https://dwarfstd.org/languages-v6.html | ||
| /// \{ | ||
| DW_LANG_VERSION_C89 = 198912, | ||
| DW_LANG_VERSION_C99 = 199901, | ||
| DW_LANG_VERSION_C11 = 201112, | ||
| DW_LANG_VERSION_C17 = 201710, | ||
| DW_LANG_VERSION_C23 = 202311, | ||
| DW_LANG_VERSION_C_plus_plus_98 = 199711, | ||
| DW_LANG_VERSION_C_plus_plus_11 = 201103, | ||
| DW_LANG_VERSION_C_plus_plus_14 = 201402, | ||
| DW_LANG_VERSION_C_plus_plus_17 = 201703, | ||
| DW_LANG_VERSION_C_plus_plus_20 = 202002, | ||
| DW_LANG_VERSION_C_plus_plus_23 = 202302, | ||
| /// \} | ||
|
|
||
| /// Identifiers we use to distinguish vendor extensions. | ||
| /// \{ | ||
| DWARF_VENDOR_DWARF = 0, ///< Defined in v2 or later of the DWARF standard. | ||
|
|
@@ -246,29 +262,29 @@ inline std::optional<SourceLanguage> toDW_LANG(SourceLanguageName name, | |
| case DW_LNAME_C: // YYYYMM, K&R 000000 | ||
| if (version == 0) | ||
| return DW_LANG_C; | ||
| if (version <= 198912) | ||
| if (version <= DW_LANG_VERSION_C89) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do you think about adding a table to Dwarf.def that ties these together, such as: ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm how would we be able to re-use it in this function though? Because we're enumerating There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right, we would either need one macro per language or a real lookup table. And wether the table lives in code or data doesn't make a huge difference. |
||
| return DW_LANG_C89; | ||
| if (version <= 199901) | ||
| if (version <= DW_LANG_VERSION_C99) | ||
| return DW_LANG_C99; | ||
| if (version <= 201112) | ||
| if (version <= DW_LANG_VERSION_C11) | ||
| return DW_LANG_C11; | ||
| if (version <= 201710) | ||
| if (version <= DW_LANG_VERSION_C17) | ||
| return DW_LANG_C17; | ||
| return {}; | ||
| case DW_LNAME_C_plus_plus: // YYYYMM | ||
| if (version == 0) | ||
| return DW_LANG_C_plus_plus; | ||
| if (version <= 199711) | ||
| if (version <= DW_LANG_VERSION_C_plus_plus_98) | ||
| return DW_LANG_C_plus_plus; | ||
| if (version <= 200310) | ||
| return DW_LANG_C_plus_plus_03; | ||
| if (version <= 201103) | ||
| if (version <= DW_LANG_VERSION_C_plus_plus_11) | ||
| return DW_LANG_C_plus_plus_11; | ||
| if (version <= 201402) | ||
| if (version <= DW_LANG_VERSION_C_plus_plus_14) | ||
| return DW_LANG_C_plus_plus_14; | ||
| if (version <= 201703) | ||
| if (version <= DW_LANG_VERSION_C_plus_plus_17) | ||
| return DW_LANG_C_plus_plus_17; | ||
| if (version <= 202002) | ||
| if (version <= DW_LANG_VERSION_C_plus_plus_20) | ||
| return DW_LANG_C_plus_plus_20; | ||
| return {}; | ||
| case DW_LNAME_Cobol: // YYYY | ||
|
|
@@ -384,25 +400,25 @@ toDW_LNAME(SourceLanguage language) { | |
| case DW_LANG_C: | ||
| return {{DW_LNAME_C, 0}}; | ||
| case DW_LANG_C89: | ||
| return {{DW_LNAME_C, 198912}}; | ||
| return {{DW_LNAME_C, DW_LANG_VERSION_C89}}; | ||
| case DW_LANG_C99: | ||
| return {{DW_LNAME_C, 199901}}; | ||
| return {{DW_LNAME_C, DW_LANG_VERSION_C99}}; | ||
| case DW_LANG_C11: | ||
| return {{DW_LNAME_C, 201112}}; | ||
| return {{DW_LNAME_C, DW_LANG_VERSION_C11}}; | ||
| case DW_LANG_C17: | ||
| return {{DW_LNAME_C, 201710}}; | ||
| return {{DW_LNAME_C, DW_LANG_VERSION_C17}}; | ||
| case DW_LANG_C_plus_plus: | ||
| return {{DW_LNAME_C_plus_plus, 0}}; | ||
| case DW_LANG_C_plus_plus_03: | ||
| return {{DW_LNAME_C_plus_plus, 200310}}; | ||
| case DW_LANG_C_plus_plus_11: | ||
| return {{DW_LNAME_C_plus_plus, 201103}}; | ||
| return {{DW_LNAME_C_plus_plus, DW_LANG_VERSION_C_plus_plus_11}}; | ||
| case DW_LANG_C_plus_plus_14: | ||
| return {{DW_LNAME_C_plus_plus, 201402}}; | ||
| return {{DW_LNAME_C_plus_plus, DW_LANG_VERSION_C_plus_plus_14}}; | ||
| case DW_LANG_C_plus_plus_17: | ||
| return {{DW_LNAME_C_plus_plus, 201703}}; | ||
| return {{DW_LNAME_C_plus_plus, DW_LANG_VERSION_C_plus_plus_17}}; | ||
| case DW_LANG_C_plus_plus_20: | ||
| return {{DW_LNAME_C_plus_plus, 202002}}; | ||
| return {{DW_LNAME_C_plus_plus, DW_LANG_VERSION_C_plus_plus_20}}; | ||
| case DW_LANG_Cobol74: | ||
| return {{DW_LNAME_Cobol, 1974}}; | ||
| case DW_LANG_Cobol85: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what the best naming convention here would be. The
DW_LANG_prefix might get confused with theDW_LANG_language codes.