From 92d8a28cc665d73d9d679b8c014dd04f95d1df18 Mon Sep 17 00:00:00 2001 From: Pete Lawrence Date: Mon, 30 Oct 2023 10:21:00 -1000 Subject: [lldb] Part 2 of 2 - Refactor `CommandObject::DoExecute(...)` return `void` (not `bool`) (#69991) [lldb] Part 2 of 2 - Refactor `CommandObject::DoExecute(...)` 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 1 refactors the `CommandObject::Execute(...)` method. - See [https://github.com/llvm/llvm-project/pull/69989](https://github.com/llvm/llvm-project/pull/69989) rdar://117378957 --- lldb/source/Commands/CommandObjectRegister.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'lldb/source/Commands/CommandObjectRegister.cpp') diff --git a/lldb/source/Commands/CommandObjectRegister.cpp b/lldb/source/Commands/CommandObjectRegister.cpp index 6e6071f..a4d53e5 100644 --- a/lldb/source/Commands/CommandObjectRegister.cpp +++ b/lldb/source/Commands/CommandObjectRegister.cpp @@ -161,7 +161,7 @@ public: } protected: - bool DoExecute(Args &command, CommandReturnObject &result) override { + void DoExecute(Args &command, CommandReturnObject &result) override { Stream &strm = result.GetOutputStream(); RegisterContext *reg_ctx = m_exe_ctx.GetRegisterContext(); @@ -234,7 +234,6 @@ protected: } } } - return result.Succeeded(); } class CommandOptions : public OptionGroup { @@ -348,7 +347,7 @@ public: } protected: - bool DoExecute(Args &command, CommandReturnObject &result) override { + void DoExecute(Args &command, CommandReturnObject &result) override { DataExtractor reg_data; RegisterContext *reg_ctx = m_exe_ctx.GetRegisterContext(); @@ -378,7 +377,7 @@ protected: // has been written. m_exe_ctx.GetThreadRef().Flush(); result.SetStatus(eReturnStatusSuccessFinishNoResult); - return true; + return; } } if (error.AsCString()) { @@ -396,7 +395,6 @@ protected: reg_name.str().c_str()); } } - return result.Succeeded(); } }; @@ -447,10 +445,10 @@ different for the same register when connected to different debug servers.)"); } protected: - bool DoExecute(Args &command, CommandReturnObject &result) override { + void DoExecute(Args &command, CommandReturnObject &result) override { if (command.GetArgumentCount() != 1) { result.AppendError("register info takes exactly 1 argument: "); - return result.Succeeded(); + return; } llvm::StringRef reg_name = command[0].ref(); @@ -464,8 +462,6 @@ protected: } else result.AppendErrorWithFormat("No register found with name '%s'.\n", reg_name.str().c_str()); - - return result.Succeeded(); } }; -- cgit v1.1