diff options
author | Zachary Turner <zturner@google.com> | 2016-10-05 23:40:23 +0000 |
---|---|---|
committer | Zachary Turner <zturner@google.com> | 2016-10-05 23:40:23 +0000 |
commit | 97d2c4011b9ccdfb9da2c5d4cb6917c9a2a18225 (patch) | |
tree | 73b9e3ce319cf6ece6d441bc75611363d81e1d30 /lldb/source/Commands/CommandObjectPlatform.cpp | |
parent | 3b564e97655e0eb732219d5a4dec6c31a34f7aa9 (diff) | |
download | bcm5719-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/CommandObjectPlatform.cpp')
-rw-r--r-- | lldb/source/Commands/CommandObjectPlatform.cpp | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/lldb/source/Commands/CommandObjectPlatform.cpp b/lldb/source/Commands/CommandObjectPlatform.cpp index 702fee9badd..e4cd5a4d70e 100644 --- a/lldb/source/Commands/CommandObjectPlatform.cpp +++ b/lldb/source/Commands/CommandObjectPlatform.cpp @@ -1453,12 +1453,14 @@ protected: if (platform_sp->IsConnected()) { Stream &ostrm = result.GetOutputStream(); - bool success; - for (size_t i = 0; i < argc; ++i) { - const char *arg = args.GetArgumentAtIndex(i); - lldb::pid_t pid = StringConvert::ToUInt32( - arg, LLDB_INVALID_PROCESS_ID, 0, &success); - if (success) { + for (auto &entry : args.entries()) { + lldb::pid_t pid; + if (entry.ref.getAsInteger(0, pid)) { + result.AppendErrorWithFormat("invalid process ID argument '%s'", + entry.ref.str().c_str()); + result.SetStatus(eReturnStatusFailed); + break; + } else { ProcessInstanceInfo proc_info; if (platform_sp->GetProcessInfo(pid, proc_info)) { ostrm.Printf("Process information for process %" PRIu64 ":\n", @@ -1470,11 +1472,6 @@ protected: pid); } ostrm.EOL(); - } else { - result.AppendErrorWithFormat("invalid process ID argument '%s'", - arg); - result.SetStatus(eReturnStatusFailed); - break; } } } else { |