diff options
author | Adrian Prantl <aprantl@apple.com> | 2019-01-15 20:33:58 +0000 |
---|---|---|
committer | Adrian Prantl <aprantl@apple.com> | 2019-01-15 20:33:58 +0000 |
commit | 39e7fe2fd6b2fe990269c8446f470573bcd75271 (patch) | |
tree | 0bf7af381fcb415181d57b7ebe910c2fc415721f | |
parent | 5d4c9d6ad9589a0956d62ecae184fcd8ae8ae832 (diff) |
Replace auto -> llvm::Optional<uint64_t>
This addresses post-commit feedback for https://reviews.llvm.org/D56688
34 files changed, 128 insertions, 94 deletions
diff --git a/lldb/source/API/SBType.cpp b/lldb/source/API/SBType.cpp index 548ba9e8dc9..77d7dc65410 100644 --- a/lldb/source/API/SBType.cpp +++ b/lldb/source/API/SBType.cpp @@ -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; } diff --git a/lldb/source/Commands/CommandObjectMemory.cpp b/lldb/source/Commands/CommandObjectMemory.cpp index 32ffd5a1dcf..b1edb1afa5d 100644 --- a/lldb/source/Commands/CommandObjectMemory.cpp +++ b/lldb/source/Commands/CommandObjectMemory.cpp @@ -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) { diff --git a/lldb/source/Core/Value.cpp b/lldb/source/Core/Value.cpp index bd942fd2187..873bd6672fd 100644 --- a/lldb/source/Core/Value.cpp +++ b/lldb/source/Core/Value.cpp @@ -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; } diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp index 1965d708284..95e944b22b8 100644 --- a/lldb/source/Core/ValueObject.cpp +++ b/lldb/source/Core/ValueObject.cpp @@ -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 = diff --git a/lldb/source/Core/ValueObjectMemory.cpp b/lldb/source/Core/ValueObjectMemory.cpp index a289962d1b4..24103204ee4 100644 --- a/lldb/source/Core/ValueObjectMemory.cpp +++ b/lldb/source/Core/ValueObjectMemory.cpp @@ -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; } diff --git a/lldb/source/Core/ValueObjectVariable.cpp b/lldb/source/Core/ValueObjectVariable.cpp index fcdd8cc8964..f026d77c9fa 100644 --- a/lldb/source/Core/ValueObjectVariable.cpp +++ b/lldb/source/Core/ValueObjectVariable.cpp @@ -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; } diff --git a/lldb/source/DataFormatters/TypeFormat.cpp b/lldb/source/DataFormatters/TypeFormat.cpp index e9a8c3b8953..f00a679cecf 100644 --- a/lldb/source/DataFormatters/TypeFormat.cpp +++ b/lldb/source/DataFormatters/TypeFormat.cpp @@ -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; diff --git a/lldb/source/DataFormatters/VectorType.cpp b/lldb/source/DataFormatters/VectorType.cpp index 5ab438e6abb..b11fb1456af 100644 --- a/lldb/source/DataFormatters/VectorType.cpp +++ b/lldb/source/DataFormatters/VectorType.cpp @@ -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; diff --git a/lldb/source/Expression/Materializer.cpp b/lldb/source/Expression/Materializer.cpp index 1d967b58f39..4d4e5e21092 100644 --- a/lldb/source/Expression/Materializer.cpp +++ b/lldb/source/Expression/Materializer.cpp @@ -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; diff --git a/lldb/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp b/lldb/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp index 6ca0be16e88..9055660f2d6 100644 --- a/lldb/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp +++ b/lldb/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp @@ -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()); diff --git a/lldb/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp b/lldb/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp index 827f80382fd..d8706c4a9cd 100644 --- a/lldb/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp +++ b/lldb/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp @@ -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; diff --git a/lldb/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp b/lldb/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp index b6e0ef4f7bc..a297bd1473b 100644 --- a/lldb/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp +++ b/lldb/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp @@ -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 = diff --git a/lldb/source/Plugins/ABI/SysV-arm/ABISysV_arm.cpp b/lldb/source/Plugins/ABI/SysV-arm/ABISysV_arm.cpp index b14048154fc..b93a8525010 100644 --- a/lldb/source/Plugins/ABI/SysV-arm/ABISysV_arm.cpp +++ b/lldb/source/Plugins/ABI/SysV-arm/ABISysV_arm.cpp @@ -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) diff --git a/lldb/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp b/lldb/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp index 0ee0b91e207..dd3f47303be 100644 --- a/lldb/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp +++ b/lldb/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp @@ -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; diff --git a/lldb/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp b/lldb/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp index f359b52e129..3358eb8c277 100644 --- a/lldb/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp +++ b/lldb/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp @@ -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) diff --git a/lldb/source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp b/lldb/source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp index df86c0cedff..6f3d2e3b369 100644 --- a/lldb/source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp +++ b/lldb/source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp @@ -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)) { diff --git a/lldb/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp b/lldb/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp index 10f33ea1cb5..1d6738d9fda 100644 --- a/lldb/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp +++ b/lldb/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp @@ -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 diff --git a/lldb/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp b/lldb/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp index 3e3de6eeed3..1fe7a6718a9 100644 --- a/lldb/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp +++ b/lldb/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp @@ -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; diff --git a/lldb/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp b/lldb/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp index 0bbf9a6648f..b6240d90878 100644 --- a/lldb/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp +++ b/lldb/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp @@ -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)) { diff --git a/lldb/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.cpp b/lldb/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.cpp index c4b28b67661..d8056ea7d35 100644 --- a/lldb/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.cpp +++ b/lldb/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.cpp @@ -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; diff --git a/lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp b/lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp index 9a3cb2f2902..dc3e475e3b8 100644 --- a/lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp +++ b/lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp @@ -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 diff --git a/lldb/source/Plugins/Architecture/Mips/ArchitectureMips.cpp b/lldb/source/Plugins/Architecture/Mips/ArchitectureMips.cpp index a8f99e2cc39..0cbbd992232 100644 --- a/lldb/source/Plugins/Architecture/Mips/ArchitectureMips.cpp +++ b/lldb/source/Plugins/Architecture/Mips/ArchitectureMips.cpp @@ -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", diff --git a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp index 1a4a1432dda..d66ee83e0fe 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp @@ -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 = diff --git a/lldb/source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp b/lldb/source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp index 6a41ff84e0b..24185b31446 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp @@ -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; diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp index af118a71d09..7e8c06bd4c7 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp @@ -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)); diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxBitset.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxBitset.cpp index 0d39e5a57cf..489ac4d9607 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxBitset.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxBitset.cpp @@ -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; diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxInitializerList.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxInitializerList.cpp index a692c120b35..390483d0266 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxInitializerList.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxInitializerList.cpp @@ -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(); diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp index 9cde54b4f4f..ed405c87517 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp @@ -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)); diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp index f25391f9512..695371fc399 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp @@ -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; diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp index b0d93460e01..8253fc8cfb4 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp @@ -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}", diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index 1d9a18dcbbe..70d48e5f1df 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -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); diff --git a/lldb/source/Symbol/ClangASTContext.cpp b/lldb/source/Symbol/ClangASTContext.cpp index dc5d1ebe93f..7386edef11a 100644 --- a/lldb/source/Symbol/ClangASTContext.cpp +++ b/lldb/source/Symbol/ClangASTContext.cpp @@ -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; diff --git a/lldb/source/Symbol/CompilerType.cpp b/lldb/source/Symbol/CompilerType.cpp index 9d23b8bf060..7e381abd7d1 100644 --- a/lldb/source/Symbol/CompilerType.cpp +++ b/lldb/source/Symbol/CompilerType.cpp @@ -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; diff --git a/lldb/source/Symbol/Type.cpp b/lldb/source/Symbol/Type.cpp index 81bc4018de4..e966c269408 100644 --- a/lldb/source/Symbol/Type.cpp +++ b/lldb/source/Symbol/Type.cpp @@ -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; |