Skip to content

Commit acbc187

Browse files
committed
[lldb] Part 2 of 2 - Refactor CommandObject::DoExecute(...) return void (not bool) (llvm#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
1 parent 72d56a7 commit acbc187

File tree

57 files changed

+745
-1038
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+745
-1038
lines changed

lldb/include/lldb/Interpreter/CommandObject.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ class CommandObjectParsed : public CommandObject {
401401
void Execute(const char *args_string, CommandReturnObject &result) override;
402402

403403
protected:
404-
virtual bool DoExecute(Args &command, CommandReturnObject &result) = 0;
404+
virtual void DoExecute(Args &command, CommandReturnObject &result) = 0;
405405

406406
bool WantsRawCommandString() override { return false; }
407407
};
@@ -418,7 +418,7 @@ class CommandObjectRaw : public CommandObject {
418418
void Execute(const char *args_string, CommandReturnObject &result) override;
419419

420420
protected:
421-
virtual bool DoExecute(llvm::StringRef command,
421+
virtual void DoExecute(llvm::StringRef command,
422422
CommandReturnObject &result) = 0;
423423

424424
bool WantsRawCommandString() override { return true; }

lldb/source/API/SBCommandInterpreter.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,11 @@ class CommandPluginInterfaceImplementation : public CommandObjectParsed {
7070
}
7171

7272
protected:
73-
bool DoExecute(Args &command, CommandReturnObject &result) override {
73+
void DoExecute(Args &command, CommandReturnObject &result) override {
7474
SBCommandReturnObject sb_return(result);
7575
SBCommandInterpreter sb_interpreter(&m_interpreter);
7676
SBDebugger debugger_sb(m_interpreter.GetDebugger().shared_from_this());
77-
bool ret = m_backend->DoExecute(debugger_sb, command.GetArgumentVector(),
78-
sb_return);
79-
return ret;
77+
m_backend->DoExecute(debugger_sb, command.GetArgumentVector(), sb_return);
8078
}
8179
std::shared_ptr<lldb::SBCommandPluginInterface> m_backend;
8280
std::optional<std::string> m_auto_repeat_command;

lldb/source/Commands/CommandObjectApropos.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ CommandObjectApropos::CommandObjectApropos(CommandInterpreter &interpreter)
3838

3939
CommandObjectApropos::~CommandObjectApropos() = default;
4040

41-
bool CommandObjectApropos::DoExecute(Args &args, CommandReturnObject &result) {
41+
void CommandObjectApropos::DoExecute(Args &args, CommandReturnObject &result) {
4242
const size_t argc = args.GetArgumentCount();
4343

4444
if (argc == 1) {
@@ -90,6 +90,4 @@ bool CommandObjectApropos::DoExecute(Args &args, CommandReturnObject &result) {
9090
} else {
9191
result.AppendError("'apropos' must be called with exactly one argument.\n");
9292
}
93-
94-
return result.Succeeded();
9593
}

lldb/source/Commands/CommandObjectApropos.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class CommandObjectApropos : public CommandObjectParsed {
2323
~CommandObjectApropos() override;
2424

2525
protected:
26-
bool DoExecute(Args &command, CommandReturnObject &result) override;
26+
void DoExecute(Args &command, CommandReturnObject &result) override;
2727
};
2828

2929
} // namespace lldb_private

0 commit comments

Comments
 (0)