[Lldb-commits] [lldb] [lldb][test] Fix unordered-map test (PR #156033)

Ebuka Ezike via lldb-commits lldb-commits at lists.llvm.org
Fri Aug 29 07:31:42 PDT 2025


https://github.com/da-viper created https://github.com/llvm/llvm-project/pull/156033

test was failing because in some version of `libc++` there is an extra struct on the stored pair in map. And it did not use the synthetic child. 

https://github.com/llvm/llvm-project/blob/20dd053160f7d933037aacb69067ef4d77996ba1/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp#L370-L384

https://github.com/llvm/llvm-project/blob/c659a3be3bab9beb3b77343b2f50585e976b74a5/libcxx/include/__cxx03/unordered_map#L749-L757


>From ca31a0589772f5cf55a2442f6019ef7a3fa460c6 Mon Sep 17 00:00:00 2001
From: Ebuka Ezike <yerimyah1 at gmail.com>
Date: Fri, 29 Aug 2025 15:17:29 +0100
Subject: [PATCH] [lldb][test] Fix unordered-map test.

test was failing because there is an extra struct on the stored pair in map
---
 .../TestDataFormatterStdUnorderedMap.py             | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered_map-iterator/TestDataFormatterStdUnorderedMap.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered_map-iterator/TestDataFormatterStdUnorderedMap.py
index d2382373f4810..95b0395ebc486 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered_map-iterator/TestDataFormatterStdUnorderedMap.py
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered_map-iterator/TestDataFormatterStdUnorderedMap.py
@@ -16,6 +16,12 @@ def check_ptr_or_ref(self, var_name: str):
         pair = var.GetChildAtIndex(0)
         self.assertTrue(pair)
 
+        # std::unordered_map previously stores the actual key/value pair
+        # in  __hash_value_type::__cc_ (or previously __cc).
+        if pair.GetNumChildren() == 1:
+            pair = pair.GetChildAtIndex(0)
+            self.assertTrue(pair)
+
         self.assertEqual(pair.GetChildAtIndex(0).summary, '"Hello"')
         self.assertEqual(pair.GetChildAtIndex(1).summary, '"World"')
 
@@ -29,6 +35,12 @@ def check_ptr_ptr(self, var_name: str):
         pair = ptr.GetChildAtIndex(0)
         self.assertTrue(pair)
 
+        # std::unordered_map previously stores the actual key/value pair
+        # in  __hash_value_type::__cc_ (or previously __cc).
+        if pair.GetNumChildren() == 1:
+            pair = pair.GetChildAtIndex(0)
+            self.assertTrue(pair)
+
         self.assertEqual(pair.GetChildAtIndex(0).summary, '"Hello"')
         self.assertEqual(pair.GetChildAtIndex(1).summary, '"World"')
 
@@ -113,7 +125,6 @@ def do_test_ptr(self):
         Test that pointers to std::unordered_map are formatted correctly.
         """
 
-        self.build()
         (self.target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
             self, "Stop here", lldb.SBFileSpec("main.cpp", False)
         )



More information about the lldb-commits mailing list