15#include "llvm/Support/ErrorExtras.h"
22 stream.
Printf(
" Has Value=%s ",
39 GenericOptionalFrontend(
ValueObject &valobj, StdLib stdlib);
41 llvm::Expected<size_t> GetIndexOfChildWithName(
ConstString name)
override {
42 if (name ==
"$$dereference$$")
44 return llvm::createStringErrorV(
"type has no child named '{0}'", name);
48 return m_has_value ? 1U : 0U;
55 bool m_has_value =
false;
61GenericOptionalFrontend::GenericOptionalFrontend(
ValueObject &valobj,
64 if (
auto target_sp = m_backend.GetTargetSP()) {
72 if (m_stdlib == StdLib::LibCxx)
73 engaged_sp = m_backend.GetChildMemberWithName(
"__engaged_");
74 else if (m_stdlib == StdLib::LibStdcpp) {
75 if (
ValueObjectSP payload = m_backend.GetChildMemberWithName(
"_M_payload"))
76 engaged_sp = payload->GetChildMemberWithName(
"_M_engaged");
77 }
else if (m_stdlib == StdLib::MsvcStl)
78 engaged_sp = m_backend.GetChildMemberWithName(
"_Has_value");
86 m_has_value = engaged_sp->GetValueAsUnsigned(0) != 0;
91ValueObjectSP GenericOptionalFrontend::GetChildAtIndex(uint32_t _idx) {
97 if (m_stdlib == StdLib::LibCxx)
102 val_sp = m_backend.GetChildMemberWithName(
"__engaged_")
105 ->GetChildMemberWithName(
"__val_");
106 else if (m_stdlib == StdLib::LibStdcpp) {
107 val_sp = m_backend.GetChildMemberWithName(
"_M_payload")
108 ->GetChildMemberWithName(
"_M_payload");
112 ValueObjectSP candidate = val_sp->GetChildMemberWithName(
"_M_value");
115 }
else if (m_stdlib == StdLib::MsvcStl)
117 val_sp = m_backend.GetChildMemberWithName(
"_Has_value")
120 ->GetChildMemberWithName(
"_Value");
130 return val_sp->Clone(
"Value");
137 return new GenericOptionalFrontend(
138 *valobj_sp, GenericOptionalFrontend::StdLib::LibStdcpp);
145 return new GenericOptionalFrontend(*valobj_sp,
146 GenericOptionalFrontend::StdLib::LibCxx);
152 return valobj_sp->GetChildMemberWithName(
"_Has_value") !=
nullptr;
159 return new GenericOptionalFrontend(
160 *valobj_sp, GenericOptionalFrontend::StdLib::MsvcStl);
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 ...
Generic representation of a type in a programming language.
A uniqued constant string class.
A stream class that can stream formatted output to a file.
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
virtual lldb::ValueObjectSP GetNonSyntheticValue()
uint32_t GetNumChildrenIgnoringErrors(uint32_t max=UINT32_MAX)
Like GetNumChildren but returns 0 on error.
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