5757#include " llvm/ADT/STLExtras.h"
5858#include " llvm/ADT/StringRef.h"
5959#include " llvm/Support/Compiler.h"
60- #include " llvm/Support/Regex.h"
6160#include " llvm/TargetParser/Triple.h"
6261
6362#include < cctype>
@@ -659,38 +658,6 @@ static char ConvertValueObjectStyleToChar(
659658 return ' \0 ' ;
660659}
661660
662- static llvm::Regex LLVMFormatPattern{" x[-+]?\\ d*|n|d" , llvm::Regex::IgnoreCase};
663-
664- static bool DumpValueWithLLVMFormat (Stream &s, llvm::StringRef options,
665- ValueObject &valobj) {
666- std::string formatted;
667- std::string llvm_format = (" {0:" + options + " }" ).str ();
668-
669- // Options supported by format_provider<T> for integral arithmetic types.
670- // See table in FormatProviders.h.
671-
672- auto type_info = valobj.GetTypeInfo ();
673- if (type_info & eTypeIsInteger && LLVMFormatPattern.match (options)) {
674- if (type_info & eTypeIsSigned) {
675- bool success = false ;
676- int64_t integer = valobj.GetValueAsSigned (0 , &success);
677- if (success)
678- formatted = llvm::formatv (llvm_format.data (), integer);
679- } else {
680- bool success = false ;
681- uint64_t integer = valobj.GetValueAsUnsigned (0 , &success);
682- if (success)
683- formatted = llvm::formatv (llvm_format.data (), integer);
684- }
685- }
686-
687- if (formatted.empty ())
688- return false ;
689-
690- s.Write (formatted.data (), formatted.size ());
691- return true ;
692- }
693-
694661static bool DumpValue (Stream &s, const SymbolContext *sc,
695662 const ExecutionContext *exe_ctx,
696663 const FormatEntity::Entry &entry, ValueObject *valobj) {
@@ -761,12 +728,9 @@ static bool DumpValue(Stream &s, const SymbolContext *sc,
761728 return RunScriptFormatKeyword (s, sc, exe_ctx, valobj, entry.string .c_str ());
762729 }
763730
764- auto split = llvm::StringRef (entry.string ).split (' :' );
765- auto subpath = split.first ;
766- auto llvm_format = split.second ;
767-
731+ llvm::StringRef subpath (entry.string );
768732 // simplest case ${var}, just print valobj's value
769- if (subpath .empty ()) {
733+ if (entry. string .empty ()) {
770734 if (entry.printf_format .empty () && entry.fmt == eFormatDefault &&
771735 entry.number == ValueObject::eValueObjectRepresentationStyleValue)
772736 was_plain_var = true ;
@@ -775,19 +739,22 @@ static bool DumpValue(Stream &s, const SymbolContext *sc,
775739 target = valobj;
776740 } else // this is ${var.something} or multiple .something nested
777741 {
778- if (subpath [0 ] == ' [' )
742+ if (entry. string [0 ] == ' [' )
779743 was_var_indexed = true ;
780744 ScanBracketedRange (subpath, close_bracket_index,
781745 var_name_final_if_array_range, index_lower,
782746 index_higher);
783747
784748 Status error;
785749
786- LLDB_LOG (log, " [Debugger::FormatPrompt] symbol to expand: {0}" , subpath);
750+ const std::string &expr_path = entry.string ;
751+
752+ LLDB_LOGF (log, " [Debugger::FormatPrompt] symbol to expand: %s" ,
753+ expr_path.c_str ());
787754
788755 target =
789756 valobj
790- ->GetValueForExpressionPath (subpath , &reason_to_stop,
757+ ->GetValueForExpressionPath (expr_path. c_str () , &reason_to_stop,
791758 &final_value_type, options, &what_next)
792759 .get ();
793760
@@ -916,18 +883,8 @@ static bool DumpValue(Stream &s, const SymbolContext *sc,
916883 }
917884
918885 if (!is_array_range) {
919- if (!llvm_format.empty ()) {
920- if (DumpValueWithLLVMFormat (s, llvm_format, *target)) {
921- LLDB_LOGF (log, " dumping using llvm format" );
922- return true ;
923- } else {
924- LLDB_LOG (
925- log,
926- " empty output using llvm format '{0}' - with type info flags {1}" ,
927- entry.printf_format , target->GetTypeInfo ());
928- }
929- }
930- LLDB_LOGF (log, " dumping ordinary printable output" );
886+ LLDB_LOGF (log,
887+ " [Debugger::FormatPrompt] dumping ordinary printable output" );
931888 return target->DumpPrintableRepresentation (s, val_obj_display,
932889 custom_format);
933890 } else {
@@ -2270,13 +2227,6 @@ static Status ParseInternal(llvm::StringRef &format, Entry &parent_entry,
22702227 if (error.Fail ())
22712228 return error;
22722229
2273- auto [_, llvm_format] = llvm::StringRef (entry.string ).split (' :' );
2274- if (!LLVMFormatPattern.match (llvm_format)) {
2275- error.SetErrorStringWithFormat (" invalid llvm format: '%s'" ,
2276- llvm_format.data ());
2277- return error;
2278- }
2279-
22802230 if (verify_is_thread_id) {
22812231 if (entry.type != Entry::Type::ThreadID &&
22822232 entry.type != Entry::Type::ThreadProtocolID) {
0 commit comments