Skip to content

Commit 749dca4

Browse files
authored
Merge pull request #6739 from compnerd/value_or
Swift: update `getValueOr` to `value_or`
2 parents 58c3a69 + 977c4f0 commit 749dca4

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

lldb/source/Plugins/ExpressionParser/Swift/SwiftREPLMaterializer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ class EntityREPLResultVariable : public Materializer::Entity {
155155
ret->ValueUpdated();
156156

157157
if (variable) {
158-
const size_t pvar_byte_size = ret->GetByteSize().getValueOr(0);
158+
const size_t pvar_byte_size = ret->GetByteSize().value_or(0);
159159
uint8_t *pvar_data = ret->GetValueBytes();
160160

161161
Status read_error;
@@ -409,7 +409,7 @@ class EntityREPLPersistentVariable : public Materializer::Entity {
409409
// FIXME: This may not work if the value is not bitwise-takable.
410410
execution_unit->ReadMemory(
411411
m_persistent_variable_sp->GetValueBytes(), var_addr,
412-
m_persistent_variable_sp->GetByteSize().getValueOr(0), read_error);
412+
m_persistent_variable_sp->GetByteSize().value_or(0), read_error);
413413

414414
if (!read_error.Success()) {
415415
err.SetErrorStringWithFormat(

lldb/source/Plugins/LanguageRuntime/Swift/SwiftLanguageRuntimeDynamicTypeResolution.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1368,7 +1368,7 @@ CompilerType SwiftLanguageRuntimeImpl::GetChildCompilerTypeAtIndex(
13681368
os << '.' << idx;
13691369
child_byte_size =
13701370
GetBitSize(pack_element_type, exe_ctx.GetBestExecutionContextScope())
1371-
.getValueOr(0);
1371+
.value_or(0);
13721372
int stack_dir = -1;
13731373
child_byte_offset = ts->GetPointerByteSize() * idx * stack_dir;
13741374
child_bitfield_bit_size = 0;
@@ -2120,7 +2120,7 @@ bool SwiftLanguageRuntimeImpl::GetDynamicTypeAndAddress_Protocol(
21202120
return {};
21212121
if (use_local_buffer)
21222122
PushLocalBuffer(existential_address,
2123-
in_value.GetByteSize().getValueOr(0));
2123+
in_value.GetByteSize().value_or(0));
21242124

21252125
auto result = remote_ast.getDynamicTypeAndAddressForExistential(
21262126
remote_existential, swift_type);
@@ -2186,7 +2186,7 @@ bool SwiftLanguageRuntimeImpl::GetDynamicTypeAndAddress_Protocol(
21862186

21872187

21882188
if (use_local_buffer)
2189-
PushLocalBuffer(existential_address, in_value.GetByteSize().getValueOr(0));
2189+
PushLocalBuffer(existential_address, in_value.GetByteSize().value_or(0));
21902190

21912191
swift::remote::RemoteAddress remote_existential(existential_address);
21922192

@@ -2850,7 +2850,7 @@ SwiftLanguageRuntimeImpl::GetValueType(ValueObject &in_value,
28502850

28512851
if (use_local_buffer)
28522852
PushLocalBuffer(existential_address,
2853-
in_value.GetByteSize().getValueOr(0));
2853+
in_value.GetByteSize().value_or(0));
28542854

28552855
// Read the value witness table and check if the data is inlined in
28562856
// the existential container or not.

lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwiftTypeRef.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2775,7 +2775,7 @@ TypeSystemSwiftTypeRef::GetNumChildren(opaque_compiler_type_t type,
27752775
(ReconstructType(type), omit_empty_base_classes, exe_ctx),
27762776
(ReconstructType(type), omit_empty_base_classes, exe_ctx));
27772777
}()
2778-
.getValueOr(0);
2778+
.value_or(0);
27792779

27802780
LLDB_LOGF(GetLog(LLDBLog::Types),
27812781
"Using SwiftASTContext::GetNumChildren fallback for type %s",
@@ -2831,7 +2831,7 @@ uint32_t TypeSystemSwiftTypeRef::GetNumFields(opaque_compiler_type_t type,
28312831
(ReconstructType(type), exe_ctx),
28322832
(ReconstructType(type), exe_ctx));
28332833
}()
2834-
.getValueOr(0);
2834+
.value_or(0);
28352835
}
28362836

28372837
LLDB_LOGF(GetLog(LLDBLog::Types),
@@ -2926,7 +2926,7 @@ CompilerType TypeSystemSwiftTypeRef::GetChildCompilerTypeAtIndex(
29262926
if (auto *swift_ast_context = GetSwiftASTContext())
29272927
ast_num_children = swift_ast_context->GetNumChildren(
29282928
ReconstructType(type), omit_empty_base_classes, exe_ctx);
2929-
return ast_num_children.getValueOr(0);
2929+
return ast_num_children.value_or(0);
29302930
};
29312931
auto impl = [&]() -> CompilerType {
29322932
ExecutionContextScope *exe_scope = nullptr;
@@ -2974,7 +2974,7 @@ CompilerType TypeSystemSwiftTypeRef::GetChildCompilerTypeAtIndex(
29742974
child_name = "rawValue";
29752975
auto bit_size = raw_value.GetBitSize(
29762976
exe_ctx ? exe_ctx->GetBestExecutionContextScope() : nullptr);
2977-
child_byte_size = bit_size.getValueOr(0) / 8;
2977+
child_byte_size = bit_size.value_or(0) / 8;
29782978
child_byte_offset = 0;
29792979
child_bitfield_bit_size = 0;
29802980
child_bitfield_bit_offset = 0;
@@ -3057,7 +3057,7 @@ CompilerType TypeSystemSwiftTypeRef::GetChildCompilerTypeAtIndex(
30573057
if (ModuleList::GetGlobalModuleListProperties().GetSwiftValidateTypeSystem())
30583058
if (get_ast_num_children() <
30593059
runtime->GetNumChildren({weak_from_this(), type}, exe_scope)
3060-
.getValueOr(0))
3060+
.value_or(0))
30613061
return impl();
30623062
if (ShouldSkipValidation(type))
30633063
return impl();
@@ -3125,7 +3125,7 @@ size_t TypeSystemSwiftTypeRef::GetIndexOfChildMemberWithName(
31253125
GetCanonicalType(type), name, exe_ctx, omit_empty_base_classes,
31263126
child_indexes);
31273127
if (found_numidx.first) {
3128-
size_t index_size = found_numidx.second.getValueOr(0);
3128+
size_t index_size = found_numidx.second.value_or(0);
31293129
#ifndef NDEBUG
31303130
// This block is a custom VALIDATE_AND_RETURN implementation to support
31313131
// checking the return value, plus the by-ref `child_indexes`.

0 commit comments

Comments
 (0)