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/CommandObjectWatchpoint.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/CommandObjectWatchpoint.cpp')
-rw-r--r-- | lldb/source/Commands/CommandObjectWatchpoint.cpp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/lldb/source/Commands/CommandObjectWatchpoint.cpp b/lldb/source/Commands/CommandObjectWatchpoint.cpp index 342913fc009..5979130853d 100644 --- a/lldb/source/Commands/CommandObjectWatchpoint.cpp +++ b/lldb/source/Commands/CommandObjectWatchpoint.cpp @@ -65,7 +65,7 @@ static bool CheckTargetForWatchpointOperations(Target *target, static const char *RSA[4] = {"-", "to", "To", "TO"}; // Return the index to RSA if found; otherwise -1 is returned. -static int32_t WithRSAIndex(llvm::StringRef &Arg) { +static int32_t WithRSAIndex(llvm::StringRef Arg) { uint32_t i; for (i = 0; i < 4; ++i) @@ -92,24 +92,24 @@ bool CommandObjectMultiwordWatchpoint::VerifyWatchpointIDs( llvm::StringRef Minus("-"); std::vector<llvm::StringRef> StrRefArgs; - std::pair<llvm::StringRef, llvm::StringRef> Pair; + llvm::StringRef first; + llvm::StringRef second; size_t i; int32_t idx; // Go through the arguments and make a canonical form of arg list containing // only numbers with possible "-" in between. - for (i = 0; i < args.GetArgumentCount(); ++i) { - llvm::StringRef Arg(args.GetArgumentAtIndex(i)); - if ((idx = WithRSAIndex(Arg)) == -1) { - StrRefArgs.push_back(Arg); + for (auto &entry : args.entries()) { + if ((idx = WithRSAIndex(entry.ref)) == -1) { + StrRefArgs.push_back(entry.ref); continue; } // The Arg contains the range specifier, split it, then. - Pair = Arg.split(RSA[idx]); - if (!Pair.first.empty()) - StrRefArgs.push_back(Pair.first); + std::tie(first, second) = entry.ref.split(RSA[idx]); + if (!first.empty()) + StrRefArgs.push_back(first); StrRefArgs.push_back(Minus); - if (!Pair.second.empty()) - StrRefArgs.push_back(Pair.second); + if (!second.empty()) + StrRefArgs.push_back(second); } // Now process the canonical list and fill in the vector of uint32_t's. // If there is any error, return false and the client should ignore wp_ids. |