aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Commands/CommandObjectCommands.cpp
diff options
context:
space:
mode:
authorJim Ingham <jingham@apple.com>2022-06-23 09:33:40 -0700
committerJim Ingham <jingham@apple.com>2022-06-27 15:14:41 -0700
commitc1b07d617705dfdb3aabbdda51c1a40d99f7cc1a (patch)
treeed7886491e1a97d19af06525fca43987a3dfb0a9 /lldb/source/Commands/CommandObjectCommands.cpp
parent6824eee94203b16de7633050367505c2ad10c56a (diff)
downloadllvm-c1b07d617705dfdb3aabbdda51c1a40d99f7cc1a.zip
llvm-c1b07d617705dfdb3aabbdda51c1a40d99f7cc1a.tar.gz
llvm-c1b07d617705dfdb3aabbdda51c1a40d99f7cc1a.tar.bz2
Have CommandObjectParsed check for "commands that take no arguments".
This is currently being done in an ad hoc way, and so for some commands it isn't being checked. We have the info to make this check, since commands are supposed to add their arguments to the m_arguments field of the CommandObject. This change uses that info to check whether the command received arguments in error. A handful of commands weren't defining their argument types, I also had to fix them. And a bunch of commands were checking for arguments by hand, so I removed those checks in favor of the CommandObject one. That also meant I had to change some tests that were checking for the ad hoc error outputs. Differential Revision: https://reviews.llvm.org/D128453
Diffstat (limited to 'lldb/source/Commands/CommandObjectCommands.cpp')
-rw-r--r--lldb/source/Commands/CommandObjectCommands.cpp12
1 files changed, 2 insertions, 10 deletions
diff --git a/lldb/source/Commands/CommandObjectCommands.cpp b/lldb/source/Commands/CommandObjectCommands.cpp
index 2334759..39c7207 100644
--- a/lldb/source/Commands/CommandObjectCommands.cpp
+++ b/lldb/source/Commands/CommandObjectCommands.cpp
@@ -824,6 +824,8 @@ 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});
}
~CommandObjectCommandsAddRegex() override = default;
@@ -1664,11 +1666,6 @@ public:
~CommandObjectCommandsScriptList() override = default;
bool DoExecute(Args &command, CommandReturnObject &result) override {
- if (command.GetArgumentCount() != 0) {
- result.AppendError("'command script list' doesn't take any arguments");
- return false;
- }
-
m_interpreter.GetHelp(result, CommandInterpreter::eCommandTypesUserDef);
result.SetStatus(eReturnStatusSuccessFinishResult);
@@ -1689,11 +1686,6 @@ public:
protected:
bool DoExecute(Args &command, CommandReturnObject &result) override {
- if (command.GetArgumentCount() != 0) {
- result.AppendError("'command script clear' doesn't take any arguments");
- return false;
- }
-
m_interpreter.RemoveAllUser();
result.SetStatus(eReturnStatusSuccessFinishResult);