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/CommandObjectHelp.cpp | |
parent | 3b564e97655e0eb732219d5a4dec6c31a34f7aa9 (diff) | |
download | llvm-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/CommandObjectHelp.cpp')
-rw-r--r-- | lldb/source/Commands/CommandObjectHelp.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/lldb/source/Commands/CommandObjectHelp.cpp b/lldb/source/Commands/CommandObjectHelp.cpp index 7d1fdcf..b4a3e01 100644 --- a/lldb/source/Commands/CommandObjectHelp.cpp +++ b/lldb/source/Commands/CommandObjectHelp.cpp @@ -114,26 +114,25 @@ bool CommandObjectHelp::DoExecute(Args &command, CommandReturnObject &result) { bool all_okay = true; CommandObject *sub_cmd_obj = cmd_obj; // Loop down through sub_command dictionaries until we find the command - // object that corresponds - // to the help command entered. + // object that corresponds to the help command entered. std::string sub_command; - for (size_t i = 1; i < argc && all_okay; ++i) { - sub_command = command.GetArgumentAtIndex(i); + for (auto &entry : command.entries().drop_front()) { + sub_command = entry.ref; matches.Clear(); if (sub_cmd_obj->IsAlias()) sub_cmd_obj = ((CommandAlias *)sub_cmd_obj)->GetUnderlyingCommand().get(); if (!sub_cmd_obj->IsMultiwordObject()) { all_okay = false; + break; } else { CommandObject *found_cmd; found_cmd = sub_cmd_obj->GetSubcommandObject(sub_command.c_str(), &matches); - if (found_cmd == nullptr) + if (found_cmd == nullptr || matches.GetSize() > 1) { all_okay = false; - else if (matches.GetSize() > 1) - all_okay = false; - else + break; + } else sub_cmd_obj = found_cmd; } } |