57
57
#include " llvm/ADT/STLExtras.h"
58
58
#include " llvm/ADT/StringRef.h"
59
59
#include " llvm/Support/Compiler.h"
60
- #include " llvm/Support/Regex.h"
61
60
#include " llvm/TargetParser/Triple.h"
62
61
63
62
#include < cctype>
@@ -659,38 +658,6 @@ static char ConvertValueObjectStyleToChar(
659
658
return ' \0 ' ;
660
659
}
661
660
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
-
694
661
static bool DumpValue (Stream &s, const SymbolContext *sc,
695
662
const ExecutionContext *exe_ctx,
696
663
const FormatEntity::Entry &entry, ValueObject *valobj) {
@@ -761,12 +728,9 @@ static bool DumpValue(Stream &s, const SymbolContext *sc,
761
728
return RunScriptFormatKeyword (s, sc, exe_ctx, valobj, entry.string .c_str ());
762
729
}
763
730
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 );
768
732
// simplest case ${var}, just print valobj's value
769
- if (subpath .empty ()) {
733
+ if (entry. string .empty ()) {
770
734
if (entry.printf_format .empty () && entry.fmt == eFormatDefault &&
771
735
entry.number == ValueObject::eValueObjectRepresentationStyleValue)
772
736
was_plain_var = true ;
@@ -775,19 +739,22 @@ static bool DumpValue(Stream &s, const SymbolContext *sc,
775
739
target = valobj;
776
740
} else // this is ${var.something} or multiple .something nested
777
741
{
778
- if (subpath [0 ] == ' [' )
742
+ if (entry. string [0 ] == ' [' )
779
743
was_var_indexed = true ;
780
744
ScanBracketedRange (subpath, close_bracket_index,
781
745
var_name_final_if_array_range, index_lower,
782
746
index_higher);
783
747
784
748
Status error;
785
749
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 ());
787
754
788
755
target =
789
756
valobj
790
- ->GetValueForExpressionPath (subpath , &reason_to_stop,
757
+ ->GetValueForExpressionPath (expr_path. c_str () , &reason_to_stop,
791
758
&final_value_type, options, &what_next)
792
759
.get ();
793
760
@@ -916,18 +883,8 @@ static bool DumpValue(Stream &s, const SymbolContext *sc,
916
883
}
917
884
918
885
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" );
931
888
return target->DumpPrintableRepresentation (s, val_obj_display,
932
889
custom_format);
933
890
} else {
@@ -2270,13 +2227,6 @@ static Status ParseInternal(llvm::StringRef &format, Entry &parent_entry,
2270
2227
if (error.Fail ())
2271
2228
return error;
2272
2229
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
-
2280
2230
if (verify_is_thread_id) {
2281
2231
if (entry.type != Entry::Type::ThreadID &&
2282
2232
entry.type != Entry::Type::ThreadProtocolID) {
0 commit comments