Index: lldb/trunk/include/lldb/Core/ValueObject.h =================================================================== --- lldb/trunk/include/lldb/Core/ValueObject.h +++ lldb/trunk/include/lldb/Core/ValueObject.h @@ -553,6 +553,9 @@ lldb::ValueObjectSP GetSP() { return m_manager->GetSharedPointer(this); } + // Change the name of the current ValueObject. Should *not* be used from a + // synthetic child provider as it would change the name of the non synthetic + // child as well. void SetName(const ConstString &name); virtual lldb::addr_t GetAddressOf(bool scalar_is_load_address = true, @@ -601,6 +604,12 @@ virtual lldb::ValueObjectSP Dereference(Error &error); + // Creates a copy of the ValueObject with a new name and setting the current + // ValueObject as its parent. It should be used when we want to change the + // name of a ValueObject without modifying the actual ValueObject itself + // (e.g. sythetic child provider). + virtual lldb::ValueObjectSP Clone(const ConstString &new_name); + virtual lldb::ValueObjectSP AddressOf(Error &error); virtual lldb::addr_t GetLiveAddress() { return LLDB_INVALID_ADDRESS; } Index: lldb/trunk/source/Core/ValueObject.cpp =================================================================== --- lldb/trunk/source/Core/ValueObject.cpp +++ lldb/trunk/source/Core/ValueObject.cpp @@ -2962,6 +2962,10 @@ return ValueObjectCast::Create(*this, GetName(), compiler_type); } +lldb::ValueObjectSP ValueObject::Clone(const ConstString &new_name) { + return ValueObjectCast::Create(*this, new_name, GetCompilerType()); +} + ValueObjectSP ValueObject::CastPointerType(const char *name, CompilerType &compiler_type) { ValueObjectSP valobj_sp; Index: lldb/trunk/source/DataFormatters/VectorType.cpp =================================================================== --- lldb/trunk/source/DataFormatters/VectorType.cpp +++ lldb/trunk/source/DataFormatters/VectorType.cpp @@ -204,14 +204,12 @@ if (idx >= CalculateNumChildren()) return lldb::ValueObjectSP(); auto offset = idx * m_child_type.GetByteSize(nullptr); - ValueObjectSP child_sp( - m_backend.GetSyntheticChildAtOffset(offset, m_child_type, true)); - if (!child_sp) - return child_sp; - StreamString idx_name; idx_name.Printf("[%" PRIu64 "]", (uint64_t)idx); - child_sp->SetName(ConstString(idx_name.GetString())); + ValueObjectSP child_sp(m_backend.GetSyntheticChildAtOffset( + offset, m_child_type, true, ConstString(idx_name.GetString()))); + if (!child_sp) + return child_sp; child_sp->SetFormat(m_item_format); Index: lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp =================================================================== --- lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp +++ lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp @@ -406,7 +406,7 @@ case 1: { auto child0_sp = potential_child_sp->GetChildAtIndex(0, true); if (child0_sp && child0_sp->GetName() == g___cc) - potential_child_sp = child0_sp; + potential_child_sp = child0_sp->Clone(ConstString(name.GetString())); break; } case 2: { @@ -414,11 +414,10 @@ auto child1_sp = potential_child_sp->GetChildAtIndex(1, true); if (child0_sp && child0_sp->GetName() == g___cc && child1_sp && child1_sp->GetName() == g___nc) - potential_child_sp = child0_sp; + potential_child_sp = child0_sp->Clone(ConstString(name.GetString())); break; } } - potential_child_sp->SetName(ConstString(name.GetString())); } m_iterators[idx] = iterator; return potential_child_sp; Index: lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp =================================================================== --- lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp +++ lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp @@ -73,9 +73,7 @@ if (value_sp) { StreamString name; name.Printf("[%zd]", m_members.size()); - value_sp->SetName(ConstString(name.GetString())); - - m_members.push_back(value_sp); + m_members.push_back(value_sp->Clone(ConstString(name.GetString()))); } } } Index: lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp =================================================================== --- lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp +++ lldb/trunk/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp @@ -70,19 +70,19 @@ std::unique_ptr tuple_frontend( LibStdcppTupleSyntheticFrontEndCreator(nullptr, tuple_sp)); - m_ptr_obj = tuple_frontend->GetChildAtIndex(0); - if (m_ptr_obj) - m_ptr_obj->SetName(ConstString("pointer")); - - m_del_obj = tuple_frontend->GetChildAtIndex(1); - if (m_del_obj) - m_del_obj->SetName(ConstString("deleter")); + ValueObjectSP ptr_obj = tuple_frontend->GetChildAtIndex(0); + if (ptr_obj) + m_ptr_obj = ptr_obj->Clone(ConstString("pointer")); + + ValueObjectSP del_obj = tuple_frontend->GetChildAtIndex(1); + if (del_obj) + m_del_obj = del_obj->Clone(ConstString("deleter")); if (m_ptr_obj) { Error error; - m_obj_obj = m_ptr_obj->Dereference(error); + ValueObjectSP obj_obj = m_ptr_obj->Dereference(error); if (error.Success()) { - m_obj_obj->SetName(ConstString("object")); + m_obj_obj = obj_obj->Clone(ConstString("object")); } }