@@ -330,8 +330,12 @@ VariableAnnotator::AnnotateStructured(Instruction &inst, Target &target,
330330
331331 // If we lost module context, mark all live variables as undefined.
332332 if (!module_sp) {
333- for (const auto &KV : Live_)
334- annotations.push_back (createAnnotation (KV.second , false , kUndefLocation ));
333+ for (const auto &KV : Live_) {
334+ auto annotation_entity = KV.second ;
335+ annotation_entity.is_live = false ;
336+ annotation_entity.location_description = kUndefLocation ;
337+ annotations.push_back (annotation_entity);
338+ }
335339 Live_.clear ();
336340 return annotations;
337341 }
@@ -343,8 +347,12 @@ VariableAnnotator::AnnotateStructured(Instruction &inst, Target &target,
343347 if (!module_sp->ResolveSymbolContextForAddress (iaddr, mask, sc) ||
344348 !sc.function ) {
345349 // No function context: everything dies here.
346- for (const auto &KV : Live_)
347- annotations.push_back (createAnnotation (KV.second , false , kUndefLocation ));
350+ for (const auto &KV : Live_) {
351+ auto annotation_entity = KV.second ;
352+ annotation_entity.is_live = false ;
353+ annotation_entity.location_description = kUndefLocation ;
354+ annotations.push_back (annotation_entity);
355+ }
348356 Live_.clear ();
349357 return annotations;
350358 }
@@ -373,7 +381,7 @@ VariableAnnotator::AnnotateStructured(Instruction &inst, Target &target,
373381 // Prefer "register-only" output when we have an ABI.
374382 opts.PrintRegisterOnly = static_cast <bool >(abi_sp);
375383
376- llvm::DenseMap<lldb::user_id_t , VarState > Current;
384+ llvm::DenseMap<lldb::user_id_t , VariableAnnotation > Current;
377385
378386 for (size_t i = 0 , e = var_list.GetSize (); i != e; ++i) {
379387 lldb::VariableSP v = var_list.GetVariableAtIndex (i);
@@ -422,10 +430,11 @@ VariableAnnotator::AnnotateStructured(Instruction &inst, Target &target,
422430 if (const char *type_str = type->GetName ().AsCString ())
423431 type_name = type_str;
424432
425- Current.try_emplace (
426- v->GetID (), VarState{std::string (name), std::string (loc), start_addr,
427- end_addr, entry.expr ->GetRegisterKind (), decl_file,
428- decl_line, type_name});
433+ Current.try_emplace (v->GetID (),
434+ VariableAnnotation{std::string (name), std::string (loc),
435+ start_addr, end_addr, true ,
436+ entry.expr ->GetRegisterKind (),
437+ decl_file, decl_line, type_name});
429438 }
430439
431440 // Diff Live_ → Current.
@@ -435,41 +444,33 @@ VariableAnnotator::AnnotateStructured(Instruction &inst, Target &target,
435444 auto it = Live_.find (KV.first );
436445 if (it == Live_.end ()) {
437446 // Newly live.
438- annotations.push_back (createAnnotation (KV.second , true ));
439- } else if (it->second .last_loc != KV.second .last_loc ) {
447+ auto annotation_entity = KV.second ;
448+ annotation_entity.is_live = true ;
449+ annotations.push_back (annotation_entity);
450+ } else if (it->second .location_description !=
451+ KV.second .location_description ) {
440452 // Location changed.
441- annotations.push_back (createAnnotation (KV.second , true ));
453+ auto annotation_entity = KV.second ;
454+ annotation_entity.is_live = true ;
455+ annotations.push_back (annotation_entity);
442456 }
443457 }
444458
445459 // 2) Ends: anything that was live but is not in Current becomes
446460 // <kUndefLocation>.
447461 for (const auto &KV : Live_)
448- if (!Current.count (KV.first ))
449- annotations.push_back (createAnnotation (KV.second , false , kUndefLocation ));
462+ if (!Current.count (KV.first )) {
463+ auto annotation_entity = KV.second ;
464+ annotation_entity.is_live = false ;
465+ annotation_entity.location_description = kUndefLocation ;
466+ annotations.push_back (annotation_entity);
467+ }
450468
451469 // Commit new state.
452470 Live_ = std::move (Current);
453471 return annotations;
454472}
455473
456- VariableAnnotation VariableAnnotator::createAnnotation (
457- const VarState &var_state, bool is_live,
458- const std::optional<std::string> &location_desc) {
459- VariableAnnotation annotation;
460- annotation.variable_name = var_state.name ;
461- annotation.location_description =
462- location_desc.has_value () ? *location_desc : var_state.last_loc ;
463- annotation.start_address = var_state.start_address ;
464- annotation.end_address = var_state.end_address ;
465- annotation.is_live = is_live;
466- annotation.register_kind = var_state.register_kind ;
467- annotation.decl_file = var_state.decl_file ;
468- annotation.decl_line = var_state.decl_line ;
469- annotation.type_name = var_state.type_name ;
470- return annotation;
471- }
472-
473474void Disassembler::PrintInstructions (Debugger &debugger, const ArchSpec &arch,
474475 const ExecutionContext &exe_ctx,
475476 bool mixed_source_and_assembly,
0 commit comments