Author: adrian Date: Mon Jan 28 13:44:35 2019 New Revision: 352434 URL: http://llvm.org/viewvc/llvm-project?rev=352434&view=rev Log: Revert "Make Type::GetByteSize optional (NFC)"
This reverts commit r352394 because it broke three windows-specific tests. Modified: lldb/trunk/include/lldb/Symbol/Type.h lldb/trunk/source/Core/ValueObjectMemory.cpp lldb/trunk/source/Expression/Materializer.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/trunk/source/Symbol/Type.cpp Modified: lldb/trunk/include/lldb/Symbol/Type.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Type.h?rev=352434&r1=352433&r2=352434&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/Type.h (original) +++ lldb/trunk/include/lldb/Symbol/Type.h Mon Jan 28 13:44:35 2019 @@ -95,7 +95,7 @@ public: } ResolveState; Type(lldb::user_id_t uid, SymbolFile *symbol_file, const ConstString &name, - llvm::Optional<uint64_t> byte_size, SymbolContextScope *context, + uint64_t byte_size, SymbolContextScope *context, lldb::user_id_t encoding_uid, EncodingDataType encoding_uid_type, const Declaration &decl, const CompilerType &compiler_qual_type, ResolveState compiler_type_resolve_state); @@ -127,7 +127,7 @@ public: const ConstString &GetName(); - llvm::Optional<uint64_t> GetByteSize(); + uint64_t GetByteSize(); uint32_t GetNumChildren(bool omit_empty_base_classes); @@ -217,8 +217,7 @@ protected: Type *m_encoding_type; lldb::user_id_t m_encoding_uid; EncodingDataType m_encoding_uid_type; - uint64_t m_byte_size : 63; - uint64_t m_byte_size_has_value : 1; + uint64_t m_byte_size; Declaration m_decl; CompilerType m_compiler_type; Modified: lldb/trunk/source/Core/ValueObjectMemory.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectMemory.cpp?rev=352434&r1=352433&r2=352434&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObjectMemory.cpp (original) +++ lldb/trunk/source/Core/ValueObjectMemory.cpp Mon Jan 28 13:44:35 2019 @@ -136,8 +136,10 @@ size_t ValueObjectMemory::CalculateNumCh uint64_t ValueObjectMemory::GetByteSize() { if (m_type_sp) - return m_type_sp->GetByteSize().getValueOr(0); - return m_compiler_type.GetByteSize(nullptr).getValueOr(0); + return m_type_sp->GetByteSize(); + if (llvm::Optional<uint64_t> size = m_compiler_type.GetByteSize(nullptr)) + return *size; + return 0; } lldb::ValueType ValueObjectMemory::GetValueType() const { Modified: lldb/trunk/source/Expression/Materializer.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/Materializer.cpp?rev=352434&r1=352433&r2=352434&view=diff ============================================================================== --- lldb/trunk/source/Expression/Materializer.cpp (original) +++ lldb/trunk/source/Expression/Materializer.cpp Mon Jan 28 13:44:35 2019 @@ -537,8 +537,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().getValueOr(0), - data.GetByteSize()); + m_variable_sp->GetType()->GetByteSize(), data.GetByteSize()); } return; } Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp?rev=352434&r1=352433&r2=352434&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp Mon Jan 28 13:44:35 2019 @@ -264,7 +264,7 @@ TypeSP DWARFASTParserClang::ParseTypeFro const char *mangled_name_cstr = NULL; ConstString type_name_const_str; Type::ResolveState resolve_state = Type::eResolveStateUnresolved; - llvm::Optional<uint64_t> byte_size; + uint64_t byte_size = 0; Declaration decl; Type::EncodingDataType encoding_data_type = Type::eEncodingIsUID; @@ -386,7 +386,7 @@ TypeSP DWARFASTParserClang::ParseTypeFro case DW_TAG_base_type: resolve_state = Type::eResolveStateFull; clang_type = m_ast.GetBuiltinTypeForDWARFEncodingAndBitSize( - type_name_cstr, encoding, byte_size.getValueOr(0) * 8); + type_name_cstr, encoding, byte_size * 8); break; case DW_TAG_pointer_type: @@ -535,6 +535,7 @@ TypeSP DWARFASTParserClang::ParseTypeFro case DW_TAG_class_type: { // Set a bit that lets us know that we are currently parsing this dwarf->GetDIEToType()[die.GetDIE()] = DIE_IS_BEING_PARSED; + bool byte_size_valid = false; LanguageType class_language = eLanguageTypeUnknown; bool is_complete_objc_class = false; @@ -568,6 +569,7 @@ TypeSP DWARFASTParserClang::ParseTypeFro case DW_AT_byte_size: byte_size = form_value.Unsigned(); + byte_size_valid = true; break; case DW_AT_accessibility: @@ -627,7 +629,7 @@ TypeSP DWARFASTParserClang::ParseTypeFro if (dwarf->GetUniqueDWARFASTTypeMap().Find( unique_typename, die, unique_decl, - byte_size ? *byte_size : -1, *unique_ast_entry_ap)) { + byte_size_valid ? byte_size : -1, *unique_ast_entry_ap)) { type_sp = unique_ast_entry_ap->m_type_sp; if (type_sp) { dwarf->GetDIEToType()[die.GetDIE()] = type_sp.get(); @@ -652,7 +654,7 @@ TypeSP DWARFASTParserClang::ParseTypeFro default_accessibility = eAccessPrivate; } - if (byte_size && *byte_size == 0 && type_name_cstr && + if (byte_size_valid && byte_size == 0 && type_name_cstr && !die.HasChildren() && sc.comp_unit->GetLanguage() == eLanguageTypeObjC) { // Work around an issue with clang at the moment where forward @@ -855,7 +857,7 @@ TypeSP DWARFASTParserClang::ParseTypeFro unique_ast_entry_ap->m_type_sp = type_sp; unique_ast_entry_ap->m_die = die; unique_ast_entry_ap->m_declaration = unique_decl; - unique_ast_entry_ap->m_byte_size = byte_size.getValueOr(0); + unique_ast_entry_ap->m_byte_size = byte_size; dwarf->GetUniqueDWARFASTTypeMap().Insert(unique_typename, *unique_ast_entry_ap); @@ -1082,10 +1084,10 @@ TypeSP DWARFASTParserClang::ParseTypeFro } if (!enumerator_clang_type) { - if (byte_size) { + if (byte_size > 0) { enumerator_clang_type = m_ast.GetBuiltinTypeForDWARFEncodingAndBitSize( - NULL, DW_ATE_signed, *byte_size * 8); + NULL, DW_ATE_signed, byte_size * 8); } else { enumerator_clang_type = m_ast.GetBasicType(eBasicTypeInt); } @@ -1113,7 +1115,7 @@ TypeSP DWARFASTParserClang::ParseTypeFro bool is_signed = false; enumerator_clang_type.IsIntegerType(is_signed); ParseChildEnumerators(cu_sc, clang_type, is_signed, - type_sp->GetByteSize().getValueOr(0), die); + type_sp->GetByteSize(), die); } ClangASTContext::CompleteTagDeclarationDefinition(clang_type); } else { @@ -1651,10 +1653,9 @@ TypeSP DWARFASTParserClang::ParseTypeFro } } } - type_sp.reset(new Type(die.GetID(), dwarf, type_name_const_str, - llvm::None, NULL, LLDB_INVALID_UID, - Type::eEncodingIsUID, &decl, clang_type, - Type::eResolveStateFull)); + type_sp.reset(new Type(die.GetID(), dwarf, type_name_const_str, 0, NULL, + LLDB_INVALID_UID, Type::eEncodingIsUID, &decl, + clang_type, Type::eResolveStateFull)); assert(type_sp.get()); } break; @@ -1738,7 +1739,7 @@ TypeSP DWARFASTParserClang::ParseTypeFro bit_stride = array_info->bit_stride; } if (byte_stride == 0 && bit_stride == 0) - byte_stride = element_type->GetByteSize().getValueOr(0); + byte_stride = element_type->GetByteSize(); CompilerType array_element_type = element_type->GetForwardCompilerType(); @@ -2311,7 +2312,7 @@ bool DWARFASTParserClang::CompleteTypeFr !layout_info.base_offsets.empty() || !layout_info.vbase_offsets.empty()) { if (type) - layout_info.bit_size = type->GetByteSize().getValueOr(0) * 8; + layout_info.bit_size = type->GetByteSize() * 8; if (layout_info.bit_size == 0) layout_info.bit_size = die.GetAttributeValueAsUnsigned(DW_AT_byte_size, 0) * 8; @@ -2395,8 +2396,8 @@ bool DWARFASTParserClang::CompleteTypeFr SymbolContext sc(die.GetLLDBCompileUnit()); bool is_signed = false; clang_type.IsIntegerType(is_signed); - ParseChildEnumerators(sc, clang_type, is_signed, - type->GetByteSize().getValueOr(0), die); + ParseChildEnumerators(sc, clang_type, is_signed, type->GetByteSize(), + die); } ClangASTContext::CompleteTagDeclarationDefinition(clang_type); } @@ -2720,7 +2721,7 @@ bool DWARFASTParserClang::ParseChildMemb AccessType accessibility = eAccessNone; uint32_t member_byte_offset = (parent_die.Tag() == DW_TAG_union_type) ? 0 : UINT32_MAX; - llvm::Optional<uint64_t> byte_size; + size_t byte_size = 0; int64_t bit_offset = 0; uint64_t data_bit_offset = UINT64_MAX; size_t bit_size = 0; @@ -2863,7 +2864,7 @@ bool DWARFASTParserClang::ParseChildMemb // 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 == 0 && bit_offset < 0) { bit_size = 0; bit_offset = 0; } @@ -2925,12 +2926,12 @@ bool DWARFASTParserClang::ParseChildMemb if (data_bit_offset != UINT64_MAX) { this_field_info.bit_offset = data_bit_offset; } else { - if (!byte_size) + if (byte_size == 0) byte_size = member_type->GetByteSize(); ObjectFile *objfile = die.GetDWARF()->GetObjectFile(); if (objfile->GetByteOrder() == eByteOrderLittle) { - this_field_info.bit_offset += byte_size.getValueOr(0) * 8; + this_field_info.bit_offset += byte_size * 8; this_field_info.bit_offset -= (bit_offset + bit_size); } else { this_field_info.bit_offset += bit_offset; Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=352434&r1=352433&r2=352434&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Mon Jan 28 13:44:35 2019 @@ -1699,8 +1699,7 @@ SymbolFileDWARF::GlobalVariableMap &Symb location_result.GetScalar().ULongLong(); lldb::addr_t byte_size = 1; if (var_sp->GetType()) - byte_size = - var_sp->GetType()->GetByteSize().getValueOr(0); + byte_size = var_sp->GetType()->GetByteSize(); m_global_aranges_ap->Append(GlobalVariableMap::Entry( file_addr, byte_size, var_sp.get())); } @@ -3535,10 +3534,9 @@ VariableSP SymbolFileDWARF::ParseVariabl new SymbolFileType(*this, DIERef(type_die_form).GetUID(this))); if (const_value.Form() && type_sp && type_sp->GetType()) - location.CopyOpcodeData( - const_value.Unsigned(), - type_sp->GetType()->GetByteSize().getValueOr(0), - die.GetCU()->GetAddressByteSize()); + location.CopyOpcodeData(const_value.Unsigned(), + type_sp->GetType()->GetByteSize(), + die.GetCU()->GetAddressByteSize()); var_sp.reset(new Variable(die.GetID(), name, mangled, type_sp, scope, symbol_context_scope, scope_ranges, &decl, Modified: lldb/trunk/source/Symbol/Type.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Type.cpp?rev=352434&r1=352433&r2=352434&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Type.cpp (original) +++ lldb/trunk/source/Symbol/Type.cpp Mon Jan 28 13:44:35 2019 @@ -107,7 +107,7 @@ Type *SymbolFileType::GetType() { } Type::Type(lldb::user_id_t uid, SymbolFile *symbol_file, - const ConstString &name, llvm::Optional<uint64_t> byte_size, + const ConstString &name, uint64_t byte_size, SymbolContextScope *context, user_id_t encoding_uid, EncodingDataType encoding_uid_type, const Declaration &decl, const CompilerType &compiler_type, @@ -115,14 +115,7 @@ Type::Type(lldb::user_id_t uid, SymbolFi : std::enable_shared_from_this<Type>(), UserID(uid), m_name(name), m_symbol_file(symbol_file), m_context(context), m_encoding_type(nullptr), m_encoding_uid(encoding_uid), m_encoding_uid_type(encoding_uid_type), - m_decl(decl), m_compiler_type(compiler_type) { - if (byte_size) { - m_byte_size = *byte_size; - m_byte_size_has_value = true; - } else { - m_byte_size = 0; - m_byte_size_has_value = false; - } + m_byte_size(byte_size), m_decl(decl), m_compiler_type(compiler_type) { m_flags.compiler_type_resolve_state = (compiler_type ? compiler_type_resolve_state : eResolveStateUnresolved); m_flags.is_complete_objc_class = false; @@ -132,8 +125,7 @@ Type::Type() : std::enable_shared_from_this<Type>(), UserID(0), m_name("<INVALID TYPE>"), m_symbol_file(nullptr), m_context(nullptr), m_encoding_type(nullptr), m_encoding_uid(LLDB_INVALID_UID), m_encoding_uid_type(eEncodingInvalid), - m_byte_size(0), m_byte_size_has_value(false), m_decl(), - m_compiler_type() { + m_byte_size(0), m_decl(), m_compiler_type() { m_flags.compiler_type_resolve_state = eResolveStateUnresolved; m_flags.is_complete_objc_class = false; } @@ -143,8 +135,7 @@ Type::Type(const Type &rhs) m_symbol_file(rhs.m_symbol_file), m_context(rhs.m_context), m_encoding_type(rhs.m_encoding_type), m_encoding_uid(rhs.m_encoding_uid), m_encoding_uid_type(rhs.m_encoding_uid_type), - m_byte_size(rhs.m_byte_size), - m_byte_size_has_value(rhs.m_byte_size_has_value), m_decl(rhs.m_decl), + m_byte_size(rhs.m_byte_size), m_decl(rhs.m_decl), m_compiler_type(rhs.m_compiler_type), m_flags(rhs.m_flags) {} void Type::GetDescription(Stream *s, lldb::DescriptionLevel level, @@ -216,7 +207,7 @@ void Type::Dump(Stream *s, bool show_con if (m_name) *s << ", name = \"" << m_name << "\""; - if (m_byte_size_has_value) + if (m_byte_size != 0) s->Printf(", size = %" PRIu64, m_byte_size); if (show_context && m_context != nullptr) { @@ -295,7 +286,7 @@ void Type::DumpValue(ExecutionContext *e GetForwardCompilerType().DumpValue( exe_ctx, s, format == lldb::eFormatDefault ? GetFormat() : format, data, - data_byte_offset, GetByteSize().getValueOr(0), + data_byte_offset, GetByteSize(), 0, // Bitfield bit size 0, // Bitfield bit offset show_types, show_summary, verbose, 0); @@ -308,46 +299,36 @@ Type *Type::GetEncodingType() { return m_encoding_type; } -llvm::Optional<uint64_t> Type::GetByteSize() { - if (m_byte_size_has_value) - return m_byte_size; - - switch (m_encoding_uid_type) { - case eEncodingInvalid: - case eEncodingIsSyntheticUID: - break; - case eEncodingIsUID: - case eEncodingIsConstUID: - case eEncodingIsRestrictUID: - case eEncodingIsVolatileUID: - case eEncodingIsTypedefUID: { - Type *encoding_type = GetEncodingType(); - if (encoding_type) - if (llvm::Optional<uint64_t> size = encoding_type->GetByteSize()) { - m_byte_size = *size; - m_byte_size_has_value = true; - return m_byte_size; - } - - if (llvm::Optional<uint64_t> size = - GetLayoutCompilerType().GetByteSize(nullptr)) { - m_byte_size = *size; - m_byte_size_has_value = true; - return m_byte_size; - } - } break; +uint64_t Type::GetByteSize() { + if (m_byte_size == 0) { + switch (m_encoding_uid_type) { + case eEncodingInvalid: + case eEncodingIsSyntheticUID: + break; + case eEncodingIsUID: + case eEncodingIsConstUID: + case eEncodingIsRestrictUID: + case eEncodingIsVolatileUID: + case eEncodingIsTypedefUID: { + Type *encoding_type = GetEncodingType(); + if (encoding_type) + m_byte_size = encoding_type->GetByteSize(); + if (m_byte_size == 0) + if (llvm::Optional<uint64_t> size = + GetLayoutCompilerType().GetByteSize(nullptr)) + m_byte_size = *size; + } break; // If we are a pointer or reference, then this is just a pointer size; case eEncodingIsPointerUID: case eEncodingIsLValueReferenceUID: case eEncodingIsRValueReferenceUID: { - if (ArchSpec arch = m_symbol_file->GetObjectFile()->GetArchitecture()) { + if (ArchSpec arch = m_symbol_file->GetObjectFile()->GetArchitecture()) m_byte_size = arch.GetAddressByteSize(); - m_byte_size_has_value = true; - } } break; + } } - return {}; + return m_byte_size; } uint32_t Type::GetNumChildren(bool omit_empty_base_classes) { @@ -401,7 +382,7 @@ bool Type::ReadFromMemory(ExecutionConte return false; } - const uint64_t byte_size = GetByteSize().getValueOr(0); + const uint64_t byte_size = GetByteSize(); if (data.GetByteSize() < byte_size) { lldb::DataBufferSP data_sp(new DataBufferHeap(byte_size, '\0')); data.SetData(data_sp); _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits