[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
This commit is contained in:
David Spickett 2021-06-16 13:56:51 +01:00
parent 983ed1b58e
commit 7a580f3c28
11 changed files with 0 additions and 59 deletions

View File

@ -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);
}
}

View File

@ -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"
" different major breakpoints, %d and %d.\n",
start_bp_id, end_bp_id);
result.SetStatus(eReturnStatusFailed);
return;
}
}

View File

@ -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);

View File

@ -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;
}
}

View File

@ -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;

View File

@ -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.");
}

View File

@ -4187,7 +4187,6 @@ public:
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 @@ public:
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 @@ public:
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 @@ public:
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 @@ public:
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 @@ public:
} else {
result.AppendErrorWithFormat(
"Argument must be either 'enable' or 'disable'");
result.SetStatus(eReturnStatusFailed);
return false;
}
@ -4566,7 +4560,6 @@ public:
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 @@ public:
if (!success) {
result.AppendErrorWithFormat("invalid allocation id argument '%s'",
id_cstr);
result.SetStatus(eReturnStatusFailed);
return false;
}
@ -4606,7 +4598,6 @@ public:
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 @@ public:
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 @@ public:
if (!success) {
result.AppendErrorWithFormat("invalid allocation id argument '%s'",
id_cstr);
result.SetStatus(eReturnStatusFailed);
return false;
}
@ -4766,7 +4755,6 @@ public:
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 @@ public:
if (!success) {
result.AppendErrorWithFormat("invalid allocation id argument '%s'",
id_cstr);
result.SetStatus(eReturnStatusFailed);
return false;
}

View File

@ -910,7 +910,6 @@ public:
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 @@ public:
"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 @@ public:
"ASCII hex characters (no "
"spaces or hex prefixes): '%s'",
ascii_hex_bytes_cstr);
result.SetStatus(eReturnStatusFailed);
return false;
}
}
@ -970,30 +967,25 @@ public:
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;
}

View File

@ -5246,7 +5246,6 @@ public:
"amount to be transferred when "
"reading/writing",
m_cmd_name.c_str());
result.SetStatus(eReturnStatusFailed);
return false;
}
@ -5287,7 +5286,6 @@ public:
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 @@ public:
if (command.empty()) {
result.AppendErrorWithFormat("'%s' takes a command string argument",
m_cmd_name.c_str());
result.SetStatus(eReturnStatusFailed);
return false;
}

View File

@ -880,7 +880,6 @@ public:
if (argc > 0) {
result.AppendErrorWithFormat("'%s' take no arguments, only options",
m_cmd_name.c_str());
result.SetStatus(eReturnStatusFailed);
return false;
}
SetDefaultOptionsIfNoneAreSet();

View File

@ -809,7 +809,6 @@ protected:
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 @@ protected:
// Report results.
if (!error.Success()) {
result.AppendError(error.AsCString());
result.SetStatus(eReturnStatusFailed);
// Our configuration failed, so we're definitely disabled.
plugin.SetEnabled(false);
} else {