diff options
author | Zachary Turner <zturner@google.com> | 2016-12-09 01:08:29 +0000 |
---|---|---|
committer | Zachary Turner <zturner@google.com> | 2016-12-09 01:08:29 +0000 |
commit | 14f6b2c0351bf432169f7bf473aae75a5264492f (patch) | |
tree | 8f335efbc98f61e0f9d0dc090a0ab8019151be5c /lldb/source/Commands/CommandObjectHelp.cpp | |
parent | 86f0bdf83205fb49cf46acf98cc2736ef85bf984 (diff) | |
download | llvm-14f6b2c0351bf432169f7bf473aae75a5264492f.zip llvm-14f6b2c0351bf432169f7bf473aae75a5264492f.tar.gz llvm-14f6b2c0351bf432169f7bf473aae75a5264492f.tar.bz2 |
Modernize the Args access pattern in a few more commands.
llvm-svn: 289164
Diffstat (limited to 'lldb/source/Commands/CommandObjectHelp.cpp')
-rw-r--r-- | lldb/source/Commands/CommandObjectHelp.cpp | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/lldb/source/Commands/CommandObjectHelp.cpp b/lldb/source/Commands/CommandObjectHelp.cpp index 41da682..99e9d7b 100644 --- a/lldb/source/Commands/CommandObjectHelp.cpp +++ b/lldb/source/Commands/CommandObjectHelp.cpp @@ -108,11 +108,8 @@ bool CommandObjectHelp::DoExecute(Args &command, CommandReturnObject &result) { // Get command object for the first command argument. Only search built-in // command dictionary. StringList matches; - cmd_obj = - m_interpreter.GetCommandObject(command.GetArgumentAtIndex(0), &matches); - bool is_alias_command = - m_interpreter.AliasExists(command.GetArgumentAtIndex(0)); - std::string alias_name = command.GetArgumentAtIndex(0); + auto command_name = command[0].ref; + cmd_obj = m_interpreter.GetCommandObject(command_name, &matches); if (cmd_obj != nullptr) { StringList matches; @@ -176,11 +173,11 @@ bool CommandObjectHelp::DoExecute(Args &command, CommandReturnObject &result) { sub_cmd_obj->GenerateHelpText(result); - if (is_alias_command) { + if (m_interpreter.AliasExists(command_name)) { StreamString sstr; - m_interpreter.GetAlias(alias_name)->GetAliasExpansion(sstr); + m_interpreter.GetAlias(command_name)->GetAliasExpansion(sstr); result.GetOutputStream().Printf("\n'%s' is an abbreviation for %s\n", - alias_name.c_str(), sstr.GetData()); + command[0].c_str(), sstr.GetData()); } } else if (matches.GetSize() > 0) { Stream &output_strm = result.GetOutputStream(); @@ -194,16 +191,16 @@ bool CommandObjectHelp::DoExecute(Args &command, CommandReturnObject &result) { // Maybe the user is asking for help about a command argument rather than // a command. const CommandArgumentType arg_type = - CommandObject::LookupArgumentName(command.GetArgumentAtIndex(0)); + CommandObject::LookupArgumentName(command_name); if (arg_type != eArgTypeLastArg) { Stream &output_strm = result.GetOutputStream(); CommandObject::GetArgumentHelp(output_strm, arg_type, m_interpreter); result.SetStatus(eReturnStatusSuccessFinishNoResult); } else { StreamString error_msg_stream; - GenerateAdditionalHelpAvenuesMessage(&error_msg_stream, - command.GetArgumentAtIndex(0), - m_interpreter.GetCommandPrefix(), ""); + GenerateAdditionalHelpAvenuesMessage(&error_msg_stream, command_name, + m_interpreter.GetCommandPrefix(), + ""); result.AppendError(error_msg_stream.GetString()); result.SetStatus(eReturnStatusFailed); } @@ -225,8 +222,7 @@ int CommandObjectHelp::HandleCompletion(Args &input, int &cursor_index, input, cursor_index, cursor_char_position, match_start_point, max_return_elements, word_complete, matches); } else { - CommandObject *cmd_obj = - m_interpreter.GetCommandObject(input.GetArgumentAtIndex(0)); + CommandObject *cmd_obj = m_interpreter.GetCommandObject(input[0].ref); // The command that they are getting help on might be ambiguous, in which // case we should complete that, |