aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Commands/CommandObjectTarget.cpp
diff options
context:
space:
mode:
authorAdrian Prantl <aprantl@apple.com>2024-08-27 10:59:31 -0700
committerGitHub <noreply@github.com>2024-08-27 10:59:31 -0700
commit0642cd768b80665585c8500bed2933a3b99123dc (patch)
treea412a5eafff54ef9a7cb884e01907a4f521f5140 /lldb/source/Commands/CommandObjectTarget.cpp
parentacb33a0c9bc902dc1aef703c02b8fd3a1132cb14 (diff)
downloadllvm-0642cd768b80665585c8500bed2933a3b99123dc.zip
llvm-0642cd768b80665585c8500bed2933a3b99123dc.tar.gz
llvm-0642cd768b80665585c8500bed2933a3b99123dc.tar.bz2
[lldb] Turn lldb_private::Status into a value type. (#106163)
This patch removes all of the Set.* methods from Status. This cleanup is part of a series of patches that make it harder use the anti-pattern of keeping a long-lives Status object around and updating it while dropping any errors it contains on the floor. This patch is largely NFC, the more interesting next steps this enables is to: 1. remove Status.Clear() 2. assert that Status::operator=() never overwrites an error 3. remove Status::operator=() Note that step (2) will bring 90% of the benefits for users, and step (3) will dramatically clean up the error handling code in various places. In the end my goal is to convert all APIs that are of the form ` ResultTy DoFoo(Status& error) ` to ` llvm::Expected<ResultTy> DoFoo() ` How to read this patch? The interesting changes are in Status.h and Status.cpp, all other changes are mostly ` perl -pi -e 's/\.SetErrorString/ = Status::FromErrorString/g' $(git grep -l SetErrorString lldb/source) ` plus the occasional manual cleanup.
Diffstat (limited to 'lldb/source/Commands/CommandObjectTarget.cpp')
-rw-r--r--lldb/source/Commands/CommandObjectTarget.cpp41
1 files changed, 21 insertions, 20 deletions
diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp
index b77bd8b..10e761f 100644
--- a/lldb/source/Commands/CommandObjectTarget.cpp
+++ b/lldb/source/Commands/CommandObjectTarget.cpp
@@ -186,8 +186,8 @@ public:
if (error.Success())
m_load_dependent_files = tmp_load_dependents;
} else {
- error.SetErrorStringWithFormat("unrecognized short option '%c'",
- short_option);
+ error = Status::FromErrorStringWithFormat(
+ "unrecognized short option '%c'", short_option);
}
return error;
@@ -3461,8 +3461,8 @@ public:
m_addr = OptionArgParser::ToAddress(execution_context, option_arg,
LLDB_INVALID_ADDRESS, &error);
if (m_addr == LLDB_INVALID_ADDRESS)
- error.SetErrorStringWithFormat("invalid address string '%s'",
- option_arg.str().c_str());
+ error = Status::FromErrorStringWithFormat(
+ "invalid address string '%s'", option_arg.str().c_str());
break;
}
@@ -3805,8 +3805,8 @@ public:
case 'o':
if (option_arg.getAsInteger(0, m_offset))
- error.SetErrorStringWithFormat("invalid offset string '%s'",
- option_arg.str().c_str());
+ error = Status::FromErrorStringWithFormat(
+ "invalid offset string '%s'", option_arg.str().c_str());
break;
case 's':
@@ -3825,10 +3825,10 @@ public:
case 'l':
if (option_arg.getAsInteger(0, m_line_number))
- error.SetErrorStringWithFormat("invalid line number string '%s'",
- option_arg.str().c_str());
+ error = Status::FromErrorStringWithFormat(
+ "invalid line number string '%s'", option_arg.str().c_str());
else if (m_line_number == 0)
- error.SetErrorString("zero is an invalid line number");
+ error = Status::FromErrorString("zero is an invalid line number");
m_type = eLookupTypeFileLine;
break;
@@ -3886,8 +3886,9 @@ public:
Status OptionParsingFinished(ExecutionContext *execution_context) override {
Status status;
if (m_all_ranges && !m_verbose) {
- status.SetErrorString("--show-variable-ranges must be used in "
- "conjunction with --verbose.");
+ status =
+ Status::FromErrorString("--show-variable-ranges must be used in "
+ "conjunction with --verbose.");
}
return status;
}
@@ -4709,8 +4710,8 @@ public:
case 'e':
if (option_arg.getAsInteger(0, m_line_end)) {
- error.SetErrorStringWithFormat("invalid end line number: \"%s\"",
- option_arg.str().c_str());
+ error = Status::FromErrorStringWithFormat(
+ "invalid end line number: \"%s\"", option_arg.str().c_str());
break;
}
m_sym_ctx_specified = true;
@@ -4722,14 +4723,14 @@ public:
if (success) {
m_auto_continue = value;
} else
- error.SetErrorStringWithFormat(
+ error = Status::FromErrorStringWithFormat(
"invalid boolean value '%s' passed for -G option",
option_arg.str().c_str());
} break;
case 'l':
if (option_arg.getAsInteger(0, m_line_start)) {
- error.SetErrorStringWithFormat("invalid start line number: \"%s\"",
- option_arg.str().c_str());
+ error = Status::FromErrorStringWithFormat(
+ "invalid start line number: \"%s\"", option_arg.str().c_str());
break;
}
m_sym_ctx_specified = true;
@@ -4757,8 +4758,8 @@ public:
case 't':
if (option_arg.getAsInteger(0, m_thread_id))
- error.SetErrorStringWithFormat("invalid thread id string '%s'",
- option_arg.str().c_str());
+ error = Status::FromErrorStringWithFormat(
+ "invalid thread id string '%s'", option_arg.str().c_str());
m_thread_specified = true;
break;
@@ -4774,8 +4775,8 @@ public:
case 'x':
if (option_arg.getAsInteger(0, m_thread_index))
- error.SetErrorStringWithFormat("invalid thread index string '%s'",
- option_arg.str().c_str());
+ error = Status::FromErrorStringWithFormat(
+ "invalid thread index string '%s'", option_arg.str().c_str());
m_thread_specified = true;
break;