Skip to content

Commit b951504

Browse files
committed
[lldb] Allow aliases to aliases of raw input commands
Allow users to create aliases for aliases to raw input commands. That probably sounds convoluted, so here's an example: ``` command alias some-setup env SOMEVAR=SOMEVALUE ``` This an alias based on `env`, which itself is an alias for `_regex-env`. `_regex-env` is a `command regex` command, which takes raw input. The above `some-setup` alias fails with: ``` error: Unable to create requested alias. ``` This change allows such aliases to be created. lldb already supports aliases to aliases for parsed commands. Differential Revision: https://reviews.llvm.org/D117259
1 parent 3726626 commit b951504

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

lldb/source/Commands/CommandObjectCommands.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -485,8 +485,9 @@ rather than using a positional placeholder:"
485485
OptionArgVectorSP option_arg_vector_sp =
486486
OptionArgVectorSP(new OptionArgVector);
487487

488-
if (CommandObjectSP cmd_obj_sp =
489-
m_interpreter.GetCommandSPExact(cmd_obj.GetCommandName())) {
488+
const bool include_aliases = true;
489+
if (CommandObjectSP cmd_obj_sp = m_interpreter.GetCommandSPExact(
490+
cmd_obj.GetCommandName(), include_aliases)) {
490491
if (m_interpreter.AliasExists(alias_command) ||
491492
m_interpreter.UserCommandExists(alias_command)) {
492493
result.AppendWarningWithFormat(

lldb/test/API/commands/command/nested_alias/TestNestedAlias.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ def cleanup():
4646
self.runCmd('command unalias rd', check=False)
4747
self.runCmd('command unalias fo', check=False)
4848
self.runCmd('command unalias foself', check=False)
49+
self.runCmd('command unalias add_two', check=False)
50+
self.runCmd('command unalias two', check=False)
4951

5052
# Execute the cleanup function during test case tear down.
5153
self.addTearDownHook(cleanup)
@@ -96,3 +98,8 @@ def cleanup():
9698
'Show variables for the current',
9799
'stack frame.'],
98100
matching=True)
101+
102+
# Check that aliases can be created for raw input commands.
103+
self.expect('command alias two expr -- 2')
104+
self.expect('command alias add_two two +')
105+
self.expect('add_two 3', patterns=[' = 5$'])

0 commit comments

Comments
 (0)