aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Commands/CommandObjectMultiword.cpp
diff options
context:
space:
mode:
authorPete Lawrence <plawrence@apple.com>2023-10-25 12:55:27 -1000
committerGitHub <noreply@github.com>2023-10-25 15:55:27 -0700
commit463a02bc2260d01ac9e8457792bb455e48097ce5 (patch)
tree4f34bc7474b64a8360f000913bd60cd404708b3d /lldb/source/Commands/CommandObjectMultiword.cpp
parentc9ca2fe739b6924575c222d0a6e02e528d606f88 (diff)
downloadllvm-463a02bc2260d01ac9e8457792bb455e48097ce5.zip
llvm-463a02bc2260d01ac9e8457792bb455e48097ce5.tar.gz
llvm-463a02bc2260d01ac9e8457792bb455e48097ce5.tar.bz2
[lldb] Part 1 of 2 - Refactor `CommandObject::Execute(...)` return `void` (not `bool`) (#69989)
[lldb] Part 1 of 2 - Refactor `CommandObject::Execute(...)` to return `void` instead of ~~`bool`~~ Justifications: - The code doesn't ultimately apply the `true`/`false` return values. - The methods already pass around a `CommandReturnObject`, typically with a `result` parameter. - Each command return object already contains: - A more precise status - The error code(s) that apply to that status Part 2 refactors the `CommandObject::DoExecute(...)` method. - See [https://github.com/llvm/llvm-project/pull/69991](https://github.com/llvm/llvm-project/pull/69991) rdar://117378957
Diffstat (limited to 'lldb/source/Commands/CommandObjectMultiword.cpp')
-rw-r--r--lldb/source/Commands/CommandObjectMultiword.cpp22
1 files changed, 10 insertions, 12 deletions
diff --git a/lldb/source/Commands/CommandObjectMultiword.cpp b/lldb/source/Commands/CommandObjectMultiword.cpp
index 7ef829a..4efa565 100644
--- a/lldb/source/Commands/CommandObjectMultiword.cpp
+++ b/lldb/source/Commands/CommandObjectMultiword.cpp
@@ -159,25 +159,25 @@ llvm::Error CommandObjectMultiword::RemoveUserSubcommand(llvm::StringRef cmd_nam
return llvm::Error::success();
}
-bool CommandObjectMultiword::Execute(const char *args_string,
+void CommandObjectMultiword::Execute(const char *args_string,
CommandReturnObject &result) {
Args args(args_string);
const size_t argc = args.GetArgumentCount();
if (argc == 0) {
this->CommandObject::GenerateHelpText(result);
- return result.Succeeded();
+ return;
}
auto sub_command = args[0].ref();
if (sub_command.empty()) {
result.AppendError("Need to specify a non-empty subcommand.");
- return result.Succeeded();
+ return;
}
if (m_subcommand_dict.empty()) {
result.AppendErrorWithFormat("'%s' does not have any subcommands.\n",
GetCommandName().str().c_str());
- return false;
+ return;
}
StringList matches;
@@ -189,7 +189,7 @@ bool CommandObjectMultiword::Execute(const char *args_string,
args.Shift();
sub_cmd_obj->Execute(args_string, result);
- return result.Succeeded();
+ return;
}
std::string error_msg;
@@ -214,7 +214,6 @@ bool CommandObjectMultiword::Execute(const char *args_string,
}
error_msg.append("\n");
result.AppendRawError(error_msg.c_str());
- return false;
}
void CommandObjectMultiword::GenerateHelpText(Stream &output_stream) {
@@ -429,11 +428,10 @@ llvm::StringRef CommandObjectProxy::GetUnsupportedError() {
return "command is not implemented";
}
-bool CommandObjectProxy::Execute(const char *args_string,
+void CommandObjectProxy::Execute(const char *args_string,
CommandReturnObject &result) {
- CommandObject *proxy_command = GetProxyCommandObject();
- if (proxy_command)
- return proxy_command->Execute(args_string, result);
- result.AppendError(GetUnsupportedError());
- return false;
+ if (CommandObject *proxy_command = GetProxyCommandObject())
+ proxy_command->Execute(args_string, result);
+ else
+ result.AppendError(GetUnsupportedError());
}