[Lldb-commits] [lldb] [lldb][DataFormatter] Format libstdc++ unique_ptr like we do libc++ (PR #146909)

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Thu Jul 3 08:22:56 PDT 2025


================
@@ -55,6 +55,12 @@ void AddFilter(TypeCategoryImpl::SharedPointer category_sp,
 
 std::optional<size_t> ExtractIndexFromString(const char *item_name);
 
+/// Returns \c false if the smart pointer formatters shouldn't continue
+/// formatting the rest of the object. Currently this is the case when the
+/// pointer is a nullptr.
+bool DumpCxxSmartPtrPointerSummary(Stream &stream, ValueObject &ptr,
+                                   const TypeSummaryOptions &options);
----------------
labath wrote:

Is it actually needed though? In my experiments, a normally constructed empty shared pointer will have these as `__ctrl_` field as null anyway.

I was able to construct a nullptr shared_ptr with a non-empty control field using the subobject constructor (`std::shared_ptr<int> si(new int(47)); std::shared_ptr<int> sie(si, nullptr);`), but in that case, maybe we actually should show the weak and shared counts?


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


More information about the lldb-commits mailing list