aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Commands/CommandObjectScript.cpp
diff options
context:
space:
mode:
authorPete Lawrence <plawrence@apple.com>2023-10-30 10:21:00 -1000
committerGitHub <noreply@github.com>2023-10-30 13:21:00 -0700
commit92d8a28cc665d73d9d679b8c014dd04f95d1df18 (patch)
tree19b3a218ad57e05a911da01c0f4f80ca3c0a4bd4 /lldb/source/Commands/CommandObjectScript.cpp
parent2446439f51cf0d2dfb11c823436a930de7a4b8a2 (diff)
downloadllvm-92d8a28cc665d73d9d679b8c014dd04f95d1df18.zip
llvm-92d8a28cc665d73d9d679b8c014dd04f95d1df18.tar.gz
llvm-92d8a28cc665d73d9d679b8c014dd04f95d1df18.tar.bz2
[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
Diffstat (limited to 'lldb/source/Commands/CommandObjectScript.cpp')
-rw-r--r--lldb/source/Commands/CommandObjectScript.cpp12
1 files changed, 5 insertions, 7 deletions
diff --git a/lldb/source/Commands/CommandObjectScript.cpp b/lldb/source/Commands/CommandObjectScript.cpp
index 7e4f18a..25f25b8 100644
--- a/lldb/source/Commands/CommandObjectScript.cpp
+++ b/lldb/source/Commands/CommandObjectScript.cpp
@@ -65,14 +65,14 @@ CommandObjectScript::CommandObjectScript(CommandInterpreter &interpreter)
CommandObjectScript::~CommandObjectScript() = default;
-bool CommandObjectScript::DoExecute(llvm::StringRef command,
+void CommandObjectScript::DoExecute(llvm::StringRef command,
CommandReturnObject &result) {
// Try parsing the language option but when the command contains a raw part
// separated by the -- delimiter.
OptionsWithRaw raw_args(command);
if (raw_args.HasArgs()) {
if (!ParseOptions(raw_args.GetArgs(), result))
- return false;
+ return;
command = raw_args.GetRawPart();
}
@@ -84,7 +84,7 @@ bool CommandObjectScript::DoExecute(llvm::StringRef command,
if (language == lldb::eScriptLanguageNone) {
result.AppendError(
"the script-lang setting is set to none - scripting not available");
- return false;
+ return;
}
ScriptInterpreter *script_interpreter =
@@ -92,7 +92,7 @@ bool CommandObjectScript::DoExecute(llvm::StringRef command,
if (script_interpreter == nullptr) {
result.AppendError("no script interpreter");
- return false;
+ return;
}
// Script might change Python code we use for formatting. Make sure we keep
@@ -102,7 +102,7 @@ bool CommandObjectScript::DoExecute(llvm::StringRef command,
if (command.empty()) {
script_interpreter->ExecuteInterpreterLoop();
result.SetStatus(eReturnStatusSuccessFinishNoResult);
- return result.Succeeded();
+ return;
}
// We can do better when reporting the status of one-liner script execution.
@@ -110,6 +110,4 @@ bool CommandObjectScript::DoExecute(llvm::StringRef command,
result.SetStatus(eReturnStatusSuccessFinishNoResult);
else
result.SetStatus(eReturnStatusFailed);
-
- return result.Succeeded();
}