[Lldb-commits] [lldb] 8953376 - [lldb] Remove redundant WithFormat suffixes (NFC)
Jonas Devlieghere via lldb-commits
lldb-commits at lists.llvm.org
Mon Jul 20 23:00:39 PDT 2020
Author: Jonas Devlieghere
Date: 2020-07-20T23:00:32-07:00
New Revision: 895337647896edefda244c7afc4b71eab41ff850
URL: https://github.com/llvm/llvm-project/commit/895337647896edefda244c7afc4b71eab41ff850
DIFF: https://github.com/llvm/llvm-project/commit/895337647896edefda244c7afc4b71eab41ff850.diff
LOG: [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.
Added:
Modified:
lldb/source/Breakpoint/Breakpoint.cpp
lldb/source/Breakpoint/BreakpointID.cpp
lldb/source/Breakpoint/BreakpointIDList.cpp
lldb/source/Breakpoint/BreakpointOptions.cpp
lldb/source/Breakpoint/BreakpointResolver.cpp
lldb/source/Breakpoint/BreakpointResolverName.cpp
lldb/source/Core/ModuleList.cpp
lldb/source/Core/SearchFilter.cpp
lldb/source/Core/Value.cpp
lldb/source/Expression/DWARFExpression.cpp
lldb/source/Expression/IRInterpreter.cpp
lldb/source/Expression/Materializer.cpp
lldb/source/Interpreter/CommandInterpreter.cpp
lldb/source/Interpreter/OptionValue.cpp
lldb/source/Interpreter/OptionValueFormatEntity.cpp
lldb/source/Interpreter/Options.cpp
lldb/source/Target/Process.cpp
Removed:
################################################################################
diff --git a/lldb/source/Breakpoint/Breakpoint.cpp b/lldb/source/Breakpoint/Breakpoint.cpp
index 317dfa231094..88c7f3352f42 100644
--- a/lldb/source/Breakpoint/Breakpoint.cpp
+++ b/lldb/source/Breakpoint/Breakpoint.cpp
@@ -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;
}
diff --git a/lldb/source/Breakpoint/BreakpointID.cpp b/lldb/source/Breakpoint/BreakpointID.cpp
index 293baf4ad1c7..a37abcfa52ab 100644
--- a/lldb/source/Breakpoint/BreakpointID.cpp
+++ b/lldb/source/Breakpoint/BreakpointID.cpp
@@ -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;
}
diff --git a/lldb/source/Breakpoint/BreakpointIDList.cpp b/lldb/source/Breakpoint/BreakpointIDList.cpp
index 705bc5ee1c8d..95ae60522262 100644
--- a/lldb/source/Breakpoint/BreakpointIDList.cpp
+++ b/lldb/source/Breakpoint/BreakpointIDList.cpp
@@ -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;
}
diff --git a/lldb/source/Breakpoint/BreakpointOptions.cpp b/lldb/source/Breakpoint/BreakpointOptions.cpp
index 0ce7b0f852e8..f6bb7633d0a9 100644
--- a/lldb/source/Breakpoint/BreakpointOptions.cpp
+++ b/lldb/source/Breakpoint/BreakpointOptions.cpp
@@ -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;
}
diff --git a/lldb/source/Breakpoint/BreakpointResolver.cpp b/lldb/source/Breakpoint/BreakpointResolver.cpp
index 7c03a0745ac6..cfd073367b00 100644
--- a/lldb/source/Breakpoint/BreakpointResolver.cpp
+++ b/lldb/source/Breakpoint/BreakpointResolver.cpp
@@ -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;
}
diff --git a/lldb/source/Breakpoint/BreakpointResolverName.cpp b/lldb/source/Breakpoint/BreakpointResolverName.cpp
index 25f5bb3f6eed..6fab20af5e59 100644
--- a/lldb/source/Breakpoint/BreakpointResolverName.cpp
+++ b/lldb/source/Breakpoint/BreakpointResolverName.cpp
@@ -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;
}
diff --git a/lldb/source/Core/ModuleList.cpp b/lldb/source/Core/ModuleList.cpp
index 1f1f5efcf4cc..164d0740acfd 100644
--- a/lldb/source/Core/ModuleList.cpp
+++ b/lldb/source/Core/ModuleList.cpp
@@ -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");
}
}
}
diff --git a/lldb/source/Core/SearchFilter.cpp b/lldb/source/Core/SearchFilter.cpp
index ea51fb379181..fc1ceff71912 100644
--- a/lldb/source/Core/SearchFilter.cpp
+++ b/lldb/source/Core/SearchFilter.cpp
@@ -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;
}
diff --git a/lldb/source/Core/Value.cpp b/lldb/source/Core/Value.cpp
index 63467644cdef..fd5f7e2565d8 100644
--- a/lldb/source/Core/Value.cpp
+++ b/lldb/source/Core/Value.cpp
@@ -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;
diff --git a/lldb/source/Expression/DWARFExpression.cpp b/lldb/source/Expression/DWARFExpression.cpp
index 6050c1922564..87e2c8243939 100644
--- a/lldb/source/Expression/DWARFExpression.cpp
+++ b/lldb/source/Expression/DWARFExpression.cpp
@@ -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;
}
diff --git a/lldb/source/Expression/IRInterpreter.cpp b/lldb/source/Expression/IRInterpreter.cpp
index 4c7a65626598..b87a759aadc5 100644
--- a/lldb/source/Expression/IRInterpreter.cpp
+++ b/lldb/source/Expression/IRInterpreter.cpp
@@ -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;
}
diff --git a/lldb/source/Expression/Materializer.cpp b/lldb/source/Expression/Materializer.cpp
index f33462053f22..200204c12cd2 100644
--- a/lldb/source/Expression/Materializer.cpp
+++ b/lldb/source/Expression/Materializer.cpp
@@ -797,7 +797,7 @@ class EntityResultVariable : public Materializer::Entity {
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;
}
diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp
index e55b25500179..963c1ea76ee8 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -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);
}
}
diff --git a/lldb/source/Interpreter/OptionValue.cpp b/lldb/source/Interpreter/OptionValue.cpp
index 0f1030927808..0bd9a591af67 100644
--- a/lldb/source/Interpreter/OptionValue.cpp
+++ b/lldb/source/Interpreter/OptionValue.cpp
@@ -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;
}
diff --git a/lldb/source/Interpreter/OptionValueFormatEntity.cpp b/lldb/source/Interpreter/OptionValueFormatEntity.cpp
index 6b36bd575186..3a32a4721b68 100644
--- a/lldb/source/Interpreter/OptionValueFormatEntity.cpp
+++ b/lldb/source/Interpreter/OptionValueFormatEntity.cpp
@@ -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);
diff --git a/lldb/source/Interpreter/Options.cpp b/lldb/source/Interpreter/Options.cpp
index c14b6b6ce66a..d9af6cc03fd2 100644
--- a/lldb/source/Interpreter/Options.cpp
+++ b/lldb/source/Interpreter/Options.cpp
@@ -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
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index d777a2713911..b7694ec43f34 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -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();
More information about the lldb-commits
mailing list