@@ -440,23 +440,20 @@ static llvm::Error AddVariableInfo(
440440}
441441
442442// / Collets all the variables visible in the current scope.
443- static bool CollectVariablesInScope (SymbolContext &sc,
443+ static void CollectVariablesInScope (SymbolContext &sc,
444444 lldb::StackFrameSP &stack_frame_sp,
445445 VariableList &variables) {
446- if (!sc.block && !sc.function )
447- return true ;
448-
449446 Block *block = sc.block ;
450- Block *top_block = block->GetContainingInlinedBlock ();
447+ Block *top_block = block ? block ->GetContainingInlinedBlock () : nullptr ;
451448
452- if (!top_block)
449+ if (!top_block && sc. function )
453450 top_block = &sc.function ->GetBlock (true );
454451
455452 // The module scoped variables are stored at the CompUnit level, so
456453 // after we go through the current context, then we have to take one
457454 // more pass through the variables in the CompUnit.
458455 bool done = false ;
459- do {
456+ while (block) {
460457 // Iterate over all parent contexts *including* the top_block.
461458 if (block == top_block)
462459 done = true ;
@@ -468,9 +465,10 @@ static bool CollectVariablesInScope(SymbolContext &sc,
468465 can_create, get_parent_variables, stop_if_block_is_inlined_function,
469466 [](Variable *) { return true ; }, &variables);
470467
471- if (!done)
472- block = block->GetParent ();
473- } while (block && !done);
468+ if (done)
469+ break ;
470+ block = block->GetParent ();
471+ }
474472
475473 // Also add local copies of globals. This is in many cases redundant
476474 // work because the globals would also be found in the expression
@@ -483,7 +481,6 @@ static bool CollectVariablesInScope(SymbolContext &sc,
483481 if (globals_sp)
484482 variables.AddVariables (globals_sp.get ());
485483 }
486- return true ;
487484}
488485
489486// / Create a \c VariableInfo record for each visible variable.
0 commit comments