summaryrefslogtreecommitdiffstats
path: root/lldb/source/Commands/CommandObjectProcess.cpp
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2016-10-05 23:40:23 +0000
committerZachary Turner <zturner@google.com>2016-10-05 23:40:23 +0000
commit97d2c4011b9ccdfb9da2c5d4cb6917c9a2a18225 (patch)
tree73b9e3ce319cf6ece6d441bc75611363d81e1d30 /lldb/source/Commands/CommandObjectProcess.cpp
parent3b564e97655e0eb732219d5a4dec6c31a34f7aa9 (diff)
downloadbcm5719-llvm-97d2c4011b9ccdfb9da2c5d4cb6917c9a2a18225.tar.gz
bcm5719-llvm-97d2c4011b9ccdfb9da2c5d4cb6917c9a2a18225.zip
Convert some Args index-based iteration to range-style iteration.
This is better for a number of reasons. Mostly style, but also: 1) Signed-unsigned comparison warnings disappear since there is no loop index. 2) Iterating with the range-for style gives you back an entry that has more than just a const char*, so it's more efficient and more useful. 3) Makes code safter since the type system enforces that it's impossible to index out of bounds. llvm-svn: 283413
Diffstat (limited to 'lldb/source/Commands/CommandObjectProcess.cpp')
-rw-r--r--lldb/source/Commands/CommandObjectProcess.cpp23
1 files changed, 10 insertions, 13 deletions
diff --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp
index e47ac0d23c1..cc38959e03c 100644
--- a/lldb/source/Commands/CommandObjectProcess.cpp
+++ b/lldb/source/Commands/CommandObjectProcess.cpp
@@ -1037,11 +1037,10 @@ protected:
bool DoExecute(Args &command, CommandReturnObject &result) override {
Process *process = m_exe_ctx.GetProcessPtr();
- const size_t argc = command.GetArgumentCount();
- for (uint32_t i = 0; i < argc; ++i) {
+ for (auto &entry : command.entries()) {
Error error;
PlatformSP platform = process->GetTarget().GetPlatform();
- const char *image_path = command.GetArgumentAtIndex(i);
+ llvm::StringRef image_path = entry.ref;
uint32_t image_token = LLDB_INVALID_IMAGE_TOKEN;
if (!m_options.do_install) {
@@ -1063,10 +1062,12 @@ protected:
if (image_token != LLDB_INVALID_IMAGE_TOKEN) {
result.AppendMessageWithFormat(
- "Loading \"%s\"...ok\nImage %u loaded.\n", image_path, image_token);
+ "Loading \"%s\"...ok\nImage %u loaded.\n", image_path.str().c_str(),
+ image_token);
result.SetStatus(eReturnStatusSuccessFinishResult);
} else {
- result.AppendErrorWithFormat("failed to load '%s': %s", image_path,
+ result.AppendErrorWithFormat("failed to load '%s': %s",
+ image_path.str().c_str(),
error.AsCString());
result.SetStatus(eReturnStatusFailed);
}
@@ -1099,15 +1100,11 @@ protected:
bool DoExecute(Args &command, CommandReturnObject &result) override {
Process *process = m_exe_ctx.GetProcessPtr();
- const size_t argc = command.GetArgumentCount();
-
- for (uint32_t i = 0; i < argc; ++i) {
- const char *image_token_cstr = command.GetArgumentAtIndex(i);
- uint32_t image_token = StringConvert::ToUInt32(
- image_token_cstr, LLDB_INVALID_IMAGE_TOKEN, 0);
- if (image_token == LLDB_INVALID_IMAGE_TOKEN) {
+ for (auto &entry : command.entries()) {
+ uint32_t image_token;
+ if (entry.ref.getAsInteger(0, image_token)) {
result.AppendErrorWithFormat("invalid image index argument '%s'",
- image_token_cstr);
+ entry.ref.str().c_str());
result.SetStatus(eReturnStatusFailed);
break;
} else {
OpenPOWER on IntegriCloud