[all-commits] [llvm/llvm-project] d366da: [lldb] Make the libcxx unique_ptr prettyprinter su...

Jorge Gorbe Moya via All-commits all-commits at lists.llvm.org
Mon May 1 13:08:28 PDT 2023

  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: d366da97bd24ddfb91c9f260fa0aaf105d947652
  Author: Jorge Gorbe Moya <jgorbe at google.com>
  Date:   2023-05-01 (Mon, 01 May 2023)

  Changed paths:
    M lldb/include/lldb/DataFormatters/FormattersHelpers.h
    M lldb/source/DataFormatters/FormattersHelpers.cpp
    M lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
    M lldb/source/Plugins/Language/CPlusPlus/LibCxx.h
    M lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp
    M lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/TestDataFormatterLibcxxUniquePtr.py
    M lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/main.cpp

  Log Message:
  [lldb] Make the libcxx unique_ptr prettyprinter support custom deleters.

The unique_ptr prettyprinter calls `GetValueOfLibCXXCompressedPair`,
which looks for a `__value_` child. However, when the second value in
the compressed pair is not an empty class, there are two `__value_`
children because `__compressed_pair` derives twice from
`__compressed_pair_elem`, one for each member of the pair. And then the
lookup fails because it's ambiguous.

This patch makes the following changes:

- Rename `GetValueOfLibCXXCompressedPair` to
  `GetFirstValueOfLibCXXCompressedPair`, and add a similar function to
  get the second value. Put both functions in
  Plugin/Language/CPlusPlus/LibCxx.cpp because it seems inappropriate to
  have libcxx-specific helpers separate from all the libcxx-dependent

- Read the second value of the `__ptr_` pair and display a "deleter"
  child in the unique_ptr synthetic child provider, when available.

- Add a test case for the non-empty deleter case.

Differential Revision: https://reviews.llvm.org/D148662

More information about the All-commits mailing list