[Lldb-commits] [lldb] 7a580f3 - [lldb] Remove redundant calls to set eReturnStatusFailed
David Spickett via lldb-commits
lldb-commits at lists.llvm.org
Thu Jun 17 04:22:00 PDT 2021
Author: David Spickett
Date: 2021-06-17T12:21:54+01:00
New Revision: 7a580f3c28cf47a7e489faa1fc1ab7b88d9a5dbd
URL: https://github.com/llvm/llvm-project/commit/7a580f3c28cf47a7e489faa1fc1ab7b88d9a5dbd
DIFF: https://github.com/llvm/llvm-project/commit/7a580f3c28cf47a7e489faa1fc1ab7b88d9a5dbd.diff
LOG: [lldb] Remove redundant calls to set eReturnStatusFailed
Since https://reviews.llvm.org/D103701 AppendError<...>
sets this for you.
This change includes all of the non-command uses.
Some uses remain where it's either tricky to reason about
the logic, or they aren't paired with AppendError calls.
Reviewed By: teemperor
Differential Revision: https://reviews.llvm.org/D104379
Added:
Modified:
lldb/source/API/SBCommandInterpreter.cpp
lldb/source/Breakpoint/BreakpointIDList.cpp
lldb/source/Interpreter/CommandAlias.cpp
lldb/source/Interpreter/CommandInterpreter.cpp
lldb/source/Interpreter/Options.cpp
lldb/source/Interpreter/ScriptInterpreter.cpp
lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp
Removed:
################################################################################
diff --git a/lldb/source/API/SBCommandInterpreter.cpp b/lldb/source/API/SBCommandInterpreter.cpp
index d28bc411042c1..b4a69c3e972a4 100644
--- a/lldb/source/API/SBCommandInterpreter.cpp
+++ b/lldb/source/API/SBCommandInterpreter.cpp
@@ -185,7 +185,6 @@ lldb::ReturnStatus SBCommandInterpreter::HandleCommand(
} else {
result->AppendError(
"SBCommandInterpreter or the command line is not valid");
- result->SetStatus(eReturnStatusFailed);
}
return result.GetStatus();
@@ -203,7 +202,6 @@ void SBCommandInterpreter::HandleCommandsFromFile(
if (!IsValid()) {
result->AppendError("SBCommandInterpreter is not valid.");
- result->SetStatus(eReturnStatusFailed);
return;
}
@@ -211,7 +209,6 @@ void SBCommandInterpreter::HandleCommandsFromFile(
SBStream s;
file.GetDescription(s);
result->AppendErrorWithFormat("File is not valid: %s.", s.GetData());
- result->SetStatus(eReturnStatusFailed);
}
FileSpec tmp_spec = file.ref();
@@ -439,7 +436,6 @@ void SBCommandInterpreter::ResolveCommand(const char *command_line,
} else {
result->AppendError(
"SBCommandInterpreter or the command line is not valid");
- result->SetStatus(eReturnStatusFailed);
}
}
@@ -469,7 +465,6 @@ void SBCommandInterpreter::SourceInitFileInHomeDirectory(
m_opaque_ptr->SourceInitFileHome(result.ref());
} else {
result->AppendError("SBCommandInterpreter is not valid");
- result->SetStatus(eReturnStatusFailed);
}
}
@@ -487,7 +482,6 @@ void SBCommandInterpreter::SourceInitFileInHomeDirectory(
m_opaque_ptr->SourceInitFileHome(result.ref(), is_repl);
} else {
result->AppendError("SBCommandInterpreter is not valid");
- result->SetStatus(eReturnStatusFailed);
}
}
@@ -506,7 +500,6 @@ void SBCommandInterpreter::SourceInitFileInCurrentWorkingDirectory(
m_opaque_ptr->SourceInitFileCwd(result.ref());
} else {
result->AppendError("SBCommandInterpreter is not valid");
- result->SetStatus(eReturnStatusFailed);
}
}
diff --git a/lldb/source/Breakpoint/BreakpointIDList.cpp b/lldb/source/Breakpoint/BreakpointIDList.cpp
index e6a5dceeb93b2..172674dc2dd2d 100644
--- a/lldb/source/Breakpoint/BreakpointIDList.cpp
+++ b/lldb/source/Breakpoint/BreakpointIDList.cpp
@@ -141,7 +141,6 @@ void BreakpointIDList::FindAndReplaceIDRanges(Args &old_args, Target *target,
if (!error.Success()) {
new_args.Clear();
result.AppendError(error.AsCString());
- result.SetStatus(eReturnStatusFailed);
return;
} else
names_found.insert(std::string(current_arg));
@@ -170,7 +169,6 @@ void BreakpointIDList::FindAndReplaceIDRanges(Args &old_args, Target *target,
new_args.Clear();
result.AppendErrorWithFormat("'%d' is not a valid breakpoint ID.\n",
bp_id->GetBreakpointID());
- result.SetStatus(eReturnStatusFailed);
return;
}
const size_t num_locations = breakpoint_sp->GetNumLocations();
@@ -199,7 +197,6 @@ void BreakpointIDList::FindAndReplaceIDRanges(Args &old_args, Target *target,
new_args.Clear();
result.AppendErrorWithFormat("'%s' is not a valid breakpoint ID.\n",
range_from.str().c_str());
- result.SetStatus(eReturnStatusFailed);
return;
}
@@ -208,7 +205,6 @@ void BreakpointIDList::FindAndReplaceIDRanges(Args &old_args, Target *target,
new_args.Clear();
result.AppendErrorWithFormat("'%s' is not a valid breakpoint ID.\n",
range_to.str().c_str());
- result.SetStatus(eReturnStatusFailed);
return;
}
break_id_t start_bp_id = start_bp->GetBreakpointID();
@@ -224,7 +220,6 @@ void BreakpointIDList::FindAndReplaceIDRanges(Args &old_args, Target *target,
"both ends of range must specify"
" a breakpoint location, or neither can "
"specify a breakpoint location.");
- result.SetStatus(eReturnStatusFailed);
return;
}
@@ -247,7 +242,6 @@ void BreakpointIDList::FindAndReplaceIDRanges(Args &old_args, Target *target,
" must be within the same major breakpoint; you specified two"
"
diff erent major breakpoints, %d and %d.\n",
start_bp_id, end_bp_id);
- result.SetStatus(eReturnStatusFailed);
return;
}
}
diff --git a/lldb/source/Interpreter/CommandAlias.cpp b/lldb/source/Interpreter/CommandAlias.cpp
index f0f577bf05856..d55b3fdd44faf 100644
--- a/lldb/source/Interpreter/CommandAlias.cpp
+++ b/lldb/source/Interpreter/CommandAlias.cpp
@@ -47,7 +47,6 @@ static bool ProcessAliasOptionsArgs(lldb::CommandObjectSP &cmd_obj_sp,
if (!args_or) {
result.AppendError(toString(args_or.takeError()));
result.AppendError("Unable to create requested alias.\n");
- result.SetStatus(eReturnStatusFailed);
return false;
}
args = std::move(*args_or);
diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp
index 85025b92d367f..8a3a4092c0f61 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -1465,7 +1465,6 @@ CommandObject *CommandInterpreter::BuildAliasResult(
"need at least %d arguments to use "
"this alias.\n",
index);
- result.SetStatus(eReturnStatusFailed);
return nullptr;
} else {
size_t strpos = raw_input_string.find(cmd_args.GetArgumentAtIndex(index));
@@ -1658,7 +1657,6 @@ bool CommandInterpreter::HandleCommand(const char *command_line,
if (WasInterrupted()) {
result.AppendError("interrupted");
- result.SetStatus(eReturnStatusFailed);
return false;
}
@@ -1694,7 +1692,6 @@ bool CommandInterpreter::HandleCommand(const char *command_line,
} else {
result.AppendErrorWithFormat("Could not find entry: %s in history",
command_string.c_str());
- result.SetStatus(eReturnStatusFailed);
return false;
}
}
@@ -1708,7 +1705,6 @@ bool CommandInterpreter::HandleCommand(const char *command_line,
if (m_command_history.IsEmpty()) {
result.AppendError("empty command");
- result.SetStatus(eReturnStatusFailed);
return false;
}
@@ -1717,7 +1713,6 @@ bool CommandInterpreter::HandleCommand(const char *command_line,
original_command_string = command_line;
if (m_repeat_command.empty()) {
result.AppendError("No auto repeat.");
- result.SetStatus(eReturnStatusFailed);
return false;
}
@@ -1731,7 +1726,6 @@ bool CommandInterpreter::HandleCommand(const char *command_line,
if (error.Fail()) {
result.AppendError(error.AsCString());
- result.SetStatus(eReturnStatusFailed);
return false;
}
@@ -1999,7 +1993,6 @@ void CommandInterpreter::BuildAliasCommandArgs(CommandObject *alias_cmd_obj,
"need at least %d arguments to use "
"this alias.\n",
index);
- result.SetStatus(eReturnStatusFailed);
return;
} else {
// Find and remove cmd_args.GetArgumentAtIndex(i) from raw_input_string
@@ -2169,7 +2162,6 @@ void CommandInterpreter::SourceInitFileCwd(CommandReturnObject &result) {
result.SetStatus(eReturnStatusSuccessFinishNoResult);
} else {
result.AppendError(InitFileWarning);
- result.SetStatus(eReturnStatusFailed);
}
}
}
@@ -2331,7 +2323,6 @@ void CommandInterpreter::HandleCommands(const StringList &commands,
"Aborting reading of commands after command #%" PRIu64
": '%s' failed with %s",
(uint64_t)idx, cmd, error_msg.str().c_str());
- result.SetStatus(eReturnStatusFailed);
m_debugger.SetAsyncExecution(old_async_execution);
return;
} else if (options.GetPrintResults()) {
@@ -2427,7 +2418,6 @@ void CommandInterpreter::HandleCommandsFromFile(FileSpec &cmd_file,
result.AppendErrorWithFormat(
"Error reading commands from file %s - file not found.\n",
cmd_file.GetFilename().AsCString("<Unknown>"));
- result.SetStatus(eReturnStatusFailed);
return;
}
@@ -2439,7 +2429,6 @@ void CommandInterpreter::HandleCommandsFromFile(FileSpec &cmd_file,
result.AppendErrorWithFormatv(
"error: an error occurred read file '{0}': {1}\n", cmd_file_path,
llvm::fmt_consume(input_file_up.takeError()));
- result.SetStatus(eReturnStatusFailed);
return;
}
FileSP input_file_sp = FileSP(std::move(input_file_up.get()));
@@ -3184,7 +3173,6 @@ CommandInterpreter::ResolveCommandImpl(std::string &command_line,
result.AppendErrorWithFormat("'%s' is not a valid command.\n",
next_word.c_str());
}
- result.SetStatus(eReturnStatusFailed);
return nullptr;
}
@@ -3196,7 +3184,6 @@ CommandInterpreter::ResolveCommandImpl(std::string &command_line,
cmd_obj->GetCommandName().str().c_str(),
next_word.empty() ? "" : next_word.c_str(),
next_word.empty() ? " -- " : " ", suffix.c_str());
- result.SetStatus(eReturnStatusFailed);
return nullptr;
}
} else {
@@ -3232,7 +3219,6 @@ CommandInterpreter::ResolveCommandImpl(std::string &command_line,
result.AppendErrorWithFormat(
"the '%s' command doesn't support the --gdb-format option\n",
cmd_obj->GetCommandName().str().c_str());
- result.SetStatus(eReturnStatusFailed);
return nullptr;
}
}
@@ -3241,7 +3227,6 @@ CommandInterpreter::ResolveCommandImpl(std::string &command_line,
default:
result.AppendErrorWithFormat(
"unknown command shorthand suffix: '%s'\n", suffix.c_str());
- result.SetStatus(eReturnStatusFailed);
return nullptr;
}
}
diff --git a/lldb/source/Interpreter/Options.cpp b/lldb/source/Interpreter/Options.cpp
index f39ef20af4f8e..4aa298f0382b1 100644
--- a/lldb/source/Interpreter/Options.cpp
+++ b/lldb/source/Interpreter/Options.cpp
@@ -137,7 +137,6 @@ bool Options::VerifyOptions(CommandReturnObject &result) {
result.SetStatus(eReturnStatusSuccessFinishNoResult);
} else {
result.AppendError("invalid combination of options for the given command");
- result.SetStatus(eReturnStatusFailed);
}
return options_are_valid;
diff --git a/lldb/source/Interpreter/ScriptInterpreter.cpp b/lldb/source/Interpreter/ScriptInterpreter.cpp
index 7fb07fb69cbea..3802f2d4e59b9 100644
--- a/lldb/source/Interpreter/ScriptInterpreter.cpp
+++ b/lldb/source/Interpreter/ScriptInterpreter.cpp
@@ -36,14 +36,12 @@ ScriptInterpreter::ScriptInterpreter(
void ScriptInterpreter::CollectDataForBreakpointCommandCallback(
std::vector<std::reference_wrapper<BreakpointOptions>> &bp_options_vec,
CommandReturnObject &result) {
- result.SetStatus(eReturnStatusFailed);
result.AppendError(
"This script interpreter does not support breakpoint callbacks.");
}
void ScriptInterpreter::CollectDataForWatchpointCommandCallback(
WatchpointOptions *bp_options, CommandReturnObject &result) {
- result.SetStatus(eReturnStatusFailed);
result.AppendError(
"This script interpreter does not support watchpoint callbacks.");
}
diff --git a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
index 8a9be6d40c7c3..7280e66617f08 100644
--- a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
@@ -4187,7 +4187,6 @@ class CommandObjectRenderScriptRuntimeReductionBreakpointSet
result.AppendErrorWithFormat("'%s' takes 1 argument of reduction name, "
"and an optional kernel type list",
m_cmd_name.c_str());
- result.SetStatus(eReturnStatusFailed);
return false;
}
@@ -4201,7 +4200,6 @@ class CommandObjectRenderScriptRuntimeReductionBreakpointSet
auto coord = m_options.m_have_coord ? &m_options.m_coord : nullptr;
if (!runtime->PlaceBreakpointOnReduction(target, outstream, name, coord,
m_options.m_kernel_types)) {
- result.SetStatus(eReturnStatusFailed);
result.AppendError("Error: unable to place breakpoint on reduction");
return false;
}
@@ -4289,7 +4287,6 @@ class CommandObjectRenderScriptRuntimeKernelBreakpointSet
result.AppendErrorWithFormat(
"'%s' takes 1 argument of kernel name, and an optional coordinate.",
m_cmd_name.c_str());
- result.SetStatus(eReturnStatusFailed);
return false;
}
@@ -4302,7 +4299,6 @@ class CommandObjectRenderScriptRuntimeKernelBreakpointSet
auto name = command.GetArgumentAtIndex(0);
auto coord = m_options.m_have_coord ? &m_options.m_coord : nullptr;
if (!runtime->PlaceBreakpointOnKernel(target, outstream, name, coord)) {
- result.SetStatus(eReturnStatusFailed);
result.AppendErrorWithFormat(
"Error: unable to set breakpoint on kernel '%s'", name);
return false;
@@ -4340,7 +4336,6 @@ class CommandObjectRenderScriptRuntimeKernelBreakpointAll
if (argc != 1) {
result.AppendErrorWithFormat(
"'%s' takes 1 argument of 'enable' or 'disable'", m_cmd_name.c_str());
- result.SetStatus(eReturnStatusFailed);
return false;
}
@@ -4359,7 +4354,6 @@ class CommandObjectRenderScriptRuntimeKernelBreakpointAll
} else {
result.AppendErrorWithFormat(
"Argument must be either 'enable' or 'disable'");
- result.SetStatus(eReturnStatusFailed);
return false;
}
@@ -4566,7 +4560,6 @@ class CommandObjectRenderScriptRuntimeAllocationDump
result.AppendErrorWithFormat("'%s' takes 1 argument, an allocation ID. "
"As well as an optional -f argument",
m_cmd_name.c_str());
- result.SetStatus(eReturnStatusFailed);
return false;
}
@@ -4581,7 +4574,6 @@ class CommandObjectRenderScriptRuntimeAllocationDump
if (!success) {
result.AppendErrorWithFormat("invalid allocation id argument '%s'",
id_cstr);
- result.SetStatus(eReturnStatusFailed);
return false;
}
@@ -4606,7 +4598,6 @@ class CommandObjectRenderScriptRuntimeAllocationDump
std::string error = llvm::toString(file.takeError());
result.AppendErrorWithFormat("Couldn't open file '%s': %s",
path.c_str(), error.c_str());
- result.SetStatus(eReturnStatusFailed);
return false;
}
} else
@@ -4715,7 +4706,6 @@ class CommandObjectRenderScriptRuntimeAllocationLoad
result.AppendErrorWithFormat(
"'%s' takes 2 arguments, an allocation ID and filename to read from.",
m_cmd_name.c_str());
- result.SetStatus(eReturnStatusFailed);
return false;
}
@@ -4730,7 +4720,6 @@ class CommandObjectRenderScriptRuntimeAllocationLoad
if (!success) {
result.AppendErrorWithFormat("invalid allocation id argument '%s'",
id_cstr);
- result.SetStatus(eReturnStatusFailed);
return false;
}
@@ -4766,7 +4755,6 @@ class CommandObjectRenderScriptRuntimeAllocationSave
result.AppendErrorWithFormat(
"'%s' takes 2 arguments, an allocation ID and filename to read from.",
m_cmd_name.c_str());
- result.SetStatus(eReturnStatusFailed);
return false;
}
@@ -4781,7 +4769,6 @@ class CommandObjectRenderScriptRuntimeAllocationSave
if (!success) {
result.AppendErrorWithFormat("invalid allocation id argument '%s'",
id_cstr);
- result.SetStatus(eReturnStatusFailed);
return false;
}
diff --git a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
index 0f0e978349b1c..19e5c01ee2885 100644
--- a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
+++ b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
@@ -910,7 +910,6 @@ class CommandObjectProcessKDPPacketSend : public CommandObjectParsed {
if (!m_command_byte.GetOptionValue().OptionWasSet()) {
result.AppendError(
"the --command option must be set to a valid command byte");
- result.SetStatus(eReturnStatusFailed);
} else {
const uint64_t command_byte =
m_command_byte.GetOptionValue().GetUInt64Value(0);
@@ -933,7 +932,6 @@ class CommandObjectProcessKDPPacketSend : public CommandObjectParsed {
"even number of ASCII hex "
"characters: '%s'",
ascii_hex_bytes_cstr);
- result.SetStatus(eReturnStatusFailed);
return false;
}
payload_bytes.resize(ascii_hex_bytes_cstr_len / 2);
@@ -943,7 +941,6 @@ class CommandObjectProcessKDPPacketSend : public CommandObjectParsed {
"ASCII hex characters (no "
"spaces or hex prefixes): '%s'",
ascii_hex_bytes_cstr);
- result.SetStatus(eReturnStatusFailed);
return false;
}
}
@@ -970,30 +967,25 @@ class CommandObjectProcessKDPPacketSend : public CommandObjectParsed {
else
result.AppendErrorWithFormat("unknown error 0x%8.8x",
error.GetError());
- result.SetStatus(eReturnStatusFailed);
return false;
}
} else {
result.AppendErrorWithFormat("process must be stopped in order "
"to send KDP packets, state is %s",
StateAsCString(state));
- result.SetStatus(eReturnStatusFailed);
}
} else {
result.AppendError("invalid process");
- result.SetStatus(eReturnStatusFailed);
}
} else {
result.AppendErrorWithFormat("invalid command byte 0x%" PRIx64
", valid values are 1 - 255",
command_byte);
- result.SetStatus(eReturnStatusFailed);
}
}
} else {
result.AppendErrorWithFormat("'%s' takes no arguments, only options.",
m_cmd_name.c_str());
- result.SetStatus(eReturnStatusFailed);
}
return false;
}
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index d53d983da744a..dbae76e99b3d7 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -5246,7 +5246,6 @@ class CommandObjectProcessGDBRemotePacketXferSize : public CommandObjectParsed {
"amount to be transferred when "
"reading/writing",
m_cmd_name.c_str());
- result.SetStatus(eReturnStatusFailed);
return false;
}
@@ -5287,7 +5286,6 @@ class CommandObjectProcessGDBRemotePacketSend : public CommandObjectParsed {
result.AppendErrorWithFormat(
"'%s' takes a one or more packet content arguments",
m_cmd_name.c_str());
- result.SetStatus(eReturnStatusFailed);
return false;
}
@@ -5337,7 +5335,6 @@ class CommandObjectProcessGDBRemotePacketMonitor : public CommandObjectRaw {
if (command.empty()) {
result.AppendErrorWithFormat("'%s' takes a command string argument",
m_cmd_name.c_str());
- result.SetStatus(eReturnStatusFailed);
return false;
}
diff --git a/lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp b/lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
index 1ece75f04e3e5..ce2cbb1091d8a 100644
--- a/lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
+++ b/lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
@@ -880,7 +880,6 @@ class CommandObjectProcessMinidumpDump : public CommandObjectParsed {
if (argc > 0) {
result.AppendErrorWithFormat("'%s' take no arguments, only options",
m_cmd_name.c_str());
- result.SetStatus(eReturnStatusFailed);
return false;
}
SetDefaultOptionsIfNoneAreSet();
diff --git a/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp b/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp
index c0dbc86fb0704..3f94954d7b686 100644
--- a/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp
+++ b/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp
@@ -809,7 +809,6 @@ class EnableCommand : public CommandObjectParsed {
StructuredDataDarwinLog::GetStaticPluginName())) {
result.AppendError("failed to get StructuredDataPlugin for "
"the process");
- result.SetStatus(eReturnStatusFailed);
}
StructuredDataDarwinLog &plugin =
*static_cast<StructuredDataDarwinLog *>(plugin_sp.get());
@@ -833,7 +832,6 @@ class EnableCommand : public CommandObjectParsed {
// Report results.
if (!error.Success()) {
result.AppendError(error.AsCString());
- result.SetStatus(eReturnStatusFailed);
// Our configuration failed, so we're definitely disabled.
plugin.SetEnabled(false);
} else {
More information about the lldb-commits
mailing list