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/CommandObjectRegexCommand.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'lldb/source/Commands/CommandObjectRegexCommand.cpp') diff --git a/lldb/source/Commands/CommandObjectRegexCommand.cpp b/lldb/source/Commands/CommandObjectRegexCommand.cpp index 6ff1d28..f638d70 100644 --- a/lldb/source/Commands/CommandObjectRegexCommand.cpp +++ b/lldb/source/Commands/CommandObjectRegexCommand.cpp @@ -54,7 +54,7 @@ llvm::Expected CommandObjectRegexCommand::SubstituteVariables( return output.str(); } -bool CommandObjectRegexCommand::DoExecute(llvm::StringRef command, +void CommandObjectRegexCommand::DoExecute(llvm::StringRef command, CommandReturnObject &result) { EntryCollection::const_iterator pos, end = m_entries.end(); for (pos = m_entries.begin(); pos != end; ++pos) { @@ -64,7 +64,7 @@ bool CommandObjectRegexCommand::DoExecute(llvm::StringRef command, SubstituteVariables(pos->command, matches); if (!new_command) { result.SetError(new_command.takeError()); - return false; + return; } // Interpret the new command and return this as the result! @@ -73,8 +73,9 @@ bool CommandObjectRegexCommand::DoExecute(llvm::StringRef command, // We don't have to pass an override_context here, as the command that // called us should have set up the context appropriately. bool force_repeat_command = true; - return m_interpreter.HandleCommand(new_command->c_str(), eLazyBoolNo, - result, force_repeat_command); + m_interpreter.HandleCommand(new_command->c_str(), eLazyBoolNo, result, + force_repeat_command); + return; } } result.SetStatus(eReturnStatusFailed); @@ -85,7 +86,6 @@ bool CommandObjectRegexCommand::DoExecute(llvm::StringRef command, << "' failed to match any " "regular expression in the '" << m_cmd_name << "' regex "; - return false; } bool CommandObjectRegexCommand::AddRegexCommand(llvm::StringRef re_cstr, -- cgit v1.1