[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:
@@ -1068,7 +1068,8 @@ ObjectFileELF::RefineModuleDetailsFromNote(lldb_private::DataExtractor &data,
|
||||
// Pull out the min version info.
|
||||
uint32_t version_info;
|
||||
if (data.GetU32(&offset, &version_info, 1) == nullptr) {
|
||||
error.SetErrorString("failed to read FreeBSD ABI note payload");
|
||||
error =
|
||||
Status::FromErrorString("failed to read FreeBSD ABI note payload");
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -1099,7 +1100,8 @@ ObjectFileELF::RefineModuleDetailsFromNote(lldb_private::DataExtractor &data,
|
||||
uint32_t version_info[4];
|
||||
if (data.GetU32(&offset, &version_info[0], note.n_descsz / 4) ==
|
||||
nullptr) {
|
||||
error.SetErrorString("failed to read GNU ABI note payload");
|
||||
error =
|
||||
Status::FromErrorString("failed to read GNU ABI note payload");
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -1160,7 +1162,8 @@ ObjectFileELF::RefineModuleDetailsFromNote(lldb_private::DataExtractor &data,
|
||||
// Save the build id as the UUID for the module.
|
||||
uuid = UUID(buf, note.n_descsz);
|
||||
} else {
|
||||
error.SetErrorString("failed to read GNU_BUILD_ID note payload");
|
||||
error = Status::FromErrorString(
|
||||
"failed to read GNU_BUILD_ID note payload");
|
||||
return error;
|
||||
}
|
||||
}
|
||||
@@ -1180,7 +1183,8 @@ ObjectFileELF::RefineModuleDetailsFromNote(lldb_private::DataExtractor &data,
|
||||
// Pull out the version info.
|
||||
uint32_t version_info;
|
||||
if (data.GetU32(&offset, &version_info, 1) == nullptr) {
|
||||
error.SetErrorString("failed to read NetBSD ABI note payload");
|
||||
error =
|
||||
Status::FromErrorString("failed to read NetBSD ABI note payload");
|
||||
return error;
|
||||
}
|
||||
// Convert the version info into a major/minor/patch number.
|
||||
@@ -1251,10 +1255,11 @@ ObjectFileELF::RefineModuleDetailsFromNote(lldb_private::DataExtractor &data,
|
||||
for (size_t i = 0; i < count; ++i) {
|
||||
cstr = data.GetCStr(&offset);
|
||||
if (cstr == nullptr) {
|
||||
error.SetErrorStringWithFormat("ObjectFileELF::%s trying to read "
|
||||
"at an offset after the end "
|
||||
"(GetCStr returned nullptr)",
|
||||
__FUNCTION__);
|
||||
error = Status::FromErrorStringWithFormat(
|
||||
"ObjectFileELF::%s trying to read "
|
||||
"at an offset after the end "
|
||||
"(GetCStr returned nullptr)",
|
||||
__FUNCTION__);
|
||||
return error;
|
||||
}
|
||||
llvm::StringRef path(cstr);
|
||||
|
||||
Reference in New Issue
Block a user