[Lldb-commits] [lldb] [lldb] Make sure Blocks always have a parent (PR #117683)

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Tue Nov 26 02:12:32 PST 2024


================
@@ -399,11 +392,9 @@ size_t Block::MemorySize() const {
   return mem_size;
 }
 
-void Block::AddChild(const BlockSP &child_block_sp) {
-  if (child_block_sp) {
-    child_block_sp->SetParentScope(this);
-    m_children.push_back(child_block_sp);
-  }
+BlockSP Block::CreateChild(user_id_t uid) {
+  m_children.push_back(std::shared_ptr<Block>(new Block(uid, *this)));
----------------
labath wrote:

make_shared won't work because that constructor is private. I think protecting that one is important as it ensures the integrity of the parent-child links.

That said, the tagged constructor approach does make it possible to use `make_shared`, so this could be another argument in favour of it.

https://github.com/llvm/llvm-project/pull/117683


More information about the lldb-commits mailing list