1 //===-- LibCxxQueue.cpp ---------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
10 #include "lldb/DataFormatters/FormattersHelpers.h"
13 using namespace lldb_private
;
17 class QueueFrontEnd
: public SyntheticChildrenFrontEnd
{
19 QueueFrontEnd(ValueObject
&valobj
) : SyntheticChildrenFrontEnd(valobj
) {
23 size_t GetIndexOfChildWithName(ConstString name
) override
{
24 return m_container_sp
? m_container_sp
->GetIndexOfChildWithName(name
)
28 bool MightHaveChildren() override
{ return true; }
29 lldb::ChildCacheState
Update() override
;
31 llvm::Expected
<uint32_t> CalculateNumChildren() override
{
32 return m_container_sp
? m_container_sp
->GetNumChildren() : 0;
35 ValueObjectSP
GetChildAtIndex(uint32_t idx
) override
{
36 return m_container_sp
? m_container_sp
->GetChildAtIndex(idx
)
41 // The lifetime of a ValueObject and all its derivative ValueObjects
42 // (children, clones, etc.) is managed by a ClusterManager. These
43 // objects are only destroyed when every shared pointer to any of them
44 // is destroyed, so we must not store a shared pointer to any ValueObject
45 // derived from our backend ValueObject (since we're in the same cluster).
46 ValueObject
* m_container_sp
= nullptr;
50 lldb::ChildCacheState
QueueFrontEnd::Update() {
51 m_container_sp
= nullptr;
52 ValueObjectSP c_sp
= m_backend
.GetChildMemberWithName("c");
54 return lldb::ChildCacheState::eRefetch
;
55 m_container_sp
= c_sp
->GetSyntheticValue().get();
56 return lldb::ChildCacheState::eRefetch
;
59 SyntheticChildrenFrontEnd
*
60 formatters::LibcxxQueueFrontEndCreator(CXXSyntheticChildren
*,
61 lldb::ValueObjectSP valobj_sp
) {
63 return new QueueFrontEnd(*valobj_sp
);