[Lldb-commits] [lldb] fffb975 - [lldb] Fix libstdc++ 11's std::unique_ptr affecting LLDB testsuite TestDataFormatterStdUniquePtr.py

Jan Kratochvil via lldb-commits lldb-commits at lists.llvm.org
Tue Jun 15 02:21:51 PDT 2021


Author: Jan Kratochvil
Date: 2021-06-15T11:19:20+02:00
New Revision: fffb975095119adb5f91be4e3c83ac0cb4b1602c

URL: https://github.com/llvm/llvm-project/commit/fffb975095119adb5f91be4e3c83ac0cb4b1602c
DIFF: https://github.com/llvm/llvm-project/commit/fffb975095119adb5f91be4e3c83ac0cb4b1602c.diff

LOG: [lldb] Fix libstdc++ 11's std::unique_ptr affecting LLDB testsuite TestDataFormatterStdUniquePtr.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

Added: 
    

Modified: 
    lldb/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp
index 0b34b4e2fc899..79e864a2cbd5e 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp
@@ -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;


        


More information about the lldb-commits mailing list