@@ -382,7 +382,7 @@ ValueObjectSP ValueObject::GetChildAtIndex(uint32_t idx, bool can_create) {
382382 if (can_create && !m_children.HasChildAtIndex (idx)) {
383383 // No we haven't created the child at this index, so lets have our
384384 // subclass do it and cache the result for quick future access.
385- m_children.SetChildAtIndex (idx, CreateChildAtIndex (idx, false , 0 ));
385+ m_children.SetChildAtIndex (idx, CreateChildAtIndex (idx));
386386 }
387387
388388 ValueObject *child = m_children.GetChildAtIndex (idx);
@@ -488,66 +488,85 @@ void ValueObject::SetNumChildren(uint32_t num_children) {
488488 m_children.SetChildrenCount (num_children);
489489}
490490
491- ValueObject *ValueObject::CreateChildAtIndex (size_t idx,
492- bool synthetic_array_member,
493- int32_t synthetic_index) {
494- ValueObject *valobj = nullptr ;
495-
491+ ValueObject *ValueObject::CreateChildAtIndex (size_t idx) {
496492 bool omit_empty_base_classes = true ;
497- bool ignore_array_bounds = synthetic_array_member ;
498- std::string child_name_str ;
493+ bool ignore_array_bounds = false ;
494+ std::string child_name ;
499495 uint32_t child_byte_size = 0 ;
500496 int32_t child_byte_offset = 0 ;
501497 uint32_t child_bitfield_bit_size = 0 ;
502498 uint32_t child_bitfield_bit_offset = 0 ;
503499 bool child_is_base_class = false ;
504500 bool child_is_deref_of_parent = false ;
505501 uint64_t language_flags = 0 ;
506-
507- const bool transparent_pointers = !synthetic_array_member;
502+ const bool transparent_pointers = true ;
508503
509504 ExecutionContext exe_ctx (GetExecutionContextRef ());
510505
511506 auto child_compiler_type_or_err =
512507 GetCompilerType ().GetChildCompilerTypeAtIndex (
513508 &exe_ctx, idx, transparent_pointers, omit_empty_base_classes,
514- ignore_array_bounds, child_name_str , child_byte_size,
515- child_byte_offset, child_bitfield_bit_size, child_bitfield_bit_offset,
509+ ignore_array_bounds, child_name , child_byte_size, child_byte_offset ,
510+ child_bitfield_bit_size, child_bitfield_bit_offset,
516511 child_is_base_class, child_is_deref_of_parent, this , language_flags);
517- CompilerType child_compiler_type;
518- if (!child_compiler_type_or_err)
512+ if (!child_compiler_type_or_err || !child_compiler_type_or_err->IsValid ()) {
519513 LLDB_LOG_ERROR (GetLog (LLDBLog::Types),
520514 child_compiler_type_or_err.takeError (),
521515 " could not find child: {0}" );
522- else
523- child_compiler_type = *child_compiler_type_or_err;
516+ return nullptr ;
517+ }
518+
519+ return new ValueObjectChild (
520+ *this , *child_compiler_type_or_err, ConstString (child_name),
521+ child_byte_size, child_byte_offset, child_bitfield_bit_size,
522+ child_bitfield_bit_offset, child_is_base_class, child_is_deref_of_parent,
523+ eAddressTypeInvalid, language_flags);
524+ }
525+
526+ ValueObject *ValueObject::CreateSyntheticArrayMember (size_t idx) {
527+ bool omit_empty_base_classes = true ;
528+ bool ignore_array_bounds = true ;
529+ std::string child_name;
530+ uint32_t child_byte_size = 0 ;
531+ int32_t child_byte_offset = 0 ;
532+ uint32_t child_bitfield_bit_size = 0 ;
533+ uint32_t child_bitfield_bit_offset = 0 ;
534+ bool child_is_base_class = false ;
535+ bool child_is_deref_of_parent = false ;
536+ uint64_t language_flags = 0 ;
537+ const bool transparent_pointers = false ;
524538
525- if (child_compiler_type) {
526- if (synthetic_index)
527- child_byte_offset += child_byte_size * synthetic_index;
539+ ExecutionContext exe_ctx (GetExecutionContextRef ());
528540
529- ConstString child_name;
530- if (!child_name_str.empty ())
531- child_name.SetCString (child_name_str.c_str ());
541+ auto child_compiler_type_or_err =
542+ GetCompilerType ().GetChildCompilerTypeAtIndex (
543+ &exe_ctx, 0 , transparent_pointers, omit_empty_base_classes,
544+ ignore_array_bounds, child_name, child_byte_size, child_byte_offset,
545+ child_bitfield_bit_size, child_bitfield_bit_offset,
546+ child_is_base_class, child_is_deref_of_parent, this , language_flags);
547+ if (!child_compiler_type_or_err) {
548+ LLDB_LOG_ERROR (GetLog (LLDBLog::Types),
549+ child_compiler_type_or_err.takeError (),
550+ " could not find child: {0}" );
551+ return nullptr ;
552+ }
553+
554+ if (child_compiler_type_or_err->IsValid ()) {
555+ child_byte_offset += child_byte_size * idx;
532556
533- valobj = new ValueObjectChild (
534- *this , child_compiler_type, child_name, child_byte_size ,
535- child_byte_offset, child_bitfield_bit_size, child_bitfield_bit_offset ,
536- child_is_base_class, child_is_deref_of_parent, eAddressTypeInvalid ,
537- language_flags);
557+ return new ValueObjectChild (
558+ *this , *child_compiler_type_or_err, ConstString ( child_name) ,
559+ child_byte_size, child_byte_offset, child_bitfield_bit_size ,
560+ child_bitfield_bit_offset, child_is_base_class ,
561+ child_is_deref_of_parent, eAddressTypeInvalid, language_flags);
538562 }
539563
540564 // In case of an incomplete type, try to use the ValueObject's
541565 // synthetic value to create the child ValueObject.
542- if (!valobj && synthetic_array_member) {
543- if (ValueObjectSP synth_valobj_sp = GetSyntheticValue ()) {
544- valobj = synth_valobj_sp
545- ->GetChildAtIndex (synthetic_index, synthetic_array_member)
546- .get ();
547- }
548- }
566+ if (ValueObjectSP synth_valobj_sp = GetSyntheticValue ())
567+ return synth_valobj_sp->GetChildAtIndex (idx, /* can_create=*/ true ).get ();
549568
550- return valobj ;
569+ return nullptr ;
551570}
552571
553572bool ValueObject::GetSummaryAsCString (TypeSummaryImpl *summary_ptr,
@@ -1616,7 +1635,7 @@ ValueObjectSP ValueObject::GetSyntheticArrayMember(size_t index,
16161635 ValueObject *synthetic_child;
16171636 // We haven't made a synthetic array member for INDEX yet, so lets make
16181637 // one and cache it for any future reference.
1619- synthetic_child = CreateChildAtIndex ( 0 , true , index);
1638+ synthetic_child = CreateSyntheticArrayMember ( index);
16201639
16211640 // Cache the value if we got one back...
16221641 if (synthetic_child) {
0 commit comments