[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.
This commit is contained in:
Adrian Prantl authored and GitHub committed 2024-08-27 10:59:31 -07:00
1 parent acb33a0c9b
commit 0642cd768b
270 files changed
+3659 -3421

No files matched your search

@@ -269,7 +269,7 @@ protected:
transformed_args);
if (llvm::Error e = expected_return_object.takeError()) {
error.SetErrorString(llvm::toString(std::move(e)).c_str());
error = Status(std::move(e));
return ErrorWithMessage<T>(caller_signature,
"Python method could not be called.", error);
}
@@ -368,9 +368,8 @@ protected:
if (boolean_arg.IsValid())
original_arg = boolean_arg.GetValue();
else
error.SetErrorString(
llvm::formatv("{}: Invalid boolean argument.", LLVM_PRETTY_FUNCTION)
.str());
error = Status::FromErrorStringWithFormatv(
"{}: Invalid boolean argument.", LLVM_PRETTY_FUNCTION);
}
template <std::size_t... I, typename... Args>