[lldb][DataFormatter] Add dereference support to libstdcpp std::shared_ptr formatter
authorMichael Buch <michaelbuch12@gmail.com>
Tue, 23 May 2023 23:01:47 +0000 (00:01 +0100)
committerMichael Buch <michaelbuch12@gmail.com>
Wed, 24 May 2023 12:01:11 +0000 (13:01 +0100)
commit44bb442fd5be3860e7819cb216621b5ea59970c3
tree096a6d3d7aa5504cc73c5683c023b8a3626db25f
parenta2ac3678cd337865ad6a8852acf94c8c5f0b03ea
[lldb][DataFormatter] Add dereference support to libstdcpp std::shared_ptr formatter

This mimicks the implementation of the libstdcpp std::unique_ptr
formatter.

This has been attempted several years ago in
`0789722d85cf1f1fdbe2ffb2245ea0ba034a9f94` but was reverted in
`e7dd3972094c2f2fb42dc9d4d5344e54a431e2ce`.

The difference to the original patch is that we now maintain
a `$$dereference$$` member and we only store weak pointers
to the other children inside the synthetic frontend. This is
what the libc++ formatters do to prevent the recursion mentioned
in the revert commit.
lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/smart_ptr/TestDataFormatterStdSmartPtr.py
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/smart_ptr/main.cpp