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
diff --git a/lldb/source/Commands/CommandObjectThread.cpp b/lldb/source/Commands/CommandObjectThread.cpp
index 3e75e64..41416d3 100644
--- a/lldb/source/Commands/CommandObjectThread.cpp
+++ b/lldb/source/Commands/CommandObjectThread.cpp
@@ -770,28 +770,22 @@
process->GetThreadList().GetMutex());
const uint32_t num_threads = process->GetThreadList().GetSize();
std::vector<Thread *> resume_threads;
- for (uint32_t i = 0; i < argc; ++i) {
- bool success;
- const int base = 0;
- uint32_t thread_idx =
- StringConvert::ToUInt32(command.GetArgumentAtIndex(i),
- LLDB_INVALID_INDEX32, base, &success);
- if (success) {
- Thread *thread =
- process->GetThreadList().FindThreadByIndexID(thread_idx).get();
-
- if (thread) {
- resume_threads.push_back(thread);
- } else {
- result.AppendErrorWithFormat("invalid thread index %u.\n",
- thread_idx);
- result.SetStatus(eReturnStatusFailed);
- return false;
- }
- } else {
+ for (auto &entry : command.entries()) {
+ uint32_t thread_idx;
+ if (entry.ref.getAsInteger(0, thread_idx)) {
result.AppendErrorWithFormat(
- "invalid thread index argument: \"%s\".\n",
- command.GetArgumentAtIndex(i));
+ "invalid thread index argument: \"%s\".\n", entry.c_str());
+ result.SetStatus(eReturnStatusFailed);
+ return false;
+ }
+ Thread *thread =
+ process->GetThreadList().FindThreadByIndexID(thread_idx).get();
+
+ if (thread) {
+ resume_threads.push_back(thread);
+ } else {
+ result.AppendErrorWithFormat("invalid thread index %u.\n",
+ thread_idx);
result.SetStatus(eReturnStatusFailed);
return false;
}