[clang] [llvm] [mlir] [llvm][DebugInfo][NFC] Abstract DICompileUnit::SourceLanguage to allow alternate DWARF SourceLanguage encoding (PR #162255)

Adrian Prantl via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 7 10:16:09 PDT 2025


================
@@ -66,6 +66,44 @@ namespace dwarf {
 enum Tag : uint16_t;
 }
 
+/// Wrapper structure that holds a language name and its version.
+///
+/// Some debug-info formats, particularly DWARF, distniguish between
+/// language codes that include the version name and codes that don't.
+/// DISourceLanguageName may hold either of these.
+///
+class DISourceLanguageName {
+  /// Language name.
+  /// If \ref Version is not std::nullopt, then this name
+  /// is version independent (i.e., doesn't include the language
+  /// version in its name).
+  uint16_t Name;
+
+  /// Language version. The version scheme is language
+  /// dependent.
+  std::optional<uint32_t> Version;
+
+public:
+  bool hasVersionedName() const { return Version.has_value(); }
+
+  /// Returns a versioned or unversioned language name.
+  uint16_t getName() const { return Name; }
+
+  // Transitional API for cases where we do not yet support
+  // versioned source language names. Use \ref getName instead.
+  //
+  // FIXME: remove once all callers of this API account for versioned
+  // names.
----------------
adrian-prantl wrote:

///

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


More information about the llvm-commits mailing list