[llvm] [llvm-debuginfo-analyzer] Add support for parsing DWARF / CodeView SourceLanguage (PR #137223)
Carlos Alberto Enciso via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 30 04:09:39 PDT 2025
================
@@ -64,6 +67,22 @@ using LVElementKindSet = std::set<LVElementKind>;
using LVElementDispatch = std::map<LVElementKind, LVElementGetFunction>;
using LVElementRequest = std::vector<LVElementGetFunction>;
+/// A source language supported by any of the debug info representations.
+struct LVSourceLanguage {
+ LVSourceLanguage() = default;
+ LVSourceLanguage(llvm::dwarf::SourceLanguage SL) : Language(SL) {}
+ LVSourceLanguage(llvm::codeview::SourceLanguage SL) : Language(SL) {}
+
+ bool isValid() const { return Language.index() != 0; }
+ template <typename T> T getAs() { return std::get<T>(Language); }
+ StringRef getName() const;
+
+private:
+ std::variant<std::monostate, llvm::dwarf::SourceLanguage,
+ llvm::codeview::SourceLanguage>
+ Language;
+};
+
----------------
CarlosAlbertoEnciso wrote:
May be explore the use of `StringPool` to store the `Language` string.
Basically, the `setSourceLanguage` function to use the logic from `StringRef LVSourceLanguage::getName()` to get the string and store it in the `StringPool`. And to get back the string in 'getSourceLanguage' query the `StringPool`.
https://github.com/llvm/llvm-project/pull/137223
More information about the llvm-commits
mailing list