/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/source/Plugins/Language/CPlusPlus/LibCxxQueue.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | //===-- LibCxxQueue.cpp ---------------------------------------------------===// |
2 | | // |
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 |
6 | | // |
7 | | //===----------------------------------------------------------------------===// |
8 | | |
9 | | #include "LibCxx.h" |
10 | | #include "lldb/DataFormatters/FormattersHelpers.h" |
11 | | |
12 | | using namespace lldb; |
13 | | using namespace lldb_private; |
14 | | |
15 | | namespace { |
16 | | |
17 | | class QueueFrontEnd : public SyntheticChildrenFrontEnd { |
18 | | public: |
19 | 8 | QueueFrontEnd(ValueObject &valobj) : SyntheticChildrenFrontEnd(valobj) { |
20 | 8 | Update(); |
21 | 8 | } |
22 | | |
23 | 0 | size_t GetIndexOfChildWithName(ConstString name) override { |
24 | 0 | return m_container_sp ? m_container_sp->GetIndexOfChildWithName(name) |
25 | 0 | : UINT32_MAX; |
26 | 0 | } |
27 | | |
28 | 0 | bool MightHaveChildren() override { return true; } |
29 | | bool Update() override; |
30 | | |
31 | 8 | size_t CalculateNumChildren() override { |
32 | 8 | return m_container_sp ? m_container_sp->GetNumChildren() : 00 ; |
33 | 8 | } |
34 | | |
35 | 24 | ValueObjectSP GetChildAtIndex(size_t idx) override { |
36 | 24 | return m_container_sp ? m_container_sp->GetChildAtIndex(idx) |
37 | 24 | : nullptr0 ; |
38 | 24 | } |
39 | | |
40 | | private: |
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; |
47 | | }; |
48 | | } // namespace |
49 | | |
50 | 18 | bool QueueFrontEnd::Update() { |
51 | 18 | m_container_sp = nullptr; |
52 | 18 | ValueObjectSP c_sp = m_backend.GetChildMemberWithName("c"); |
53 | 18 | if (!c_sp) |
54 | 0 | return false; |
55 | 18 | m_container_sp = c_sp->GetSyntheticValue().get(); |
56 | 18 | return false; |
57 | 18 | } |
58 | | |
59 | | SyntheticChildrenFrontEnd * |
60 | | formatters::LibcxxQueueFrontEndCreator(CXXSyntheticChildren *, |
61 | 8 | lldb::ValueObjectSP valobj_sp) { |
62 | 8 | if (valobj_sp) |
63 | 8 | return new QueueFrontEnd(*valobj_sp); |
64 | 0 | return nullptr; |
65 | 8 | } |