[Lldb-commits] [lldb] Fix the sort function for languages to have "strict weak ordering". (PR #114160)
via lldb-commits
lldb-commits at lists.llvm.org
Tue Oct 29 17:17:07 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-lldb
Author: None (jimingham)
<details>
<summary>Changes</summary>
If you build libstdc++ with "debug" strictness, the test TestTypeLookup.py will assert. That's because we're calling llvm::sort (which redirects to std::sort) with a function that doesn't obey strict weak ordering.
The error was that when the two languages were equal, we're sometimes returning `true` but strict weak ordering requires that always be false.
This patch just makes the function behave properly.
---
Full diff: https://github.com/llvm/llvm-project/pull/114160.diff
1 Files Affected:
- (modified) lldb/source/Commands/CommandObjectType.cpp (+1)
``````````diff
diff --git a/lldb/source/Commands/CommandObjectType.cpp b/lldb/source/Commands/CommandObjectType.cpp
index f9786529bcdb1c..b5230216bb221a 100644
--- a/lldb/source/Commands/CommandObjectType.cpp
+++ b/lldb/source/Commands/CommandObjectType.cpp
@@ -2649,6 +2649,7 @@ class CommandObjectTypeLookup : public CommandObjectRaw {
return false;
LanguageType lt1 = lang1->GetLanguageType();
LanguageType lt2 = lang2->GetLanguageType();
+ if (lt1 == lt2) return false;
if (lt1 == guessed_language)
return true; // make the selected frame's language come first
if (lt2 == guessed_language)
``````````
</details>
https://github.com/llvm/llvm-project/pull/114160
More information about the lldb-commits
mailing list