LLDB mainline
LibCxxRangesRefView.cpp
Go to the documentation of this file.
1//===-- LibCxxRangesRefView.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
14#include "llvm/ADT/APSInt.h"
15
16using namespace lldb;
17using namespace lldb_private;
18using namespace lldb_private::formatters;
19
20namespace lldb_private {
21namespace formatters {
22
25public:
27
29
30 llvm::Expected<uint32_t> CalculateNumChildren() override {
31 // __range_ will be the sole child of this type
32 return 1;
33 }
34
35 lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override {
36 // Since we only have a single child, return it
37 assert(idx == 0);
38 return m_range_sp;
39 }
40
42
43 bool MightHaveChildren() override { return true; }
44
45 size_t GetIndexOfChildWithName(ConstString name) override {
46 // We only have a single child
47 return 0;
48 }
49
50private:
51 /// Pointer to the dereferenced __range_ member
53};
54
57 : SyntheticChildrenFrontEnd(*valobj_sp) {
58 if (valobj_sp)
59 Update();
60}
61
64 ValueObjectSP range_ptr =
65 GetChildMemberWithName(m_backend, {ConstString("__range_")});
66 if (!range_ptr)
68
70 m_range_sp = range_ptr->Dereference(error);
71
72 return error.Success() ? lldb::ChildCacheState::eReuse
74}
75
78 lldb::ValueObjectSP valobj_sp) {
79 if (!valobj_sp)
80 return nullptr;
81 CompilerType type = valobj_sp->GetCompilerType();
82 if (!type.IsValid())
83 return nullptr;
84 return new LibcxxStdRangesRefViewSyntheticFrontEnd(valobj_sp);
85}
86
87} // namespace formatters
88} // namespace lldb_private
static llvm::raw_ostream & error(Stream &strm)
Generic representation of a type in a programming language.
Definition: CompilerType.h:36
A uniqued constant string class.
Definition: ConstString.h:40
An error handling class.
Definition: Status.h:115
lldb::ChildCacheState Update() override
This function is assumed to always succeed and if it fails, the front-end should know to deal with it...
lldb::ValueObjectSP m_range_sp
Pointer to the dereferenced __range_ member.
lldb::ValueObjectSP GetChildMemberWithName(ValueObject &obj, llvm::ArrayRef< ConstString > alternative_names)
Find a child member of obj_sp, trying all alternative names in order.
Definition: LibCxx.cpp:64
SyntheticChildrenFrontEnd * LibcxxStdRangesRefViewSyntheticFrontEndCreator(CXXSyntheticChildren *, lldb::ValueObjectSP)
A class that represents a running process on the host machine.
Definition: SBAddress.h:15
ChildCacheState
Specifies if children need to be re-computed after a call to SyntheticChildrenFrontEnd::Update.
@ eRefetch
Children need to be recomputed dynamically.
@ eReuse
Children did not change and don't need to be recomputed; re-use what we computed the last time we cal...
std::shared_ptr< lldb_private::ValueObject > ValueObjectSP
Definition: lldb-forward.h:484