diff --git a/lldb/include/lldb/Symbol/CompilerType.h b/lldb/include/lldb/Symbol/CompilerType.h index 53358799bff08..c28d78b4e2b24 100644 --- a/lldb/include/lldb/Symbol/CompilerType.h +++ b/lldb/include/lldb/Symbol/CompilerType.h @@ -154,7 +154,7 @@ class CompilerType { bool IsBoundsSafetyBidiIndexable() const; /* TO_UPSTREAM(BoundsSafety) OFF */ - bool IsFloatingPointType(uint32_t &count, bool &is_complex) const; + bool IsFloatingPointType(bool &is_complex) const; bool IsFunctionType() const; diff --git a/lldb/include/lldb/Symbol/TypeSystem.h b/lldb/include/lldb/Symbol/TypeSystem.h index e36b5ca0bcedf..ea910881ab238 100644 --- a/lldb/include/lldb/Symbol/TypeSystem.h +++ b/lldb/include/lldb/Symbol/TypeSystem.h @@ -169,7 +169,7 @@ class TypeSystem : public PluginInterface, virtual bool IsDefined(lldb::opaque_compiler_type_t type) = 0; virtual bool IsFloatingPointType(lldb::opaque_compiler_type_t type, - uint32_t &count, bool &is_complex) = 0; + bool &is_complex) = 0; virtual bool IsFunctionType(lldb::opaque_compiler_type_t type) = 0; diff --git a/lldb/source/Plugins/ABI/ARM/ABIMacOSX_arm.cpp b/lldb/source/Plugins/ABI/ARM/ABIMacOSX_arm.cpp index 5b5f6facc924c..8e690218843fa 100644 --- a/lldb/source/Plugins/ABI/ARM/ABIMacOSX_arm.cpp +++ b/lldb/source/Plugins/ABI/ARM/ABIMacOSX_arm.cpp @@ -1695,7 +1695,6 @@ Status ABIMacOSX_arm::SetReturnValueObject(lldb::StackFrameSP &frame_sp, Thread *thread = frame_sp->GetThread().get(); bool is_signed; - uint32_t count; bool is_complex; RegisterContext *reg_ctx = thread->GetRegisterContext().get(); @@ -1767,7 +1766,7 @@ Status ABIMacOSX_arm::SetReturnValueObject(lldb::StackFrameSP &frame_sp, "We don't support returning longer than 64 bit " "integer values at present."); } - } else if (compiler_type.IsFloatingPointType(count, is_complex)) { + } else if (compiler_type.IsFloatingPointType(is_complex)) { if (is_complex) error = Status::FromErrorString( "We don't support returning complex values at present"); diff --git a/lldb/source/Plugins/ABI/ARM/ABISysV_arm.cpp b/lldb/source/Plugins/ABI/ARM/ABISysV_arm.cpp index bb0c4ba3f1b57..7258f5cc9acb5 100644 --- a/lldb/source/Plugins/ABI/ARM/ABISysV_arm.cpp +++ b/lldb/source/Plugins/ABI/ARM/ABISysV_arm.cpp @@ -1550,7 +1550,6 @@ ValueObjectSP ABISysV_arm::GetReturnValueObjectImpl( bool is_signed; bool is_complex; - uint32_t float_count; bool is_vfp_candidate = false; uint8_t vfp_count = 0; uint8_t vfp_byte_size = 0; @@ -1634,8 +1633,9 @@ ValueObjectSP ABISysV_arm::GetReturnValueObjectImpl( if (!GetReturnValuePassedInMemory(thread, reg_ctx, *byte_size, value)) return return_valobj_sp; } - } else if (compiler_type.IsFloatingPointType(float_count, is_complex)) { - if (float_count == 1 && !is_complex) { + } else if (compiler_type.IsFloatingPointType(is_complex)) { + // Vector types are handled above. + if (!is_complex) { switch (*bit_width) { default: return return_valobj_sp; @@ -1681,7 +1681,7 @@ ValueObjectSP ABISysV_arm::GetReturnValueObjectImpl( break; } } - } else if (is_complex && float_count == 2) { + } else if (is_complex) { if (IsArmHardFloat(thread)) { is_vfp_candidate = true; vfp_byte_size = *byte_size / 2; @@ -1709,8 +1709,9 @@ ValueObjectSP ABISysV_arm::GetReturnValueObjectImpl( vfp_count = (*base_byte_size == 8 ? homogeneous_count : homogeneous_count * 2); } - } else if (base_type.IsFloatingPointType(float_count, is_complex)) { - if (float_count == 1 && !is_complex) { + } else if (base_type.IsFloatingPointType(is_complex)) { + // Vector types are handled above. + if (!is_complex) { is_vfp_candidate = true; if (base_byte_size) vfp_byte_size = *base_byte_size; @@ -1727,10 +1728,10 @@ ValueObjectSP ABISysV_arm::GetReturnValueObjectImpl( base_type = compiler_type.GetFieldAtIndex(index, name, nullptr, nullptr, nullptr); - if (base_type.IsFloatingPointType(float_count, is_complex)) { + if (base_type.IsFloatingPointType(is_complex)) { std::optional base_byte_size = llvm::expectedToOptional(base_type.GetByteSize(&thread)); - if (float_count == 2 && is_complex) { + if (is_complex) { if (index != 0 && base_byte_size && vfp_byte_size != *base_byte_size) break; @@ -1841,7 +1842,6 @@ Status ABISysV_arm::SetReturnValueObject(lldb::StackFrameSP &frame_sp, Thread *thread = frame_sp->GetThread().get(); bool is_signed; - uint32_t count; bool is_complex; RegisterContext *reg_ctx = thread->GetRegisterContext().get(); @@ -1884,7 +1884,7 @@ Status ABISysV_arm::SetReturnValueObject(lldb::StackFrameSP &frame_sp, "We don't support returning longer than 64 bit " "integer values at present."); } - } else if (compiler_type.IsFloatingPointType(count, is_complex)) { + } else if (compiler_type.IsFloatingPointType(is_complex)) { if (is_complex) error = Status::FromErrorString( "We don't support returning complex values at present"); diff --git a/lldb/source/Plugins/ABI/LoongArch/ABISysV_loongarch.cpp b/lldb/source/Plugins/ABI/LoongArch/ABISysV_loongarch.cpp index e6c8c8b469873..9bb7d032d6751 100644 --- a/lldb/source/Plugins/ABI/LoongArch/ABISysV_loongarch.cpp +++ b/lldb/source/Plugins/ABI/LoongArch/ABISysV_loongarch.cpp @@ -510,11 +510,10 @@ ValueObjectSP ABISysV_loongarch::GetReturnValueObjectSimple( value, ConstString("")); } if (type_flags & eTypeIsFloat) { - uint32_t float_count = 0; bool is_complex = false; - if (compiler_type.IsFloatingPointType(float_count, is_complex) && - float_count == 1 && !is_complex) { + if (compiler_type.IsFloatingPointType(is_complex) && + !(type_flags & eTypeIsVector) && !is_complex) { return_valobj_sp = GetValObjFromFPRegs(thread, reg_ctx, machine, type_flags, byte_size); return return_valobj_sp; diff --git a/lldb/source/Plugins/ABI/Mips/ABISysV_mips.cpp b/lldb/source/Plugins/ABI/Mips/ABISysV_mips.cpp index dd91a05534e37..e03604467ceec 100644 --- a/lldb/source/Plugins/ABI/Mips/ABISysV_mips.cpp +++ b/lldb/source/Plugins/ABI/Mips/ABISysV_mips.cpp @@ -708,7 +708,6 @@ Status ABISysV_mips::SetReturnValueObject(lldb::StackFrameSP &frame_sp, Thread *thread = frame_sp->GetThread().get(); bool is_signed; - uint32_t count; bool is_complex; RegisterContext *reg_ctx = thread->GetRegisterContext().get(); @@ -750,7 +749,7 @@ Status ABISysV_mips::SetReturnValueObject(lldb::StackFrameSP &frame_sp, "We don't support returning longer than 64 bit " "integer values at present."); } - } else if (compiler_type.IsFloatingPointType(count, is_complex)) { + } else if (compiler_type.IsFloatingPointType(is_complex)) { if (is_complex) error = Status::FromErrorString( "We don't support returning complex values at present"); @@ -797,7 +796,6 @@ ValueObjectSP ABISysV_mips::GetReturnValueObjectImpl( bool is_signed = false; bool is_complex = false; - uint32_t count = 0; // In MIPS register "r2" (v0) holds the integer function return values const RegisterInfo *r2_reg_info = reg_ctx->GetRegisterInfoByName("r2", 0); @@ -860,10 +858,10 @@ ValueObjectSP ABISysV_mips::GetReturnValueObjectImpl( return_valobj_sp = ValueObjectMemory::Create( &thread, "", Address(mem_address, nullptr), return_compiler_type); return return_valobj_sp; - } else if (return_compiler_type.IsFloatingPointType(count, is_complex)) { + } else if (return_compiler_type.IsFloatingPointType(is_complex)) { if (IsSoftFloat(fp_flag)) { uint64_t raw_value = reg_ctx->ReadRegisterAsUnsigned(r2_reg_info, 0); - if (count != 1 && is_complex) + if (is_complex) return return_valobj_sp; switch (*bit_width) { default: @@ -896,7 +894,7 @@ ValueObjectSP ABISysV_mips::GetReturnValueObjectImpl( f0_value.GetData(f0_data); lldb::offset_t offset = 0; - if (count == 1 && !is_complex) { + if (!return_compiler_type.IsVectorType() && !is_complex) { switch (*bit_width) { default: return return_valobj_sp; diff --git a/lldb/source/Plugins/ABI/Mips/ABISysV_mips64.cpp b/lldb/source/Plugins/ABI/Mips/ABISysV_mips64.cpp index baefbfc363d99..0dd9db0948220 100644 --- a/lldb/source/Plugins/ABI/Mips/ABISysV_mips64.cpp +++ b/lldb/source/Plugins/ABI/Mips/ABISysV_mips64.cpp @@ -923,7 +923,6 @@ ValueObjectSP ABISysV_mips64::GetReturnValueObjectImpl( bool sucess = false; std::string name; bool is_complex; - uint32_t count; const uint32_t num_children = return_compiler_type.GetNumFields(); // A structure consisting of one or two FP values (and nothing else) will @@ -937,7 +936,7 @@ ValueObjectSP ABISysV_mips64::GetReturnValueObjectImpl( return_compiler_type.GetFieldAtIndex(idx, name, &field_bit_offset, nullptr, nullptr); - if (field_compiler_type.IsFloatingPointType(count, is_complex)) + if (field_compiler_type.IsFloatingPointType(is_complex)) use_fp_regs = true; else found_non_fp_field = true; @@ -1044,7 +1043,7 @@ ValueObjectSP ABISysV_mips64::GetReturnValueObjectImpl( if (field_compiler_type.IsIntegerOrEnumerationType(is_signed) || field_compiler_type.IsPointerType() || - field_compiler_type.IsFloatingPointType(count, is_complex)) { + field_compiler_type.IsFloatingPointType(is_complex)) { padding = field_byte_offset - integer_bytes; if (integer_bytes < 8) { diff --git a/lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc.cpp b/lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc.cpp index e4bdc44c59c10..0d25faef1c659 100644 --- a/lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc.cpp +++ b/lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc.cpp @@ -426,7 +426,6 @@ Status ABISysV_ppc::SetReturnValueObject(lldb::StackFrameSP &frame_sp, Thread *thread = frame_sp->GetThread().get(); bool is_signed; - uint32_t count; bool is_complex; RegisterContext *reg_ctx = thread->GetRegisterContext().get(); @@ -454,7 +453,7 @@ Status ABISysV_ppc::SetReturnValueObject(lldb::StackFrameSP &frame_sp, "We don't support returning longer than 64 bit " "integer values at present."); } - } else if (compiler_type.IsFloatingPointType(count, is_complex)) { + } else if (compiler_type.IsFloatingPointType(is_complex)) { if (is_complex) error = Status::FromErrorString( "We don't support returning complex values at present"); @@ -695,7 +694,6 @@ ValueObjectSP ABISysV_ppc::GetReturnValueObjectImpl( uint64_t field_bit_offset = 0; bool is_signed; bool is_complex; - uint32_t count; CompilerType field_compiler_type = return_compiler_type.GetFieldAtIndex( idx, name, &field_bit_offset, nullptr, nullptr); @@ -741,7 +739,7 @@ ValueObjectSP ABISysV_ppc::GetReturnValueObjectImpl( // return a nullptr return value object. return return_valobj_sp; } - } else if (field_compiler_type.IsFloatingPointType(count, is_complex)) { + } else if (field_compiler_type.IsFloatingPointType(is_complex)) { // Structs with long doubles are always passed in memory. if (*field_bit_width == 128) { is_memory = true; diff --git a/lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc64.cpp b/lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc64.cpp index f5327a1f403c0..63357618774d4 100644 --- a/lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc64.cpp +++ b/lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc64.cpp @@ -309,7 +309,6 @@ Status ABISysV_ppc64::SetReturnValueObject(lldb::StackFrameSP &frame_sp, Thread *thread = frame_sp->GetThread().get(); bool is_signed; - uint32_t count; bool is_complex; RegisterContext *reg_ctx = thread->GetRegisterContext().get(); @@ -339,7 +338,7 @@ Status ABISysV_ppc64::SetReturnValueObject(lldb::StackFrameSP &frame_sp, "We don't support returning longer than 64 bit " "integer values at present."); } - } else if (compiler_type.IsFloatingPointType(count, is_complex)) { + } else if (compiler_type.IsFloatingPointType(is_complex)) { if (is_complex) error = Status::FromErrorString( "We don't support returning complex values at present"); diff --git a/lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp b/lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp index b313ca03fb970..d56f32d0ce22b 100644 --- a/lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp +++ b/lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp @@ -643,11 +643,10 @@ ABISysV_riscv::GetReturnValueObjectSimple(Thread &thread, } // Floating point return type. else if (type_flags & eTypeIsFloat) { - uint32_t float_count = 0; bool is_complex = false; - if (compiler_type.IsFloatingPointType(float_count, is_complex) && - float_count == 1 && !is_complex) { + if (compiler_type.IsFloatingPointType(is_complex) && + !(type_flags & eTypeIsVector) && !is_complex) { const uint32_t arch_fp_flags = arch.GetFlags() & ArchSpec::eRISCV_float_abi_mask; return_valobj_sp = GetValObjFromFPRegs( diff --git a/lldb/source/Plugins/ABI/SystemZ/ABISysV_s390x.cpp b/lldb/source/Plugins/ABI/SystemZ/ABISysV_s390x.cpp index 5e52b6e4db499..301c3b309ffd5 100644 --- a/lldb/source/Plugins/ABI/SystemZ/ABISysV_s390x.cpp +++ b/lldb/source/Plugins/ABI/SystemZ/ABISysV_s390x.cpp @@ -393,7 +393,6 @@ Status ABISysV_s390x::SetReturnValueObject(lldb::StackFrameSP &frame_sp, Thread *thread = frame_sp->GetThread().get(); bool is_signed; - uint32_t count; bool is_complex; RegisterContext *reg_ctx = thread->GetRegisterContext().get(); @@ -423,7 +422,7 @@ Status ABISysV_s390x::SetReturnValueObject(lldb::StackFrameSP &frame_sp, "We don't support returning longer than 64 bit " "integer values at present."); } - } else if (compiler_type.IsFloatingPointType(count, is_complex)) { + } else if (compiler_type.IsFloatingPointType(is_complex)) { if (is_complex) error = Status::FromErrorString( "We don't support returning complex values at present"); diff --git a/lldb/source/Plugins/ABI/X86/ABIMacOSX_i386.cpp b/lldb/source/Plugins/ABI/X86/ABIMacOSX_i386.cpp index eaeed6c04590c..ee79abe55ead0 100644 --- a/lldb/source/Plugins/ABI/X86/ABIMacOSX_i386.cpp +++ b/lldb/source/Plugins/ABI/X86/ABIMacOSX_i386.cpp @@ -198,7 +198,6 @@ Status ABIMacOSX_i386::SetReturnValueObject(lldb::StackFrameSP &frame_sp, Thread *thread = frame_sp->GetThread().get(); bool is_signed; - uint32_t count; bool is_complex; RegisterContext *reg_ctx = thread->GetRegisterContext().get(); @@ -240,7 +239,7 @@ Status ABIMacOSX_i386::SetReturnValueObject(lldb::StackFrameSP &frame_sp, "We don't support returning longer than 64 bit " "integer values at present."); } - } else if (compiler_type.IsFloatingPointType(count, is_complex)) { + } else if (compiler_type.IsFloatingPointType(is_complex)) { if (is_complex) error = Status::FromErrorString( "We don't support returning complex values at present"); diff --git a/lldb/source/Plugins/ABI/X86/ABISysV_x86_64.cpp b/lldb/source/Plugins/ABI/X86/ABISysV_x86_64.cpp index e8cf2258f948b..5aaa9489da154 100644 --- a/lldb/source/Plugins/ABI/X86/ABISysV_x86_64.cpp +++ b/lldb/source/Plugins/ABI/X86/ABISysV_x86_64.cpp @@ -307,7 +307,6 @@ Status ABISysV_x86_64::SetReturnValueObject(lldb::StackFrameSP &frame_sp, Thread *thread = frame_sp->GetThread().get(); bool is_signed; - uint32_t count; bool is_complex; RegisterContext *reg_ctx = thread->GetRegisterContext().get(); @@ -337,7 +336,7 @@ Status ABISysV_x86_64::SetReturnValueObject(lldb::StackFrameSP &frame_sp, "We don't support returning longer than 64 bit " "integer values at present."); } - } else if (compiler_type.IsFloatingPointType(count, is_complex)) { + } else if (compiler_type.IsFloatingPointType(is_complex)) { if (is_complex) error = Status::FromErrorString( "We don't support returning complex values at present"); @@ -831,7 +830,6 @@ static bool FlattenAggregateType( for (uint32_t idx = 0; idx < num_children; ++idx) { std::string name; bool is_signed; - uint32_t count; bool is_complex; uint64_t field_bit_offset = 0; @@ -850,7 +848,7 @@ static bool FlattenAggregateType( const uint32_t field_type_flags = field_compiler_type.GetTypeInfo(); if (field_compiler_type.IsIntegerOrEnumerationType(is_signed) || field_compiler_type.IsPointerType() || - field_compiler_type.IsFloatingPointType(count, is_complex)) { + field_compiler_type.IsFloatingPointType(is_complex)) { aggregate_field_offsets.push_back(field_byte_offset); aggregate_compiler_types.push_back(field_compiler_type); } else if (field_type_flags & eTypeHasChildren) { @@ -975,7 +973,6 @@ ValueObjectSP ABISysV_x86_64::GetReturnValueObjectImpl( std::string name; bool is_signed; bool already_copied = false; - uint32_t count; bool is_complex; CompilerType field_compiler_type = aggregate_compiler_types[idx]; @@ -1065,7 +1062,7 @@ ValueObjectSP ABISysV_x86_64::GetReturnValueObjectImpl( // return a nullptr return value object. return return_valobj_sp; } - } else if (field_compiler_type.IsFloatingPointType(count, is_complex)) { + } else if (field_compiler_type.IsFloatingPointType(is_complex)) { // Structs with long doubles are always passed in memory. if (field_bit_width == 128) { is_memory = true; diff --git a/lldb/source/Plugins/ABI/X86/ABIWindows_x86_64.cpp b/lldb/source/Plugins/ABI/X86/ABIWindows_x86_64.cpp index 56df6f6b5e97c..b4214a4882e07 100644 --- a/lldb/source/Plugins/ABI/X86/ABIWindows_x86_64.cpp +++ b/lldb/source/Plugins/ABI/X86/ABIWindows_x86_64.cpp @@ -312,7 +312,6 @@ Status ABIWindows_x86_64::SetReturnValueObject(lldb::StackFrameSP &frame_sp, Thread *thread = frame_sp->GetThread().get(); bool is_signed; - uint32_t count; bool is_complex; RegisterContext *reg_ctx = thread->GetRegisterContext().get(); @@ -342,7 +341,7 @@ Status ABIWindows_x86_64::SetReturnValueObject(lldb::StackFrameSP &frame_sp, "We don't support returning longer than 64 bit " "integer values at present."); } - } else if (compiler_type.IsFloatingPointType(count, is_complex)) { + } else if (compiler_type.IsFloatingPointType(is_complex)) { if (is_complex) error = Status::FromErrorString( "We don't support returning complex values at present"); @@ -558,7 +557,6 @@ static bool FlattenAggregateType( for (uint32_t idx = 0; idx < num_children; ++idx) { std::string name; bool is_signed; - uint32_t count; bool is_complex; uint64_t field_bit_offset = 0; @@ -582,7 +580,7 @@ static bool FlattenAggregateType( const uint32_t field_type_flags = field_compiler_type.GetTypeInfo(); if (field_compiler_type.IsIntegerOrEnumerationType(is_signed) || field_compiler_type.IsPointerType() || - field_compiler_type.IsFloatingPointType(count, is_complex)) { + field_compiler_type.IsFloatingPointType(is_complex)) { aggregate_field_offsets.push_back(field_byte_offset); aggregate_compiler_types.push_back(field_compiler_type); } else if (field_type_flags & eTypeHasChildren) { @@ -672,7 +670,6 @@ ValueObjectSP ABIWindows_x86_64::GetReturnValueObjectImpl( for (uint32_t idx = 0; idx < num_children; idx++) { bool is_signed; bool is_complex; - uint32_t count; CompilerType field_compiler_type = aggregate_compiler_types[idx]; uint32_t field_byte_width = @@ -691,7 +688,7 @@ ValueObjectSP ABIWindows_x86_64::GetReturnValueObjectImpl( uint32_t copy_from_offset = 0; if (field_compiler_type.IsIntegerOrEnumerationType(is_signed) || field_compiler_type.IsPointerType() || - field_compiler_type.IsFloatingPointType(count, is_complex)) { + field_compiler_type.IsFloatingPointType(is_complex)) { copy_from_extractor = &rax_data; copy_from_offset = used_bytes; used_bytes += field_byte_width; diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index ee903c1d53fc4..16928aca6d7a1 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -2142,11 +2142,10 @@ static std::optional MakeAPValue(const clang::ASTContext &ast, if (is_integral) return clang::APValue(apint); - uint32_t count; bool is_complex; // FIXME: we currently support a limited set of floating point types. // E.g., 16-bit floats are not supported. - if (!clang_type.IsFloatingPointType(count, is_complex)) + if (!clang_type.IsFloatingPointType(is_complex)) return std::nullopt; return clang::APValue(llvm::APFloat( diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp index f068401e6cde4..99d31ff9c29bc 100644 --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp @@ -3483,7 +3483,7 @@ bool TypeSystemClang::IsReferenceType(lldb::opaque_compiler_type_t type, } bool TypeSystemClang::IsFloatingPointType(lldb::opaque_compiler_type_t type, - uint32_t &count, bool &is_complex) { + bool &is_complex) { if (type) { clang::QualType qual_type(GetCanonicalQualType(type)); @@ -3492,30 +3492,26 @@ bool TypeSystemClang::IsFloatingPointType(lldb::opaque_compiler_type_t type, clang::BuiltinType::Kind kind = BT->getKind(); if (kind >= clang::BuiltinType::Float && kind <= clang::BuiltinType::LongDouble) { - count = 1; is_complex = false; return true; } } else if (const clang::ComplexType *CT = llvm::dyn_cast( qual_type->getCanonicalTypeInternal())) { - if (IsFloatingPointType(CT->getElementType().getAsOpaquePtr(), count, + if (IsFloatingPointType(CT->getElementType().getAsOpaquePtr(), is_complex)) { - count = 2; is_complex = true; return true; } } else if (const clang::VectorType *VT = llvm::dyn_cast( qual_type->getCanonicalTypeInternal())) { - if (IsFloatingPointType(VT->getElementType().getAsOpaquePtr(), count, + if (IsFloatingPointType(VT->getElementType().getAsOpaquePtr(), is_complex)) { - count = VT->getNumElements(); is_complex = false; return true; } } } - count = 0; is_complex = false; return false; } @@ -3997,9 +3993,9 @@ TypeSystemClang::GetTypeInfo(lldb::opaque_compiler_type_t type, if (complex_type) { clang::QualType complex_element_type(complex_type->getElementType()); if (complex_element_type->isIntegerType()) - complex_type_flags |= eTypeIsFloat; - else if (complex_element_type->isFloatingType()) complex_type_flags |= eTypeIsInteger; + else if (complex_element_type->isFloatingType()) + complex_type_flags |= eTypeIsFloat; } return complex_type_flags; } break; @@ -4095,12 +4091,17 @@ TypeSystemClang::GetTypeInfo(lldb::opaque_compiler_type_t type, uint32_t vector_type_flags = eTypeHasChildren | eTypeIsVector; const clang::VectorType *vector_type = llvm::dyn_cast( qual_type->getCanonicalTypeInternal()); - if (vector_type) { - if (vector_type->isIntegerType()) - vector_type_flags |= eTypeIsFloat; - else if (vector_type->isFloatingType()) - vector_type_flags |= eTypeIsInteger; - } + if (!vector_type) + return 0; + + QualType element_type = vector_type->getElementType(); + if (element_type.isNull()) + return 0; + + if (element_type->isIntegerType()) + vector_type_flags |= eTypeIsInteger; + else if (element_type->isFloatingType()) + vector_type_flags |= eTypeIsFloat; return vector_type_flags; } default: diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h index 6bf8b81147ca1..2cdbadce33b40 100644 --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h @@ -701,7 +701,7 @@ class TypeSystemClang : public TypeSystem { bool IsDefined(lldb::opaque_compiler_type_t type) override; - bool IsFloatingPointType(lldb::opaque_compiler_type_t type, uint32_t &count, + bool IsFloatingPointType(lldb::opaque_compiler_type_t type, bool &is_complex) override; unsigned GetPtrAuthKey(lldb::opaque_compiler_type_t type) override; diff --git a/lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwift.cpp b/lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwift.cpp index b33c8f8e7b9e4..73da6ad2aa82d 100644 --- a/lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwift.cpp +++ b/lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwift.cpp @@ -120,11 +120,9 @@ void TypeSystemSwift::Dump(llvm::raw_ostream &output, llvm::StringRef filter) { } bool TypeSystemSwift::IsFloatingPointType(opaque_compiler_type_t type, - uint32_t &count, bool &is_complex) { - count = 0; + bool &is_complex) { is_complex = false; if (GetTypeInfo(type, nullptr) & eTypeIsFloat) { - count = 1; return true; } return false; diff --git a/lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwift.h b/lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwift.h index 75d04a6d3db6d..d14083b1eeb9a 100644 --- a/lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwift.h +++ b/lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwift.h @@ -237,7 +237,7 @@ class TypeSystemSwift : public TypeSystem { return true; } bool IsConst(lldb::opaque_compiler_type_t type) override { return false; } - bool IsFloatingPointType(lldb::opaque_compiler_type_t type, uint32_t &count, + bool IsFloatingPointType(lldb::opaque_compiler_type_t type, bool &is_complex) override; bool IsIntegerType(lldb::opaque_compiler_type_t type, bool &is_signed) override; diff --git a/lldb/source/Symbol/CompilerType.cpp b/lldb/source/Symbol/CompilerType.cpp index 9bba50259bf19..a788fa51e07f4 100644 --- a/lldb/source/Symbol/CompilerType.cpp +++ b/lldb/source/Symbol/CompilerType.cpp @@ -240,13 +240,11 @@ bool CompilerType::ShouldTreatScalarValueAsAddress() const { return false; } -bool CompilerType::IsFloatingPointType(uint32_t &count, - bool &is_complex) const { +bool CompilerType::IsFloatingPointType(bool &is_complex) const { if (IsValid()) { if (auto type_system_sp = GetTypeSystem()) - return type_system_sp->IsFloatingPointType(m_type, count, is_complex); + return type_system_sp->IsFloatingPointType(m_type, is_complex); } - count = 0; is_complex = false; return false; } @@ -347,9 +345,8 @@ bool CompilerType::IsInteger() const { } bool CompilerType::IsFloat() const { - uint32_t count = 0; bool is_complex = false; - return IsFloatingPointType(count, is_complex); + return IsFloatingPointType(is_complex); } bool CompilerType::IsEnumerationType() const { diff --git a/lldb/unittests/Symbol/TestTypeSystemClang.cpp b/lldb/unittests/Symbol/TestTypeSystemClang.cpp index b0dcc01189c71..4cbe4d4231f68 100644 --- a/lldb/unittests/Symbol/TestTypeSystemClang.cpp +++ b/lldb/unittests/Symbol/TestTypeSystemClang.cpp @@ -1117,6 +1117,30 @@ TEST_F(TestTypeSystemClang, AddMethodToCXXRecordType_ParmVarDecls) { EXPECT_EQ(method_it->getParamDecl(1)->getDeclContext(), *method_it); } +TEST_F(TestTypeSystemClang, TestGetTypeInfo) { + // Tests TypeSystemClang::GetTypeInfo + + const ASTContext &ast = m_ast->getASTContext(); + + CompilerType complex_int = m_ast->GetType(ast.getComplexType(ast.IntTy)); + EXPECT_EQ(complex_int.GetTypeInfo(), + (eTypeIsInteger | eTypeIsComplex | eTypeIsBuiltIn | eTypeHasValue)); + + CompilerType complex_float = m_ast->GetType(ast.getComplexType(ast.FloatTy)); + EXPECT_EQ(complex_float.GetTypeInfo(), + (eTypeIsFloat | eTypeIsComplex | eTypeIsBuiltIn | eTypeHasValue)); + + CompilerType vector_of_int = + m_ast->GetType(ast.getVectorType(ast.IntTy, 1, VectorKind::Generic)); + EXPECT_EQ(vector_of_int.GetTypeInfo(), + (eTypeIsInteger | eTypeIsVector | eTypeHasChildren)); + + CompilerType vector_of_float = + m_ast->GetType(ast.getVectorType(ast.FloatTy, 1, VectorKind::Generic)); + EXPECT_EQ(vector_of_float.GetTypeInfo(), + (eTypeIsFloat | eTypeIsVector | eTypeHasChildren)); +} + TEST_F(TestTypeSystemClang, AsmLabel_CtorDtor) { // Tests TypeSystemClang::DeclGetMangledName for constructors/destructors // with and without AsmLabels. diff --git a/lldb/unittests/Symbol/TestTypeSystemSwiftTypeRef.cpp b/lldb/unittests/Symbol/TestTypeSystemSwiftTypeRef.cpp index ba98e61f487f3..b592dd10dfa2d 100644 --- a/lldb/unittests/Symbol/TestTypeSystemSwiftTypeRef.cpp +++ b/lldb/unittests/Symbol/TestTypeSystemSwiftTypeRef.cpp @@ -406,10 +406,8 @@ TEST_F(TestTypeSystemSwiftTypeRef, Scalar) { { NodePointer int_node = b.GlobalTypeMangling(b.IntType()); CompilerType int_type = GetCompilerType(b.Mangle(int_node)); - uint32_t count = 99; bool is_complex = true; - ASSERT_FALSE(int_type.IsFloatingPointType(count, is_complex)); - ASSERT_EQ(count, 0UL); + ASSERT_FALSE(int_type.IsFloatingPointType(is_complex)); ASSERT_EQ(is_complex, false); bool is_signed = true; ASSERT_TRUE(int_type.IsIntegerType(is_signed)); @@ -418,10 +416,8 @@ TEST_F(TestTypeSystemSwiftTypeRef, Scalar) { { NodePointer float_node = b.GlobalTypeMangling(b.FloatType()); CompilerType float_type = GetCompilerType(b.Mangle(float_node)); - uint32_t count = 99; bool is_complex = true; - ASSERT_TRUE(float_type.IsFloatingPointType(count, is_complex)); - ASSERT_EQ(count, 1UL); + ASSERT_TRUE(float_type.IsFloatingPointType(is_complex)); ASSERT_EQ(is_complex, false); bool is_signed = true; ASSERT_FALSE(float_type.IsIntegerType(is_signed));