diff options
author | Adrian Prantl <aprantl@apple.com> | 2024-08-27 10:59:31 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-27 10:59:31 -0700 |
commit | 0642cd768b80665585c8500bed2933a3b99123dc (patch) | |
tree | a412a5eafff54ef9a7cb884e01907a4f521f5140 /lldb/source/Commands/CommandObjectExpression.cpp | |
parent | acb33a0c9bc902dc1aef703c02b8fd3a1132cb14 (diff) | |
download | llvm-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/CommandObjectExpression.cpp')
-rw-r--r-- | lldb/source/Commands/CommandObjectExpression.cpp | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/lldb/source/Commands/CommandObjectExpression.cpp b/lldb/source/Commands/CommandObjectExpression.cpp index 769f01d..7711946 100644 --- a/lldb/source/Commands/CommandObjectExpression.cpp +++ b/lldb/source/Commands/CommandObjectExpression.cpp @@ -52,7 +52,7 @@ Status CommandObjectExpression::CommandOptions::SetOptionValue( option_arg.str().c_str()); Language::PrintSupportedLanguagesForExpressions(sstr, " ", "\n"); - error.SetErrorString(sstr.GetString()); + error = Status(sstr.GetString().str()); } break; @@ -61,7 +61,7 @@ Status CommandObjectExpression::CommandOptions::SetOptionValue( bool result; result = OptionArgParser::ToBoolean(option_arg, true, &success); if (!success) - error.SetErrorStringWithFormat( + error = Status::FromErrorStringWithFormat( "invalid all-threads value setting: \"%s\"", option_arg.str().c_str()); else @@ -74,7 +74,7 @@ Status CommandObjectExpression::CommandOptions::SetOptionValue( if (success) ignore_breakpoints = tmp_value; else - error.SetErrorStringWithFormat( + error = Status::FromErrorStringWithFormat( "could not convert \"%s\" to a boolean value.", option_arg.str().c_str()); break; @@ -86,7 +86,7 @@ Status CommandObjectExpression::CommandOptions::SetOptionValue( if (success) allow_jit = tmp_value; else - error.SetErrorStringWithFormat( + error = Status::FromErrorStringWithFormat( "could not convert \"%s\" to a boolean value.", option_arg.str().c_str()); break; @@ -95,8 +95,8 @@ Status CommandObjectExpression::CommandOptions::SetOptionValue( case 't': if (option_arg.getAsInteger(0, timeout)) { timeout = 0; - error.SetErrorStringWithFormat("invalid timeout setting \"%s\"", - option_arg.str().c_str()); + error = Status::FromErrorStringWithFormat( + "invalid timeout setting \"%s\"", option_arg.str().c_str()); } break; @@ -106,7 +106,7 @@ Status CommandObjectExpression::CommandOptions::SetOptionValue( if (success) unwind_on_error = tmp_value; else - error.SetErrorStringWithFormat( + error = Status::FromErrorStringWithFormat( "could not convert \"%s\" to a boolean value.", option_arg.str().c_str()); break; @@ -121,7 +121,7 @@ Status CommandObjectExpression::CommandOptions::SetOptionValue( OptionArgParser::ToOptionEnum( option_arg, GetDefinitions()[option_idx].enum_values, 0, error); if (!error.Success()) - error.SetErrorStringWithFormat( + error = Status::FromErrorStringWithFormat( "unrecognized value for description-verbosity '%s'", option_arg.str().c_str()); break; @@ -142,7 +142,7 @@ Status CommandObjectExpression::CommandOptions::SetOptionValue( if (success) auto_apply_fixits = tmp_value ? eLazyBoolYes : eLazyBoolNo; else - error.SetErrorStringWithFormat( + error = Status::FromErrorStringWithFormat( "could not convert \"%s\" to a boolean value.", option_arg.str().c_str()); break; @@ -155,7 +155,7 @@ Status CommandObjectExpression::CommandOptions::SetOptionValue( if (success) suppress_persistent_result = !persist_result ? eLazyBoolYes : eLazyBoolNo; else - error.SetErrorStringWithFormat( + error = Status::FromErrorStringWithFormat( "could not convert \"%s\" to a boolean value.", option_arg.str().c_str()); break; @@ -392,9 +392,9 @@ CanBeUsedForElementCountPrinting(ValueObject &valobj) { CompilerType type(valobj.GetCompilerType()); CompilerType pointee; if (!type.IsPointerType(&pointee)) - return Status("as it does not refer to a pointer"); + return Status::FromErrorString("as it does not refer to a pointer"); if (pointee.IsVoidType()) - return Status("as it refers to a pointer to void"); + return Status::FromErrorString("as it refers to a pointer to void"); return Status(); } @@ -650,7 +650,7 @@ void CommandObjectExpression::DoExecute(llvm::StringRef command, io_handler_sp->SetIsDone(false); debugger.RunIOHandlerAsync(io_handler_sp); } else { - repl_error.SetErrorStringWithFormat( + repl_error = Status::FromErrorStringWithFormat( "Couldn't create a REPL for %s", Language::GetNameForLanguageType(m_command_options.language)); result.SetError(repl_error); |