Replace auto -> llvm::Optional<uint64_t>

This addresses post-commit feedback for https://reviews.llvm.org/D56688

llvm-svn: 351237
This commit is contained in:
Adrian Prantl 2019-01-15 20:33:58 +00:00
parent 3cdd1a7d47
commit d6a9bbf68e
34 changed files with 128 additions and 94 deletions

View File

@ -104,7 +104,8 @@ bool SBType::IsValid() const {
uint64_t SBType::GetByteSize() {
if (IsValid())
if (auto size = m_opaque_sp->GetCompilerType(false).GetByteSize(nullptr))
if (llvm::Optional<uint64_t> size =
m_opaque_sp->GetCompilerType(false).GetByteSize(nullptr))
return *size;
return 0;
}

View File

@ -519,7 +519,7 @@ protected:
--pointer_count;
}
auto size = clang_ast_type.GetByteSize(nullptr);
llvm::Optional<uint64_t> size = clang_ast_type.GetByteSize(nullptr);
if (!size) {
result.AppendErrorWithFormat(
"unable to get the byte size of the type '%s'\n",
@ -642,7 +642,7 @@ protected:
if (!m_format_options.GetFormatValue().OptionWasSet())
m_format_options.GetFormatValue().SetCurrentValue(eFormatDefault);
auto size = clang_ast_type.GetByteSize(nullptr);
llvm::Optional<uint64_t> size = clang_ast_type.GetByteSize(nullptr);
if (!size) {
result.AppendError("can't get size of type");
return false;
@ -1064,7 +1064,8 @@ protected:
m_memory_options.m_expr.GetStringValue(), frame, result_sp)) &&
result_sp) {
uint64_t value = result_sp->GetValueAsUnsigned(0);
auto size = result_sp->GetCompilerType().GetByteSize(nullptr);
llvm::Optional<uint64_t> size =
result_sp->GetCompilerType().GetByteSize(nullptr);
if (!size)
return false;
switch (*size) {

View File

@ -224,7 +224,7 @@ uint64_t Value::GetValueByteSize(Status *error_ptr, ExecutionContext *exe_ctx) {
{
const CompilerType &ast_type = GetCompilerType();
if (ast_type.IsValid())
if (auto size = ast_type.GetByteSize(
if (llvm::Optional<uint64_t> size = ast_type.GetByteSize(
exe_ctx ? exe_ctx->GetBestExecutionContextScope() : nullptr))
byte_size = *size;
} break;
@ -346,7 +346,7 @@ Status Value::GetValueAsData(ExecutionContext *exe_ctx, DataExtractor &data,
uint32_t limit_byte_size = UINT32_MAX;
if (ast_type.IsValid()) {
if (auto size = ast_type.GetByteSize(
if (llvm::Optional<uint64_t> size = ast_type.GetByteSize(
exe_ctx ? exe_ctx->GetBestExecutionContextScope() : nullptr))
limit_byte_size = *size;
}

View File

@ -756,8 +756,9 @@ size_t ValueObject::GetPointeeData(DataExtractor &data, uint32_t item_idx,
ExecutionContext exe_ctx(GetExecutionContextRef());
auto item_type_size = pointee_or_element_compiler_type.GetByteSize(
exe_ctx.GetBestExecutionContextScope());
llvm::Optional<uint64_t> item_type_size =
pointee_or_element_compiler_type.GetByteSize(
exe_ctx.GetBestExecutionContextScope());
if (!item_type_size)
return 0;
const uint64_t bytes = item_count * *item_type_size;
@ -1823,7 +1824,8 @@ ValueObjectSP ValueObject::GetSyntheticChildAtOffset(
return {};
ExecutionContext exe_ctx(GetExecutionContextRef());
auto size = type.GetByteSize(exe_ctx.GetBestExecutionContextScope());
llvm::Optional<uint64_t> size =
type.GetByteSize(exe_ctx.GetBestExecutionContextScope());
if (!size)
return {};
ValueObjectChild *synthetic_child =
@ -1864,7 +1866,8 @@ ValueObjectSP ValueObject::GetSyntheticBase(uint32_t offset,
const bool is_base_class = true;
ExecutionContext exe_ctx(GetExecutionContextRef());
auto size = type.GetByteSize(exe_ctx.GetBestExecutionContextScope());
llvm::Optional<uint64_t> size =
type.GetByteSize(exe_ctx.GetBestExecutionContextScope());
if (!size)
return {};
ValueObjectChild *synthetic_child =

View File

@ -138,7 +138,7 @@ size_t ValueObjectMemory::CalculateNumChildren(uint32_t max) {
uint64_t ValueObjectMemory::GetByteSize() {
if (m_type_sp)
return m_type_sp->GetByteSize();
if (auto size = m_compiler_type.GetByteSize(nullptr))
if (llvm::Optional<uint64_t> size = m_compiler_type.GetByteSize(nullptr))
return *size;
return 0;
}

View File

@ -112,7 +112,8 @@ uint64_t ValueObjectVariable::GetByteSize() {
if (!type.IsValid())
return 0;
auto size = type.GetByteSize(exe_ctx.GetBestExecutionContextScope());
llvm::Optional<uint64_t> size =
type.GetByteSize(exe_ctx.GetBestExecutionContextScope());
return size ? *size : 0;
}

View File

@ -96,7 +96,7 @@ bool TypeFormatImpl_Format::FormatObject(ValueObject *valobj,
ExecutionContextScope *exe_scope =
exe_ctx.GetBestExecutionContextScope();
auto size = compiler_type.GetByteSize(exe_scope);
llvm::Optional<uint64_t> size = compiler_type.GetByteSize(exe_scope);
if (!size)
return false;
StreamString sstr;

View File

@ -171,8 +171,9 @@ static size_t CalculateNumChildren(
lldb_private::ExecutionContextScope *exe_scope =
nullptr // does not matter here because all we trade in are basic types
) {
auto container_size = container_type.GetByteSize(exe_scope);
auto element_size = element_type.GetByteSize(exe_scope);
llvm::Optional<uint64_t> container_size =
container_type.GetByteSize(exe_scope);
llvm::Optional<uint64_t> element_size = element_type.GetByteSize(exe_scope);
if (container_size && element_size && *element_size) {
if (*container_size % *element_size)
@ -198,7 +199,7 @@ public:
lldb::ValueObjectSP GetChildAtIndex(size_t idx) override {
if (idx >= CalculateNumChildren())
return {};
auto size = m_child_type.GetByteSize(nullptr);
llvm::Optional<uint64_t> size = m_child_type.GetByteSize(nullptr);
if (!size)
return {};
auto offset = idx * *size;

View File

@ -46,7 +46,7 @@ uint32_t Materializer::AddStructMember(Entity &entity) {
}
void Materializer::Entity::SetSizeAndAlignmentFromType(CompilerType &type) {
if (auto size = type.GetByteSize(nullptr))
if (llvm::Optional<uint64_t> size = type.GetByteSize(nullptr))
m_size = *size;
uint32_t bit_alignment = type.GetTypeBitAlign();
@ -795,7 +795,7 @@ public:
ExecutionContextScope *exe_scope = map.GetBestExecutionContextScope();
auto byte_size = m_type.GetByteSize(exe_scope);
llvm::Optional<uint64_t> byte_size = m_type.GetByteSize(exe_scope);
if (!byte_size) {
err.SetErrorString("can't get size of type");
return;

View File

@ -1470,7 +1470,7 @@ bool ABIMacOSX_arm::GetArgumentValues(Thread &thread, ValueList &values) const {
if (compiler_type) {
bool is_signed = false;
size_t bit_width = 0;
auto bit_size = compiler_type.GetBitSize(&thread);
llvm::Optional<uint64_t> bit_size = compiler_type.GetBitSize(&thread);
if (!bit_size)
return false;
if (compiler_type.IsIntegerOrEnumerationType(is_signed))
@ -1576,7 +1576,7 @@ ValueObjectSP ABIMacOSX_arm::GetReturnValueObjectImpl(
const RegisterInfo *r0_reg_info = reg_ctx->GetRegisterInfoByName("r0", 0);
if (compiler_type.IsIntegerOrEnumerationType(is_signed)) {
auto bit_width = compiler_type.GetBitSize(&thread);
llvm::Optional<uint64_t> bit_width = compiler_type.GetBitSize(&thread);
if (!bit_width)
return return_valobj_sp;
@ -1596,7 +1596,8 @@ ValueObjectSP ABIMacOSX_arm::GetReturnValueObjectImpl(
const RegisterInfo *r3_reg_info =
reg_ctx->GetRegisterInfoByName("r3", 0);
if (r1_reg_info && r2_reg_info && r3_reg_info) {
auto byte_size = compiler_type.GetByteSize(&thread);
llvm::Optional<uint64_t> byte_size =
compiler_type.GetByteSize(&thread);
if (!byte_size)
return return_valobj_sp;
ProcessSP process_sp(thread.GetProcess());

View File

@ -1762,7 +1762,7 @@ bool ABIMacOSX_arm64::GetArgumentValues(Thread &thread,
return false;
CompilerType value_type = value->GetCompilerType();
auto bit_size = value_type.GetBitSize(&thread);
llvm::Optional<uint64_t> bit_size = value_type.GetBitSize(&thread);
if (!bit_size)
return false;
@ -2111,7 +2111,7 @@ static bool LoadValueFromConsecutiveGPRRegisters(
uint32_t &NGRN, // NGRN (see ABI documentation)
uint32_t &NSRN, // NSRN (see ABI documentation)
DataExtractor &data) {
auto byte_size = value_type.GetByteSize(nullptr);
llvm::Optional<uint64_t> byte_size = value_type.GetByteSize(nullptr);
if (!byte_size || *byte_size == 0)
return false;
@ -2128,7 +2128,7 @@ static bool LoadValueFromConsecutiveGPRRegisters(
if (NSRN < 8 && (8 - NSRN) >= homogeneous_count) {
if (!base_type)
return false;
auto base_byte_size = base_type.GetByteSize(nullptr);
llvm::Optional<uint64_t> base_byte_size = base_type.GetByteSize(nullptr);
if (!base_byte_size)
return false;
uint32_t data_offset = 0;
@ -2264,7 +2264,8 @@ ValueObjectSP ABIMacOSX_arm64::GetReturnValueObjectImpl(
if (!reg_ctx)
return return_valobj_sp;
auto byte_size = return_compiler_type.GetByteSize(nullptr);
llvm::Optional<uint64_t> byte_size =
return_compiler_type.GetByteSize(nullptr);
if (!byte_size)
return return_valobj_sp;

View File

@ -824,7 +824,7 @@ bool ABIMacOSX_i386::GetArgumentValues(Thread &thread,
// We currently only support extracting values with Clang QualTypes. Do we
// care about others?
CompilerType compiler_type(value->GetCompilerType());
auto bit_size = compiler_type.GetBitSize(&thread);
llvm::Optional<uint64_t> bit_size = compiler_type.GetBitSize(&thread);
if (bit_size) {
bool is_signed;
if (compiler_type.IsIntegerOrEnumerationType(is_signed))
@ -933,7 +933,7 @@ ABIMacOSX_i386::GetReturnValueObjectImpl(Thread &thread,
bool is_signed;
if (compiler_type.IsIntegerOrEnumerationType(is_signed)) {
auto bit_width = compiler_type.GetBitSize(&thread);
llvm::Optional<uint64_t> bit_width = compiler_type.GetBitSize(&thread);
if (!bit_width)
return return_valobj_sp;
unsigned eax_id =

View File

@ -1473,7 +1473,7 @@ bool ABISysV_arm::GetArgumentValues(Thread &thread, ValueList &values) const {
size_t bit_width = 0;
if (compiler_type.IsIntegerOrEnumerationType(is_signed) ||
compiler_type.IsPointerOrReferenceType()) {
if (auto size = compiler_type.GetBitSize(&thread))
if (llvm::Optional<uint64_t> size = compiler_type.GetBitSize(&thread))
bit_width = *size;
} else {
// We only handle integer, pointer and reference types currently...
@ -1580,8 +1580,8 @@ ValueObjectSP ABISysV_arm::GetReturnValueObjectImpl(
const RegisterInfo *r0_reg_info =
reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1);
auto bit_width = compiler_type.GetBitSize(&thread);
auto byte_size = compiler_type.GetByteSize(&thread);
llvm::Optional<uint64_t> bit_width = compiler_type.GetBitSize(&thread);
llvm::Optional<uint64_t> byte_size = compiler_type.GetByteSize(&thread);
if (!bit_width || !byte_size)
return return_valobj_sp;
@ -1717,7 +1717,8 @@ ValueObjectSP ABISysV_arm::GetReturnValueObjectImpl(
compiler_type.IsHomogeneousAggregate(&base_type);
if (homogeneous_count > 0 && homogeneous_count <= 4) {
auto base_byte_size = base_type.GetByteSize(nullptr);
llvm::Optional<uint64_t> base_byte_size =
base_type.GetByteSize(nullptr);
if (base_type.IsVectorType(nullptr, nullptr)) {
if (base_byte_size &&
(*base_byte_size == 8 || *base_byte_size == 16)) {
@ -1745,7 +1746,8 @@ ValueObjectSP ABISysV_arm::GetReturnValueObjectImpl(
compiler_type.GetFieldAtIndex(index, name, NULL, NULL, NULL);
if (base_type.IsFloatingPointType(float_count, is_complex)) {
auto base_byte_size = base_type.GetByteSize(nullptr);
llvm::Optional<uint64_t> base_byte_size =
base_type.GetByteSize(nullptr);
if (float_count == 2 && is_complex) {
if (index != 0 && base_byte_size &&
vfp_byte_size != *base_byte_size)

View File

@ -1767,7 +1767,7 @@ bool ABISysV_arm64::GetArgumentValues(Thread &thread, ValueList &values) const {
if (value_type) {
bool is_signed = false;
size_t bit_width = 0;
auto bit_size = value_type.GetBitSize(&thread);
llvm::Optional<uint64_t> bit_size = value_type.GetBitSize(&thread);
if (!bit_size)
return false;
if (value_type.IsIntegerOrEnumerationType(is_signed)) {
@ -2086,7 +2086,7 @@ static bool LoadValueFromConsecutiveGPRRegisters(
uint32_t &NGRN, // NGRN (see ABI documentation)
uint32_t &NSRN, // NSRN (see ABI documentation)
DataExtractor &data) {
auto byte_size = value_type.GetByteSize(nullptr);
llvm::Optional<uint64_t> byte_size = value_type.GetByteSize(nullptr);
if (byte_size || *byte_size == 0)
return false;
@ -2104,7 +2104,7 @@ static bool LoadValueFromConsecutiveGPRRegisters(
if (NSRN < 8 && (8 - NSRN) >= homogeneous_count) {
if (!base_type)
return false;
auto base_byte_size = base_type.GetByteSize(nullptr);
llvm::Optional<uint64_t> base_byte_size = base_type.GetByteSize(nullptr);
if (!base_byte_size)
return false;
uint32_t data_offset = 0;
@ -2233,7 +2233,8 @@ ValueObjectSP ABISysV_arm64::GetReturnValueObjectImpl(
if (!reg_ctx)
return return_valobj_sp;
auto byte_size = return_compiler_type.GetByteSize(nullptr);
llvm::Optional<uint64_t> byte_size =
return_compiler_type.GetByteSize(nullptr);
if (!byte_size)
return return_valobj_sp;

View File

@ -308,7 +308,7 @@ bool ABISysV_i386::GetArgumentValues(Thread &thread, ValueList &values) const {
// Currently: Support for extracting values with Clang QualTypes only.
CompilerType compiler_type(value->GetCompilerType());
auto bit_size = compiler_type.GetBitSize(&thread);
llvm::Optional<uint64_t> bit_size = compiler_type.GetBitSize(&thread);
if (bit_size) {
bool is_signed;
if (compiler_type.IsIntegerOrEnumerationType(is_signed)) {
@ -513,7 +513,8 @@ ValueObjectSP ABISysV_i386::GetReturnValueObjectSimple(
(type_flags & eTypeIsEnumeration)) //'Integral' + 'Floating Point'
{
value.SetValueType(Value::eValueTypeScalar);
auto byte_size = return_compiler_type.GetByteSize(nullptr);
llvm::Optional<uint64_t> byte_size =
return_compiler_type.GetByteSize(nullptr);
if (!byte_size)
return return_valobj_sp;
bool success = false;
@ -637,7 +638,8 @@ ValueObjectSP ABISysV_i386::GetReturnValueObjectSimple(
// ToDo: Yet to be implemented
} else if (type_flags & eTypeIsVector) // 'Packed'
{
auto byte_size = return_compiler_type.GetByteSize(nullptr);
llvm::Optional<uint64_t> byte_size =
return_compiler_type.GetByteSize(nullptr);
if (byte_size && *byte_size > 0) {
const RegisterInfo *vec_reg = reg_ctx->GetRegisterInfoByName("xmm0", 0);
if (vec_reg == nullptr)

View File

@ -812,7 +812,7 @@ ValueObjectSP ABISysV_mips::GetReturnValueObjectImpl(
// In MIPS register "r2" (v0) holds the integer function return values
const RegisterInfo *r2_reg_info = reg_ctx->GetRegisterInfoByName("r2", 0);
auto bit_width = return_compiler_type.GetBitSize(&thread);
llvm::Optional<uint64_t> bit_width = return_compiler_type.GetBitSize(&thread);
if (!bit_width)
return return_valobj_sp;
if (return_compiler_type.IsIntegerOrEnumerationType(is_signed)) {

View File

@ -762,7 +762,8 @@ ValueObjectSP ABISysV_mips64::GetReturnValueObjectImpl(
Target *target = exe_ctx.GetTargetPtr();
const ArchSpec target_arch = target->GetArchitecture();
ByteOrder target_byte_order = target_arch.GetByteOrder();
auto byte_size = return_compiler_type.GetByteSize(nullptr);
llvm::Optional<uint64_t> byte_size =
return_compiler_type.GetByteSize(nullptr);
if (!byte_size)
return return_valobj_sp;
const uint32_t type_flags = return_compiler_type.GetTypeInfo(nullptr);
@ -970,7 +971,8 @@ ValueObjectSP ABISysV_mips64::GetReturnValueObjectImpl(
CompilerType field_compiler_type =
return_compiler_type.GetFieldAtIndex(
idx, name, &field_bit_offset, nullptr, nullptr);
auto field_byte_width = field_compiler_type.GetByteSize(nullptr);
llvm::Optional<uint64_t> field_byte_width =
field_compiler_type.GetByteSize(nullptr);
if (!field_byte_width)
return return_valobj_sp;
@ -1041,7 +1043,8 @@ ValueObjectSP ABISysV_mips64::GetReturnValueObjectImpl(
CompilerType field_compiler_type = return_compiler_type.GetFieldAtIndex(
idx, name, &field_bit_offset, nullptr, nullptr);
auto field_byte_width = field_compiler_type.GetByteSize(nullptr);
llvm::Optional<uint64_t> field_byte_width =
field_compiler_type.GetByteSize(nullptr);
// if we don't know the size of the field (e.g. invalid type), just
// bail out

View File

@ -398,7 +398,7 @@ bool ABISysV_ppc::GetArgumentValues(Thread &thread, ValueList &values) const {
// We currently only support extracting values with Clang QualTypes. Do we
// care about others?
CompilerType compiler_type = value->GetCompilerType();
auto bit_size = compiler_type.GetBitSize(&thread);
llvm::Optional<uint64_t> bit_size = compiler_type.GetBitSize(&thread);
if (!bit_size)
return false;
bool is_signed;
@ -466,7 +466,8 @@ Status ABISysV_ppc::SetReturnValueObject(lldb::StackFrameSP &frame_sp,
error.SetErrorString(
"We don't support returning complex values at present");
else {
auto bit_width = compiler_type.GetBitSize(frame_sp.get());
llvm::Optional<uint64_t> bit_width =
compiler_type.GetBitSize(frame_sp.get());
if (!bit_width) {
error.SetErrorString("can't get type size");
return error;
@ -529,7 +530,8 @@ ValueObjectSP ABISysV_ppc::GetReturnValueObjectSimple(
if (type_flags & eTypeIsInteger) {
// Extract the register context so we can read arguments from registers
auto byte_size = return_compiler_type.GetByteSize(nullptr);
llvm::Optional<uint64_t> byte_size =
return_compiler_type.GetByteSize(nullptr);
if (!byte_size)
return return_valobj_sp;
uint64_t raw_value = thread.GetRegisterContext()->ReadRegisterAsUnsigned(
@ -575,7 +577,8 @@ ValueObjectSP ABISysV_ppc::GetReturnValueObjectSimple(
if (type_flags & eTypeIsComplex) {
// Don't handle complex yet.
} else {
auto byte_size = return_compiler_type.GetByteSize(nullptr);
llvm::Optional<uint64_t> byte_size =
return_compiler_type.GetByteSize(nullptr);
if (byte_size && *byte_size <= sizeof(long double)) {
const RegisterInfo *f1_info = reg_ctx->GetRegisterInfoByName("f1", 0);
RegisterValue f1_value;
@ -608,7 +611,8 @@ ValueObjectSP ABISysV_ppc::GetReturnValueObjectSimple(
return_valobj_sp = ValueObjectConstResult::Create(
thread.GetStackFrameAtIndex(0).get(), value, ConstString(""));
} else if (type_flags & eTypeIsVector) {
auto byte_size = return_compiler_type.GetByteSize(nullptr);
llvm::Optional<uint64_t> byte_size =
return_compiler_type.GetByteSize(nullptr);
if (byte_size && *byte_size > 0) {
const RegisterInfo *altivec_reg = reg_ctx->GetRegisterInfoByName("v2", 0);
if (altivec_reg) {
@ -658,7 +662,7 @@ ValueObjectSP ABISysV_ppc::GetReturnValueObjectImpl(
if (!reg_ctx_sp)
return return_valobj_sp;
auto bit_width = return_compiler_type.GetBitSize(&thread);
llvm::Optional<uint64_t> bit_width = return_compiler_type.GetBitSize(&thread);
if (!bit_width)
return return_valobj_sp;
if (return_compiler_type.IsAggregateType()) {
@ -702,7 +706,8 @@ ValueObjectSP ABISysV_ppc::GetReturnValueObjectImpl(
CompilerType field_compiler_type = return_compiler_type.GetFieldAtIndex(
idx, name, &field_bit_offset, nullptr, nullptr);
auto field_bit_width = field_compiler_type.GetBitSize(&thread);
llvm::Optional<uint64_t> field_bit_width =
field_compiler_type.GetBitSize(&thread);
if (!field_bit_width)
return return_valobj_sp;

View File

@ -280,7 +280,7 @@ bool ABISysV_ppc64::GetArgumentValues(Thread &thread, ValueList &values) const {
// We currently only support extracting values with Clang QualTypes. Do we
// care about others?
CompilerType compiler_type = value->GetCompilerType();
auto bit_size = compiler_type.GetBitSize(&thread);
llvm::Optional<uint64_t> bit_size = compiler_type.GetBitSize(&thread);
if (!bit_size)
return false;
bool is_signed;
@ -350,7 +350,8 @@ Status ABISysV_ppc64::SetReturnValueObject(lldb::StackFrameSP &frame_sp,
error.SetErrorString(
"We don't support returning complex values at present");
else {
auto bit_width = compiler_type.GetBitSize(frame_sp.get());
llvm::Optional<uint64_t> bit_width =
compiler_type.GetBitSize(frame_sp.get());
if (!bit_width) {
error.SetErrorString("can't get size of type");
return error;
@ -653,7 +654,7 @@ private:
DataExtractor de(&raw_data, sizeof(raw_data), m_byte_order, m_addr_size);
offset_t offset = 0;
auto byte_size = type.GetByteSize(nullptr);
llvm::Optional<uint64_t> byte_size = type.GetByteSize(nullptr);
if (!byte_size)
return {};
switch (*byte_size) {
@ -787,7 +788,7 @@ private:
CompilerType elem_type;
if (m_type.IsHomogeneousAggregate(&elem_type)) {
uint32_t type_flags = elem_type.GetTypeInfo();
auto elem_size = elem_type.GetByteSize(nullptr);
llvm::Optional<uint64_t> elem_size = elem_type.GetByteSize(nullptr);
if (!elem_size)
return {};
if (type_flags & eTypeIsComplex || !(type_flags & eTypeIsFloat)) {

View File

@ -376,7 +376,7 @@ bool ABISysV_s390x::GetArgumentValues(Thread &thread, ValueList &values) const {
// We currently only support extracting values with Clang QualTypes. Do we
// care about others?
CompilerType compiler_type = value->GetCompilerType();
auto bit_size = compiler_type.GetBitSize(&thread);
llvm::Optional<uint64_t> bit_size = compiler_type.GetBitSize(&thread);
if (!bit_size)
return false;
bool is_signed;
@ -446,7 +446,8 @@ Status ABISysV_s390x::SetReturnValueObject(lldb::StackFrameSP &frame_sp,
error.SetErrorString(
"We don't support returning complex values at present");
else {
auto bit_width = compiler_type.GetBitSize(frame_sp.get());
llvm::Optional<uint64_t> bit_width =
compiler_type.GetBitSize(frame_sp.get());
if (!bit_width) {
error.SetErrorString("can't get type size");
return error;
@ -511,9 +512,9 @@ ValueObjectSP ABISysV_s390x::GetReturnValueObjectSimple(
bool success = false;
if (type_flags & eTypeIsInteger) {
// Extract the register context so we can read arguments from registers
auto byte_size = return_compiler_type.GetByteSize(nullptr);
// Extract the register context so we can read arguments from registers.
llvm::Optional<uint64_t> byte_size =
return_compiler_type.GetByteSize(nullptr);
if (!byte_size)
return return_valobj_sp;
uint64_t raw_value = thread.GetRegisterContext()->ReadRegisterAsUnsigned(
@ -559,7 +560,8 @@ ValueObjectSP ABISysV_s390x::GetReturnValueObjectSimple(
if (type_flags & eTypeIsComplex) {
// Don't handle complex yet.
} else {
auto byte_size = return_compiler_type.GetByteSize(nullptr);
llvm::Optional<uint64_t> byte_size =
return_compiler_type.GetByteSize(nullptr);
if (byte_size && *byte_size <= sizeof(long double)) {
const RegisterInfo *f0_info = reg_ctx->GetRegisterInfoByName("f0", 0);
RegisterValue f0_value;

View File

@ -1263,7 +1263,7 @@ bool ABISysV_x86_64::GetArgumentValues(Thread &thread,
// We currently only support extracting values with Clang QualTypes. Do we
// care about others?
CompilerType compiler_type = value->GetCompilerType();
auto bit_size = compiler_type.GetBitSize(&thread);
llvm::Optional<uint64_t> bit_size = compiler_type.GetBitSize(&thread);
if (!bit_size)
return false;
bool is_signed;
@ -1333,7 +1333,8 @@ Status ABISysV_x86_64::SetReturnValueObject(lldb::StackFrameSP &frame_sp,
error.SetErrorString(
"We don't support returning complex values at present");
else {
auto bit_width = compiler_type.GetBitSize(frame_sp.get());
llvm::Optional<uint64_t> bit_width =
compiler_type.GetBitSize(frame_sp.get());
if (!bit_width) {
error.SetErrorString("can't get type size");
return error;
@ -1401,7 +1402,8 @@ ValueObjectSP ABISysV_x86_64::GetReturnValueObjectSimple(
if (type_flags & eTypeIsInteger) {
// Extract the register context so we can read arguments from registers
auto byte_size = return_compiler_type.GetByteSize(nullptr);
llvm::Optional<uint64_t> byte_size =
return_compiler_type.GetByteSize(nullptr);
if (!byte_size)
return return_valobj_sp;
uint64_t raw_value = thread.GetRegisterContext()->ReadRegisterAsUnsigned(
@ -1447,7 +1449,8 @@ ValueObjectSP ABISysV_x86_64::GetReturnValueObjectSimple(
if (type_flags & eTypeIsComplex) {
// Don't handle complex yet.
} else {
auto byte_size = return_compiler_type.GetByteSize(nullptr);
llvm::Optional<uint64_t> byte_size =
return_compiler_type.GetByteSize(nullptr);
if (byte_size && *byte_size <= sizeof(long double)) {
const RegisterInfo *xmm0_info =
reg_ctx->GetRegisterInfoByName("xmm0", 0);
@ -1485,7 +1488,8 @@ ValueObjectSP ABISysV_x86_64::GetReturnValueObjectSimple(
return_valobj_sp = ValueObjectConstResult::Create(
thread.GetStackFrameAtIndex(0).get(), value, ConstString(""));
} else if (type_flags & eTypeIsVector) {
auto byte_size = return_compiler_type.GetByteSize(nullptr);
llvm::Optional<uint64_t> byte_size =
return_compiler_type.GetByteSize(nullptr);
if (byte_size && *byte_size > 0) {
const RegisterInfo *altivec_reg =
reg_ctx->GetRegisterInfoByName("xmm0", 0);
@ -1571,7 +1575,7 @@ ValueObjectSP ABISysV_x86_64::GetReturnValueObjectImpl(
if (!reg_ctx_sp)
return return_valobj_sp;
auto bit_width = return_compiler_type.GetBitSize(&thread);
llvm::Optional<uint64_t> bit_width = return_compiler_type.GetBitSize(&thread);
if (!bit_width)
return return_valobj_sp;
if (return_compiler_type.IsAggregateType()) {
@ -1624,7 +1628,8 @@ ValueObjectSP ABISysV_x86_64::GetReturnValueObjectImpl(
CompilerType field_compiler_type = return_compiler_type.GetFieldAtIndex(
idx, name, &field_bit_offset, nullptr, nullptr);
auto field_bit_width = field_compiler_type.GetBitSize(&thread);
llvm::Optional<uint64_t> field_bit_width =
field_compiler_type.GetBitSize(&thread);
// if we don't know the size of the field (e.g. invalid type), just
// bail out

View File

@ -127,7 +127,7 @@ lldb::addr_t ArchitectureMips::GetBreakableLoadAddress(lldb::addr_t addr,
return addr;
// Adjust the breakable address
auto breakable_addr = addr - insn->GetOpcode().GetByteSize();
uint64_t breakable_addr = addr - insn->GetOpcode().GetByteSize();
if (log)
log->Printf("Target::%s Breakpoint at 0x%8.8" PRIx64
" is adjusted to 0x%8.8" PRIx64 " due to delay slot\n",

View File

@ -310,7 +310,7 @@ bool IRForTarget::CreateResultVariable(llvm::Function &llvm_function) {
lldb::TargetSP target_sp(m_execution_unit.GetTarget());
lldb_private::ExecutionContext exe_ctx(target_sp, true);
auto bit_size =
llvm::Optional<uint64_t> bit_size =
m_result_type.GetBitSize(exe_ctx.GetBestExecutionContextScope());
if (!bit_size) {
lldb_private::StreamString type_desc_stream;
@ -1372,7 +1372,7 @@ bool IRForTarget::MaybeHandleVariable(Value *llvm_value_ptr) {
value_type = global_variable->getType();
}
auto value_size = compiler_type.GetByteSize(nullptr);
llvm::Optional<uint64_t> value_size = compiler_type.GetByteSize(nullptr);
if (!value_size)
return false;
lldb::offset_t value_alignment =

View File

@ -101,7 +101,7 @@ bool lldb_private::formatters::WCharStringSummaryProvider(
return false;
// Safe to pass nullptr for exe_scope here.
auto size = wchar_compiler_type.GetBitSize(nullptr);
llvm::Optional<uint64_t> size = wchar_compiler_type.GetBitSize(nullptr);
if (!size)
return false;
const uint32_t wchar_size = *size;
@ -198,7 +198,7 @@ bool lldb_private::formatters::WCharSummaryProvider(
return false;
// Safe to pass nullptr for exe_scope here.
auto size = wchar_compiler_type.GetBitSize(nullptr);
llvm::Optional<uint64_t> size = wchar_compiler_type.GetBitSize(nullptr);
if (!size)
return false;
const uint32_t wchar_size = *size;

View File

@ -255,7 +255,7 @@ bool lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd::Update() {
ast_ctx->GetBasicType(lldb::eBasicTypeVoid).GetPointerType()},
{"cw", ast_ctx->GetBasicType(lldb::eBasicTypeBool)},
{"payload", pair_type}});
auto size = tree_node_type.GetByteSize(nullptr);
llvm::Optional<uint64_t> size = tree_node_type.GetByteSize(nullptr);
if (!size)
return false;
DataBufferSP buffer_sp(new DataBufferHeap(*size, 0));

View File

@ -80,7 +80,8 @@ ValueObjectSP BitsetFrontEnd::GetChildAtIndex(size_t idx) {
ValueObjectSP chunk;
// For small bitsets __first_ is not an array, but a plain size_t.
if (m_first->GetCompilerType().IsArrayType(&type, nullptr, nullptr)) {
auto bit_size = type.GetBitSize(ctx.GetBestExecutionContextScope());
llvm::Optional<uint64_t> bit_size =
type.GetBitSize(ctx.GetBestExecutionContextScope());
if (!bit_size || *bit_size == 0)
return {};
chunk = m_first->GetChildAtIndex(idx / *bit_size, true);
@ -91,7 +92,8 @@ ValueObjectSP BitsetFrontEnd::GetChildAtIndex(size_t idx) {
if (!type || !chunk)
return {};
auto bit_size = type.GetBitSize(ctx.GetBestExecutionContextScope());
llvm::Optional<uint64_t> bit_size =
type.GetBitSize(ctx.GetBestExecutionContextScope());
if (!bit_size || *bit_size == 0)
return {};
size_t chunk_idx = idx % *bit_size;

View File

@ -94,7 +94,7 @@ bool lldb_private::formatters::LibcxxInitializerListSyntheticFrontEnd::
if (!m_element_type.IsValid())
return false;
if (auto size = m_element_type.GetByteSize(nullptr)) {
if (llvm::Optional<uint64_t> size = m_element_type.GetByteSize(nullptr)) {
m_element_size = *size;
// Store raw pointers or end up with a circular dependency.
m_start = m_backend.GetChildMemberWithName(g___begin_, true).get();

View File

@ -145,7 +145,7 @@ bool lldb_private::formatters::LibcxxStdVectorSyntheticFrontEnd::Update() {
if (!data_type_finder_sp)
return false;
m_element_type = data_type_finder_sp->GetCompilerType().GetPointeeType();
if (auto size = m_element_type.GetByteSize(nullptr)) {
if (llvm::Optional<uint64_t> size = m_element_type.GetByteSize(nullptr)) {
m_element_size = *size;
if (m_element_size > 0) {
@ -213,7 +213,7 @@ lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEnd::GetChildAtIndex(
return {};
mask = 1 << bit_index;
bool bit_set = ((byte & mask) != 0);
auto size = m_bool_type.GetByteSize(nullptr);
llvm::Optional<uint64_t> size = m_bool_type.GetByteSize(nullptr);
if (!size)
return {};
DataBufferSP buffer_sp(new DataBufferHeap(*size, 0));

View File

@ -298,7 +298,7 @@ bool lldb_private::formatters::LibStdcppWStringSummaryProvider(
return false;
// Safe to pass nullptr for exe_scope here.
auto size = wchar_compiler_type.GetBitSize(nullptr);
llvm::Optional<uint64_t> size = wchar_compiler_type.GetBitSize(nullptr);
if (!size)
return false;
const uint32_t wchar_size = *size;

View File

@ -513,7 +513,7 @@ void ClassDescriptorV2::iVarsStorage::fill(AppleObjCRuntimeV2 &runtime,
CompilerType ivar_type =
encoding_to_type_sp->RealizeType(type, for_expression);
if (ivar_type) {
auto ivar_size = ivar_type.GetByteSize(nullptr);
llvm::Optional<uint64_t> ivar_size = ivar_type.GetByteSize(nullptr);
LLDB_LOGV(log,
"name = {0}, encoding = {1}, offset_ptr = {2:x}, size = "
"{3}, type_size = {4}",

View File

@ -1850,7 +1850,8 @@ TypeSP DWARFASTParserClang::ParseTypeFromDWARF(const SymbolContext &sc,
clang_type = ClangASTContext::CreateMemberPointerType(
class_clang_type, pointee_clang_type);
if (auto clang_type_size = clang_type.GetByteSize(nullptr)) {
if (llvm::Optional<uint64_t> clang_type_size =
clang_type.GetByteSize(nullptr)) {
byte_size = *clang_type_size;
type_sp.reset(new Type(die.GetID(), dwarf, type_name_const_str,
byte_size, NULL, LLDB_INVALID_UID,
@ -2046,7 +2047,7 @@ bool DWARFASTParserClang::ParseTemplateDIE(
clang_type.IsIntegerOrEnumerationType(is_signed);
if (tag == DW_TAG_template_value_parameter && uval64_valid) {
auto size = clang_type.GetBitSize(nullptr);
llvm::Optional<uint64_t> size = clang_type.GetBitSize(nullptr);
if (!size)
return false;
llvm::APInt apint(*size, uval64, is_signed);

View File

@ -4506,7 +4506,7 @@ ClangASTContext::GetArrayElementType(lldb::opaque_compiler_type_t type,
// TODO: the real stride will be >= this value.. find the real one!
if (stride)
if (auto size = element_type.GetByteSize(nullptr))
if (llvm::Optional<uint64_t> size = element_type.GetByteSize(nullptr))
*stride = *size;
return element_type;
@ -6684,7 +6684,7 @@ CompilerType ClangASTContext::GetChildCompilerTypeAtIndex(
CompilerType base_class_clang_type(getASTContext(),
base_class->getType());
child_name = base_class_clang_type.GetTypeName().AsCString("");
auto size = base_class_clang_type.GetBitSize(
llvm::Optional<uint64_t> size = base_class_clang_type.GetBitSize(
exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL);
if (!size)
return {};
@ -6716,7 +6716,7 @@ CompilerType ClangASTContext::GetChildCompilerTypeAtIndex(
// alignment (field_type_info.second) from the AST context.
CompilerType field_clang_type(getASTContext(), field->getType());
assert(field_idx < record_layout.getFieldCount());
auto size = field_clang_type.GetByteSize(
llvm::Optional<uint64_t> size = field_clang_type.GetByteSize(
exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL);
if (!size)
return {};
@ -6891,7 +6891,7 @@ CompilerType ClangASTContext::GetChildCompilerTypeAtIndex(
// We have a pointer to an simple type
if (idx == 0 && pointee_clang_type.GetCompleteType()) {
if (auto size = pointee_clang_type.GetByteSize(
if (llvm::Optional<uint64_t> size = pointee_clang_type.GetByteSize(
exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL)) {
child_byte_size = *size;
child_byte_offset = 0;
@ -6914,7 +6914,7 @@ CompilerType ClangASTContext::GetChildCompilerTypeAtIndex(
::snprintf(element_name, sizeof(element_name), "[%" PRIu64 "]",
static_cast<uint64_t>(idx));
child_name.assign(element_name);
if (auto size = element_type.GetByteSize(
if (llvm::Optional<uint64_t> size = element_type.GetByteSize(
exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL)) {
child_byte_size = *size;
child_byte_offset = (int32_t)idx * (int32_t)child_byte_size;
@ -6933,7 +6933,7 @@ CompilerType ClangASTContext::GetChildCompilerTypeAtIndex(
CompilerType element_type(getASTContext(), array->getElementType());
if (element_type.GetCompleteType()) {
child_name = llvm::formatv("[{0}]", idx);
if (auto size = element_type.GetByteSize(
if (llvm::Optional<uint64_t> size = element_type.GetByteSize(
exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL)) {
child_byte_size = *size;
child_byte_offset = (int32_t)idx * (int32_t)child_byte_size;
@ -6972,7 +6972,7 @@ CompilerType ClangASTContext::GetChildCompilerTypeAtIndex(
// We have a pointer to an simple type
if (idx == 0) {
if (auto size = pointee_clang_type.GetByteSize(
if (llvm::Optional<uint64_t> size = pointee_clang_type.GetByteSize(
exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL)) {
child_byte_size = *size;
child_byte_offset = 0;
@ -7009,7 +7009,7 @@ CompilerType ClangASTContext::GetChildCompilerTypeAtIndex(
// We have a pointer to an simple type
if (idx == 0) {
if (auto size = pointee_clang_type.GetByteSize(
if (llvm::Optional<uint64_t> size = pointee_clang_type.GetByteSize(
exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL)) {
child_byte_size = *size;
child_byte_offset = 0;

View File

@ -513,7 +513,7 @@ CompilerType::GetBitSize(ExecutionContextScope *exe_scope) const {
llvm::Optional<uint64_t>
CompilerType::GetByteSize(ExecutionContextScope *exe_scope) const {
if (auto bit_size = GetBitSize(exe_scope))
if (llvm::Optional<uint64_t> bit_size = GetBitSize(exe_scope))
return (*bit_size + 7) / 8;
return {};
}
@ -819,7 +819,7 @@ bool CompilerType::GetValueAsScalar(const lldb_private::DataExtractor &data,
if (encoding == lldb::eEncodingInvalid || count != 1)
return false;
auto byte_size = GetByteSize(nullptr);
llvm::Optional<uint64_t> byte_size = GetByteSize(nullptr);
if (!byte_size)
return false;
lldb::offset_t offset = data_byte_offset;
@ -917,7 +917,7 @@ bool CompilerType::SetValueFromScalar(const Scalar &value, Stream &strm) {
if (encoding == lldb::eEncodingInvalid || count != 1)
return false;
auto bit_width = GetBitSize(nullptr);
llvm::Optional<uint64_t> bit_width = GetBitSize(nullptr);
if (!bit_width)
return false;

View File

@ -321,7 +321,8 @@ uint64_t Type::GetByteSize() {
if (encoding_type)
m_byte_size = encoding_type->GetByteSize();
if (m_byte_size == 0)
if (auto size = GetLayoutCompilerType().GetByteSize(nullptr))
if (llvm::Optional<uint64_t> size =
GetLayoutCompilerType().GetByteSize(nullptr))
m_byte_size = *size;
} break;