[Lldb-commits] [PATCH] D21984: Add data formatter for libstdc++ shared_ptr and weak_ptr
Enrico Granata via lldb-commits
lldb-commits at lists.llvm.org
Tue Jul 5 11:19:28 PDT 2016
granata.enrico added inline comments.
================
Comment at: source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp:665
@@ +664,3 @@
+
+ stl_summary_flags.SetDontShowChildren(true);
+ AddCXXSummary(cpp_category_sp, lldb_private::formatters::LibStdcppSmartPointerSummaryProvider,
----------------
tberghammer wrote:
> granata.enrico wrote:
> > Is there any reason to hide the children for a type that you provide synthetic children for?
> Without hiding the children the content of the shard_ptr will be displayed 2 times. Once in the first line as part of the summary and then 2nd time as a children. I think it is cleaner if we display the value only once but it can make it more difficult to access to the content of the shared pointer.
>
> If you think displaying the children is better then I am happy with that option too.
>
> The 2 possible output for a type Foo:
>
> ```
> (std::shared_ptr<Foo>) f = Foo @ 0x0000000000606118 {
> _M_ptr = 0x0000000000606118
> }
> ```
> ```
> (std::shared_ptr<Foo>) f = Foo @ 0x0000000000606118
> ```
>
> The 2 possible output for an std::string:
> ```
> (std::shared_ptr<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >) s = "123456" {
> _M_ptr = "123456"
> }
> ```
> ```
> (std::shared_ptr<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >) s = "123456"
> ```
Oh, I see. Yeah, I had to solve a similar problem for Swift Optionals.
Essentially, you're discovering that for shared_ptr<T>, T can have combinations of values, summaries, synthetic values, ...
Unfortunately right now there is no automated formatter for the concept of a box<T> that handles all those intricacies automatically for you. It would be a nice thing to add, but it's probably beyond the scope of your change
Feel free to pick your favorite solution for now, and I'll try to get to a universal box formatter at some point.
http://reviews.llvm.org/D21984
More information about the lldb-commits
mailing list