diff options
author | Zachary Turner <zturner@google.com> | 2016-12-09 05:46:41 +0000 |
---|---|---|
committer | Zachary Turner <zturner@google.com> | 2016-12-09 05:46:41 +0000 |
commit | 2c84f908afc851a1ba83c6a8471a62db81475ef8 (patch) | |
tree | d51372b98dfbb090aafdab5dc233b32f790981d3 /lldb/source/Commands/CommandObjectRegister.cpp | |
parent | 8db7e5e4eed4c4e697dc3164f2c9351d8c3e942b (diff) | |
download | llvm-2c84f908afc851a1ba83c6a8471a62db81475ef8.zip llvm-2c84f908afc851a1ba83c6a8471a62db81475ef8.tar.gz llvm-2c84f908afc851a1ba83c6a8471a62db81475ef8.tar.bz2 |
Remove some more uses of Args::GetArgumentAtIndex.
llvm-svn: 289188
Diffstat (limited to 'lldb/source/Commands/CommandObjectRegister.cpp')
-rw-r--r-- | lldb/source/Commands/CommandObjectRegister.cpp | 50 |
1 files changed, 22 insertions, 28 deletions
diff --git a/lldb/source/Commands/CommandObjectRegister.cpp b/lldb/source/Commands/CommandObjectRegister.cpp index 8d7afbd..0ba6526 100644 --- a/lldb/source/Commands/CommandObjectRegister.cpp +++ b/lldb/source/Commands/CommandObjectRegister.cpp @@ -212,27 +212,23 @@ protected: "registers names are supplied as arguments\n"); result.SetStatus(eReturnStatusFailed); } else { - const char *arg_cstr; - for (int arg_idx = 0; - (arg_cstr = command.GetArgumentAtIndex(arg_idx)) != nullptr; - ++arg_idx) { + for (auto &entry : command) { // in most LLDB commands we accept $rbx as the name for register RBX - - // and here we would - // reject it and non-existant. we should be more consistent towards - // the user and allow them - // to say reg read $rbx - internally, however, we should be strict and - // not allow ourselves + // and here we would reject it and non-existant. we should be more + // consistent towards the user and allow them to say reg read $rbx - + // internally, however, we should be strict and not allow ourselves // to call our registers $rbx in our own API - if (*arg_cstr == '$') - arg_cstr = arg_cstr + 1; - reg_info = reg_ctx->GetRegisterInfoByName(arg_cstr); + auto arg_str = entry.ref; + arg_str.consume_front("$"); + + reg_info = reg_ctx->GetRegisterInfoByName(arg_str); if (reg_info) { if (!DumpRegister(m_exe_ctx, strm, reg_ctx, reg_info)) strm.Printf("%-12s = error: unavailable\n", reg_info->name); } else { result.AppendErrorWithFormat("Invalid register name '%s'.\n", - arg_cstr); + arg_str.str().c_str()); } } } @@ -355,18 +351,15 @@ protected: "register write takes exactly 2 arguments: <reg-name> <value>"); result.SetStatus(eReturnStatusFailed); } else { - const char *reg_name = command.GetArgumentAtIndex(0); - llvm::StringRef value_str = command.GetArgumentAtIndex(1); + auto reg_name = command[0].ref; + auto value_str = command[1].ref; // in most LLDB commands we accept $rbx as the name for register RBX - and - // here we would - // reject it and non-existant. we should be more consistent towards the - // user and allow them - // to say reg write $rbx - internally, however, we should be strict and - // not allow ourselves - // to call our registers $rbx in our own API - if (reg_name && *reg_name == '$') - reg_name = reg_name + 1; + // here we would reject it and non-existant. we should be more consistent + // towards the user and allow them to say reg write $rbx - internally, + // however, we should be strict and not allow ourselves to call our + // registers $rbx in our own API + reg_name.consume_front("$"); const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoByName(reg_name); @@ -385,17 +378,18 @@ protected: } if (error.AsCString()) { result.AppendErrorWithFormat( - "Failed to write register '%s' with value '%s': %s\n", reg_name, - value_str.str().c_str(), error.AsCString()); + "Failed to write register '%s' with value '%s': %s\n", + reg_name.str().c_str(), value_str.str().c_str(), + error.AsCString()); } else { result.AppendErrorWithFormat( - "Failed to write register '%s' with value '%s'", reg_name, - value_str.str().c_str()); + "Failed to write register '%s' with value '%s'", + reg_name.str().c_str(), value_str.str().c_str()); } result.SetStatus(eReturnStatusFailed); } else { result.AppendErrorWithFormat("Register not found for '%s'.\n", - reg_name); + reg_name.str().c_str()); result.SetStatus(eReturnStatusFailed); } } |