Skip to content

Commit

Permalink
[lldb] Fix libstdc++ 11's std::unique_ptr affecting LLDB testsuite Te…
Browse files Browse the repository at this point in the history
…stDataFormatterStdUniquePtr.py

libstdc++ since version 11 has a conditional compilation based on
[[no_unique_address]] availability whether one element is either
inherited or put there as a field with [[no_unique_address]].

The code comment is by teemperor.

Reviewed By: teemperor

Differential Revision: https://reviews.llvm.org/D104283
  • Loading branch information
jankratochvil committed Jun 15, 2021
1 parent 88da6c1 commit fffb975
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions lldb/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,17 @@ bool LibStdcppUniquePtrSyntheticFrontEnd::Update() {
if (ptr_obj)
m_ptr_obj = ptr_obj->Clone(ConstString("pointer")).get();

ValueObjectSP del_obj = tuple_frontend->GetChildAtIndex(1);
if (del_obj)
m_del_obj = del_obj->Clone(ConstString("deleter")).get();
// Add a 'deleter' child if there was a non-empty deleter type specified.
//
// The object might have size=1 in the TypeSystem but occupies no dedicated
// storage due to no_unique_address, so infer the actual size from the total
// size of the unique_ptr class. If sizeof(unique_ptr) == sizeof(void*) then
// the deleter is empty and should be hidden.
if (tuple_sp->GetByteSize() > ptr_obj->GetByteSize()) {
ValueObjectSP del_obj = tuple_frontend->GetChildAtIndex(1);
if (del_obj)
m_del_obj = del_obj->Clone(ConstString("deleter")).get();
}

if (m_ptr_obj) {
Status error;
Expand Down

0 comments on commit fffb975

Please sign in to comment.