[llvm] [llvm-debuginfo-analyzer] Add support for parsing DWARF / CodeView SourceLanguage (PR #137223)

Javier Lopez-Gomez via llvm-commits llvm-commits at lists.llvm.org
Mon May 26 10:44:59 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;
+};
+
----------------
jalopezg-git wrote:

@CarlosAlbertoEnciso I have explored option (2) above, and I tend to like it more than the previous `std::variant<Ts...>`-based solution (given that all supported languages are part of the same `enum`, which makes it easier to compare).

Please, take a look and let me know what you think.

https://github.com/llvm/llvm-project/pull/137223


More information about the llvm-commits mailing list