@@ -398,14 +398,10 @@ static bool AddVariableInfo(
398
398
return true ;
399
399
}
400
400
401
- // / Create a \c VariableInfo record for each visible variable.
402
- static bool RegisterAllVariables (
403
- SymbolContext &sc, lldb::StackFrameSP &stack_frame_sp,
404
- SwiftASTContextForExpressions &ast_context,
405
- llvm::SmallVectorImpl<SwiftASTManipulator::VariableInfo> &local_variables,
406
- lldb::DynamicValueType use_dynamic,
407
- lldb::BindGenericTypes bind_generic_types) {
408
- LLDB_SCOPED_TIMER ();
401
+ // / Collets all the variables visible in the current scope.
402
+ static bool CollectVariablesInScope (SymbolContext &sc,
403
+ lldb::StackFrameSP &stack_frame_sp,
404
+ VariableList &variables) {
409
405
if (!sc.block && !sc.function )
410
406
return true ;
411
407
@@ -415,20 +411,9 @@ static bool RegisterAllVariables(
415
411
if (!top_block)
416
412
top_block = &sc.function ->GetBlock (true );
417
413
418
- SwiftLanguageRuntime *language_runtime = nullptr ;
419
-
420
- if (stack_frame_sp)
421
- language_runtime =
422
- SwiftLanguageRuntime::Get (stack_frame_sp->GetThread ()->GetProcess ());
423
-
424
414
// The module scoped variables are stored at the CompUnit level, so
425
415
// after we go through the current context, then we have to take one
426
416
// more pass through the variables in the CompUnit.
427
- VariableList variables;
428
-
429
- // Proceed from the innermost scope outwards, adding all variables
430
- // not already shadowed by an inner declaration.
431
- llvm::SmallDenseSet<const char *, 8 > processed_names;
432
417
bool done = false ;
433
418
do {
434
419
// Iterate over all parent contexts *including* the top_block.
@@ -457,7 +442,29 @@ static bool RegisterAllVariables(
457
442
if (globals_sp)
458
443
variables.AddVariables (globals_sp.get ());
459
444
}
445
+ return true ;
446
+ }
447
+
448
+ // / Create a \c VariableInfo record for each visible variable.
449
+ static bool RegisterAllVariables (
450
+ SymbolContext &sc, lldb::StackFrameSP &stack_frame_sp,
451
+ SwiftASTContextForExpressions &ast_context,
452
+ llvm::SmallVectorImpl<SwiftASTManipulator::VariableInfo> &local_variables,
453
+ lldb::DynamicValueType use_dynamic,
454
+ lldb::BindGenericTypes bind_generic_types) {
455
+ LLDB_SCOPED_TIMER ();
456
+ SwiftLanguageRuntime *language_runtime = nullptr ;
457
+
458
+ if (stack_frame_sp)
459
+ language_runtime =
460
+ SwiftLanguageRuntime::Get (stack_frame_sp->GetThread ()->GetProcess ());
460
461
462
+ VariableList variables;
463
+ CollectVariablesInScope (sc, stack_frame_sp, variables);
464
+
465
+ // Proceed from the innermost scope outwards, adding all variables
466
+ // not already shadowed by an inner declaration.
467
+ llvm::SmallDenseSet<const char *, 8 > processed_names;
461
468
for (size_t vi = 0 , ve = variables.GetSize (); vi != ve; ++vi)
462
469
if (!AddVariableInfo ({variables.GetVariableAtIndex (vi)}, stack_frame_sp,
463
470
ast_context, language_runtime, processed_names,
0 commit comments