[lldb/libc++] Simplify the libc++ string formatter
authorPavel Labath <pavel@labath.sk>
Mon, 11 Jul 2022 14:56:04 +0000 (16:56 +0200)
committerPavel Labath <pavel@labath.sk>
Tue, 12 Jul 2022 07:57:13 +0000 (09:57 +0200)
commitd4381153ea63e9458ffb9dd20ea92fb35d4e3042
tree5566d59e2839f329df2c78ce1d892893393bef36
parentf44d28f840c0b0877b09d5547fd09e191bbdc90e
[lldb/libc++] Simplify the libc++ string formatter

Precise string layout has changed a lot recently, but a long of these
changes did not have any effect on the usages of its fields -- e.g.
introduction/removal of an anonymous struct or union does not change the
way one can access the field in C++. Our name-based variable lookup
rules (deliberately) copy the C++ semantics, which means these changes
would have been invisible to the them, if only we were using name-based
lookup.

This patch replaces the opaque child index accesses with name-based
lookups, which allows us to greatly simplify the data formatter code.
The formatter continues to support all the string layouts that it
previously supported.

It is unclear why the formatter was not using this approach from the
beginning. I would speculate that the original version was working
around some (now fixed) issue with anonymous members or base classes,
and the subsequent revisions stuck with that approach out of inertia.

Differential Revision: https://reviews.llvm.org/D129490
lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp