diff options
author | Zachary Turner <zturner@google.com> | 2016-11-12 16:56:47 +0000 |
---|---|---|
committer | Zachary Turner <zturner@google.com> | 2016-11-12 16:56:47 +0000 |
commit | fe11483b57c1dc6a6758725e6de0d6804ec59ed1 (patch) | |
tree | af50255449e1a57e1a528735cfa3458a5e9e66d2 /lldb/source/Commands/CommandObjectProcess.cpp | |
parent | c351fb16079ae8c88e868960829107a823a86246 (diff) | |
download | bcm5719-llvm-fe11483b57c1dc6a6758725e6de0d6804ec59ed1.tar.gz bcm5719-llvm-fe11483b57c1dc6a6758725e6de0d6804ec59ed1.zip |
Make Options::SetOptionValue take a StringRef.
llvm-svn: 286723
Diffstat (limited to 'lldb/source/Commands/CommandObjectProcess.cpp')
-rw-r--r-- | lldb/source/Commands/CommandObjectProcess.cpp | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp index ef927d81db7..5d255218c93 100644 --- a/lldb/source/Commands/CommandObjectProcess.cpp +++ b/lldb/source/Commands/CommandObjectProcess.cpp @@ -337,21 +337,20 @@ public: ~CommandOptions() override = default; - Error SetOptionValue(uint32_t option_idx, const char *option_arg, + Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override { Error error; const int short_option = m_getopt_table[option_idx].val; - bool success = false; switch (short_option) { case 'c': attach_info.SetContinueOnceAttached(true); break; case 'p': { - lldb::pid_t pid = StringConvert::ToUInt32( - option_arg, LLDB_INVALID_PROCESS_ID, 0, &success); - if (!success || pid == LLDB_INVALID_PROCESS_ID) { - error.SetErrorStringWithFormat("invalid process ID '%s'", option_arg); + lldb::pid_t pid; + if (option_arg.getAsInteger(0, pid)) { + error.SetErrorStringWithFormat("invalid process ID '%s'", + option_arg.str().c_str()); } else { attach_info.SetProcessID(pid); } @@ -604,18 +603,16 @@ protected: ~CommandOptions() override = default; - Error SetOptionValue(uint32_t option_idx, const char *option_arg, + Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override { Error error; const int short_option = m_getopt_table[option_idx].val; - bool success = false; switch (short_option) { case 'i': - m_ignore = StringConvert::ToUInt32(option_arg, 0, 0, &success); - if (!success) + if (option_arg.getAsInteger(0, m_ignore)) error.SetErrorStringWithFormat( "invalid value for ignore option: \"%s\", should be a number.", - option_arg); + option_arg.str().c_str()); break; default: @@ -755,20 +752,19 @@ public: ~CommandOptions() override = default; - Error SetOptionValue(uint32_t option_idx, const char *option_arg, + Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override { Error error; const int short_option = m_getopt_table[option_idx].val; - auto option_strref = llvm::StringRef::withNullAsEmpty(option_arg); switch (short_option) { case 's': bool tmp_result; bool success; - tmp_result = Args::StringToBoolean(option_strref, false, &success); + tmp_result = Args::StringToBoolean(option_arg, false, &success); if (!success) error.SetErrorStringWithFormat("invalid boolean option: \"%s\"", - option_arg); + option_arg.str().c_str()); else { if (tmp_result) m_keep_stopped = eLazyBoolYes; @@ -859,7 +855,7 @@ public: ~CommandOptions() override = default; - Error SetOptionValue(uint32_t option_idx, const char *option_arg, + Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override { Error error; const int short_option = m_getopt_table[option_idx].val; @@ -988,14 +984,14 @@ public: ~CommandOptions() override = default; - Error SetOptionValue(uint32_t option_idx, const char *option_arg, + Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override { Error error; const int short_option = m_getopt_table[option_idx].val; switch (short_option) { case 'i': do_install = true; - if (option_arg && option_arg[0]) + if (!option_arg.empty()) install_path.SetFile(option_arg, false); break; default: @@ -1382,7 +1378,7 @@ public: ~CommandOptions() override = default; - Error SetOptionValue(uint32_t option_idx, const char *option_arg, + Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override { Error error; const int short_option = m_getopt_table[option_idx].val; |