[lldb] Use value_or instead of getValueOr (NFC)

This commit is contained in:
Kazu Hirata 2022-06-19 09:12:01 -07:00
parent 0399473de8
commit aa88161b37
37 changed files with 87 additions and 86 deletions

View File

@ -350,9 +350,9 @@ private:
if (!line_entry_ptr)
return best_match;
const uint32_t line = src_location_spec.GetLine().getValueOr(0);
const uint32_t line = src_location_spec.GetLine().value_or(0);
const uint16_t column =
src_location_spec.GetColumn().getValueOr(LLDB_INVALID_COLUMN_NUMBER);
src_location_spec.GetColumn().value_or(LLDB_INVALID_COLUMN_NUMBER);
const bool exact_match = src_location_spec.GetExactMatch();
for (size_t idx = start_idx; idx < count; ++idx) {

View File

@ -617,9 +617,9 @@ uint32_t SBModule::GetVersion(uint32_t *versions, uint32_t num_versions) {
if (num_versions > 0)
versions[0] = version.empty() ? UINT32_MAX : version.getMajor();
if (num_versions > 1)
versions[1] = version.getMinor().getValueOr(UINT32_MAX);
versions[1] = version.getMinor().value_or(UINT32_MAX);
if (num_versions > 2)
versions[2] = version.getSubminor().getValueOr(UINT32_MAX);
versions[2] = version.getSubminor().value_or(UINT32_MAX);
for (uint32_t i = 3; i < num_versions; ++i)
versions[i] = UINT32_MAX;
return result;

View File

@ -424,7 +424,7 @@ const char *SBPlatform::GetOSBuild() {
PlatformSP platform_sp(GetSP());
if (platform_sp) {
std::string s = platform_sp->GetOSBuildString().getValueOr("");
std::string s = platform_sp->GetOSBuildString().value_or("");
if (!s.empty()) {
// Const-ify the string so we don't need to worry about the lifetime of
// the string
@ -439,7 +439,7 @@ const char *SBPlatform::GetOSDescription() {
PlatformSP platform_sp(GetSP());
if (platform_sp) {
std::string s = platform_sp->GetOSKernelDescription().getValueOr("");
std::string s = platform_sp->GetOSKernelDescription().value_or("");
if (!s.empty()) {
// Const-ify the string so we don't need to worry about the lifetime of
// the string
@ -473,7 +473,7 @@ uint32_t SBPlatform::GetOSMinorVersion() {
llvm::VersionTuple version;
if (PlatformSP platform_sp = GetSP())
version = platform_sp->GetOSVersion();
return version.getMinor().getValueOr(UINT32_MAX);
return version.getMinor().value_or(UINT32_MAX);
}
uint32_t SBPlatform::GetOSUpdateVersion() {
@ -482,7 +482,7 @@ uint32_t SBPlatform::GetOSUpdateVersion() {
llvm::VersionTuple version;
if (PlatformSP platform_sp = GetSP())
version = platform_sp->GetOSVersion();
return version.getSubminor().getValueOr(UINT32_MAX);
return version.getSubminor().value_or(UINT32_MAX);
}
void SBPlatform::SetSDKRoot(const char *sysroot) {

View File

@ -330,7 +330,7 @@ size_t SBValue::GetByteSize() {
ValueLocker locker;
lldb::ValueObjectSP value_sp(GetSP(locker));
if (value_sp) {
result = value_sp->GetByteSize().getValueOr(0);
result = value_sp->GetByteSize().value_or(0);
}
return result;

View File

@ -100,10 +100,10 @@ BreakpointResolverFileLine::SerializeToStructuredData() {
options_dict_sp->AddStringItem(GetKey(OptionNames::FileName),
m_location_spec.GetFileSpec().GetPath());
options_dict_sp->AddIntegerItem(GetKey(OptionNames::LineNumber),
m_location_spec.GetLine().getValueOr(0));
m_location_spec.GetLine().value_or(0));
options_dict_sp->AddIntegerItem(
GetKey(OptionNames::Column),
m_location_spec.GetColumn().getValueOr(LLDB_INVALID_COLUMN_NUMBER));
m_location_spec.GetColumn().value_or(LLDB_INVALID_COLUMN_NUMBER));
options_dict_sp->AddBooleanItem(GetKey(OptionNames::Inlines),
m_location_spec.GetCheckInlines());
options_dict_sp->AddBooleanItem(GetKey(OptionNames::ExactMatch),
@ -227,7 +227,7 @@ Searcher::CallbackReturn BreakpointResolverFileLine::SearchCallback(
// file. So we go through the match list and pull out the sets that have the
// same file spec in their line_entry and treat each set separately.
const uint32_t line = m_location_spec.GetLine().getValueOr(0);
const uint32_t line = m_location_spec.GetLine().value_or(0);
const llvm::Optional<uint16_t> column = m_location_spec.GetColumn();
// We'll create a new SourceLocationSpec that can take into account the
@ -238,7 +238,7 @@ Searcher::CallbackReturn BreakpointResolverFileLine::SearchCallback(
if (is_relative)
search_file_spec.GetDirectory().Clear();
SourceLocationSpec search_location_spec(
search_file_spec, m_location_spec.GetLine().getValueOr(0),
search_file_spec, m_location_spec.GetLine().value_or(0),
m_location_spec.GetColumn(), m_location_spec.GetCheckInlines(),
m_location_spec.GetExactMatch());
@ -272,7 +272,7 @@ lldb::SearchDepth BreakpointResolverFileLine::GetDepth() {
void BreakpointResolverFileLine::GetDescription(Stream *s) {
s->Printf("file = '%s', line = %u, ",
m_location_spec.GetFileSpec().GetPath().c_str(),
m_location_spec.GetLine().getValueOr(0));
m_location_spec.GetLine().value_or(0));
auto column = m_location_spec.GetColumn();
if (column)
s->Printf("column = %u, ", *column);

View File

@ -146,7 +146,7 @@ protected:
valobj_sp = frame_sp->GuessValueForAddress(m_options.address.getValue());
} else if (m_options.reg.hasValue()) {
valobj_sp = frame_sp->GuessValueForRegisterAndOffset(
m_options.reg.getValue(), m_options.offset.getValueOr(0));
m_options.reg.getValue(), m_options.offset.value_or(0));
} else {
StopInfoSP stop_info_sp = thread->GetStopInfo();
if (!stop_info_sp) {

View File

@ -929,7 +929,7 @@ protected:
// We're in business.
// Find out the size of this variable.
size = m_option_watchpoint.watch_size == 0
? valobj_sp->GetByteSize().getValueOr(0)
? valobj_sp->GetByteSize().value_or(0)
: m_option_watchpoint.watch_size;
}
compiler_type = valobj_sp->GetCompilerType();

View File

@ -61,7 +61,7 @@ AddressResolverFileLine::SearchCallback(SearchFilter &filter,
line_start.GetFileAddress(),
m_src_location_spec.GetFileSpec().GetFilename().AsCString(
"<Unknown>"),
m_src_location_spec.GetLine().getValueOr(0));
m_src_location_spec.GetLine().value_or(0));
}
}
}
@ -76,5 +76,5 @@ void AddressResolverFileLine::GetDescription(Stream *s) {
s->Printf(
"File and line address - file: \"%s\" line: %u",
m_src_location_spec.GetFileSpec().GetFilename().AsCString("<Unknown>"),
m_src_location_spec.GetLine().getValueOr(0));
m_src_location_spec.GetLine().value_or(0));
}

View File

@ -16,7 +16,7 @@ SourceLocationSpec::SourceLocationSpec(FileSpec file_spec, uint32_t line,
llvm::Optional<uint16_t> column,
bool check_inlines, bool exact_match)
: m_declaration(file_spec, line,
column.getValueOr(LLDB_INVALID_COLUMN_NUMBER)),
column.value_or(LLDB_INVALID_COLUMN_NUMBER)),
m_check_inlines(check_inlines), m_exact_match(exact_match) {}
SourceLocationSpec::operator bool() const { return m_declaration.IsValid(); }

View File

@ -792,7 +792,7 @@ bool ValueObject::SetData(DataExtractor &data, Status &error) {
uint64_t count = 0;
const Encoding encoding = GetCompilerType().GetEncoding(count);
const size_t byte_size = GetByteSize().getValueOr(0);
const size_t byte_size = GetByteSize().value_or(0);
Value::ValueType value_type = m_value.GetValueType();
@ -1474,7 +1474,7 @@ bool ValueObject::SetValueFromCString(const char *value_str, Status &error) {
uint64_t count = 0;
const Encoding encoding = GetCompilerType().GetEncoding(count);
const size_t byte_size = GetByteSize().getValueOr(0);
const size_t byte_size = GetByteSize().value_or(0);
Value::ValueType value_type = m_value.GetValueType();
@ -1656,13 +1656,13 @@ ValueObjectSP ValueObject::GetSyntheticBitFieldChild(uint32_t from, uint32_t to,
uint32_t bit_field_offset = from;
if (GetDataExtractor().GetByteOrder() == eByteOrderBig)
bit_field_offset =
GetByteSize().getValueOr(0) * 8 - bit_field_size - bit_field_offset;
GetByteSize().value_or(0) * 8 - bit_field_size - bit_field_offset;
// We haven't made a synthetic array member for INDEX yet, so lets make
// one and cache it for any future reference.
ValueObjectChild *synthetic_child = new ValueObjectChild(
*this, GetCompilerType(), index_const_str,
GetByteSize().getValueOr(0), 0, bit_field_size, bit_field_offset,
false, false, eAddressTypeInvalid, 0);
*this, GetCompilerType(), index_const_str, GetByteSize().value_or(0),
0, bit_field_size, bit_field_offset, false, false,
eAddressTypeInvalid, 0);
// Cache the value if we got one back...
if (synthetic_child) {

View File

@ -68,7 +68,7 @@ public:
const bool zero_memory = false;
lldb::addr_t mem = map.Malloc(
m_persistent_variable_sp->GetByteSize().getValueOr(0), 8,
m_persistent_variable_sp->GetByteSize().value_or(0), 8,
lldb::ePermissionsReadable | lldb::ePermissionsWritable,
IRMemoryMap::eAllocationPolicyMirror, zero_memory, allocate_error);
@ -107,7 +107,7 @@ public:
Status write_error;
map.WriteMemory(mem, m_persistent_variable_sp->GetValueBytes(),
m_persistent_variable_sp->GetByteSize().getValueOr(0),
m_persistent_variable_sp->GetByteSize().value_or(0),
write_error);
if (!write_error.Success()) {
@ -236,7 +236,7 @@ public:
map.GetBestExecutionContextScope(),
m_persistent_variable_sp.get()->GetCompilerType(),
m_persistent_variable_sp->GetName(), location, eAddressTypeLoad,
m_persistent_variable_sp->GetByteSize().getValueOr(0));
m_persistent_variable_sp->GetByteSize().value_or(0));
if (frame_top != LLDB_INVALID_ADDRESS &&
frame_bottom != LLDB_INVALID_ADDRESS && location >= frame_bottom &&
@ -282,7 +282,7 @@ public:
m_persistent_variable_sp->GetName().GetCString(),
(uint64_t)mem,
(unsigned long long)m_persistent_variable_sp->GetByteSize()
.getValueOr(0));
.value_or(0));
// Read the contents of the spare memory area
@ -291,7 +291,8 @@ public:
Status read_error;
map.ReadMemory(m_persistent_variable_sp->GetValueBytes(), mem,
m_persistent_variable_sp->GetByteSize().getValueOr(0), read_error);
m_persistent_variable_sp->GetByteSize().value_or(0),
read_error);
if (!read_error.Success()) {
err.SetErrorStringWithFormat(
@ -372,11 +373,12 @@ public:
if (!err.Success()) {
dump_stream.Printf(" <could not be read>\n");
} else {
DataBufferHeap data(
m_persistent_variable_sp->GetByteSize().getValueOr(0), 0);
DataBufferHeap data(m_persistent_variable_sp->GetByteSize().value_or(0),
0);
map.ReadMemory(data.GetBytes(), target_address,
m_persistent_variable_sp->GetByteSize().getValueOr(0), err);
m_persistent_variable_sp->GetByteSize().value_or(0),
err);
if (!err.Success()) {
dump_stream.Printf(" <could not be read>\n");
@ -527,7 +529,7 @@ public:
"size of variable %s (%" PRIu64
") is larger than the ValueObject's size (%" PRIu64 ")",
m_variable_sp->GetName().AsCString(),
m_variable_sp->GetType()->GetByteSize(scope).getValueOr(0),
m_variable_sp->GetType()->GetByteSize(scope).value_or(0),
data.GetByteSize());
}
return;
@ -624,7 +626,7 @@ public:
Status extract_error;
map.GetMemoryData(data, m_temporary_allocation,
valobj_sp->GetByteSize().getValueOr(0), extract_error);
valobj_sp->GetByteSize().value_or(0), extract_error);
if (!extract_error.Success()) {
err.SetErrorStringWithFormat("couldn't get the data for variable %s",
@ -921,7 +923,7 @@ public:
ret->ValueUpdated();
const size_t pvar_byte_size = ret->GetByteSize().getValueOr(0);
const size_t pvar_byte_size = ret->GetByteSize().value_or(0);
uint8_t *pvar_data = ret->GetValueBytes();
map.ReadMemory(pvar_data, address, pvar_byte_size, read_error);

View File

@ -567,7 +567,7 @@ private:
ReturnValueExtractor(Thread &thread, CompilerType &type,
RegisterContext *reg_ctx, ProcessSP process_sp)
: m_thread(thread), m_type(type),
m_byte_size(m_type.GetByteSize(&thread).getValueOr(0)),
m_byte_size(m_type.GetByteSize(&thread).value_or(0)),
m_data_up(new DataBufferHeap(m_byte_size, 0)), m_reg_ctx(reg_ctx),
m_process_sp(process_sp), m_byte_order(process_sp->GetByteOrder()),
m_addr_size(

View File

@ -323,7 +323,7 @@ bool IRForTarget::CreateResultVariable(llvm::Function &llvm_function) {
LLDB_LOG(log, "Creating a new result global: \"{0}\" with size {1}",
m_result_name,
m_result_type.GetByteSize(target_sp.get()).getValueOr(0));
m_result_type.GetByteSize(target_sp.get()).value_or(0));
// Construct a new result global and set up its metadata

View File

@ -569,7 +569,7 @@ void ClassDescriptorV2::iVarsStorage::fill(AppleObjCRuntimeV2 &runtime,
"name = {0}, encoding = {1}, offset_ptr = {2:x}, size = "
"{3}, type_size = {4}",
name, type, offset_ptr, size,
ivar_type.GetByteSize(nullptr).getValueOr(0));
ivar_type.GetByteSize(nullptr).value_or(0));
Scalar offset_scalar;
Status error;
const int offset_ptr_size = 4;

View File

@ -128,7 +128,7 @@ Status PlatformAndroidRemoteGDBServer::ConnectRemote(Args &args) {
std::string connect_url;
auto error =
MakeConnectURL(g_remote_platform_pid, parsed_url->port.getValueOr(0),
MakeConnectURL(g_remote_platform_pid, parsed_url->port.value_or(0),
parsed_url->path, connect_url);
if (error.Fail())
@ -217,7 +217,7 @@ lldb::ProcessSP PlatformAndroidRemoteGDBServer::ConnectProcess(
std::string new_connect_url;
error = MakeConnectURL(s_remote_gdbserver_fake_pid--,
parsed_url->port.getValueOr(0), parsed_url->path,
parsed_url->port.value_or(0), parsed_url->path,
new_connect_url);
if (error.Fail())
return nullptr;

View File

@ -824,7 +824,7 @@ FileSpec PlatformDarwin::GetSDKDirectoryForModules(XcodeSDK::Type sdk_type) {
FileSpec native_sdk_spec = sdks_spec;
StreamString native_sdk_name;
native_sdk_name.Printf("MacOSX%u.%u.sdk", version.getMajor(),
version.getMinor().getValueOr(0));
version.getMinor().value_or(0));
native_sdk_spec.AppendPathComponent(native_sdk_name.GetString());
if (FileSystem::Instance().Exists(native_sdk_spec)) {

View File

@ -20,7 +20,7 @@ using namespace llvm;
static bool IsTotalBufferLimitReached(ArrayRef<cpu_id_t> cores,
const TraceIntelPTStartRequest &request) {
uint64_t required = cores.size() * request.ipt_trace_size;
uint64_t limit = request.process_buffer_size_limit.getValueOr(
uint64_t limit = request.process_buffer_size_limit.value_or(
std::numeric_limits<uint64_t>::max());
return required > limit;
}

View File

@ -77,8 +77,8 @@ llvm::Expected<PerfEvent> PerfEvent::Init(perf_event_attr &attr,
Optional<long> group_fd,
unsigned long flags) {
errno = 0;
long fd = syscall(SYS_perf_event_open, &attr, pid.getValueOr(-1),
cpu.getValueOr(-1), group_fd.getValueOr(-1), flags);
long fd = syscall(SYS_perf_event_open, &attr, pid.value_or(-1),
cpu.value_or(-1), group_fd.value_or(-1), flags);
if (fd == -1) {
std::string err_msg =
llvm::formatv("perf event syscall failed: {0}", std::strerror(errno));

View File

@ -45,8 +45,7 @@ llvm::ArrayRef<uint8_t> MinidumpParser::GetData() {
}
llvm::ArrayRef<uint8_t> MinidumpParser::GetStream(StreamType stream_type) {
return m_file->getRawStream(stream_type)
.getValueOr(llvm::ArrayRef<uint8_t>());
return m_file->getRawStream(stream_type).value_or(llvm::ArrayRef<uint8_t>());
}
UUID MinidumpParser::GetModuleUUID(const minidump::Module *module) {

View File

@ -488,7 +488,7 @@ void SymbolFileBreakpad::AddSymbols(Symtab &symtab) {
/*is_global*/ true, /*is_debug*/ false,
/*is_trampoline*/ false, /*is_artificial*/ false,
AddressRange(section_sp, address - section_sp->GetFileAddress(),
size.getValueOr(0)),
size.value_or(0)),
size.hasValue(), /*contains_linker_annotations*/ false, /*flags*/ 0);
};
@ -806,7 +806,7 @@ void SymbolFileBreakpad::ParseFileRecords() {
if (record->Number >= m_files->size())
m_files->resize(record->Number + 1);
FileSpec::Style style = FileSpec::GuessPathStyle(record->Name)
.getValueOr(FileSpec::Style::native);
.value_or(FileSpec::Style::native);
(*m_files)[record->Number] = FileSpec(record->Name, style);
}
}

View File

@ -29,7 +29,7 @@ public:
DIERef(llvm::Optional<uint32_t> dwo_num, Section section,
dw_offset_t die_offset)
: m_dwo_num(dwo_num.getValueOr(0)), m_dwo_num_valid(bool(dwo_num)),
: m_dwo_num(dwo_num.value_or(0)), m_dwo_num_valid(bool(dwo_num)),
m_section(section), m_die_offset(die_offset) {
assert(this->dwo_num() == dwo_num && "Dwo number out of range?");
}

View File

@ -614,7 +614,7 @@ DWARFASTParserClang::ParseTypeModifier(const SymbolContext &sc,
resolve_state = Type::ResolveState::Full;
clang_type = m_ast.GetBuiltinTypeForDWARFEncodingAndBitSize(
attrs.name.GetStringRef(), attrs.encoding,
attrs.byte_size.getValueOr(0) * 8);
attrs.byte_size.value_or(0) * 8);
break;
case DW_TAG_pointer_type:
@ -849,7 +849,7 @@ TypeSP DWARFASTParserClang::ParseEnum(const SymbolContext &sc,
bool is_signed = false;
enumerator_clang_type.IsIntegerType(is_signed);
ParseChildEnumerators(clang_type, is_signed,
type_sp->GetByteSize(nullptr).getValueOr(0), die);
type_sp->GetByteSize(nullptr).value_or(0), die);
}
TypeSystemClang::CompleteTagDeclarationDefinition(clang_type);
} else {
@ -1297,7 +1297,7 @@ TypeSP DWARFASTParserClang::ParseArrayType(const DWARFDIE &die,
attrs.bit_stride = array_info->bit_stride;
}
if (attrs.byte_stride == 0 && attrs.bit_stride == 0)
attrs.byte_stride = element_type->GetByteSize(nullptr).getValueOr(0);
attrs.byte_stride = element_type->GetByteSize(nullptr).value_or(0);
CompilerType array_element_type = element_type->GetForwardCompilerType();
RequireCompleteType(array_element_type);
@ -1532,7 +1532,7 @@ DWARFASTParserClang::ParseStructureLikeDIE(const SymbolContext &sc,
}
if (dwarf->GetUniqueDWARFASTTypeMap().Find(
unique_typename, die, unique_decl, attrs.byte_size.getValueOr(-1),
unique_typename, die, unique_decl, attrs.byte_size.value_or(-1),
*unique_ast_entry_up)) {
type_sp = unique_ast_entry_up->m_type_sp;
if (type_sp) {
@ -1757,7 +1757,7 @@ DWARFASTParserClang::ParseStructureLikeDIE(const SymbolContext &sc,
unique_ast_entry_up->m_type_sp = type_sp;
unique_ast_entry_up->m_die = die;
unique_ast_entry_up->m_declaration = unique_decl;
unique_ast_entry_up->m_byte_size = attrs.byte_size.getValueOr(0);
unique_ast_entry_up->m_byte_size = attrs.byte_size.value_or(0);
dwarf->GetUniqueDWARFASTTypeMap().Insert(unique_typename,
*unique_ast_entry_up);
@ -2114,7 +2114,7 @@ bool DWARFASTParserClang::CompleteRecordType(const DWARFDIE &die,
if (!layout_info.field_offsets.empty() || !layout_info.base_offsets.empty() ||
!layout_info.vbase_offsets.empty()) {
if (type)
layout_info.bit_size = type->GetByteSize(nullptr).getValueOr(0) * 8;
layout_info.bit_size = type->GetByteSize(nullptr).value_or(0) * 8;
if (layout_info.bit_size == 0)
layout_info.bit_size =
die.GetAttributeValueAsUnsigned(DW_AT_byte_size, 0) * 8;
@ -2136,7 +2136,7 @@ bool DWARFASTParserClang::CompleteEnumType(const DWARFDIE &die,
bool is_signed = false;
clang_type.IsIntegerType(is_signed);
ParseChildEnumerators(clang_type, is_signed,
type->GetByteSize(nullptr).getValueOr(0), die);
type->GetByteSize(nullptr).value_or(0), die);
}
TypeSystemClang::CompleteTagDeclarationDefinition(clang_type);
}
@ -2488,7 +2488,7 @@ MemberAttributes::MemberAttributes(const DWARFDIE &die,
// are not sane, remove them. If we don't do this then we will end up
// with a crash if we try to use this type in an expression when clang
// becomes unhappy with its recycled debug info.
if (byte_size.getValueOr(0) == 0 && bit_offset < 0) {
if (byte_size.value_or(0) == 0 && bit_offset < 0) {
bit_size = 0;
bit_offset = 0;
}
@ -2669,7 +2669,7 @@ void DWARFASTParserClang::ParseSingleMember(
ObjectFile *objfile = die.GetDWARF()->GetObjectFile();
if (objfile->GetByteOrder() == eByteOrderLittle) {
this_field_info.bit_offset += attrs.byte_size.getValueOr(0) * 8;
this_field_info.bit_offset += attrs.byte_size.value_or(0) * 8;
this_field_info.bit_offset -= (attrs.bit_offset + attrs.bit_size);
} else {
this_field_info.bit_offset += attrs.bit_offset;

View File

@ -789,7 +789,7 @@ void DWARFUnit::ComputeCompDirAndGuessPathStyle() {
die->GetAttributeValueAsString(this, DW_AT_comp_dir, nullptr));
if (!comp_dir.empty()) {
FileSpec::Style comp_dir_style =
FileSpec::GuessPathStyle(comp_dir).getValueOr(FileSpec::Style::native);
FileSpec::GuessPathStyle(comp_dir).value_or(FileSpec::Style::native);
m_comp_dir = FileSpec(comp_dir, comp_dir_style);
} else {
// Try to detect the style based on the DW_AT_name attribute, but just store
@ -797,7 +797,7 @@ void DWARFUnit::ComputeCompDirAndGuessPathStyle() {
const char *name =
die->GetAttributeValueAsString(this, DW_AT_name, nullptr);
m_comp_dir = FileSpec(
"", FileSpec::GuessPathStyle(name).getValueOr(FileSpec::Style::native));
"", FileSpec::GuessPathStyle(name).value_or(FileSpec::Style::native));
}
}

View File

@ -155,7 +155,7 @@ public:
const DWARFAbbreviationDeclarationSet *GetAbbreviations() const;
dw_offset_t GetAbbrevOffset() const;
uint8_t GetAddressByteSize() const { return m_header.GetAddressByteSize(); }
dw_addr_t GetAddrBase() const { return m_addr_base.getValueOr(0); }
dw_addr_t GetAddrBase() const { return m_addr_base.value_or(0); }
dw_addr_t GetBaseAddress() const { return m_base_addr; }
dw_offset_t GetLineTableOffset();
dw_addr_t GetRangesBase() const { return m_ranges_base; }

View File

@ -1371,8 +1371,8 @@ user_id_t SymbolFileDWARF::GetUID(DIERef ref) {
if (GetDebugMapSymfile())
return GetID() | ref.die_offset();
lldbassert(GetDwoNum().getValueOr(0) <= 0x3fffffff);
return user_id_t(GetDwoNum().getValueOr(0)) << 32 | ref.die_offset() |
lldbassert(GetDwoNum().value_or(0) <= 0x3fffffff);
return user_id_t(GetDwoNum().value_or(0)) << 32 | ref.die_offset() |
lldb::user_id_t(GetDwoNum().hasValue()) << 62 |
lldb::user_id_t(ref.section() == DIERef::Section::DebugTypes) << 63;
}
@ -1897,7 +1897,7 @@ SymbolFileDWARF::GlobalVariableMap &SymbolFileDWARF::GetGlobalAranges() {
lldb::addr_t byte_size = 1;
if (var_sp->GetType())
byte_size =
var_sp->GetType()->GetByteSize(nullptr).getValueOr(0);
var_sp->GetType()->GetByteSize(nullptr).value_or(0);
m_global_aranges_up->Append(GlobalVariableMap::Entry(
file_addr, byte_size, var_sp.get()));
}
@ -3244,7 +3244,7 @@ VariableSP SymbolFileDWARF::ParseVariableDIE(const SymbolContext &sc,
DataExtractor data = die.GetCU()->GetLocationData();
dw_offset_t offset = location_form.Unsigned();
if (location_form.Form() == DW_FORM_loclistx)
offset = die.GetCU()->GetLoclistOffset(offset).getValueOr(-1);
offset = die.GetCU()->GetLoclistOffset(offset).value_or(-1);
if (data.ValidOffset(offset)) {
data = DataExtractor(data, offset, data.GetByteSize() - offset);
location = DWARFExpression(module, data, die.GetCU());
@ -3465,7 +3465,7 @@ VariableSP SymbolFileDWARF::ParseVariableDIE(const SymbolContext &sc,
if (use_type_size_for_value && type_sp->GetType())
location.UpdateValue(const_value_form.Unsigned(),
type_sp->GetType()->GetByteSize(nullptr).getValueOr(0),
type_sp->GetType()->GetByteSize(nullptr).value_or(0),
die.GetCU()->GetAddressByteSize());
return std::make_shared<Variable>(

View File

@ -71,7 +71,7 @@ clang::QualType UdtRecordCompleter::AddBaseClassForTypeIndex(
return {};
m_bases.push_back(
std::make_pair(vtable_idx.getValueOr(0), std::move(base_spec)));
std::make_pair(vtable_idx.value_or(0), std::move(base_spec)));
return qt;
}

View File

@ -711,7 +711,7 @@ lldb::TypeSP PDBASTParser::CreateLLDBTypeFromPDBType(const PDBSymbol &type) {
bytes = size;
Encoding encoding = TranslateBuiltinEncoding(builtin_kind);
CompilerType builtin_ast_type = GetBuiltinTypeForPDBEncodingAndBitSize(
m_ast, *builtin_type, encoding, bytes.getValueOr(0) * 8);
m_ast, *builtin_type, encoding, bytes.value_or(0) * 8);
if (builtin_type->isConstType())
builtin_ast_type = builtin_ast_type.AddConstModifier();

View File

@ -797,7 +797,7 @@ uint32_t SymbolFilePDB::ResolveSymbolContext(
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
const size_t old_size = sc_list.GetSize();
const FileSpec &file_spec = src_location_spec.GetFileSpec();
const uint32_t line = src_location_spec.GetLine().getValueOr(0);
const uint32_t line = src_location_spec.GetLine().value_or(0);
if (resolve_scope & lldb::eSymbolContextCompUnit) {
// Locate all compilation units with line numbers referencing the specified
// file. For example, if `file_spec` is <vector>, then this should return

View File

@ -74,7 +74,7 @@ SymbolVendorELF::CreateInstance(const lldb::ModuleSP &module_sp,
FileSpec fspec = module_sp->GetSymbolFileFileSpec();
// Otherwise, try gnu_debuglink, if one exists.
if (!fspec)
fspec = obj_file->GetDebugLink().getValueOr(FileSpec());
fspec = obj_file->GetDebugLink().value_or(FileSpec());
LLDB_SCOPED_TIMERF("SymbolVendorELF::CreateInstance (module = %s)",
module_sp->GetFileSpec().GetPath().c_str());

View File

@ -74,7 +74,7 @@ SymbolVendorPECOFF::CreateInstance(const lldb::ModuleSP &module_sp,
FileSpec fspec = module_sp->GetSymbolFileFileSpec();
// Otherwise, try gnu_debuglink, if one exists.
if (!fspec)
fspec = obj_file->GetDebugLink().getValueOr(FileSpec());
fspec = obj_file->GetDebugLink().value_or(FileSpec());
LLDB_SCOPED_TIMERF("SymbolVendorPECOFF::CreateInstance (module = %s)",
module_sp->GetFileSpec().GetPath().c_str());

View File

@ -73,7 +73,7 @@ bool CommandObjectThreadTraceExportCTF::DoExecute(Args &command,
if (thread == nullptr) {
const uint32_t num_threads = process->GetThreadList().GetSize();
size_t tid = m_options.m_thread_index.getValueOr(LLDB_INVALID_THREAD_ID);
size_t tid = m_options.m_thread_index.value_or(LLDB_INVALID_THREAD_ID);
result.AppendErrorWithFormatv(
"Thread index {0} is out of range (valid values are 1 - {1}).\n", tid,
num_threads);

View File

@ -249,7 +249,7 @@ void CompileUnit::ResolveSymbolContext(
const SourceLocationSpec &src_location_spec,
SymbolContextItem resolve_scope, SymbolContextList &sc_list) {
const FileSpec file_spec = src_location_spec.GetFileSpec();
const uint32_t line = src_location_spec.GetLine().getValueOr(0);
const uint32_t line = src_location_spec.GetLine().value_or(0);
const bool check_inlines = src_location_spec.GetCheckInlines();
// First find all of the file indexes that match our "file_spec". If

View File

@ -324,7 +324,7 @@ void Type::DumpValue(ExecutionContext *exe_ctx, Stream *s,
exe_ctx, s, format == lldb::eFormatDefault ? GetFormat() : format, data,
data_byte_offset,
GetByteSize(exe_ctx ? exe_ctx->GetBestExecutionContextScope() : nullptr)
.getValueOr(0),
.value_or(0),
0, // Bitfield bit size
0, // Bitfield bit offset
show_types, show_summary, verbose, 0);
@ -434,7 +434,7 @@ bool Type::ReadFromMemory(ExecutionContext *exe_ctx, lldb::addr_t addr,
const uint64_t byte_size =
GetByteSize(exe_ctx ? exe_ctx->GetBestExecutionContextScope() : nullptr)
.getValueOr(0);
.value_or(0);
if (data.GetByteSize() < byte_size) {
lldb::DataBufferSP data_sp(new DataBufferHeap(byte_size, '\0'));
data.SetData(data_sp);

View File

@ -188,7 +188,7 @@ PathMappingList::RemapPath(llvm::StringRef mapping_path,
continue;
}
FileSpec remapped(it.second.GetStringRef());
auto orig_style = FileSpec::GuessPathStyle(prefix).getValueOr(
auto orig_style = FileSpec::GuessPathStyle(prefix).value_or(
llvm::sys::path::Style::native);
AppendPathComponents(remapped, path, orig_style);
if (!only_if_exists || FileSystem::Instance().Exists(remapped))
@ -204,7 +204,7 @@ bool PathMappingList::ReverseRemapPath(const FileSpec &file, FileSpec &fixed) co
if (!path_ref.consume_front(it.second.GetStringRef()))
continue;
auto orig_file = it.first.GetStringRef();
auto orig_style = FileSpec::GuessPathStyle(orig_file).getValueOr(
auto orig_style = FileSpec::GuessPathStyle(orig_file).value_or(
llvm::sys::path::Style::native);
fixed.SetFile(orig_file, orig_style);
AppendPathComponents(fixed, path_ref, orig_style);

View File

@ -1390,7 +1390,7 @@ ValueObjectSP GetValueForOffset(StackFrame &frame, ValueObjectSP &parent,
}
int64_t child_offset = child_sp->GetByteOffset();
int64_t child_size = child_sp->GetByteSize().getValueOr(0);
int64_t child_size = child_sp->GetByteSize().value_or(0);
if (offset >= child_offset && offset < (child_offset + child_size)) {
return GetValueForOffset(frame, child_sp, offset - child_offset);
@ -1423,8 +1423,8 @@ ValueObjectSP GetValueForDereferincingOffset(StackFrame &frame,
}
if (offset >= 0 && uint64_t(offset) >= pointee->GetByteSize()) {
int64_t index = offset / pointee->GetByteSize().getValueOr(1);
offset = offset % pointee->GetByteSize().getValueOr(1);
int64_t index = offset / pointee->GetByteSize().value_or(1);
offset = offset % pointee->GetByteSize().value_or(1);
const bool can_create = true;
pointee = base->GetSyntheticArrayMember(index, can_create);
}

View File

@ -144,19 +144,19 @@ void ProcessInstanceInfo::Dump(Stream &s, UserIDResolver &resolver) const {
if (UserIDIsValid()) {
s.Format(" uid = {0,-5} ({1})\n", GetUserID(),
resolver.GetUserName(GetUserID()).getValueOr(""));
resolver.GetUserName(GetUserID()).value_or(""));
}
if (GroupIDIsValid()) {
s.Format(" gid = {0,-5} ({1})\n", GetGroupID(),
resolver.GetGroupName(GetGroupID()).getValueOr(""));
resolver.GetGroupName(GetGroupID()).value_or(""));
}
if (EffectiveUserIDIsValid()) {
s.Format(" euid = {0,-5} ({1})\n", GetEffectiveUserID(),
resolver.GetUserName(GetEffectiveUserID()).getValueOr(""));
resolver.GetUserName(GetEffectiveUserID()).value_or(""));
}
if (EffectiveGroupIDIsValid()) {
s.Format(" egid = {0,-5} ({1})\n", GetEffectiveGroupID(),
resolver.GetGroupName(GetEffectiveGroupID()).getValueOr(""));
resolver.GetGroupName(GetEffectiveGroupID()).value_or(""));
}
}

View File

@ -19,7 +19,7 @@ const char *IntelPTDataKinds::kPerfContextSwitchTrace =
"perfContextSwitchTrace";
bool TraceIntelPTStartRequest::IsPerCpuTracing() const {
return per_cpu_tracing.getValueOr(false);
return per_cpu_tracing.value_or(false);
}
json::Value toJSON(const JSONUINT64 &uint64, bool hex) {