@@ -440,23 +440,22 @@ 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 = nullptr ;
448+ if (block)
449+ block->GetContainingInlinedBlock ();
451450
452- if (!top_block)
451+ if (!top_block && sc. function )
453452 top_block = &sc.function ->GetBlock (true );
454453
455454 // The module scoped variables are stored at the CompUnit level, so
456455 // after we go through the current context, then we have to take one
457456 // more pass through the variables in the CompUnit.
458457 bool done = false ;
459- do {
458+ while (block) {
460459 // Iterate over all parent contexts *including* the top_block.
461460 if (block == top_block)
462461 done = true ;
@@ -468,9 +467,10 @@ static bool CollectVariablesInScope(SymbolContext &sc,
468467 can_create, get_parent_variables, stop_if_block_is_inlined_function,
469468 [](Variable *) { return true ; }, &variables);
470469
471- if (!done)
472- block = block->GetParent ();
473- } while (block && !done);
470+ if (done)
471+ break ;
472+ block = block->GetParent ();
473+ }
474474
475475 // Also add local copies of globals. This is in many cases redundant
476476 // work because the globals would also be found in the expression
@@ -483,7 +483,6 @@ static bool CollectVariablesInScope(SymbolContext &sc,
483483 if (globals_sp)
484484 variables.AddVariables (globals_sp.get ());
485485 }
486- return true ;
487486}
488487
489488// / Create a \c VariableInfo record for each visible variable.
0 commit comments