[lldb] Remove redundant WithFormat suffixes (NFC)

Replace calls to FooWithFormat() with calls to Foo() when only one
argument is provided and the given string doesn't need to be formatted.
This commit is contained in:
Jonas Devlieghere 2020-07-20 22:57:06 -07:00
parent 0ebdc3be41
commit 8953376478
17 changed files with 39 additions and 46 deletions

View File

@ -144,8 +144,7 @@ lldb::BreakpointSP Breakpoint::CreateFromStructuredData(
bool success = breakpoint_dict->GetValueForKeyAsDictionary(
BreakpointResolver::GetSerializationKey(), resolver_dict);
if (!success) {
error.SetErrorStringWithFormat(
"Breakpoint data missing toplevel resolver key");
error.SetErrorString("Breakpoint data missing toplevel resolver key");
return result_sp;
}

View File

@ -96,7 +96,7 @@ bool BreakpointID::StringIsBreakpointName(llvm::StringRef str, Status &error) {
error.Clear();
if (str.empty())
{
error.SetErrorStringWithFormat("Empty breakpoint names are not allowed");
error.SetErrorString("Empty breakpoint names are not allowed");
return false;
}

View File

@ -220,10 +220,10 @@ void BreakpointIDList::FindAndReplaceIDRanges(Args &old_args, Target *target,
((start_loc_id != LLDB_INVALID_BREAK_ID) &&
(end_loc_id == LLDB_INVALID_BREAK_ID))) {
new_args.Clear();
result.AppendErrorWithFormat("Invalid breakpoint id range: Either "
"both ends of range must specify"
" a breakpoint location, or neither can "
"specify a breakpoint location.\n");
result.AppendError("Invalid breakpoint id range: Either "
"both ends of range must specify"
" a breakpoint location, or neither can "
"specify a breakpoint location.\n");
result.SetStatus(eReturnStatusFailed);
return;
}

View File

@ -319,7 +319,7 @@ std::unique_ptr<BreakpointOptions> BreakpointOptions::CreateFromStructuredData(
else {
ScriptInterpreter *interp = target.GetDebugger().GetScriptInterpreter();
if (!interp) {
error.SetErrorStringWithFormat(
error.SetErrorString(
"Can't set script commands - no script interpreter");
return nullptr;
}

View File

@ -81,8 +81,7 @@ BreakpointResolverSP BreakpointResolver::CreateFromStructuredData(
GetSerializationSubclassKey(), subclass_name);
if (!success) {
error.SetErrorStringWithFormat(
"Resolver data missing subclass resolver key");
error.SetErrorString("Resolver data missing subclass resolver key");
return result_sp;
}

View File

@ -108,7 +108,7 @@ BreakpointResolver *BreakpointResolverName::CreateFromStructuredData(
success =
options_dict.GetValueForKeyAsInteger(GetKey(OptionNames::Offset), offset);
if (!success) {
error.SetErrorStringWithFormat("BRN::CFSD: Missing offset entry.");
error.SetErrorString("BRN::CFSD: Missing offset entry.");
return nullptr;
}
@ -116,7 +116,7 @@ BreakpointResolver *BreakpointResolverName::CreateFromStructuredData(
success = options_dict.GetValueForKeyAsBoolean(
GetKey(OptionNames::SkipPrologue), skip_prologue);
if (!success) {
error.SetErrorStringWithFormat("BRN::CFSD: Missing Skip prologue entry.");
error.SetErrorString("BRN::CFSD: Missing Skip prologue entry.");
return nullptr;
}
@ -131,15 +131,14 @@ BreakpointResolver *BreakpointResolverName::CreateFromStructuredData(
success = options_dict.GetValueForKeyAsArray(
GetKey(OptionNames::SymbolNameArray), names_array);
if (!success) {
error.SetErrorStringWithFormat("BRN::CFSD: Missing symbol names entry.");
error.SetErrorString("BRN::CFSD: Missing symbol names entry.");
return nullptr;
}
StructuredData::Array *names_mask_array;
success = options_dict.GetValueForKeyAsArray(
GetKey(OptionNames::NameMaskArray), names_mask_array);
if (!success) {
error.SetErrorStringWithFormat(
"BRN::CFSD: Missing symbol names mask entry.");
error.SetErrorString("BRN::CFSD: Missing symbol names mask entry.");
return nullptr;
}

View File

@ -978,7 +978,7 @@ Status ModuleList::GetSharedModule(const ModuleSpec &module_spec,
error.SetErrorStringWithFormat(
"cannot locate a module for UUID '%s'", uuid_str.c_str());
else
error.SetErrorStringWithFormat("cannot locate a module");
error.SetErrorString("cannot locate a module");
}
}
}

View File

@ -89,7 +89,7 @@ SearchFilterSP SearchFilter::CreateFromStructuredData(
bool success = filter_dict.GetValueForKeyAsString(
GetSerializationSubclassKey(), subclass_name);
if (!success) {
error.SetErrorStringWithFormat("Filter data missing subclass key");
error.SetErrorString("Filter data missing subclass key");
return result_sp;
}

View File

@ -354,7 +354,7 @@ Status Value::GetValueAsData(ExecutionContext *exe_ctx, DataExtractor &data,
return error; // Success;
}
error.SetErrorStringWithFormat("extracting data from value failed");
error.SetErrorString("extracting data from value failed");
break;
}
case eValueTypeLoadAddress:
@ -535,8 +535,7 @@ Status Value::GetValueAsData(ExecutionContext *exe_ctx, DataExtractor &data,
if (address_type == eAddressTypeHost) {
// The address is an address in this process, so just copy it.
if (address == 0) {
error.SetErrorStringWithFormat(
"trying to read from host address of 0.");
error.SetErrorString("trying to read from host address of 0.");
return error;
}
memcpy(dst, reinterpret_cast<uint8_t *>(address), byte_size);
@ -580,7 +579,7 @@ Status Value::GetValueAsData(ExecutionContext *exe_ctx, DataExtractor &data,
address_type);
}
} else {
error.SetErrorStringWithFormat("out of memory");
error.SetErrorString("out of memory");
}
return error;

View File

@ -158,7 +158,7 @@ static bool ReadRegisterValueAsScalar(RegisterContext *reg_ctx,
Value &value) {
if (reg_ctx == nullptr) {
if (error_ptr)
error_ptr->SetErrorStringWithFormat("No register context in frame.\n");
error_ptr->SetErrorString("No register context in frame.\n");
} else {
uint32_t native_reg =
reg_ctx->ConvertRegisterKindToRegisterNumber(reg_kind, reg_num);
@ -1036,22 +1036,21 @@ bool DWARFExpression::Evaluate(
LLDB_INVALID_ADDRESS);
if (!module_sp) {
if (error_ptr)
error_ptr->SetErrorStringWithFormat(
error_ptr->SetErrorString(
"need module to resolve file address for DW_OP_deref");
return false;
}
Address so_addr;
if (!module_sp->ResolveFileAddress(file_addr, so_addr)) {
if (error_ptr)
error_ptr->SetErrorStringWithFormat(
error_ptr->SetErrorString(
"failed to resolve file address in module");
return false;
}
addr_t load_Addr = so_addr.GetLoadAddress(exe_ctx->GetTargetPtr());
if (load_Addr == LLDB_INVALID_ADDRESS) {
if (error_ptr)
error_ptr->SetErrorStringWithFormat(
"failed to resolve load address");
error_ptr->SetErrorString("failed to resolve load address");
return false;
}
stack.back().GetScalar() = load_Addr;
@ -1079,13 +1078,12 @@ bool DWARFExpression::Evaluate(
}
} else {
if (error_ptr)
error_ptr->SetErrorStringWithFormat(
"NULL process for DW_OP_deref.\n");
error_ptr->SetErrorString("NULL process for DW_OP_deref.\n");
return false;
}
} else {
if (error_ptr)
error_ptr->SetErrorStringWithFormat(
error_ptr->SetErrorString(
"NULL execution context for DW_OP_deref.\n");
return false;
}
@ -1199,13 +1197,12 @@ bool DWARFExpression::Evaluate(
}
} else {
if (error_ptr)
error_ptr->SetErrorStringWithFormat(
"NULL process for DW_OP_deref.\n");
error_ptr->SetErrorString("NULL process for DW_OP_deref.\n");
return false;
}
} else {
if (error_ptr)
error_ptr->SetErrorStringWithFormat(
error_ptr->SetErrorString(
"NULL execution context for DW_OP_deref.\n");
return false;
}
@ -2036,7 +2033,7 @@ bool DWARFExpression::Evaluate(
}
} else {
if (error_ptr)
error_ptr->SetErrorStringWithFormat(
error_ptr->SetErrorString(
"NULL execution context for DW_OP_fbreg.\n");
return false;
}

View File

@ -1356,14 +1356,14 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function,
// Check we can actually get a thread
if (exe_ctx.GetThreadPtr() == nullptr) {
error.SetErrorToGenericError();
error.SetErrorStringWithFormat("unable to acquire thread");
error.SetErrorString("unable to acquire thread");
return false;
}
// Make sure we have a valid process
if (!exe_ctx.GetProcessPtr()) {
error.SetErrorToGenericError();
error.SetErrorStringWithFormat("unable to get the process");
error.SetErrorString("unable to get the process");
return false;
}
@ -1404,7 +1404,7 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function,
static lldb_private::ABI::CallArgument rawArgs[16];
if (numArgs >= 16) {
error.SetErrorToGenericError();
error.SetErrorStringWithFormat("function takes too many arguments");
error.SetErrorString("function takes too many arguments");
return false;
}
@ -1490,7 +1490,7 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function,
// Check that the thread plan completed successfully
if (res != lldb::ExpressionResults::eExpressionCompleted) {
error.SetErrorToGenericError();
error.SetErrorStringWithFormat("ThreadPlanCallFunctionUsingABI failed");
error.SetErrorString("ThreadPlanCallFunctionUsingABI failed");
return false;
}
@ -1511,7 +1511,7 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function,
// Check if the return value is valid
if (vobj == nullptr || !retVal) {
error.SetErrorToGenericError();
error.SetErrorStringWithFormat("unable to get the return value");
error.SetErrorString("unable to get the return value");
return false;
}

View File

@ -797,7 +797,7 @@ public:
llvm::Optional<size_t> opt_bit_align = m_type.GetTypeBitAlign(exe_scope);
if (!opt_bit_align) {
err.SetErrorStringWithFormat("can't get the type alignment");
err.SetErrorString("can't get the type alignment");
return;
}

View File

@ -1708,7 +1708,7 @@ bool CommandInterpreter::HandleCommand(const char *command_line,
command_string = command_line;
original_command_string = command_line;
if (m_repeat_command.empty()) {
result.AppendErrorWithFormat("No auto repeat.\n");
result.AppendError("No auto repeat.\n");
result.SetStatus(eReturnStatusFailed);
return false;
}
@ -2141,7 +2141,7 @@ void CommandInterpreter::SourceInitFileCwd(CommandReturnObject &result) {
llvm::sys::path::parent_path(home_init_file)) {
result.SetStatus(eReturnStatusSuccessFinishNoResult);
} else {
result.AppendErrorWithFormat(InitFileWarning);
result.AppendError(InitFileWarning);
result.SetStatus(eReturnStatusFailed);
}
}

View File

@ -39,7 +39,7 @@ Status OptionValue::SetSubValue(const ExecutionContext *exe_ctx,
VarSetOperationType op, llvm::StringRef name,
llvm::StringRef value) {
Status error;
error.SetErrorStringWithFormat("SetSubValue is not supported");
error.SetErrorString("SetSubValue is not supported");
return error;
}

View File

@ -85,7 +85,7 @@ Status OptionValueFormatEntity::SetValueFromString(llvm::StringRef value_str,
if (first_char == '"' || first_char == '\'') {
const size_t trimmed_len = trimmed_value_str.size();
if (trimmed_len == 1 || value_str[trimmed_len - 1] != first_char) {
error.SetErrorStringWithFormat("mismatched quotes");
error.SetErrorString("mismatched quotes");
return error;
}
value_str = trimmed_value_str.substr(1, trimmed_len - 2);

View File

@ -1308,7 +1308,7 @@ llvm::Expected<Args> Options::Parse(const Args &args,
&long_options_index);
if (val == ':') {
error.SetErrorStringWithFormat("last option requires an argument");
error.SetErrorString("last option requires an argument");
break;
}
@ -1317,7 +1317,7 @@ llvm::Expected<Args> Options::Parse(const Args &args,
// Did we get an error?
if (val == '?') {
error.SetErrorStringWithFormat("unknown or ambiguous option");
error.SetErrorString("unknown or ambiguous option");
break;
}
// The option auto-set itself

View File

@ -3154,7 +3154,7 @@ Status Process::PrivateResume() {
if (m_thread_list.WillResume()) {
// Last thing, do the PreResumeActions.
if (!RunPreResumeActions()) {
error.SetErrorStringWithFormat(
error.SetErrorString(
"Process::PrivateResume PreResumeActions failed, not resuming.");
} else {
m_mod_id.BumpResumeID();