[lldb][NFC] Don't inherit from UserID in ValueObject

ValueObject inherits from UserID which is just a bad idea:

* The inheritance gives ValueObject some member functions that are at best
  misleading (such as `Clear()` which doesn't clear any value beside `id`).

* It allows passing ValueObject to the overloaded operators for UserID (such as
  `==` or `<<` which won't actually compare or print anything in the ValueObject).

* It exposes the `SetID` and `Clear` which both allow users to change the
  internal id value.

Similar to D91699 which did the same for Process

Reviewed By: #lldb, JDevlieghere

Differential Revision: https://reviews.llvm.org/D97205
This commit is contained in:
Raphael Isemann
2021-02-23 10:14:43 +01:00
parent f8b9035aae
commit d77e3c6aec
3 changed files with 13 additions and 8 deletions

View File

@@ -76,9 +76,8 @@ static user_id_t g_value_obj_uid = 0;
// ValueObject constructor
ValueObject::ValueObject(ValueObject &parent)
: UserID(++g_value_obj_uid), // Unique identifier for every value object
m_parent(&parent), m_update_point(parent.GetUpdatePoint()),
m_manager(parent.GetManager()) {
: m_parent(&parent), m_update_point(parent.GetUpdatePoint()),
m_manager(parent.GetManager()), m_id(++g_value_obj_uid) {
m_flags.m_is_synthetic_children_generated =
parent.m_flags.m_is_synthetic_children_generated;
m_data.SetByteOrder(parent.GetDataExtractor().GetByteOrder());
@@ -90,9 +89,9 @@ ValueObject::ValueObject(ValueObject &parent)
ValueObject::ValueObject(ExecutionContextScope *exe_scope,
ValueObjectManager &manager,
AddressType child_ptr_or_ref_addr_type)
: UserID(++g_value_obj_uid), // Unique identifier for every value object
m_update_point(exe_scope), m_manager(&manager),
m_address_type_of_ptr_or_ref_children(child_ptr_or_ref_addr_type) {
: m_update_point(exe_scope), m_manager(&manager),
m_address_type_of_ptr_or_ref_children(child_ptr_or_ref_addr_type),
m_id(++g_value_obj_uid) {
if (exe_scope) {
TargetSP target_sp(exe_scope->CalculateTarget());
if (target_sp) {