aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Commands/CommandObjectCommands.cpp
diff options
context:
space:
mode:
authorjimingham <jingham@apple.com>2024-02-27 10:34:01 -0800
committerGitHub <noreply@github.com>2024-02-27 10:34:01 -0800
commit2d704f4bf2edb0f9343dac818ab4d29442be9968 (patch)
treeef20273e98e399b40906c2b36e8172d3ef36e2e8 /lldb/source/Commands/CommandObjectCommands.cpp
parentabc693fb4051dfb3a49ba2dcdbc2d164c53f2a51 (diff)
downloadllvm-2d704f4bf2edb0f9343dac818ab4d29442be9968.zip
llvm-2d704f4bf2edb0f9343dac818ab4d29442be9968.tar.gz
llvm-2d704f4bf2edb0f9343dac818ab4d29442be9968.tar.bz2
Start to clean up the process of defining command arguments. (#83097)
Partly, there's just a lot of unnecessary boiler plate. It's also possible to define combinations of arguments that make no sense (e.g. eArgRepeatPlus followed by eArgRepeatPlain...) but these are never checked since we just push_back directly into the argument definitions. This commit is step 1 of this cleanup - do the obvious stuff. In it, all the simple homogenous argument lists and the breakpoint/watchpoint ID/Range types, are set with common functions. This is an NFC change, it just centralizes boiler plate. There's no checking yet because you can't get a single argument wrong. The end goal is that all argument definition goes through functions and m_arguments is hidden so that you can't define inconsistent argument sets.
Diffstat (limited to 'lldb/source/Commands/CommandObjectCommands.cpp')
-rw-r--r--lldb/source/Commands/CommandObjectCommands.cpp119
1 files changed, 9 insertions, 110 deletions
diff --git a/lldb/source/Commands/CommandObjectCommands.cpp b/lldb/source/Commands/CommandObjectCommands.cpp
index 7c459bd..f4903e3 100644
--- a/lldb/source/Commands/CommandObjectCommands.cpp
+++ b/lldb/source/Commands/CommandObjectCommands.cpp
@@ -41,19 +41,7 @@ public:
interpreter, "command source",
"Read and execute LLDB commands from the file <filename>.",
nullptr) {
- CommandArgumentEntry arg;
- CommandArgumentData file_arg;
-
- // Define the first (and only) variant of this arg.
- file_arg.arg_type = eArgTypeFilename;
- file_arg.arg_repetition = eArgRepeatPlain;
-
- // There is only one variant this argument could be; put it into the
- // argument entry.
- arg.push_back(file_arg);
-
- // Push the data for the first argument into the m_arguments vector.
- m_arguments.push_back(arg);
+ AddSimpleArgumentList(eArgTypeFilename);
}
~CommandObjectCommandsSource() override = default;
@@ -614,19 +602,7 @@ public:
interpreter, "command unalias",
"Delete one or more custom commands defined by 'command alias'.",
nullptr) {
- CommandArgumentEntry arg;
- CommandArgumentData alias_arg;
-
- // Define the first (and only) variant of this arg.
- alias_arg.arg_type = eArgTypeAliasName;
- alias_arg.arg_repetition = eArgRepeatPlain;
-
- // There is only one variant this argument could be; put it into the
- // argument entry.
- arg.push_back(alias_arg);
-
- // Push the data for the first argument into the m_arguments vector.
- m_arguments.push_back(arg);
+ AddSimpleArgumentList(eArgTypeAliasName);
}
~CommandObjectCommandsUnalias() override = default;
@@ -701,19 +677,7 @@ public:
interpreter, "command delete",
"Delete one or more custom commands defined by 'command regex'.",
nullptr) {
- CommandArgumentEntry arg;
- CommandArgumentData alias_arg;
-
- // Define the first (and only) variant of this arg.
- alias_arg.arg_type = eArgTypeCommandName;
- alias_arg.arg_repetition = eArgRepeatPlain;
-
- // There is only one variant this argument could be; put it into the
- // argument entry.
- arg.push_back(alias_arg);
-
- // Push the data for the first argument into the m_arguments vector.
- m_arguments.push_back(arg);
+ AddSimpleArgumentList(eArgTypeCommandName);
}
~CommandObjectCommandsDelete() override = default;
@@ -815,8 +779,7 @@ a number follows 'f':"
R"(
(lldb) command regex f s/^$/finish/ 's/([0-9]+)/frame select %1/')");
- CommandArgumentData thread_arg{eArgTypeSEDStylePair, eArgRepeatOptional};
- m_arguments.push_back({thread_arg});
+ AddSimpleArgumentList(eArgTypeSEDStylePair, eArgRepeatOptional);
}
~CommandObjectCommandsAddRegex() override = default;
@@ -1944,19 +1907,7 @@ public:
CommandObjectCommandsScriptImport(CommandInterpreter &interpreter)
: CommandObjectParsed(interpreter, "command script import",
"Import a scripting module in LLDB.", nullptr) {
- CommandArgumentEntry arg1;
- CommandArgumentData cmd_arg;
-
- // Define the first (and only) variant of this arg.
- cmd_arg.arg_type = eArgTypeFilename;
- cmd_arg.arg_repetition = eArgRepeatPlus;
-
- // There is only one variant this argument could be; put it into the
- // argument entry.
- arg1.push_back(cmd_arg);
-
- // Push the data for the first argument into the m_arguments vector.
- m_arguments.push_back(arg1);
+ AddSimpleArgumentList(eArgTypeFilename, eArgRepeatPlus);
}
~CommandObjectCommandsScriptImport() override = default;
@@ -2066,20 +2017,7 @@ public:
"command, and the last element will be the new "
"command name."),
IOHandlerDelegateMultiline("DONE") {
- CommandArgumentEntry arg1;
- CommandArgumentData cmd_arg;
-
- // This is one or more command names, which form the path to the command
- // you want to add.
- cmd_arg.arg_type = eArgTypeCommand;
- cmd_arg.arg_repetition = eArgRepeatPlus;
-
- // There is only one variant this argument could be; put it into the
- // argument entry.
- arg1.push_back(cmd_arg);
-
- // Push the data for the first argument into the m_arguments vector.
- m_arguments.push_back(arg1);
+ AddSimpleArgumentList(eArgTypeCommand, eArgRepeatPlus);
}
~CommandObjectCommandsScriptAdd() override = default;
@@ -2400,20 +2338,7 @@ public:
interpreter, "command script delete",
"Delete a scripted command by specifying the path to the command.",
nullptr) {
- CommandArgumentEntry arg1;
- CommandArgumentData cmd_arg;
-
- // This is a list of command names forming the path to the command
- // to be deleted.
- cmd_arg.arg_type = eArgTypeCommand;
- cmd_arg.arg_repetition = eArgRepeatPlus;
-
- // There is only one variant this argument could be; put it into the
- // argument entry.
- arg1.push_back(cmd_arg);
-
- // Push the data for the first argument into the m_arguments vector.
- m_arguments.push_back(arg1);
+ AddSimpleArgumentList(eArgTypeCommand, eArgRepeatPlus);
}
~CommandObjectCommandsScriptDelete() override = default;
@@ -2549,20 +2474,7 @@ public:
"Add a container command to lldb. Adding to built-"
"in container commands is not allowed.",
"command container add [[path1]...] container-name") {
- CommandArgumentEntry arg1;
- CommandArgumentData cmd_arg;
-
- // This is one or more command names, which form the path to the command
- // you want to add.
- cmd_arg.arg_type = eArgTypeCommand;
- cmd_arg.arg_repetition = eArgRepeatPlus;
-
- // There is only one variant this argument could be; put it into the
- // argument entry.
- arg1.push_back(cmd_arg);
-
- // Push the data for the first argument into the m_arguments vector.
- m_arguments.push_back(arg1);
+ AddSimpleArgumentList(eArgTypeCommand, eArgRepeatPlus);
}
~CommandObjectCommandsContainerAdd() override = default;
@@ -2690,20 +2602,7 @@ public:
"Delete a container command previously added to "
"lldb.",
"command container delete [[path1] ...] container-cmd") {
- CommandArgumentEntry arg1;
- CommandArgumentData cmd_arg;
-
- // This is one or more command names, which form the path to the command
- // you want to add.
- cmd_arg.arg_type = eArgTypeCommand;
- cmd_arg.arg_repetition = eArgRepeatPlus;
-
- // There is only one variant this argument could be; put it into the
- // argument entry.
- arg1.push_back(cmd_arg);
-
- // Push the data for the first argument into the m_arguments vector.
- m_arguments.push_back(arg1);
+ AddSimpleArgumentList(eArgTypeCommand, eArgRepeatPlus);
}
~CommandObjectCommandsContainerDelete() override = default;