This is an archive of the discontinued LLVM Phabricator instance.

[lldb][Language] Add more language types
ClosedPublic

Authored by Michael137 on Feb 1 2023, 3:47 AM.

Details

Summary

Adds more languages to the language_names list in
preparation for adding support for C++20 expression
evaluation.

The language constants were taken from the DWARFv5
constants defined in LLVM's Dwarf.def. Two vendor
constants overlap with the DWARFv5 constants so bump
their values. Their actual value is not important,
whereas keeping the enum values consecutive is (since
they are used for array lookups).

Diff Detail

Event Timeline

Michael137 created this revision.Feb 1 2023, 3:47 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 1 2023, 3:47 AM
Michael137 requested review of this revision.Feb 1 2023, 3:47 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 1 2023, 3:47 AM
aprantl added inline comments.Feb 1 2023, 9:39 AM
lldb/include/lldb/lldb-enumerations.h
492

Would it make sense to generate this list from the macros in llvm/include/llvm/BinaryFormat/Dwarf.def with some clever application of the ## operator?

lldb/source/Target/Language.cpp
211

Should we sink this into the Dwarf.def?

Michael137 added inline comments.Feb 1 2023, 9:46 AM
lldb/include/lldb/lldb-enumerations.h
492

The only thing that's stopping us from doing this is that the constants for the vendor extensions are not consecutive with the rest of the constants. So if one ever does try to use that language constant we'd run into out-of-bounds accesses here and there

aprantl added inline comments.Feb 1 2023, 9:57 AM
lldb/include/lldb/lldb-enumerations.h
492

Do have arrays that are indexed by language? Or what would be an example of that?

492

Also, we could still define eNumLanguagesTypes to be at the end of the official block?

Michael137 added inline comments.Apr 3 2023, 4:21 AM
lldb/include/lldb/lldb-enumerations.h
492

Do have arrays that are indexed by language? Or what would be an example of that?

Yup, e.g., Language::GetNameForLanguageType and more crucially the LanguageSet type gets used by things like GetAllTypeSystemSupportedLanguagesForExpressions

Michael137 marked an inline comment as not done.Apr 3 2023, 4:24 AM
Michael137 added inline comments.
lldb/include/lldb/lldb-enumerations.h
492

Also, we could still define eNumLanguagesTypes to be at the end of the official block?

That wouldn't quite work for the LanguageSet indexing because the vendor extension language codes are no consecutive to the other language codes. So the size of the LanguageSet would just balloon

Michael137 added inline comments.Apr 3 2023, 4:28 AM
lldb/include/lldb/lldb-enumerations.h
492

Interestingly I found another language enum that does exactly what LLDB does to (in regards to the vendor extensions): llvm/include/llvm-c/DebugInfo.h

aprantl accepted this revision.Apr 3 2023, 5:06 PM

Well, I guess we'll have to revisit this for DWARF 6 split of language names and versions anyway....

This revision is now accepted and ready to land.Apr 3 2023, 5:06 PM
This revision was automatically updated to reflect the committed changes.