gdb: add cmd_list_element::is_alias

Add the cmd_list_element::is_alias helper to check whether a command is
an alias.  I find it easier to understand the intention in:

  if (c->is_alias ())

than

  if (c->alias_target != nullptr)

Change all the spots that are reading alias_target just to compare it to
NULL/nullptr to use is_alias instead.

gdb/ChangeLog:

	* cli/cli-decode.h (cmd_list_element) <is_alias>: New, use it.

Change-Id: I26ed56f99ee47fe884fdfedf87016501631693ce
This commit is contained in:
Simon Marchi 2021-05-17 14:01:20 -04:00
parent 9985872497
commit 1be99b11f8
5 changed files with 20 additions and 12 deletions

View file

@ -740,7 +740,7 @@ cmd_show_list (struct cmd_list_element *list, int from_tty)
/* If we find a prefix, run its list, prefixing our output by its
prefix (with "show " skipped). */
if (list->subcommands && list->alias_target == nullptr)
if (list->subcommands && !list->is_alias ())
{
ui_out_emit_tuple optionlist_emitter (uiout, "optionlist");
std::string prefixname = list->prefixname ();
@ -750,7 +750,7 @@ cmd_show_list (struct cmd_list_element *list, int from_tty)
uiout->field_string ("prefix", new_prefix);
cmd_show_list (*list->subcommands, from_tty);
}
else if (list->theclass != no_set_class && list->alias_target == nullptr)
else if (list->theclass != no_set_class && !list->is_alias ())
{
ui_out_emit_tuple option_emitter (uiout, "option");