aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Commands/CommandObjectThread.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/CommandObjectThread.cpp
parent3b564e97655e0eb732219d5a4dec6c31a34f7aa9 (diff)
downloadllvm-97d2c4011b9ccdfb9da2c5d4cb6917c9a2a18225.zip
llvm-97d2c4011b9ccdfb9da2c5d4cb6917c9a2a18225.tar.gz
llvm-97d2c4011b9ccdfb9da2c5d4cb6917c9a2a18225.tar.bz2
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/CommandObjectThread.cpp')
-rw-r--r--lldb/source/Commands/CommandObjectThread.cpp34
1 files changed, 14 insertions, 20 deletions
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 @@ public:
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();
+ for (auto &entry : command.entries()) {
+ uint32_t thread_idx;
+ if (entry.ref.getAsInteger(0, thread_idx)) {
+ result.AppendErrorWithFormat(
+ "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;
- }
+ if (thread) {
+ resume_threads.push_back(thread);
} else {
- result.AppendErrorWithFormat(
- "invalid thread index argument: \"%s\".\n",
- command.GetArgumentAtIndex(i));
+ result.AppendErrorWithFormat("invalid thread index %u.\n",
+ thread_idx);
result.SetStatus(eReturnStatusFailed);
return false;
}