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,
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; }
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;
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);
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: {
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;
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())));
}
}
}
std::unique_ptr<SyntheticChildrenFrontEnd> tuple_frontend(
LibStdcppTupleSyntheticFrontEndCreator(nullptr, tuple_sp));
- m_ptr_obj = tuple_frontend->GetChildAtIndex(0);
- if (m_ptr_obj)
- m_ptr_obj->SetName(ConstString("pointer"));
+ ValueObjectSP ptr_obj = tuple_frontend->GetChildAtIndex(0);
+ if (ptr_obj)
+ m_ptr_obj = ptr_obj->Clone(ConstString("pointer"));
- m_del_obj = tuple_frontend->GetChildAtIndex(1);
- if (m_del_obj)
- m_del_obj->SetName(ConstString("deleter"));
+ 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"));
}
}