@@ -286,6 +286,9 @@ bool Disassembler::ElideMixedSourceAndDisassemblyLine(
286286 return false ;
287287}
288288
289+ const std::string VariableAnnotator::kUndefLocationFormatted =
290+ llvm::formatv (" <{0}>" , kUndefLocation ).str();
291+
289292// For each instruction, this block attempts to resolve in-scope variables
290293// and determine if the current PC falls within their
291294// DWARF location entry. If so, it prints a simplified annotation using the
@@ -309,15 +312,16 @@ std::vector<std::string> VariableAnnotator::Annotate(Instruction &inst,
309312
310313 for (const auto &annotation : structured_annotations) {
311314 std::string display_string;
312- display_string =
313- llvm::formatv (
314- " {0} = {1}" , annotation.variable_name ,
315- annotation.location_description == VariableAnnotator::kUndefLocation
316- ? llvm::formatv (" <{0}>" , VariableAnnotator::kUndefLocation )
317- .str ()
318- : annotation.location_description )
319- .str ();
320- events.push_back (display_string);
315+ llvm::raw_string_ostream os (display_string);
316+
317+ os << annotation.variable_name ;
318+ os << " = " ;
319+ os << (annotation.location_description == VariableAnnotator::kUndefLocation
320+ ? VariableAnnotator::kUndefLocationFormatted
321+ : annotation.location_description );
322+ os.flush ();
323+
324+ events.push_back (std::move (display_string));
321325 }
322326
323327 return events;
@@ -423,11 +427,11 @@ VariableAnnotator::AnnotateStructured(Instruction &inst, Target &target,
423427 if (const char *type_str = type->GetName ().AsCString ())
424428 type_name = type_str;
425429
426- current_vars.try_emplace (v-> GetID (),
427- VariableAnnotation{ std::string (name), std::string (loc ),
428- true , entry. expr -> GetRegisterKind () ,
429- entry.file_range , decl_file ,
430- decl_line, type_name});
430+ current_vars.try_emplace (
431+ v-> GetID ( ),
432+ VariableAnnotation{ std::string (name), std::string (loc), true ,
433+ entry.expr -> GetRegisterKind (), entry. file_range ,
434+ decl_file, decl_line, type_name});
431435 }
432436
433437 // Diff m_live_vars → current_vars.
0 commit comments