diff options
Diffstat (limited to 'lldb/source/Commands/CommandObjectCommands.cpp')
-rw-r--r-- | lldb/source/Commands/CommandObjectCommands.cpp | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/lldb/source/Commands/CommandObjectCommands.cpp b/lldb/source/Commands/CommandObjectCommands.cpp index 3d4893d..9bf07f3 100644 --- a/lldb/source/Commands/CommandObjectCommands.cpp +++ b/lldb/source/Commands/CommandObjectCommands.cpp @@ -485,29 +485,31 @@ protected: OptionArgVectorSP(new OptionArgVector); const bool include_aliases = true; - if (CommandObjectSP cmd_obj_sp = m_interpreter.GetCommandSPExact( - cmd_obj.GetCommandName(), include_aliases)) { - if (m_interpreter.AliasExists(alias_command) || - m_interpreter.UserCommandExists(alias_command)) { - result.AppendWarningWithFormat( - "Overwriting existing definition for '%s'.\n", - alias_command.str().c_str()); - } - if (CommandAlias *alias = m_interpreter.AddAlias( - alias_command, cmd_obj_sp, raw_command_string)) { - if (m_command_options.m_help.OptionWasSet()) - alias->SetHelp(m_command_options.m_help.GetCurrentValue()); - if (m_command_options.m_long_help.OptionWasSet()) - alias->SetHelpLong(m_command_options.m_long_help.GetCurrentValue()); - result.SetStatus(eReturnStatusSuccessFinishNoResult); - } else { - result.AppendError("Unable to create requested alias.\n"); - } + // Look up the command using command's name first. This is to resolve + // aliases when you are making nested aliases. But if you don't find + // it that way, then it wasn't an alias and we can just use the object + // we were passed in. + CommandObjectSP cmd_obj_sp = m_interpreter.GetCommandSPExact( + cmd_obj.GetCommandName(), include_aliases); + if (!cmd_obj_sp) + cmd_obj_sp = cmd_obj.shared_from_this(); + if (m_interpreter.AliasExists(alias_command) || + m_interpreter.UserCommandExists(alias_command)) { + result.AppendWarningWithFormat( + "Overwriting existing definition for '%s'.\n", + alias_command.str().c_str()); + } + if (CommandAlias *alias = m_interpreter.AddAlias( + alias_command, cmd_obj_sp, raw_command_string)) { + if (m_command_options.m_help.OptionWasSet()) + alias->SetHelp(m_command_options.m_help.GetCurrentValue()); + if (m_command_options.m_long_help.OptionWasSet()) + alias->SetHelpLong(m_command_options.m_long_help.GetCurrentValue()); + result.SetStatus(eReturnStatusSuccessFinishNoResult); } else { result.AppendError("Unable to create requested alias.\n"); } - return result.Succeeded(); } |