From 308f73c5a3c53f2b9fe8df4c1e73f6786ad7735e Mon Sep 17 00:00:00 2001 From: Enrico Granata Date: Tue, 8 Mar 2016 02:49:15 +0000 Subject: Change the way command aliases are stored. Go from a model where a map holds the alias -> underlying command binding and another map holds the alias -> options, to a model where one single map holds the alias -> (all useful data) combination Right now, obviously, this is just the pair of (CommandObjectSP,OptionArgVectorSP), so NFC This is step one of a larger - and tricky - refactoring which will turn command aliases into interesting objects instead of passive storage that the command interpreter does smart things to This refactoring, in turn, will allow us to do interesting things with aliases, such as intelligent and customizable help llvm-svn: 262900 --- lldb/source/Commands/CommandObjectCommands.cpp | 22 +++------------------- lldb/source/Commands/CommandObjectMultiword.cpp | 8 ++++---- 2 files changed, 7 insertions(+), 23 deletions(-) (limited to 'lldb/source/Commands') diff --git a/lldb/source/Commands/CommandObjectCommands.cpp b/lldb/source/Commands/CommandObjectCommands.cpp index e2e2bb81ea0..d5816db0dbf 100644 --- a/lldb/source/Commands/CommandObjectCommands.cpp +++ b/lldb/source/Commands/CommandObjectCommands.cpp @@ -635,21 +635,13 @@ protected: if (m_interpreter.AliasExists (alias_command.c_str()) || m_interpreter.UserCommandExists (alias_command.c_str())) { - OptionArgVectorSP temp_option_arg_sp (m_interpreter.GetAliasOptions (alias_command.c_str())); - if (temp_option_arg_sp) - { - if (option_arg_vector->empty()) - m_interpreter.RemoveAliasOptions (alias_command.c_str()); - } result.AppendWarningWithFormat ("Overwriting existing definition for '%s'.\n", alias_command.c_str()); } if (cmd_obj_sp) { - m_interpreter.AddAlias (alias_command.c_str(), cmd_obj_sp); - if (!option_arg_vector->empty()) - m_interpreter.AddOrReplaceAliasOptions (alias_command.c_str(), option_arg_vector_sp); + m_interpreter.AddAlias (alias_command.c_str(), cmd_obj_sp, option_arg_vector_sp); result.SetStatus (eReturnStatusSuccessFinishNoResult); } else @@ -747,22 +739,14 @@ protected: if (m_interpreter.AliasExists (alias_command.c_str()) || m_interpreter.UserCommandExists (alias_command.c_str())) { - OptionArgVectorSP tmp_option_arg_sp (m_interpreter.GetAliasOptions (alias_command.c_str())); - if (tmp_option_arg_sp) - { - if (option_arg_vector->empty()) - m_interpreter.RemoveAliasOptions (alias_command.c_str()); - } result.AppendWarningWithFormat ("Overwriting existing definition for '%s'.\n", alias_command.c_str()); } if (use_subcommand) - m_interpreter.AddAlias (alias_command.c_str(), subcommand_obj_sp); + m_interpreter.AddAlias (alias_command.c_str(), subcommand_obj_sp, option_arg_vector_sp); else - m_interpreter.AddAlias (alias_command.c_str(), command_obj_sp); - if (!option_arg_vector->empty()) - m_interpreter.AddOrReplaceAliasOptions (alias_command.c_str(), option_arg_vector_sp); + m_interpreter.AddAlias (alias_command.c_str(), command_obj_sp, option_arg_vector_sp); result.SetStatus (eReturnStatusSuccessFinishNoResult); } else diff --git a/lldb/source/Commands/CommandObjectMultiword.cpp b/lldb/source/Commands/CommandObjectMultiword.cpp index 6d35c9cec1f..18e162dcec4 100644 --- a/lldb/source/Commands/CommandObjectMultiword.cpp +++ b/lldb/source/Commands/CommandObjectMultiword.cpp @@ -56,7 +56,7 @@ CommandObjectMultiword::GetSubcommandSP (const char *sub_cmd, StringList *matche StringList local_matches; if (matches == nullptr) matches = &local_matches; - int num_matches = CommandObject::AddNamesMatchingPartialString (m_subcommand_dict, sub_cmd, *matches); + int num_matches = AddNamesMatchingPartialString (m_subcommand_dict, sub_cmd, *matches); if (num_matches == 1) { @@ -227,9 +227,9 @@ CommandObjectMultiword::HandleCompletion(Args &input, const char *arg0 = input.GetArgumentAtIndex(0); if (cursor_index == 0) { - CommandObject::AddNamesMatchingPartialString (m_subcommand_dict, - arg0, - matches); + AddNamesMatchingPartialString (m_subcommand_dict, + arg0, + matches); if (matches.GetSize() == 1 && matches.GetStringAtIndex(0) != nullptr -- cgit v1.2.3