[all-commits] [llvm/llvm-project] da827d: [lldb][DataFormatter] Simplify std::unordered_map:...
Michael Buch via All-commits
all-commits at lists.llvm.org
Mon Jul 8 06:39:21 PDT 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: da827d0896e5e66fe9130f8f4479537d3bbee1da
https://github.com/llvm/llvm-project/commit/da827d0896e5e66fe9130f8f4479537d3bbee1da
Author: Michael Buch <michaelbuch12 at gmail.com>
Date: 2024-07-08 (Mon, 08 Jul 2024)
Changed paths:
M lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
M lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/TestDataFormatterLibccIterator.py
M lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/main.cpp
Log Message:
-----------
[lldb][DataFormatter] Simplify std::unordered_map::iterator formatter (#97754)
Depends on https://github.com/llvm/llvm-project/pull/97752
This patch changes the way we retrieve the key/value pair in the
`std::unordered_map::iterator` formatter (similar to how we are changing
it for `std::map::iterator` in
https://github.com/llvm/llvm-project/pull/97713, the motivations being
the same).
The old logic was not very easy to follow, and encoded the libc++ layout
in non-obvious ways. But mainly it was also fragile to alignment
miscalculations (https://github.com/llvm/llvm-project/pull/97443); this
would break once the new layout of `std::unordered_map` landed as part
of https://github.com/llvm/llvm-project/issues/93069.
Instead, this patch simply casts the `__hash_iterator` to a
`__node_pointer` (which is what libc++ does too) and uses a
straightforward `GetChildMemberWithName("__value_")` to get to the
key/value we care about.
The `std::unordered_map` already does it this way, so we align the
iterator counterpart to do the same. We can eventually re-use the
core-part of the `std::unordered_map` and `std::unordered_map::iterator`
formatters. But it will be an easier to change to review once both
simplifications landed.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list