LLDB mainline
MsvcStlUnordered.cpp
Go to the documentation of this file.
1//===-- MsvcStlUnordered.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 "MsvcStl.h"
11
12using namespace lldb;
13using namespace lldb_private;
14
15namespace {
16
17class UnorderedFrontEnd : public SyntheticChildrenFrontEnd {
18public:
19 UnorderedFrontEnd(ValueObject &valobj) : SyntheticChildrenFrontEnd(valobj) {
20 Update();
21 }
22
23 llvm::Expected<size_t> GetIndexOfChildWithName(ConstString name) override {
24 if (!m_list_sp)
25 return llvm::createStringError("Missing _List");
26 return m_list_sp->GetIndexOfChildWithName(name);
27 }
28
29 lldb::ChildCacheState Update() override;
30
31 llvm::Expected<uint32_t> CalculateNumChildren() override {
32 if (!m_list_sp)
33 return llvm::createStringError("Missing _List");
34 return m_list_sp->GetNumChildren();
35 }
36
37 ValueObjectSP GetChildAtIndex(uint32_t idx) override {
38 if (!m_list_sp)
39 return nullptr;
40 return m_list_sp->GetChildAtIndex(idx);
41 }
42
43private:
44 ValueObjectSP m_list_sp;
45};
46
47} // namespace
48
49lldb::ChildCacheState UnorderedFrontEnd::Update() {
50 m_list_sp = nullptr;
51 ValueObjectSP list_sp = m_backend.GetChildMemberWithName("_List");
52 if (!list_sp)
54 m_list_sp = list_sp->GetSyntheticValue();
56}
57
59 if (auto valobj_sp = valobj.GetNonSyntheticValue())
60 return valobj_sp->GetChildMemberWithName("_List") != nullptr;
61 return false;
62}
63
66 if (valobj_sp)
67 return new UnorderedFrontEnd(*valobj_sp);
68 return nullptr;
69}
static std::optional< size_t > CalculateNumChildren(CompilerType container_elem_type, uint64_t num_elements, CompilerType element_type)
Calculates the number of elements stored in a container (with element type 'container_elem_type') as ...
virtual lldb::ValueObjectSP GetNonSyntheticValue()
bool IsMsvcStlUnordered(ValueObject &valobj)
SyntheticChildrenFrontEnd * MsvcStlUnorderedSyntheticFrontEndCreator(CXXSyntheticChildren *, lldb::ValueObjectSP valobj_sp)
A class that represents a running process on the host machine.
ChildCacheState
Specifies if children need to be re-computed after a call to SyntheticChildrenFrontEnd::Update.
@ eRefetch
Children need to be recomputed dynamically.
std::shared_ptr< lldb_private::ValueObject > ValueObjectSP