Patch for ValueObjectPrinter::PrintChildrenIfNeeded

I couldn't figure out how to post a patch to, so here it is per email, with the hope that someone adopts it :slight_smile:

Basically it's just moving the `bool print_oneline` out of the execution path, if no children are

printed, since this value is then never used. This may not seem like a big deal, but solves a big

problem in my debugger :slight_smile:

void ValueObjectPrinter::PrintChildrenIfNeeded(bool value_printed,
                                                bool summary_printed) {
   // this flag controls whether we tried to display a description for this
   // object and failed if that happens, we want to display the children, if any
   bool is_failed_description =
       !PrintObjectDescriptionIfNeeded(value_printed, summary_printed);

   auto curr_ptr_depth = m_ptr_depth;
   bool print_children =
       ShouldPrintChildren(is_failed_description, curr_ptr_depth);

   // DataVisualization::ShouldPrintAsOneLiner is often called for
   // print_oneline (see below) and it is very expensive, so use an
   // early exit, if we are not printing children (also easier to read)
   if (!print_children) {
     if (m_curr_depth >= m_options.m_max_depth && IsAggregate() &&
                ShouldPrintValueObject()) {
     } else

   // TODO: maybe move the bool print_oneline line to #1#, but its unclear to
   // me if DataVisualization::ShouldPrintAsOneLiner can modify *m_valobj or not
   bool print_oneline =
       (curr_ptr_depth.CanAllowExpansion() || m_options.m_show_types ||
        !m_options.m_allow_oneliner_mode || m_options.m_flat_output ||
        (m_options.m_pointer_as_array) || m_options.m_show_location)
           ? false
           : DataVisualization::ShouldPrintAsOneLiner(*m_valobj);

   bool is_instance_ptr = IsInstancePointer();
   uint64_t instance_ptr_value = LLDB_INVALID_ADDRESS;

   if (is_instance_ptr) {
     instance_ptr_value = m_valobj->GetValueAsUnsigned(0);
     if (m_printed_instance_pointers->count(instance_ptr_value)) {
       // we already printed this instance-is-pointer thing, so don't expand it
       m_stream->PutCString(" {...}\n");

       // we're done here - get out fast
     } else
           instance_ptr_value); // remember this guy for future reference

   // #1#
   if (print_oneline) {
     m_stream->PutChar(' ');
   } else
     PrintChildren(value_printed, summary_printed, curr_ptr_depth);



Hi Nat!,

The best way to do this is to go to .
Under Differential, click Create Diff, then paste in the raw diff for your patch.
We like to see a full context diff, so reviewers can easily see the full file.

More info on how to submit a patch here: