summaryrefslogtreecommitdiff
path: root/lldb/source/Interpreter/OptionGroupFormat.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/Interpreter/OptionGroupFormat.cpp
parentacb33a0c9bc902dc1aef703c02b8fd3a1132cb14 (diff)
[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/Interpreter/OptionGroupFormat.cpp')
-rw-r--r--lldb/source/Interpreter/OptionGroupFormat.cpp21
1 files changed, 11 insertions, 10 deletions
diff --git a/lldb/source/Interpreter/OptionGroupFormat.cpp b/lldb/source/Interpreter/OptionGroupFormat.cpp
index 6b56ad2ea819..d9eab13e0bc2 100644
--- a/lldb/source/Interpreter/OptionGroupFormat.cpp
+++ b/lldb/source/Interpreter/OptionGroupFormat.cpp
@@ -81,23 +81,23 @@ Status OptionGroupFormat::SetOptionValue(uint32_t option_idx,
case 'c':
if (m_count.GetDefaultValue() == 0) {
- error.SetErrorString("--count option is disabled");
+ error = Status::FromErrorString("--count option is disabled");
} else {
error = m_count.SetValueFromString(option_arg);
if (m_count.GetCurrentValue() == 0)
- error.SetErrorStringWithFormat("invalid --count option value '%s'",
- option_arg.str().c_str());
+ error = Status::FromErrorStringWithFormat(
+ "invalid --count option value '%s'", option_arg.str().c_str());
}
break;
case 's':
if (m_byte_size.GetDefaultValue() == 0) {
- error.SetErrorString("--size option is disabled");
+ error = Status::FromErrorString("--size option is disabled");
} else {
error = m_byte_size.SetValueFromString(option_arg);
if (m_byte_size.GetCurrentValue() == 0)
- error.SetErrorStringWithFormat("invalid --size option value '%s'",
- option_arg.str().c_str());
+ error = Status::FromErrorStringWithFormat(
+ "invalid --size option value '%s'", option_arg.str().c_str());
}
break;
@@ -122,8 +122,8 @@ Status OptionGroupFormat::SetOptionValue(uint32_t option_idx,
if (!gdb_format_str.empty() ||
(format == eFormatInvalid && byte_size == 0 && count == 0)) {
// Nothing got set correctly
- error.SetErrorStringWithFormat("invalid gdb format string '%s'",
- option_arg.str().c_str());
+ error = Status::FromErrorStringWithFormat(
+ "invalid gdb format string '%s'", option_arg.str().c_str());
return error;
}
@@ -144,7 +144,7 @@ Status OptionGroupFormat::SetOptionValue(uint32_t option_idx,
// Byte size is disabled, make sure it wasn't specified but if this is an
// address, it's actually necessary to specify one so don't error out
if (byte_size > 0 && format != lldb::eFormatAddressInfo) {
- error.SetErrorString(
+ error = Status::FromErrorString(
"this command doesn't support specifying a byte size");
return error;
}
@@ -158,7 +158,8 @@ Status OptionGroupFormat::SetOptionValue(uint32_t option_idx,
} else {
// Count is disabled, make sure it wasn't specified
if (count > 0) {
- error.SetErrorString("this command doesn't support specifying a count");
+ error = Status::FromErrorString(
+ "this command doesn't support specifying a count");
return error;
}
}