[Lldb-commits] [lldb] [lldb][TypeSystemClang] Don't treat float vector types as floating point types (PR #179213)
Michael Buch via lldb-commits
lldb-commits at lists.llvm.org
Mon Feb 2 03:58:35 PST 2026
https://github.com/Michael137 created https://github.com/llvm/llvm-project/pull/179213
Depends on:
* https://github.com/llvm/llvm-project/pull/179212
>From dd76fef58c56b09cbe967927772d4ff96b8d8be4 Mon Sep 17 00:00:00 2001
From: Michael Buch <michaelbuch12 at gmail.com>
Date: Fri, 30 Jan 2026 13:39:56 +0000
Subject: [PATCH 1/4] [lldb][CompilerType] Add
CompilerType::IsRealFloatingPointType
---
lldb/include/lldb/Symbol/CompilerType.h | 4 +
lldb/source/Plugins/ABI/ARC/ABISysV_arc.cpp | 21 ++--
lldb/source/Plugins/ABI/ARM/ABIMacOSX_arm.cpp | 8 --
lldb/source/Plugins/ABI/ARM/ABISysV_arm.cpp | 8 --
.../ABI/LoongArch/ABISysV_loongarch.cpp | 14 +--
lldb/source/Plugins/ABI/Mips/ABISysV_mips.cpp | 96 ++++++++-----------
.../Plugins/ABI/PowerPC/ABISysV_ppc.cpp | 52 +++++-----
.../Plugins/ABI/PowerPC/ABISysV_ppc64.cpp | 52 +++++-----
.../Plugins/ABI/RISCV/ABISysV_riscv.cpp | 18 ++--
.../Plugins/ABI/SystemZ/ABISysV_s390x.cpp | 60 ++++++------
.../source/Plugins/ABI/X86/ABIMacOSX_i386.cpp | 8 --
.../source/Plugins/ABI/X86/ABISysV_x86_64.cpp | 61 ++++++------
.../Plugins/ABI/X86/ABIWindows_x86_64.cpp | 61 ++++++------
.../SymbolFile/DWARF/DWARFASTParserClang.cpp | 3 +-
lldb/source/Symbol/CompilerType.cpp | 5 +
lldb/unittests/Symbol/TestTypeSystemClang.cpp | 21 ++++
16 files changed, 218 insertions(+), 274 deletions(-)
diff --git a/lldb/include/lldb/Symbol/CompilerType.h b/lldb/include/lldb/Symbol/CompilerType.h
index 869c5076ee0a7..4f1662ee6d162 100644
--- a/lldb/include/lldb/Symbol/CompilerType.h
+++ b/lldb/include/lldb/Symbol/CompilerType.h
@@ -144,8 +144,12 @@ class CompilerType {
bool IsDefined() const;
+ /// Returns \c true for floating point types (including complex floats).
bool IsFloatingPointType(bool &is_complex) const;
+ /// Returns \c true for non-complex float types.
+ bool IsRealFloatingPointType() const;
+
bool IsFunctionType() const;
uint32_t IsHomogeneousAggregate(CompilerType *base_type_ptr) const;
diff --git a/lldb/source/Plugins/ABI/ARC/ABISysV_arc.cpp b/lldb/source/Plugins/ABI/ARC/ABISysV_arc.cpp
index e41a28bd21c36..95f4057b1d3e8 100644
--- a/lldb/source/Plugins/ABI/ARC/ABISysV_arc.cpp
+++ b/lldb/source/Plugins/ABI/ARC/ABISysV_arc.cpp
@@ -479,19 +479,14 @@ ABISysV_arc::GetReturnValueObjectSimple(Thread &thread,
value.SetValueType(Value::ValueType::Scalar);
}
// Floating point return type.
- else if (type_flags & eTypeIsFloat) {
- bool is_complex = false;
-
- if (compiler_type.IsFloatingPointType(is_complex) &&
- !compiler_type.IsVectorType() && !is_complex) {
- const size_t byte_size =
- llvm::expectedToOptional(compiler_type.GetByteSize(&thread))
- .value_or(0);
- auto raw_value = ReadRawValue(reg_ctx, byte_size);
-
- if (!SetSizedFloat(value.GetScalar(), raw_value, byte_size))
- return ValueObjectSP();
- }
+ else if (compiler_type.IsRealFloatingPointType()) {
+ const size_t byte_size =
+ llvm::expectedToOptional(compiler_type.GetByteSize(&thread))
+ .value_or(0);
+ auto raw_value = ReadRawValue(reg_ctx, byte_size);
+
+ if (!SetSizedFloat(value.GetScalar(), raw_value, byte_size))
+ return ValueObjectSP();
}
// Unsupported return type.
else
diff --git a/lldb/source/Plugins/ABI/ARM/ABIMacOSX_arm.cpp b/lldb/source/Plugins/ABI/ARM/ABIMacOSX_arm.cpp
index 8e690218843fa..84791a90a450d 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;
- bool is_complex;
RegisterContext *reg_ctx = thread->GetRegisterContext().get();
@@ -1766,13 +1765,6 @@ 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(is_complex)) {
- if (is_complex)
- error = Status::FromErrorString(
- "We don't support returning complex values at present");
- else
- error = Status::FromErrorString(
- "We don't support returning float values at present");
}
if (!set_it_simple)
diff --git a/lldb/source/Plugins/ABI/ARM/ABISysV_arm.cpp b/lldb/source/Plugins/ABI/ARM/ABISysV_arm.cpp
index 7258f5cc9acb5..1831daaa16f88 100644
--- a/lldb/source/Plugins/ABI/ARM/ABISysV_arm.cpp
+++ b/lldb/source/Plugins/ABI/ARM/ABISysV_arm.cpp
@@ -1842,7 +1842,6 @@ Status ABISysV_arm::SetReturnValueObject(lldb::StackFrameSP &frame_sp,
Thread *thread = frame_sp->GetThread().get();
bool is_signed;
- bool is_complex;
RegisterContext *reg_ctx = thread->GetRegisterContext().get();
@@ -1884,13 +1883,6 @@ 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(is_complex)) {
- if (is_complex)
- error = Status::FromErrorString(
- "We don't support returning complex values at present");
- else
- error = Status::FromErrorString(
- "We don't support returning float values at present");
}
if (!set_it_simple)
diff --git a/lldb/source/Plugins/ABI/LoongArch/ABISysV_loongarch.cpp b/lldb/source/Plugins/ABI/LoongArch/ABISysV_loongarch.cpp
index 91b965d3b5715..d2a2cbe0643ac 100644
--- a/lldb/source/Plugins/ABI/LoongArch/ABISysV_loongarch.cpp
+++ b/lldb/source/Plugins/ABI/LoongArch/ABISysV_loongarch.cpp
@@ -509,16 +509,12 @@ ValueObjectSP ABISysV_loongarch::GetReturnValueObjectSimple(
return ValueObjectConstResult::Create(thread.GetStackFrameAtIndex(0).get(),
value, ConstString(""));
}
- if (type_flags & eTypeIsFloat) {
- bool is_complex = false;
-
- 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;
- }
+ if (compiler_type.IsRealFloatingPointType()) {
+ return_valobj_sp =
+ GetValObjFromFPRegs(thread, reg_ctx, machine, type_flags, byte_size);
+ return return_valobj_sp;
}
+
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 e03604467ceec..338d5c152f612 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;
- bool is_complex;
RegisterContext *reg_ctx = thread->GetRegisterContext().get();
@@ -749,13 +748,6 @@ 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(is_complex)) {
- if (is_complex)
- error = Status::FromErrorString(
- "We don't support returning complex values at present");
- else
- error = Status::FromErrorString(
- "We don't support returning float values at present");
}
if (!set_it_simple)
@@ -795,7 +787,6 @@ ValueObjectSP ABISysV_mips::GetReturnValueObjectImpl(
return return_valobj_sp;
bool is_signed = false;
- bool is_complex = false;
// In MIPS register "r2" (v0) holds the integer function return values
const RegisterInfo *r2_reg_info = reg_ctx->GetRegisterInfoByName("r2", 0);
@@ -858,11 +849,9 @@ 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(is_complex)) {
+ } else if (return_compiler_type.IsRealFloatingPointType()) {
if (IsSoftFloat(fp_flag)) {
uint64_t raw_value = reg_ctx->ReadRegisterAsUnsigned(r2_reg_info, 0);
- if (is_complex)
- return return_valobj_sp;
switch (*bit_width) {
default:
return return_valobj_sp;
@@ -894,51 +883,46 @@ ValueObjectSP ABISysV_mips::GetReturnValueObjectImpl(
f0_value.GetData(f0_data);
lldb::offset_t offset = 0;
- if (!return_compiler_type.IsVectorType() && !is_complex) {
- switch (*bit_width) {
- default:
- return return_valobj_sp;
- case 64: {
- static_assert(sizeof(double) == sizeof(uint64_t));
- const RegisterInfo *f1_info = reg_ctx->GetRegisterInfoByName("f1", 0);
- RegisterValue f1_value;
- DataExtractor f1_data;
- reg_ctx->ReadRegister(f1_info, f1_value);
- DataExtractor *copy_from_extractor = nullptr;
- WritableDataBufferSP data_sp(new DataBufferHeap(8, 0));
- DataExtractor return_ext(
- data_sp, target_byte_order,
- target->GetArchitecture().GetAddressByteSize());
-
- if (target_byte_order == eByteOrderLittle) {
- copy_from_extractor = &f0_data;
- copy_from_extractor->CopyByteOrderedData(
- offset, 4, data_sp->GetBytes(), 4, target_byte_order);
- f1_value.GetData(f1_data);
- copy_from_extractor = &f1_data;
- copy_from_extractor->CopyByteOrderedData(
- offset, 4, data_sp->GetBytes() + 4, 4, target_byte_order);
- } else {
- copy_from_extractor = &f0_data;
- copy_from_extractor->CopyByteOrderedData(
- offset, 4, data_sp->GetBytes() + 4, 4, target_byte_order);
- f1_value.GetData(f1_data);
- copy_from_extractor = &f1_data;
- copy_from_extractor->CopyByteOrderedData(
- offset, 4, data_sp->GetBytes(), 4, target_byte_order);
- }
- value.GetScalar() = (double)return_ext.GetDouble(&offset);
- break;
- }
- case 32: {
- static_assert(sizeof(float) == sizeof(uint32_t));
- value.GetScalar() = (float)f0_data.GetFloat(&offset);
- break;
- }
- }
- } else {
- // not handled yet
+ switch (*bit_width) {
+ default:
return return_valobj_sp;
+ case 64: {
+ static_assert(sizeof(double) == sizeof(uint64_t));
+ const RegisterInfo *f1_info = reg_ctx->GetRegisterInfoByName("f1", 0);
+ RegisterValue f1_value;
+ DataExtractor f1_data;
+ reg_ctx->ReadRegister(f1_info, f1_value);
+ DataExtractor *copy_from_extractor = nullptr;
+ WritableDataBufferSP data_sp(new DataBufferHeap(8, 0));
+ DataExtractor return_ext(
+ data_sp, target_byte_order,
+ target->GetArchitecture().GetAddressByteSize());
+
+ if (target_byte_order == eByteOrderLittle) {
+ copy_from_extractor = &f0_data;
+ copy_from_extractor->CopyByteOrderedData(
+ offset, 4, data_sp->GetBytes(), 4, target_byte_order);
+ f1_value.GetData(f1_data);
+ copy_from_extractor = &f1_data;
+ copy_from_extractor->CopyByteOrderedData(
+ offset, 4, data_sp->GetBytes() + 4, 4, target_byte_order);
+ } else {
+ copy_from_extractor = &f0_data;
+ copy_from_extractor->CopyByteOrderedData(
+ offset, 4, data_sp->GetBytes() + 4, 4, target_byte_order);
+ f1_value.GetData(f1_data);
+ copy_from_extractor = &f1_data;
+ copy_from_extractor->CopyByteOrderedData(
+ offset, 4, data_sp->GetBytes(), 4, target_byte_order);
+ }
+ value.GetScalar() = (double)return_ext.GetDouble(&offset);
+ break;
+ }
+ case 32: {
+ static_assert(sizeof(float) == sizeof(uint32_t));
+ value.GetScalar() = (float)f0_data.GetFloat(&offset);
+ break;
+ }
}
}
} else {
diff --git a/lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc.cpp b/lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc.cpp
index 0d25faef1c659..944bc66bafeb1 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;
- bool is_complex;
RegisterContext *reg_ctx = thread->GetRegisterContext().get();
@@ -453,38 +452,33 @@ 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(is_complex)) {
- if (is_complex)
- error = Status::FromErrorString(
- "We don't support returning complex values at present");
- else {
- std::optional<uint64_t> bit_width =
- llvm::expectedToOptional(compiler_type.GetBitSize(frame_sp.get()));
- if (!bit_width) {
- error = Status::FromErrorString("can't get type size");
+ } else if (compiler_type.IsRealFloatingPointType()) {
+ std::optional<uint64_t> bit_width =
+ llvm::expectedToOptional(compiler_type.GetBitSize(frame_sp.get()));
+ if (!bit_width) {
+ error = Status::FromErrorString("can't get type size");
+ return error;
+ }
+ if (*bit_width <= 64) {
+ DataExtractor data;
+ Status data_error;
+ size_t num_bytes = new_value_sp->GetData(data, data_error);
+ if (data_error.Fail()) {
+ error = Status::FromErrorStringWithFormat(
+ "Couldn't convert return value to raw data: %s",
+ data_error.AsCString());
return error;
}
- if (*bit_width <= 64) {
- DataExtractor data;
- Status data_error;
- size_t num_bytes = new_value_sp->GetData(data, data_error);
- if (data_error.Fail()) {
- error = Status::FromErrorStringWithFormat(
- "Couldn't convert return value to raw data: %s",
- data_error.AsCString());
- return error;
- }
- unsigned char buffer[16];
- ByteOrder byte_order = data.GetByteOrder();
+ unsigned char buffer[16];
+ ByteOrder byte_order = data.GetByteOrder();
- data.CopyByteOrderedData(0, num_bytes, buffer, 16, byte_order);
- set_it_simple = true;
- } else {
- // FIXME - don't know how to do 80 bit long doubles yet.
- error = Status::FromErrorString(
- "We don't support returning float values > 64 bits at present");
- }
+ data.CopyByteOrderedData(0, num_bytes, buffer, 16, byte_order);
+ set_it_simple = true;
+ } else {
+ // FIXME - don't know how to do 80 bit long doubles yet.
+ error = Status::FromErrorString(
+ "We don't support returning float values > 64 bits at present");
}
}
diff --git a/lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc64.cpp b/lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc64.cpp
index 63357618774d4..0895cd3d75df6 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;
- bool is_complex;
RegisterContext *reg_ctx = thread->GetRegisterContext().get();
@@ -338,38 +337,33 @@ 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(is_complex)) {
- if (is_complex)
- error = Status::FromErrorString(
- "We don't support returning complex values at present");
- else {
- std::optional<uint64_t> bit_width =
- llvm::expectedToOptional(compiler_type.GetBitSize(frame_sp.get()));
- if (!bit_width) {
- error = Status::FromErrorString("can't get size of type");
+ } else if (compiler_type.IsRealFloatingPointType()) {
+ std::optional<uint64_t> bit_width =
+ llvm::expectedToOptional(compiler_type.GetBitSize(frame_sp.get()));
+ if (!bit_width) {
+ error = Status::FromErrorString("can't get size of type");
+ return error;
+ }
+ if (*bit_width <= 64) {
+ DataExtractor data;
+ Status data_error;
+ size_t num_bytes = new_value_sp->GetData(data, data_error);
+ if (data_error.Fail()) {
+ error = Status::FromErrorStringWithFormat(
+ "Couldn't convert return value to raw data: %s",
+ data_error.AsCString());
return error;
}
- if (*bit_width <= 64) {
- DataExtractor data;
- Status data_error;
- size_t num_bytes = new_value_sp->GetData(data, data_error);
- if (data_error.Fail()) {
- error = Status::FromErrorStringWithFormat(
- "Couldn't convert return value to raw data: %s",
- data_error.AsCString());
- return error;
- }
- unsigned char buffer[16];
- ByteOrder byte_order = data.GetByteOrder();
+ unsigned char buffer[16];
+ ByteOrder byte_order = data.GetByteOrder();
- data.CopyByteOrderedData(0, num_bytes, buffer, 16, byte_order);
- set_it_simple = true;
- } else {
- // FIXME - don't know how to do 80 bit long doubles yet.
- error = Status::FromErrorString(
- "We don't support returning float values > 64 bits at present");
- }
+ data.CopyByteOrderedData(0, num_bytes, buffer, 16, byte_order);
+ set_it_simple = true;
+ } else {
+ // FIXME - don't know how to do 80 bit long doubles yet.
+ error = Status::FromErrorString(
+ "We don't support returning float values > 64 bits at present");
}
}
diff --git a/lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp b/lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp
index d209980d65589..dce905f08aa5f 100644
--- a/lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp
+++ b/lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp
@@ -642,18 +642,14 @@ ABISysV_riscv::GetReturnValueObjectSimple(Thread &thread,
value, ConstString(""));
}
// Floating point return type.
- else if (type_flags & eTypeIsFloat) {
- bool is_complex = false;
-
- 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(
- thread, reg_ctx, machine, arch_fp_flags, type_flags, byte_size);
- return return_valobj_sp;
- }
+ else if (compiler_type.IsRealFloatingPointType()) {
+ const uint32_t arch_fp_flags =
+ arch.GetFlags() & ArchSpec::eRISCV_float_abi_mask;
+ return_valobj_sp = GetValObjFromFPRegs(
+ thread, reg_ctx, machine, arch_fp_flags, type_flags, byte_size);
+ return return_valobj_sp;
}
+
// Unsupported return type.
return return_valobj_sp;
}
diff --git a/lldb/source/Plugins/ABI/SystemZ/ABISysV_s390x.cpp b/lldb/source/Plugins/ABI/SystemZ/ABISysV_s390x.cpp
index 301c3b309ffd5..063ca39c56475 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;
- bool is_complex;
RegisterContext *reg_ctx = thread->GetRegisterContext().get();
@@ -422,42 +421,37 @@ 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(is_complex)) {
- if (is_complex)
- error = Status::FromErrorString(
- "We don't support returning complex values at present");
- else {
- std::optional<uint64_t> bit_width =
- llvm::expectedToOptional(compiler_type.GetBitSize(frame_sp.get()));
- if (!bit_width) {
- error = Status::FromErrorString("can't get type size");
+ } else if (compiler_type.IsRealFloatingPointType()) {
+ std::optional<uint64_t> bit_width =
+ llvm::expectedToOptional(compiler_type.GetBitSize(frame_sp.get()));
+ if (!bit_width) {
+ error = Status::FromErrorString("can't get type size");
+ return error;
+ }
+ if (*bit_width <= 64) {
+ const RegisterInfo *f0_info = reg_ctx->GetRegisterInfoByName("f0", 0);
+ RegisterValue f0_value;
+ DataExtractor data;
+ Status data_error;
+ size_t num_bytes = new_value_sp->GetData(data, data_error);
+ if (data_error.Fail()) {
+ error = Status::FromErrorStringWithFormat(
+ "Couldn't convert return value to raw data: %s",
+ data_error.AsCString());
return error;
}
- if (*bit_width <= 64) {
- const RegisterInfo *f0_info = reg_ctx->GetRegisterInfoByName("f0", 0);
- RegisterValue f0_value;
- DataExtractor data;
- Status data_error;
- size_t num_bytes = new_value_sp->GetData(data, data_error);
- if (data_error.Fail()) {
- error = Status::FromErrorStringWithFormat(
- "Couldn't convert return value to raw data: %s",
- data_error.AsCString());
- return error;
- }
- unsigned char buffer[8];
- ByteOrder byte_order = data.GetByteOrder();
+ unsigned char buffer[8];
+ ByteOrder byte_order = data.GetByteOrder();
- data.CopyByteOrderedData(0, num_bytes, buffer, 8, byte_order);
- f0_value.SetBytes(buffer, 8, byte_order);
- reg_ctx->WriteRegister(f0_info, f0_value);
- set_it_simple = true;
- } else {
- // FIXME - don't know how to do long doubles yet.
- error = Status::FromErrorString(
- "We don't support returning float values > 64 bits at present");
- }
+ data.CopyByteOrderedData(0, num_bytes, buffer, 8, byte_order);
+ f0_value.SetBytes(buffer, 8, byte_order);
+ reg_ctx->WriteRegister(f0_info, f0_value);
+ set_it_simple = true;
+ } else {
+ // FIXME - don't know how to do long doubles yet.
+ error = Status::FromErrorString(
+ "We don't support returning float values > 64 bits at present");
}
}
diff --git a/lldb/source/Plugins/ABI/X86/ABIMacOSX_i386.cpp b/lldb/source/Plugins/ABI/X86/ABIMacOSX_i386.cpp
index ee79abe55ead0..8fd1752429535 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;
- bool is_complex;
RegisterContext *reg_ctx = thread->GetRegisterContext().get();
@@ -239,13 +238,6 @@ 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(is_complex)) {
- if (is_complex)
- error = Status::FromErrorString(
- "We don't support returning complex values at present");
- else
- error = Status::FromErrorString(
- "We don't support returning float values at present");
}
if (!set_it_simple)
diff --git a/lldb/source/Plugins/ABI/X86/ABISysV_x86_64.cpp b/lldb/source/Plugins/ABI/X86/ABISysV_x86_64.cpp
index 29fd9f0eceb93..9ec3a6f9e3db6 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;
- bool is_complex;
RegisterContext *reg_ctx = thread->GetRegisterContext().get();
@@ -336,43 +335,37 @@ 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(is_complex)) {
- if (is_complex)
- error = Status::FromErrorString(
- "We don't support returning complex values at present");
- else {
- std::optional<uint64_t> bit_width =
- llvm::expectedToOptional(compiler_type.GetBitSize(frame_sp.get()));
- if (!bit_width) {
- error = Status::FromErrorString("can't get type size");
+ } else if (compiler_type.IsRealFloatingPointType()) {
+ std::optional<uint64_t> bit_width =
+ llvm::expectedToOptional(compiler_type.GetBitSize(frame_sp.get()));
+ if (!bit_width) {
+ error = Status::FromErrorString("can't get type size");
+ return error;
+ }
+ if (*bit_width <= 64) {
+ const RegisterInfo *xmm0_info = reg_ctx->GetRegisterInfoByName("xmm0", 0);
+ RegisterValue xmm0_value;
+ DataExtractor data;
+ Status data_error;
+ size_t num_bytes = new_value_sp->GetData(data, data_error);
+ if (data_error.Fail()) {
+ error = Status::FromErrorStringWithFormat(
+ "Couldn't convert return value to raw data: %s",
+ data_error.AsCString());
return error;
}
- if (*bit_width <= 64) {
- const RegisterInfo *xmm0_info =
- reg_ctx->GetRegisterInfoByName("xmm0", 0);
- RegisterValue xmm0_value;
- DataExtractor data;
- Status data_error;
- size_t num_bytes = new_value_sp->GetData(data, data_error);
- if (data_error.Fail()) {
- error = Status::FromErrorStringWithFormat(
- "Couldn't convert return value to raw data: %s",
- data_error.AsCString());
- return error;
- }
- unsigned char buffer[16];
- ByteOrder byte_order = data.GetByteOrder();
+ unsigned char buffer[16];
+ ByteOrder byte_order = data.GetByteOrder();
- data.CopyByteOrderedData(0, num_bytes, buffer, 16, byte_order);
- xmm0_value.SetBytes(buffer, 16, byte_order);
- reg_ctx->WriteRegister(xmm0_info, xmm0_value);
- set_it_simple = true;
- } else {
- // FIXME - don't know how to do 80 bit long doubles yet.
- error = Status::FromErrorString(
- "We don't support returning float values > 64 bits at present");
- }
+ data.CopyByteOrderedData(0, num_bytes, buffer, 16, byte_order);
+ xmm0_value.SetBytes(buffer, 16, byte_order);
+ reg_ctx->WriteRegister(xmm0_info, xmm0_value);
+ set_it_simple = true;
+ } else {
+ // FIXME - don't know how to do 80 bit long doubles yet.
+ error = Status::FromErrorString(
+ "We don't support returning float values > 64 bits at present");
}
}
diff --git a/lldb/source/Plugins/ABI/X86/ABIWindows_x86_64.cpp b/lldb/source/Plugins/ABI/X86/ABIWindows_x86_64.cpp
index 6520af2f643ee..6c72eb2d45716 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;
- bool is_complex;
RegisterContext *reg_ctx = thread->GetRegisterContext().get();
@@ -341,43 +340,37 @@ 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(is_complex)) {
- if (is_complex)
- error = Status::FromErrorString(
- "We don't support returning complex values at present");
- else {
- std::optional<uint64_t> bit_width =
- llvm::expectedToOptional(compiler_type.GetBitSize(frame_sp.get()));
- if (!bit_width) {
- error = Status::FromErrorString("can't get type size");
+ } else if (compiler_type.IsRealFloatingPointType()) {
+ std::optional<uint64_t> bit_width =
+ llvm::expectedToOptional(compiler_type.GetBitSize(frame_sp.get()));
+ if (!bit_width) {
+ error = Status::FromErrorString("can't get type size");
+ return error;
+ }
+ if (*bit_width <= 64) {
+ const RegisterInfo *xmm0_info = reg_ctx->GetRegisterInfoByName("xmm0", 0);
+ RegisterValue xmm0_value;
+ DataExtractor data;
+ Status data_error;
+ size_t num_bytes = new_value_sp->GetData(data, data_error);
+ if (data_error.Fail()) {
+ error = Status::FromErrorStringWithFormat(
+ "Couldn't convert return value to raw data: %s",
+ data_error.AsCString());
return error;
}
- if (*bit_width <= 64) {
- const RegisterInfo *xmm0_info =
- reg_ctx->GetRegisterInfoByName("xmm0", 0);
- RegisterValue xmm0_value;
- DataExtractor data;
- Status data_error;
- size_t num_bytes = new_value_sp->GetData(data, data_error);
- if (data_error.Fail()) {
- error = Status::FromErrorStringWithFormat(
- "Couldn't convert return value to raw data: %s",
- data_error.AsCString());
- return error;
- }
- unsigned char buffer[16];
- ByteOrder byte_order = data.GetByteOrder();
+ unsigned char buffer[16];
+ ByteOrder byte_order = data.GetByteOrder();
- data.CopyByteOrderedData(0, num_bytes, buffer, 16, byte_order);
- xmm0_value.SetBytes(buffer, 16, byte_order);
- reg_ctx->WriteRegister(xmm0_info, xmm0_value);
- set_it_simple = true;
- } else {
- // Windows doesn't support 80 bit FP
- error = Status::FromErrorString(
- "Windows-x86_64 doesn't allow FP larger than 64 bits.");
- }
+ data.CopyByteOrderedData(0, num_bytes, buffer, 16, byte_order);
+ xmm0_value.SetBytes(buffer, 16, byte_order);
+ reg_ctx->WriteRegister(xmm0_info, xmm0_value);
+ set_it_simple = true;
+ } else {
+ // Windows doesn't support 80 bit FP
+ error = Status::FromErrorString(
+ "Windows-x86_64 doesn't allow FP larger than 64 bits.");
}
}
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index a9945aa14a506..f5fcd3e571d0e 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -2041,10 +2041,9 @@ static std::optional<clang::APValue> MakeAPValue(const clang::ASTContext &ast,
if (is_integral)
return clang::APValue(apint);
- 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(is_complex))
+ if (!clang_type.IsRealFloatingPointType())
return std::nullopt;
return clang::APValue(llvm::APFloat(
diff --git a/lldb/source/Symbol/CompilerType.cpp b/lldb/source/Symbol/CompilerType.cpp
index 1a39ea9476390..e3c41555e5717 100644
--- a/lldb/source/Symbol/CompilerType.cpp
+++ b/lldb/source/Symbol/CompilerType.cpp
@@ -249,6 +249,11 @@ bool CompilerType::IsFloatingPointType(bool &is_complex) const {
return false;
}
+bool CompilerType::IsRealFloatingPointType() const {
+ bool is_complex = false;
+ return IsFloatingPointType(is_complex) && !is_complex && !IsVectorType();
+}
+
bool CompilerType::IsDefined() const {
if (IsValid())
if (auto type_system_sp = GetTypeSystem())
diff --git a/lldb/unittests/Symbol/TestTypeSystemClang.cpp b/lldb/unittests/Symbol/TestTypeSystemClang.cpp
index c3290e0616c89..202f24b26f9bd 100644
--- a/lldb/unittests/Symbol/TestTypeSystemClang.cpp
+++ b/lldb/unittests/Symbol/TestTypeSystemClang.cpp
@@ -1350,6 +1350,27 @@ TEST_F(TestTypeSystemClang, TestGetTypeInfo) {
(eTypeIsFloat | eTypeIsVector | eTypeHasChildren));
}
+TEST_F(TestTypeSystemClang, TestIsRealFloatingPointType) {
+ // Tests CompilerType::IsRealFloatingPointType
+
+ const ASTContext &ast = m_ast->getASTContext();
+
+ EXPECT_FALSE(m_ast->GetType(ast.getComplexType(ast.FloatTy))
+ .IsRealFloatingPointType());
+ EXPECT_FALSE(
+ m_ast->GetType(ast.getVectorType(ast.FloatTy, 1, VectorKind::Generic))
+ .IsRealFloatingPointType());
+ EXPECT_TRUE(m_ast->GetType(ast.FloatTy).IsRealFloatingPointType());
+ EXPECT_TRUE(m_ast->GetType(ast.DoubleTy).IsRealFloatingPointType());
+ EXPECT_TRUE(m_ast->GetType(ast.LongDoubleTy).IsRealFloatingPointType());
+
+ // FIXME: these should be true
+ EXPECT_FALSE(m_ast->GetType(ast.HalfTy).IsRealFloatingPointType());
+ EXPECT_FALSE(m_ast->GetType(ast.Float128Ty).IsRealFloatingPointType());
+ EXPECT_FALSE(m_ast->GetType(ast.BFloat16Ty).IsRealFloatingPointType());
+ EXPECT_FALSE(m_ast->GetType(ast.Ibm128Ty).IsRealFloatingPointType());
+}
+
TEST_F(TestTypeSystemClang, AsmLabel_CtorDtor) {
// Tests TypeSystemClang::DeclGetMangledName for constructors/destructors
// with and without AsmLabels.
>From d1db2781aad1a0e96c6958e8b7c50e83f49ca66c Mon Sep 17 00:00:00 2001
From: Michael Buch <michaelbuch12 at gmail.com>
Date: Fri, 30 Jan 2026 15:23:12 +0000
Subject: [PATCH 2/4] [lldb][TypeSystemClang] Remove mostly unused is_complex
output parameter to IsFloatingPointType
---
lldb/include/lldb/Symbol/CompilerType.h | 4 +++-
lldb/include/lldb/Symbol/TypeSystem.h | 3 +--
lldb/source/Plugins/ABI/ARM/ABISysV_arm.cpp | 22 ++++++++----------
.../Plugins/ABI/Mips/ABISysV_mips64.cpp | 5 ++--
.../Plugins/ABI/PowerPC/ABISysV_ppc.cpp | 3 +--
.../source/Plugins/ABI/X86/ABISysV_x86_64.cpp | 6 ++---
.../Plugins/ABI/X86/ABIWindows_x86_64.cpp | 6 ++---
.../TypeSystem/Clang/TypeSystemClang.cpp | 19 ++++-----------
.../TypeSystem/Clang/TypeSystemClang.h | 3 +--
lldb/source/Symbol/CompilerType.cpp | 23 ++++++++++---------
lldb/unittests/Symbol/TestTypeSystemClang.cpp | 15 ++++++++++++
11 files changed, 54 insertions(+), 55 deletions(-)
diff --git a/lldb/include/lldb/Symbol/CompilerType.h b/lldb/include/lldb/Symbol/CompilerType.h
index 4f1662ee6d162..b65a75041c387 100644
--- a/lldb/include/lldb/Symbol/CompilerType.h
+++ b/lldb/include/lldb/Symbol/CompilerType.h
@@ -144,8 +144,10 @@ class CompilerType {
bool IsDefined() const;
+ bool IsComplexType() const;
+
/// Returns \c true for floating point types (including complex floats).
- bool IsFloatingPointType(bool &is_complex) const;
+ bool IsFloatingPointType() const;
/// Returns \c true for non-complex float types.
bool IsRealFloatingPointType() const;
diff --git a/lldb/include/lldb/Symbol/TypeSystem.h b/lldb/include/lldb/Symbol/TypeSystem.h
index 99ea0585e5370..d7f4cfcf0ffc7 100644
--- a/lldb/include/lldb/Symbol/TypeSystem.h
+++ b/lldb/include/lldb/Symbol/TypeSystem.h
@@ -162,8 +162,7 @@ class TypeSystem : public PluginInterface,
virtual bool IsDefined(lldb::opaque_compiler_type_t type) = 0;
- virtual bool IsFloatingPointType(lldb::opaque_compiler_type_t type,
- bool &is_complex) = 0;
+ virtual bool IsFloatingPointType(lldb::opaque_compiler_type_t type) = 0;
virtual bool IsFunctionType(lldb::opaque_compiler_type_t type) = 0;
diff --git a/lldb/source/Plugins/ABI/ARM/ABISysV_arm.cpp b/lldb/source/Plugins/ABI/ARM/ABISysV_arm.cpp
index 1831daaa16f88..8c54159965f3c 100644
--- a/lldb/source/Plugins/ABI/ARM/ABISysV_arm.cpp
+++ b/lldb/source/Plugins/ABI/ARM/ABISysV_arm.cpp
@@ -1549,7 +1549,6 @@ ValueObjectSP ABISysV_arm::GetReturnValueObjectImpl(
return return_valobj_sp;
bool is_signed;
- bool is_complex;
bool is_vfp_candidate = false;
uint8_t vfp_count = 0;
uint8_t vfp_byte_size = 0;
@@ -1633,9 +1632,9 @@ ValueObjectSP ABISysV_arm::GetReturnValueObjectImpl(
if (!GetReturnValuePassedInMemory(thread, reg_ctx, *byte_size, value))
return return_valobj_sp;
}
- } else if (compiler_type.IsFloatingPointType(is_complex)) {
+ } else if (compiler_type.IsFloatingPointType()) {
// Vector types are handled above.
- if (!is_complex) {
+ if (!compiler_type.IsCompleteType()) {
switch (*bit_width) {
default:
return return_valobj_sp;
@@ -1681,7 +1680,7 @@ ValueObjectSP ABISysV_arm::GetReturnValueObjectImpl(
break;
}
}
- } else if (is_complex) {
+ } else {
if (IsArmHardFloat(thread)) {
is_vfp_candidate = true;
vfp_byte_size = *byte_size / 2;
@@ -1689,9 +1688,7 @@ ValueObjectSP ABISysV_arm::GetReturnValueObjectImpl(
} else if (!GetReturnValuePassedInMemory(thread, reg_ctx, *bit_width / 8,
value))
return return_valobj_sp;
- } else
- // not handled yet
- return return_valobj_sp;
+ }
} else if (compiler_type.IsAggregateType()) {
if (IsArmHardFloat(thread)) {
CompilerType base_type;
@@ -1709,9 +1706,10 @@ ValueObjectSP ABISysV_arm::GetReturnValueObjectImpl(
vfp_count = (*base_byte_size == 8 ? homogeneous_count
: homogeneous_count * 2);
}
- } else if (base_type.IsFloatingPointType(is_complex)) {
- // Vector types are handled above.
- if (!is_complex) {
+ } else if (base_type.IsFloatingPointType()) {
+ assert(!base_type.IsVectorType() &&
+ "Vector types should've been handled above.");
+ if (!base_type.IsComplexType()) {
is_vfp_candidate = true;
if (base_byte_size)
vfp_byte_size = *base_byte_size;
@@ -1728,10 +1726,10 @@ ValueObjectSP ABISysV_arm::GetReturnValueObjectImpl(
base_type = compiler_type.GetFieldAtIndex(index, name, nullptr,
nullptr, nullptr);
- if (base_type.IsFloatingPointType(is_complex)) {
+ if (base_type.IsFloatingPointType()) {
std::optional<uint64_t> base_byte_size =
llvm::expectedToOptional(base_type.GetByteSize(&thread));
- if (is_complex) {
+ if (base_type.IsComplexType()) {
if (index != 0 && base_byte_size &&
vfp_byte_size != *base_byte_size)
break;
diff --git a/lldb/source/Plugins/ABI/Mips/ABISysV_mips64.cpp b/lldb/source/Plugins/ABI/Mips/ABISysV_mips64.cpp
index 0dd9db0948220..af71f4ad08342 100644
--- a/lldb/source/Plugins/ABI/Mips/ABISysV_mips64.cpp
+++ b/lldb/source/Plugins/ABI/Mips/ABISysV_mips64.cpp
@@ -922,7 +922,6 @@ ValueObjectSP ABISysV_mips64::GetReturnValueObjectImpl(
// True if the result is copied into our data buffer
bool sucess = false;
std::string name;
- bool is_complex;
const uint32_t num_children = return_compiler_type.GetNumFields();
// A structure consisting of one or two FP values (and nothing else) will
@@ -936,7 +935,7 @@ ValueObjectSP ABISysV_mips64::GetReturnValueObjectImpl(
return_compiler_type.GetFieldAtIndex(idx, name, &field_bit_offset,
nullptr, nullptr);
- if (field_compiler_type.IsFloatingPointType(is_complex))
+ if (field_compiler_type.IsFloatingPointType())
use_fp_regs = true;
else
found_non_fp_field = true;
@@ -1043,7 +1042,7 @@ ValueObjectSP ABISysV_mips64::GetReturnValueObjectImpl(
if (field_compiler_type.IsIntegerOrEnumerationType(is_signed) ||
field_compiler_type.IsPointerType() ||
- field_compiler_type.IsFloatingPointType(is_complex)) {
+ field_compiler_type.IsFloatingPointType()) {
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 944bc66bafeb1..604a6d6ee9c16 100644
--- a/lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc.cpp
+++ b/lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc.cpp
@@ -687,7 +687,6 @@ ValueObjectSP ABISysV_ppc::GetReturnValueObjectImpl(
std::string name;
uint64_t field_bit_offset = 0;
bool is_signed;
- bool is_complex;
CompilerType field_compiler_type = return_compiler_type.GetFieldAtIndex(
idx, name, &field_bit_offset, nullptr, nullptr);
@@ -733,7 +732,7 @@ ValueObjectSP ABISysV_ppc::GetReturnValueObjectImpl(
// return a nullptr return value object.
return return_valobj_sp;
}
- } else if (field_compiler_type.IsFloatingPointType(is_complex)) {
+ } else if (field_compiler_type.IsFloatingPointType()) {
// 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/ABISysV_x86_64.cpp b/lldb/source/Plugins/ABI/X86/ABISysV_x86_64.cpp
index 9ec3a6f9e3db6..bb19545d14165 100644
--- a/lldb/source/Plugins/ABI/X86/ABISysV_x86_64.cpp
+++ b/lldb/source/Plugins/ABI/X86/ABISysV_x86_64.cpp
@@ -579,7 +579,6 @@ static bool FlattenAggregateType(
for (uint32_t idx = 0; idx < num_children; ++idx) {
std::string name;
bool is_signed;
- bool is_complex;
uint64_t field_bit_offset = 0;
CompilerType field_compiler_type = return_compiler_type.GetFieldAtIndex(
@@ -597,7 +596,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(is_complex)) {
+ field_compiler_type.IsFloatingPointType()) {
aggregate_field_offsets.push_back(field_byte_offset);
aggregate_compiler_types.push_back(field_compiler_type);
} else if (field_type_flags & eTypeHasChildren) {
@@ -687,7 +686,6 @@ ValueObjectSP ABISysV_x86_64::GetReturnValueObjectImpl(
is_memory = false;
for (uint32_t idx = 0; idx < num_children; idx++) {
bool is_signed;
- bool is_complex;
CompilerType field_compiler_type = aggregate_compiler_types[idx];
uint32_t field_byte_width =
@@ -726,7 +724,7 @@ ValueObjectSP ABISysV_x86_64::GetReturnValueObjectImpl(
// return a nullptr return value object.
return return_valobj_sp;
}
- } else if (field_compiler_type.IsFloatingPointType(is_complex)) {
+ } else if (field_compiler_type.IsFloatingPointType()) {
// 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 6c72eb2d45716..05498d0b36448 100644
--- a/lldb/source/Plugins/ABI/X86/ABIWindows_x86_64.cpp
+++ b/lldb/source/Plugins/ABI/X86/ABIWindows_x86_64.cpp
@@ -550,7 +550,6 @@ static bool FlattenAggregateType(
for (uint32_t idx = 0; idx < num_children; ++idx) {
std::string name;
bool is_signed;
- bool is_complex;
uint64_t field_bit_offset = 0;
CompilerType field_compiler_type = return_compiler_type.GetFieldAtIndex(
@@ -573,7 +572,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(is_complex)) {
+ field_compiler_type.IsFloatingPointType()) {
aggregate_field_offsets.push_back(field_byte_offset);
aggregate_compiler_types.push_back(field_compiler_type);
} else if (field_type_flags & eTypeHasChildren) {
@@ -662,7 +661,6 @@ ValueObjectSP ABIWindows_x86_64::GetReturnValueObjectImpl(
const uint32_t num_children = aggregate_compiler_types.size();
for (uint32_t idx = 0; idx < num_children; idx++) {
bool is_signed;
- bool is_complex;
CompilerType field_compiler_type = aggregate_compiler_types[idx];
uint32_t field_byte_width =
@@ -681,7 +679,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(is_complex)) {
+ field_compiler_type.IsFloatingPointType()) {
copy_from_extractor = &rax_data;
copy_from_offset = used_bytes;
used_bytes += field_byte_width;
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 478f10a60a865..812b4508f4937 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -3473,8 +3473,7 @@ bool TypeSystemClang::IsReferenceType(lldb::opaque_compiler_type_t type,
return false;
}
-bool TypeSystemClang::IsFloatingPointType(lldb::opaque_compiler_type_t type,
- bool &is_complex) {
+bool TypeSystemClang::IsFloatingPointType(lldb::opaque_compiler_type_t type) {
if (type) {
clang::QualType qual_type(GetCanonicalQualType(type));
@@ -3482,28 +3481,20 @@ bool TypeSystemClang::IsFloatingPointType(lldb::opaque_compiler_type_t type,
qual_type->getCanonicalTypeInternal())) {
clang::BuiltinType::Kind kind = BT->getKind();
if (kind >= clang::BuiltinType::Float &&
- kind <= clang::BuiltinType::LongDouble) {
- is_complex = false;
+ kind <= clang::BuiltinType::LongDouble)
return true;
- }
} else if (const clang::ComplexType *CT =
llvm::dyn_cast<clang::ComplexType>(
qual_type->getCanonicalTypeInternal())) {
- if (IsFloatingPointType(CT->getElementType().getAsOpaquePtr(),
- is_complex)) {
- is_complex = true;
+ if (IsFloatingPointType(CT->getElementType().getAsOpaquePtr()))
return true;
- }
} else if (const clang::VectorType *VT = llvm::dyn_cast<clang::VectorType>(
qual_type->getCanonicalTypeInternal())) {
- if (IsFloatingPointType(VT->getElementType().getAsOpaquePtr(),
- is_complex)) {
- is_complex = false;
+ if (IsFloatingPointType(VT->getElementType().getAsOpaquePtr()))
return true;
- }
}
}
- is_complex = false;
+
return false;
}
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
index 22a4887dffb0b..40844f67b2445 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
@@ -657,8 +657,7 @@ class TypeSystemClang : public TypeSystem {
bool IsDefined(lldb::opaque_compiler_type_t type) override;
- bool IsFloatingPointType(lldb::opaque_compiler_type_t type,
- bool &is_complex) override;
+ bool IsFloatingPointType(lldb::opaque_compiler_type_t type) override;
unsigned GetPtrAuthKey(lldb::opaque_compiler_type_t type) override;
unsigned GetPtrAuthDiscriminator(lldb::opaque_compiler_type_t type) override;
diff --git a/lldb/source/Symbol/CompilerType.cpp b/lldb/source/Symbol/CompilerType.cpp
index e3c41555e5717..3ec5962a2b583 100644
--- a/lldb/source/Symbol/CompilerType.cpp
+++ b/lldb/source/Symbol/CompilerType.cpp
@@ -20,6 +20,7 @@
#include "lldb/Utility/Scalar.h"
#include "lldb/Utility/Stream.h"
#include "lldb/Utility/StreamString.h"
+#include "lldb/lldb-enumerations.h"
#include <iterator>
#include <mutex>
@@ -240,18 +241,21 @@ bool CompilerType::ShouldTreatScalarValueAsAddress() const {
return false;
}
-bool CompilerType::IsFloatingPointType(bool &is_complex) const {
- if (IsValid()) {
+bool CompilerType::IsComplexType() const {
+ return GetTypeClass() & eTypeClassComplexFloat ||
+ GetTypeClass() & eTypeClassComplexInteger;
+}
+
+bool CompilerType::IsFloatingPointType() const {
+ if (IsValid())
if (auto type_system_sp = GetTypeSystem())
- return type_system_sp->IsFloatingPointType(m_type, is_complex);
- }
- is_complex = false;
+ return type_system_sp->IsFloatingPointType(m_type);
+
return false;
}
bool CompilerType::IsRealFloatingPointType() const {
- bool is_complex = false;
- return IsFloatingPointType(is_complex) && !is_complex && !IsVectorType();
+ return IsFloatingPointType() && !IsComplexType() && !IsVectorType();
}
bool CompilerType::IsDefined() const {
@@ -333,10 +337,7 @@ bool CompilerType::IsInteger() const {
return IsIntegerType(is_signed);
}
-bool CompilerType::IsFloat() const {
- bool is_complex = false;
- return IsFloatingPointType(is_complex);
-}
+bool CompilerType::IsFloat() const { return IsFloatingPointType(); }
bool CompilerType::IsEnumerationType() const {
bool is_signed = false; // May be reset by the call below.
diff --git a/lldb/unittests/Symbol/TestTypeSystemClang.cpp b/lldb/unittests/Symbol/TestTypeSystemClang.cpp
index 202f24b26f9bd..ef13c788ee4a6 100644
--- a/lldb/unittests/Symbol/TestTypeSystemClang.cpp
+++ b/lldb/unittests/Symbol/TestTypeSystemClang.cpp
@@ -1371,6 +1371,21 @@ TEST_F(TestTypeSystemClang, TestIsRealFloatingPointType) {
EXPECT_FALSE(m_ast->GetType(ast.Ibm128Ty).IsRealFloatingPointType());
}
+TEST_F(TestTypeSystemClang, TestGetIsComplexType) {
+ // Tests CompilerType::IsComplexType
+
+ const ASTContext &ast = m_ast->getASTContext();
+
+ EXPECT_TRUE(m_ast->GetType(ast.getComplexType(ast.IntTy)).IsComplexType());
+ EXPECT_TRUE(m_ast->GetType(ast.getComplexType(ast.FloatTy)).IsComplexType());
+ EXPECT_TRUE(m_ast->GetType(ast.getComplexType(ast.VoidTy)).IsComplexType());
+ EXPECT_FALSE(m_ast
+ ->GetType(ast.getIncompleteArrayType(
+ ast.getComplexType(ast.FloatTy), /*ASM=*/{},
+ /*IndexTypeQuals=*/{}))
+ .IsComplexType());
+}
+
TEST_F(TestTypeSystemClang, AsmLabel_CtorDtor) {
// Tests TypeSystemClang::DeclGetMangledName for constructors/destructors
// with and without AsmLabels.
>From 492977f5551bb1756787b4ca3cad406b43c7fe57 Mon Sep 17 00:00:00 2001
From: Michael Buch <michaelbuch12 at gmail.com>
Date: Fri, 30 Jan 2026 19:02:19 +0000
Subject: [PATCH 3/4] [lldb][CompilerType] Remove CompilerType::IsFloat
It's the same as `IsFloatingPointType`. There's no compelling reason for
this to exist.
---
lldb/include/lldb/Symbol/CompilerType.h | 2 --
lldb/source/Symbol/CompilerType.cpp | 2 --
lldb/source/ValueObject/DILEval.cpp | 5 +++--
lldb/source/ValueObject/ValueObject.cpp | 18 +++++++++---------
4 files changed, 12 insertions(+), 15 deletions(-)
diff --git a/lldb/include/lldb/Symbol/CompilerType.h b/lldb/include/lldb/Symbol/CompilerType.h
index b65a75041c387..5f152b6f26a89 100644
--- a/lldb/include/lldb/Symbol/CompilerType.h
+++ b/lldb/include/lldb/Symbol/CompilerType.h
@@ -205,8 +205,6 @@ class CompilerType {
/// This is used when you don't care about the signedness of the integer.
bool IsInteger() const;
- bool IsFloat() const;
-
/// This is used when you don't care about the signedness of the enum.
bool IsEnumerationType() const;
diff --git a/lldb/source/Symbol/CompilerType.cpp b/lldb/source/Symbol/CompilerType.cpp
index 3ec5962a2b583..a568923e83201 100644
--- a/lldb/source/Symbol/CompilerType.cpp
+++ b/lldb/source/Symbol/CompilerType.cpp
@@ -337,8 +337,6 @@ bool CompilerType::IsInteger() const {
return IsIntegerType(is_signed);
}
-bool CompilerType::IsFloat() const { return IsFloatingPointType(); }
-
bool CompilerType::IsEnumerationType() const {
bool is_signed = false; // May be reset by the call below.
return IsEnumerationType(is_signed);
diff --git a/lldb/source/ValueObject/DILEval.cpp b/lldb/source/ValueObject/DILEval.cpp
index 5ffebc107bfb3..5077d8b1aa647 100644
--- a/lldb/source/ValueObject/DILEval.cpp
+++ b/lldb/source/ValueObject/DILEval.cpp
@@ -814,7 +814,7 @@ Interpreter::VerifyArithmeticCast(CompilerType source_type,
CompilerType target_type, int location) {
if (source_type.IsPointerType() || source_type.IsNullPtrType()) {
// Cast from pointer to float/double is not allowed.
- if (target_type.IsFloat()) {
+ if (target_type.IsFloatingPointType()) {
std::string errMsg = llvm::formatv("Cast from {0} to {1} is not allowed",
source_type.TypeDescription(),
target_type.TypeDescription());
@@ -951,7 +951,8 @@ llvm::Expected<lldb::ValueObjectSP> Interpreter::Visit(const CastNode &node) {
switch (cast_kind) {
case CastKind::eEnumeration: {
- if (op_type.IsFloat() || op_type.IsInteger() || op_type.IsEnumerationType())
+ if (op_type.IsFloatingPointType() || op_type.IsInteger() ||
+ op_type.IsEnumerationType())
return operand->CastToEnumType(target_type);
break;
}
diff --git a/lldb/source/ValueObject/ValueObject.cpp b/lldb/source/ValueObject/ValueObject.cpp
index aed2b074a2b16..4bc7ad17cd257 100644
--- a/lldb/source/ValueObject/ValueObject.cpp
+++ b/lldb/source/ValueObject/ValueObject.cpp
@@ -1165,7 +1165,7 @@ llvm::Expected<llvm::APSInt> ValueObject::GetValueAsAPSInt() {
}
llvm::Expected<llvm::APFloat> ValueObject::GetValueAsAPFloat() {
- if (!GetCompilerType().IsFloat())
+ if (!GetCompilerType().IsFloatingPointType())
return llvm::make_error<llvm::StringError>(
"type cannot be converted to APFloat", llvm::inconvertibleErrorCode());
@@ -1188,7 +1188,7 @@ llvm::Expected<bool> ValueObject::GetValueAsBool() {
if (value_or_err)
return value_or_err->getBoolValue();
}
- if (val_type.IsFloat()) {
+ if (val_type.IsFloatingPointType()) {
auto value_or_err = GetValueAsAPFloat();
if (value_or_err)
return value_or_err->isNonZero();
@@ -1204,7 +1204,7 @@ void ValueObject::SetValueFromInteger(const llvm::APInt &value, Status &error) {
// Verify the current object is an integer object
CompilerType val_type = GetCompilerType();
if (!val_type.IsInteger() && !val_type.IsUnscopedEnumerationType() &&
- !val_type.IsFloat() && !val_type.IsPointerType() &&
+ !val_type.IsFloatingPointType() && !val_type.IsPointerType() &&
!val_type.IsScalarType()) {
error =
Status::FromErrorString("current value object is not an integer objet");
@@ -1244,7 +1244,7 @@ void ValueObject::SetValueFromInteger(lldb::ValueObjectSP new_val_sp,
// Verify the current object is an integer object
CompilerType val_type = GetCompilerType();
if (!val_type.IsInteger() && !val_type.IsUnscopedEnumerationType() &&
- !val_type.IsFloat() && !val_type.IsPointerType() &&
+ !val_type.IsFloatingPointType() && !val_type.IsPointerType() &&
!val_type.IsScalarType()) {
error =
Status::FromErrorString("current value object is not an integer objet");
@@ -1261,7 +1261,7 @@ void ValueObject::SetValueFromInteger(lldb::ValueObjectSP new_val_sp,
// Verify the proposed new value is the right type.
CompilerType new_val_type = new_val_sp->GetCompilerType();
- if (!new_val_type.IsInteger() && !new_val_type.IsFloat() &&
+ if (!new_val_type.IsInteger() && !new_val_type.IsFloatingPointType() &&
!new_val_type.IsPointerType()) {
error = Status::FromErrorString(
"illegal argument: new value should be of the same size");
@@ -1274,7 +1274,7 @@ void ValueObject::SetValueFromInteger(lldb::ValueObjectSP new_val_sp,
SetValueFromInteger(*value_or_err, error);
else
error = Status::FromErrorString("error getting APSInt from new_val_sp");
- } else if (new_val_type.IsFloat()) {
+ } else if (new_val_type.IsFloatingPointType()) {
auto value_or_err = new_val_sp->GetValueAsAPFloat();
if (value_or_err)
SetValueFromInteger(value_or_err->bitcastToAPInt(), error);
@@ -3142,7 +3142,7 @@ lldb::ValueObjectSP ValueObject::CastToBasicType(CompilerType type) {
bool is_enum = GetCompilerType().IsEnumerationType();
bool is_pointer =
GetCompilerType().IsPointerType() || GetCompilerType().IsNullPtrType();
- bool is_float = GetCompilerType().IsFloat();
+ bool is_float = GetCompilerType().IsFloatingPointType();
bool is_integer = GetCompilerType().IsInteger();
ExecutionContext exe_ctx(GetExecutionContextRef());
@@ -3234,7 +3234,7 @@ lldb::ValueObjectSP ValueObject::CastToBasicType(CompilerType type) {
}
}
- if (type.IsFloat()) {
+ if (type.IsFloatingPointType()) {
if (!is_scalar) {
auto int_value_or_err = GetValueAsAPSInt();
if (int_value_or_err) {
@@ -3296,7 +3296,7 @@ lldb::ValueObjectSP ValueObject::CastToBasicType(CompilerType type) {
lldb::ValueObjectSP ValueObject::CastToEnumType(CompilerType type) {
bool is_enum = GetCompilerType().IsEnumerationType();
bool is_integer = GetCompilerType().IsInteger();
- bool is_float = GetCompilerType().IsFloat();
+ bool is_float = GetCompilerType().IsFloatingPointType();
ExecutionContext exe_ctx(GetExecutionContextRef());
if (!is_enum && !is_integer && !is_float)
>From 468a336529bf4354bb50f3cef1ba7633de46e326 Mon Sep 17 00:00:00 2001
From: Michael Buch <michaelbuch12 at gmail.com>
Date: Sat, 31 Jan 2026 09:11:29 +0000
Subject: [PATCH 4/4] [lldb][TypeSystemClang] Don't treat float vector types as
floating point types
---
lldb/source/Plugins/ABI/ARM/ABISysV_arm.cpp | 6 +--
.../Plugins/ABI/Mips/ABISysV_mips64.cpp | 4 +-
.../Plugins/ABI/PowerPC/ABISysV_ppc.cpp | 2 +-
.../source/Plugins/ABI/X86/ABISysV_x86_64.cpp | 5 ++-
.../Plugins/ABI/X86/ABIWindows_x86_64.cpp | 6 ++-
.../TypeSystem/Clang/TypeSystemClang.cpp | 26 +++----------
lldb/source/ValueObject/DILEval.cpp | 5 ++-
lldb/source/ValueObject/ValueObject.cpp | 28 ++++++++-----
lldb/unittests/Symbol/TestTypeSystemClang.cpp | 39 ++++++++++++++++---
9 files changed, 73 insertions(+), 48 deletions(-)
diff --git a/lldb/source/Plugins/ABI/ARM/ABISysV_arm.cpp b/lldb/source/Plugins/ABI/ARM/ABISysV_arm.cpp
index 8c54159965f3c..5b6cdbf74504c 100644
--- a/lldb/source/Plugins/ABI/ARM/ABISysV_arm.cpp
+++ b/lldb/source/Plugins/ABI/ARM/ABISysV_arm.cpp
@@ -1633,7 +1633,6 @@ ValueObjectSP ABISysV_arm::GetReturnValueObjectImpl(
return return_valobj_sp;
}
} else if (compiler_type.IsFloatingPointType()) {
- // Vector types are handled above.
if (!compiler_type.IsCompleteType()) {
switch (*bit_width) {
default:
@@ -1707,8 +1706,6 @@ ValueObjectSP ABISysV_arm::GetReturnValueObjectImpl(
: homogeneous_count * 2);
}
} else if (base_type.IsFloatingPointType()) {
- assert(!base_type.IsVectorType() &&
- "Vector types should've been handled above.");
if (!base_type.IsComplexType()) {
is_vfp_candidate = true;
if (base_byte_size)
@@ -1726,7 +1723,8 @@ ValueObjectSP ABISysV_arm::GetReturnValueObjectImpl(
base_type = compiler_type.GetFieldAtIndex(index, name, nullptr,
nullptr, nullptr);
- if (base_type.IsFloatingPointType()) {
+ // TODO: is this correct for float vector types?
+ if (base_type.GetTypeInfo() & eTypeIsFloat) {
std::optional<uint64_t> base_byte_size =
llvm::expectedToOptional(base_type.GetByteSize(&thread));
if (base_type.IsComplexType()) {
diff --git a/lldb/source/Plugins/ABI/Mips/ABISysV_mips64.cpp b/lldb/source/Plugins/ABI/Mips/ABISysV_mips64.cpp
index af71f4ad08342..2cd49478878eb 100644
--- a/lldb/source/Plugins/ABI/Mips/ABISysV_mips64.cpp
+++ b/lldb/source/Plugins/ABI/Mips/ABISysV_mips64.cpp
@@ -935,7 +935,7 @@ ValueObjectSP ABISysV_mips64::GetReturnValueObjectImpl(
return_compiler_type.GetFieldAtIndex(idx, name, &field_bit_offset,
nullptr, nullptr);
- if (field_compiler_type.IsFloatingPointType())
+ if (field_compiler_type.GetTypeInfo() & eTypeIsFloat)
use_fp_regs = true;
else
found_non_fp_field = true;
@@ -1042,7 +1042,7 @@ ValueObjectSP ABISysV_mips64::GetReturnValueObjectImpl(
if (field_compiler_type.IsIntegerOrEnumerationType(is_signed) ||
field_compiler_type.IsPointerType() ||
- field_compiler_type.IsFloatingPointType()) {
+ field_compiler_type.GetTypeInfo() & eTypeIsFloat) {
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 604a6d6ee9c16..fea5174e8fbba 100644
--- a/lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc.cpp
+++ b/lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc.cpp
@@ -732,7 +732,7 @@ ValueObjectSP ABISysV_ppc::GetReturnValueObjectImpl(
// return a nullptr return value object.
return return_valobj_sp;
}
- } else if (field_compiler_type.IsFloatingPointType()) {
+ } else if (field_compiler_type.GetTypeInfo() & eTypeIsFloat) {
// 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/ABISysV_x86_64.cpp b/lldb/source/Plugins/ABI/X86/ABISysV_x86_64.cpp
index bb19545d14165..1d184d64f5a4e 100644
--- a/lldb/source/Plugins/ABI/X86/ABISysV_x86_64.cpp
+++ b/lldb/source/Plugins/ABI/X86/ABISysV_x86_64.cpp
@@ -596,7 +596,8 @@ 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()) {
+ // FIXME: is this correct for complex floats or float vector types?
+ field_type_flags & eTypeIsFloat) {
aggregate_field_offsets.push_back(field_byte_offset);
aggregate_compiler_types.push_back(field_compiler_type);
} else if (field_type_flags & eTypeHasChildren) {
@@ -724,7 +725,7 @@ ValueObjectSP ABISysV_x86_64::GetReturnValueObjectImpl(
// return a nullptr return value object.
return return_valobj_sp;
}
- } else if (field_compiler_type.IsFloatingPointType()) {
+ } else if (field_compiler_type.GetTypeInfo() & eTypeIsFloat) {
// 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 05498d0b36448..620a247be547e 100644
--- a/lldb/source/Plugins/ABI/X86/ABIWindows_x86_64.cpp
+++ b/lldb/source/Plugins/ABI/X86/ABIWindows_x86_64.cpp
@@ -572,7 +572,8 @@ 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()) {
+ // FIXME: is this correct for complex floats or float vector types?
+ field_type_flags & eTypeIsFloat) {
aggregate_field_offsets.push_back(field_byte_offset);
aggregate_compiler_types.push_back(field_compiler_type);
} else if (field_type_flags & eTypeHasChildren) {
@@ -679,7 +680,8 @@ 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()) {
+ // FIXME: is this correct for complex floats or float vector types?
+ field_compiler_type.GetTypeInfo() & eTypeIsFloat) {
copy_from_extractor = &rax_data;
copy_from_offset = used_bytes;
used_bytes += field_byte_width;
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 812b4508f4937..c9192938fca80 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -3474,28 +3474,14 @@ bool TypeSystemClang::IsReferenceType(lldb::opaque_compiler_type_t type,
}
bool TypeSystemClang::IsFloatingPointType(lldb::opaque_compiler_type_t type) {
- if (type) {
- clang::QualType qual_type(GetCanonicalQualType(type));
+ if (!type)
+ return false;
- if (const clang::BuiltinType *BT = llvm::dyn_cast<clang::BuiltinType>(
- qual_type->getCanonicalTypeInternal())) {
- clang::BuiltinType::Kind kind = BT->getKind();
- if (kind >= clang::BuiltinType::Float &&
- kind <= clang::BuiltinType::LongDouble)
- return true;
- } else if (const clang::ComplexType *CT =
- llvm::dyn_cast<clang::ComplexType>(
- qual_type->getCanonicalTypeInternal())) {
- if (IsFloatingPointType(CT->getElementType().getAsOpaquePtr()))
- return true;
- } else if (const clang::VectorType *VT = llvm::dyn_cast<clang::VectorType>(
- qual_type->getCanonicalTypeInternal())) {
- if (IsFloatingPointType(VT->getElementType().getAsOpaquePtr()))
- return true;
- }
- }
+ clang::QualType qual_type(GetCanonicalQualType(type));
+ if (qual_type.isNull())
+ return false;
- return false;
+ return qual_type->isFloatingType();
}
bool TypeSystemClang::IsDefined(lldb::opaque_compiler_type_t type) {
diff --git a/lldb/source/ValueObject/DILEval.cpp b/lldb/source/ValueObject/DILEval.cpp
index 5077d8b1aa647..48aa4af1d9fd2 100644
--- a/lldb/source/ValueObject/DILEval.cpp
+++ b/lldb/source/ValueObject/DILEval.cpp
@@ -814,7 +814,7 @@ Interpreter::VerifyArithmeticCast(CompilerType source_type,
CompilerType target_type, int location) {
if (source_type.IsPointerType() || source_type.IsNullPtrType()) {
// Cast from pointer to float/double is not allowed.
- if (target_type.IsFloatingPointType()) {
+ if (target_type.GetTypeInfo() & lldb::eTypeIsFloat) {
std::string errMsg = llvm::formatv("Cast from {0} to {1} is not allowed",
source_type.TypeDescription(),
target_type.TypeDescription());
@@ -951,7 +951,8 @@ llvm::Expected<lldb::ValueObjectSP> Interpreter::Visit(const CastNode &node) {
switch (cast_kind) {
case CastKind::eEnumeration: {
- if (op_type.IsFloatingPointType() || op_type.IsInteger() ||
+ // FIXME: is this correct for float vector types?
+ if (op_type.GetTypeInfo() & lldb::eTypeIsFloat || op_type.IsInteger() ||
op_type.IsEnumerationType())
return operand->CastToEnumType(target_type);
break;
diff --git a/lldb/source/ValueObject/ValueObject.cpp b/lldb/source/ValueObject/ValueObject.cpp
index 4bc7ad17cd257..a804ade9a53c5 100644
--- a/lldb/source/ValueObject/ValueObject.cpp
+++ b/lldb/source/ValueObject/ValueObject.cpp
@@ -48,7 +48,7 @@
#include "lldb/ValueObject/ValueObjectMemory.h"
#include "lldb/ValueObject/ValueObjectSynthetic.h"
#include "lldb/ValueObject/ValueObjectVTable.h"
-#include "lldb/lldb-private-types.h"
+#include "lldb/lldb-enumerations.h"
#include "llvm/Support/Compiler.h"
@@ -76,6 +76,14 @@ using namespace lldb_private;
static user_id_t g_value_obj_uid = 0;
+// FIXME: this will return true for vector types whose elements
+// are floats. Audit all usages of this function and call
+// IsFloatingPointType() instead if vectors of floats aren't intended
+// to be supported.
+static bool HasFloatRepresentation(CompilerType ct) {
+ return ct.GetTypeInfo() & eTypeIsFloat;
+}
+
// ValueObject constructor
ValueObject::ValueObject(ValueObject &parent)
: m_parent(&parent), m_update_point(parent.GetUpdatePoint()),
@@ -1165,7 +1173,7 @@ llvm::Expected<llvm::APSInt> ValueObject::GetValueAsAPSInt() {
}
llvm::Expected<llvm::APFloat> ValueObject::GetValueAsAPFloat() {
- if (!GetCompilerType().IsFloatingPointType())
+ if (!HasFloatRepresentation(GetCompilerType()))
return llvm::make_error<llvm::StringError>(
"type cannot be converted to APFloat", llvm::inconvertibleErrorCode());
@@ -1188,7 +1196,7 @@ llvm::Expected<bool> ValueObject::GetValueAsBool() {
if (value_or_err)
return value_or_err->getBoolValue();
}
- if (val_type.IsFloatingPointType()) {
+ if (HasFloatRepresentation(val_type)) {
auto value_or_err = GetValueAsAPFloat();
if (value_or_err)
return value_or_err->isNonZero();
@@ -1204,7 +1212,7 @@ void ValueObject::SetValueFromInteger(const llvm::APInt &value, Status &error) {
// Verify the current object is an integer object
CompilerType val_type = GetCompilerType();
if (!val_type.IsInteger() && !val_type.IsUnscopedEnumerationType() &&
- !val_type.IsFloatingPointType() && !val_type.IsPointerType() &&
+ !HasFloatRepresentation(val_type) && !val_type.IsPointerType() &&
!val_type.IsScalarType()) {
error =
Status::FromErrorString("current value object is not an integer objet");
@@ -1244,7 +1252,7 @@ void ValueObject::SetValueFromInteger(lldb::ValueObjectSP new_val_sp,
// Verify the current object is an integer object
CompilerType val_type = GetCompilerType();
if (!val_type.IsInteger() && !val_type.IsUnscopedEnumerationType() &&
- !val_type.IsFloatingPointType() && !val_type.IsPointerType() &&
+ !HasFloatRepresentation(val_type) && !val_type.IsPointerType() &&
!val_type.IsScalarType()) {
error =
Status::FromErrorString("current value object is not an integer objet");
@@ -1261,7 +1269,7 @@ void ValueObject::SetValueFromInteger(lldb::ValueObjectSP new_val_sp,
// Verify the proposed new value is the right type.
CompilerType new_val_type = new_val_sp->GetCompilerType();
- if (!new_val_type.IsInteger() && !new_val_type.IsFloatingPointType() &&
+ if (!new_val_type.IsInteger() && !HasFloatRepresentation(new_val_type) &&
!new_val_type.IsPointerType()) {
error = Status::FromErrorString(
"illegal argument: new value should be of the same size");
@@ -1274,7 +1282,7 @@ void ValueObject::SetValueFromInteger(lldb::ValueObjectSP new_val_sp,
SetValueFromInteger(*value_or_err, error);
else
error = Status::FromErrorString("error getting APSInt from new_val_sp");
- } else if (new_val_type.IsFloatingPointType()) {
+ } else if (HasFloatRepresentation(new_val_type)) {
auto value_or_err = new_val_sp->GetValueAsAPFloat();
if (value_or_err)
SetValueFromInteger(value_or_err->bitcastToAPInt(), error);
@@ -3142,7 +3150,7 @@ lldb::ValueObjectSP ValueObject::CastToBasicType(CompilerType type) {
bool is_enum = GetCompilerType().IsEnumerationType();
bool is_pointer =
GetCompilerType().IsPointerType() || GetCompilerType().IsNullPtrType();
- bool is_float = GetCompilerType().IsFloatingPointType();
+ bool is_float = HasFloatRepresentation(GetCompilerType());
bool is_integer = GetCompilerType().IsInteger();
ExecutionContext exe_ctx(GetExecutionContextRef());
@@ -3234,7 +3242,7 @@ lldb::ValueObjectSP ValueObject::CastToBasicType(CompilerType type) {
}
}
- if (type.IsFloatingPointType()) {
+ if (HasFloatRepresentation(type)) {
if (!is_scalar) {
auto int_value_or_err = GetValueAsAPSInt();
if (int_value_or_err) {
@@ -3296,7 +3304,7 @@ lldb::ValueObjectSP ValueObject::CastToBasicType(CompilerType type) {
lldb::ValueObjectSP ValueObject::CastToEnumType(CompilerType type) {
bool is_enum = GetCompilerType().IsEnumerationType();
bool is_integer = GetCompilerType().IsInteger();
- bool is_float = GetCompilerType().IsFloatingPointType();
+ bool is_float = HasFloatRepresentation(GetCompilerType());
ExecutionContext exe_ctx(GetExecutionContextRef());
if (!is_enum && !is_integer && !is_float)
diff --git a/lldb/unittests/Symbol/TestTypeSystemClang.cpp b/lldb/unittests/Symbol/TestTypeSystemClang.cpp
index ef13c788ee4a6..b88f14d2062f0 100644
--- a/lldb/unittests/Symbol/TestTypeSystemClang.cpp
+++ b/lldb/unittests/Symbol/TestTypeSystemClang.cpp
@@ -1360,15 +1360,44 @@ TEST_F(TestTypeSystemClang, TestIsRealFloatingPointType) {
EXPECT_FALSE(
m_ast->GetType(ast.getVectorType(ast.FloatTy, 1, VectorKind::Generic))
.IsRealFloatingPointType());
+ EXPECT_TRUE(m_ast->GetType(ast.HalfTy).IsRealFloatingPointType());
EXPECT_TRUE(m_ast->GetType(ast.FloatTy).IsRealFloatingPointType());
EXPECT_TRUE(m_ast->GetType(ast.DoubleTy).IsRealFloatingPointType());
EXPECT_TRUE(m_ast->GetType(ast.LongDoubleTy).IsRealFloatingPointType());
+ EXPECT_TRUE(m_ast->GetType(ast.Float128Ty).IsRealFloatingPointType());
+ EXPECT_TRUE(m_ast->GetType(ast.BFloat16Ty).IsRealFloatingPointType());
+ EXPECT_TRUE(m_ast->GetType(ast.Ibm128Ty).IsRealFloatingPointType());
+}
+
+TEST_F(TestTypeSystemClang, TestIsFloatingPointType) {
+ // Tests CompilerType::IsFloatingPointType
+
+ const ASTContext &ast = m_ast->getASTContext();
- // FIXME: these should be true
- EXPECT_FALSE(m_ast->GetType(ast.HalfTy).IsRealFloatingPointType());
- EXPECT_FALSE(m_ast->GetType(ast.Float128Ty).IsRealFloatingPointType());
- EXPECT_FALSE(m_ast->GetType(ast.BFloat16Ty).IsRealFloatingPointType());
- EXPECT_FALSE(m_ast->GetType(ast.Ibm128Ty).IsRealFloatingPointType());
+ // Vectors of floats
+ EXPECT_FALSE(
+ m_ast->GetType(ast.getVectorType(ast.FloatTy, 1, VectorKind::Generic))
+ .IsFloatingPointType());
+ EXPECT_FALSE(
+ m_ast->GetType(ast.getVectorType(ast.DoubleTy, 1, VectorKind::Generic))
+ .IsFloatingPointType());
+
+ // Complex floats
+ EXPECT_TRUE(
+ m_ast->GetType(ast.getComplexType(ast.FloatTy)).IsFloatingPointType());
+ EXPECT_TRUE(
+ m_ast->GetType(ast.getComplexType(ast.DoubleTy)).IsFloatingPointType());
+ EXPECT_FALSE(
+ m_ast->GetType(ast.getComplexType(ast.IntTy)).IsFloatingPointType());
+
+ // Builtin floats
+ EXPECT_TRUE(m_ast->GetType(ast.HalfTy).IsFloatingPointType());
+ EXPECT_TRUE(m_ast->GetType(ast.FloatTy).IsFloatingPointType());
+ EXPECT_TRUE(m_ast->GetType(ast.DoubleTy).IsFloatingPointType());
+ EXPECT_TRUE(m_ast->GetType(ast.LongDoubleTy).IsFloatingPointType());
+ EXPECT_TRUE(m_ast->GetType(ast.Float128Ty).IsFloatingPointType());
+ EXPECT_TRUE(m_ast->GetType(ast.BFloat16Ty).IsFloatingPointType());
+ EXPECT_TRUE(m_ast->GetType(ast.Ibm128Ty).IsFloatingPointType());
}
TEST_F(TestTypeSystemClang, TestGetIsComplexType) {
More information about the lldb-commits
mailing list