[Lldb-commits] [lldb] [lldb] Fix off-by-one error in ToDwarfSourceLanguage (PR #162315)

via lldb-commits lldb-commits at lists.llvm.org
Tue Oct 7 09:18:33 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lldb

Author: Joshua Peterson (joshpeterson)

<details>
<summary>Changes</summary>

The ToDwarfSourceLanguage function incorrectly excluded languages that equal eLanguageTypeLastStandardLanguage. The comparison used `<` instead of `<=`, causing the last standard language to fall through to the default case and return std::nullopt.

This broke language plugins that use eLanguageTypeLastStandardLanguage (currently Mojo at 0x0033) as their language code, preventing proper DWARF language conversion and breaking REPL functionality.

The fix changes the comparison from `<` to `<=` to include the last standard language in the automatic conversion to DWARF source language.

This is a regression from commit 7f51a2a47d2e706d04855b0e41690ebafa2b3238 which introduced the ToDwarfSourceLanguage function.

---
Full diff: https://github.com/llvm/llvm-project/pull/162315.diff


1 Files Affected:

- (modified) lldb/source/Target/Language.cpp (+1-1) 


``````````diff
diff --git a/lldb/source/Target/Language.cpp b/lldb/source/Target/Language.cpp
index 395718ecbe292..2efd4bc1e2c09 100644
--- a/lldb/source/Target/Language.cpp
+++ b/lldb/source/Target/Language.cpp
@@ -549,7 +549,7 @@ Language::~Language() = default;
 
 static std::optional<llvm::dwarf::SourceLanguage>
 ToDwarfSourceLanguage(lldb::LanguageType language_type) {
-  if (language_type < lldb::eLanguageTypeLastStandardLanguage)
+  if (language_type <= lldb::eLanguageTypeLastStandardLanguage)
     return static_cast<llvm::dwarf::SourceLanguage>(language_type);
 
   switch (language_type) {

``````````

</details>


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


More information about the lldb-commits mailing list