diff options
author | Zachary Turner <zturner@google.com> | 2016-09-23 17:48:13 +0000 |
---|---|---|
committer | Zachary Turner <zturner@google.com> | 2016-09-23 17:48:13 +0000 |
commit | 8cef4b0bb4bae8598efa7cd1274e54f534b0f4a4 (patch) | |
tree | 1ce2972876d13303fcd7f12d5774f806921d3421 /lldb/source/Interpreter/OptionGroupFormat.cpp | |
parent | 6c46efba7818644ddab8d8c52940583c0672fd98 (diff) | |
download | bcm5719-llvm-8cef4b0bb4bae8598efa7cd1274e54f534b0f4a4.tar.gz bcm5719-llvm-8cef4b0bb4bae8598efa7cd1274e54f534b0f4a4.zip |
Update OptionGroup::SetValue to take StringRef.
Then deal with all the fallout.
Differential Revision: https://reviews.llvm.org/D24847
llvm-svn: 282265
Diffstat (limited to 'lldb/source/Interpreter/OptionGroupFormat.cpp')
-rw-r--r-- | lldb/source/Interpreter/OptionGroupFormat.cpp | 30 |
1 files changed, 11 insertions, 19 deletions
diff --git a/lldb/source/Interpreter/OptionGroupFormat.cpp b/lldb/source/Interpreter/OptionGroupFormat.cpp index 0e5cd2bfc2b..c97d16ad986 100644 --- a/lldb/source/Interpreter/OptionGroupFormat.cpp +++ b/lldb/source/Interpreter/OptionGroupFormat.cpp @@ -59,7 +59,7 @@ llvm::ArrayRef<OptionDefinition> OptionGroupFormat::GetDefinitions() { } Error OptionGroupFormat::SetOptionValue(uint32_t option_idx, - const char *option_arg, + llvm::StringRef option_arg, ExecutionContext *execution_context) { Error error; const int short_option = g_option_table[option_idx].short_option; @@ -76,7 +76,7 @@ Error OptionGroupFormat::SetOptionValue(uint32_t option_idx, error = m_count.SetValueFromString(option_arg); if (m_count.GetCurrentValue() == 0) error.SetErrorStringWithFormat("invalid --count option value '%s'", - option_arg); + option_arg.str().c_str()); } break; @@ -87,41 +87,33 @@ Error OptionGroupFormat::SetOptionValue(uint32_t option_idx, error = m_byte_size.SetValueFromString(option_arg); if (m_byte_size.GetCurrentValue() == 0) error.SetErrorStringWithFormat("invalid --size option value '%s'", - option_arg); + option_arg.str().c_str()); } break; case 'G': { - char *end = nullptr; - const char *gdb_format_cstr = option_arg; uint64_t count = 0; - if (::isdigit(gdb_format_cstr[0])) { - count = strtoull(gdb_format_cstr, &end, 0); - - if (option_arg != end) - gdb_format_cstr = - end; // We have a valid count, advance the string position - else - count = 0; - } + llvm::StringRef gdb_format_str = option_arg; + gdb_format_str.consumeInteger(0, count); Format format = eFormatDefault; uint32_t byte_size = 0; - while (ParserGDBFormatLetter(execution_context, gdb_format_cstr[0], format, + while (!gdb_format_str.empty() && + ParserGDBFormatLetter(execution_context, gdb_format_str[0], format, byte_size)) { - ++gdb_format_cstr; + gdb_format_str = gdb_format_str.drop_front(); } - // We the first character of the "gdb_format_cstr" is not the + // We the first character of the "gdb_format_str" is not the // NULL terminator, we didn't consume the entire string and // something is wrong. Also, if none of the format, size or count // was specified correctly, then abort. - if (gdb_format_cstr[0] || + if (!gdb_format_str.empty() || (format == eFormatInvalid && byte_size == 0 && count == 0)) { // Nothing got set correctly error.SetErrorStringWithFormat("invalid gdb format string '%s'", - option_arg); + option_arg.str().c_str()); return error; } |