[libcxx-commits] [libcxx] [libc++] Refactor key extraction for __hash_table and __tree (PR #154512)

Michael Buch via libcxx-commits libcxx-commits at lists.llvm.org
Tue Aug 26 14:31:37 PDT 2025


Michael137 wrote:

Ok had a look at the test failure (TestLibcxxInternalsRecognizer.py). Seems like after this libc++ patch, the backtrace that LLDB prints when stopped inside a std::map comparator is:
```
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
  * frame #0: 0x00000001000097e8 a.out`MyKey::operator<(this=0x000000016fdfebbc, other=0x00000001007f5c3c) at main.cpp:70:5
    frame #1: 0x00000001000097c0 a.out`std::__1::less<MyKey>::operator()[abi:se220000](this=0x000000016fdfebf8, __x=0x000000016fdfebbc, __y=0x00000001007f5c3c) at operations.h:357:16
    frame #4: 0x0000000100009224 a.out`std::__1::pair<std::__1::__tree_iterator<std::__1::__value_type<MyKey, int>, std::__1::__tree_node<std::__1::__value_type<MyKey, int>, void*>*, long>, bool> std::__1::__tree<std::__1::__value_type<MyKey, int>, std::__1::__map_value_compare<MyKey, std::__1::pair<MyKey const, int>, std::__1::less<MyKey>, true>, std::__1::allocator<std::__1::pair<MyKey const, int>>>::__emplace_unique[abi:se220000]<MyKey, int>(MyKey&&, int&&)::'lambda'(MyKey const&, MyKey&&, int&&)::operator()(this=0x000000016fdfe9d8, __key=0x000000016fdfebbc, __args2=0x000000016fdfebbc, __args2=0x000000016fdfebb8) at __tree:914:42
    frame #8: 0x0000000100000f54 a.out`std::__1::map<MyKey, int, std::__1::less<MyKey>, std::__1::allocator<std::__1::pair<MyKey const, int>>>::emplace[abi:se220000]<MyKey, int>(this=size=1, __args=0x000000016fdfebbc, __args=0x000000016fdfebb8) at map:1053:20
    frame #9: 0x0000000100000ea0 a.out`test_containers() at main.cpp:78:7
    frame #10: 0x000000010000100c a.out`main at main.cpp:84:3
    frame #11: 0x0000000193ec1d54 dyld`start + 7184
```

We have a regex that will try to determine which libc++ frames to hide (introduced in https://github.com/llvm/llvm-project/pull/108870). So the test expects following frames to show up in the backtrace:
```
            "MyKey::operator<(MyKey const&) const": [
                "less",
                "::emplace",
                "test_containers",
            ],
```

But now we have these lambda `operator()` in the backtrace which don't get hidden.

A quick fix to get this PR unblocked is to adjust the test expectations:
```
diff --git i/lldb/test/API/lang/cpp/libcxx-internals-recognizer/TestLibcxxInternalsRecognizer.py w/lldb/test/API/lang/cpp/libcxx-internals-recognizer/TestLibcxxInternalsRecognizer.py
index 8efa53bdbf72..f3693113baa0 100644
--- i/lldb/test/API/lang/cpp/libcxx-internals-recognizer/TestLibcxxInternalsRecognizer.py
+++ w/lldb/test/API/lang/cpp/libcxx-internals-recognizer/TestLibcxxInternalsRecognizer.py
@@ -40,7 +40,8 @@ class LibCxxInternalsRecognizerTestCase(TestBase):
             "Callable::operator()(int) const": ["::invoke", "test_invoke"],
             # Containers
             "MyKey::operator<(MyKey const&) const": [
-                "less",
+                "::operator()",
+                "::operator()",
                 "::emplace",
                 "test_containers",
             ],
```

But as a follow-up, I'd like @vogelsgesang to chime in on whether he thinks the regex should be adjusted/whether the lambdas should get hidden (I think we do want to hide those since they are implementation details). TBH I'm not sure why these lambdas don't get hidden. I thought we just hide everything in the `__1` namespace..

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


More information about the libcxx-commits mailing list