Skip to content

Commit ef3cf72

Browse files
committed
Move to llvm::expected, clean up comments
1 parent 53d8c0b commit ef3cf72

File tree

4 files changed

+18
-11
lines changed

4 files changed

+18
-11
lines changed

lldb/include/lldb/API/SBSaveCoreOptions.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ class LLDB_API SBSaveCoreOptions {
119119
/// an empty collection will be returned.
120120
SBThreadCollection GetThreadsToSave() const;
121121

122-
/// Get the current total number of bytes the core is expected to be but not
123-
/// including the overhead of the core file format. Requires a Process and
122+
/// Get the current total number of bytes the core is expected to have
123+
/// excluding the overhead of the core file format. Requires a Process and
124124
/// Style to be specified.
125125
///
126126
/// \note

lldb/include/lldb/Symbol/SaveCoreOptions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class SaveCoreOptions {
4949

5050
lldb_private::ThreadCollection::collection GetThreadsToSave() const;
5151

52-
uint64_t GetCurrentSizeInBytes(Status &error);
52+
llvm::Expected<uint64_t> GetCurrentSizeInBytes();
5353

5454
void Clear();
5555

lldb/source/API/SBSaveCoreOptions.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,14 @@ void SBSaveCoreOptions::Clear() {
116116

117117
uint64_t SBSaveCoreOptions::GetCurrentSizeInBytes(SBError &error) {
118118
LLDB_INSTRUMENT_VA(this, error);
119-
return m_opaque_up->GetCurrentSizeInBytes(error.ref());
119+
llvm::Expected<uint64_t> expected_bytes = m_opaque_up->GetCurrentSizeInBytes();
120+
if (!expected_bytes) {
121+
error = SBError(lldb_private::Status::FromError(expected_bytes.takeError()));
122+
return 0;
123+
}
124+
// Clear the error, so if the clearer uses it we set it to success.
125+
error.Clear();
126+
return *expected_bytes;
120127
}
121128

122129
lldb_private::SaveCoreOptions &SBSaveCoreOptions::ref() const {

lldb/source/Symbol/SaveCoreOptions.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -145,20 +145,20 @@ SaveCoreOptions::GetThreadsToSave() const {
145145
return thread_collection;
146146
}
147147

148-
uint64_t SaveCoreOptions::GetCurrentSizeInBytes(Status &error) {
149-
if (!m_process_sp) {
150-
error = Status::FromErrorString("Requires a process to be set.");
151-
return 0;
152-
}
148+
llvm::Expected<uint64_t> SaveCoreOptions::GetCurrentSizeInBytes() {
149+
Status error;
150+
if (!m_process_sp)
151+
return Status::FromErrorString("Requires a process to be set.").takeError();
152+
153153

154154
error = EnsureValidConfiguration(m_process_sp);
155155
if (error.Fail())
156-
return 0;
156+
return error.takeError();
157157

158158
CoreFileMemoryRanges ranges;
159159
error = m_process_sp->CalculateCoreFileSaveRanges(*this, ranges);
160160
if (error.Fail())
161-
return 0;
161+
return error.takeError();
162162

163163
uint64_t total_in_bytes = 0;
164164
for (auto &core_range : ranges)

0 commit comments

Comments
 (0)