Skip to content

Commit 6683453

Browse files
committed
[lldb][TypeSystem] Remove count parameter from TypeSystem::IsFloatingPointType
Similar motivation to llvm#165702. It was unused in all callsites and inconsistent with other APIs like `IsIntegerType` (which doesn't take a `count` parameter). If we ever need a "how many elements does this type represent", we can implement one with a new TypeSystem API that does exactly that.
1 parent 31180ba commit 6683453

File tree

9 files changed

+17
-32
lines changed

9 files changed

+17
-32
lines changed

lldb/include/lldb/Symbol/CompilerType.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ class CompilerType {
144144

145145
bool IsDefined() const;
146146

147-
bool IsFloatingPointType(uint32_t &count, bool &is_complex) const;
147+
bool IsFloatingPointType(bool &is_complex) const;
148148

149149
bool IsFunctionType() const;
150150

lldb/include/lldb/Symbol/TypeSystem.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ class TypeSystem : public PluginInterface,
163163
virtual bool IsDefined(lldb::opaque_compiler_type_t type) = 0;
164164

165165
virtual bool IsFloatingPointType(lldb::opaque_compiler_type_t type,
166-
uint32_t &count, bool &is_complex) = 0;
166+
bool &is_complex) = 0;
167167

168168
virtual bool IsFunctionType(lldb::opaque_compiler_type_t type) = 0;
169169

lldb/source/Plugins/ABI/X86/ABIMacOSX_i386.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@ Status ABIMacOSX_i386::SetReturnValueObject(lldb::StackFrameSP &frame_sp,
198198
Thread *thread = frame_sp->GetThread().get();
199199

200200
bool is_signed;
201-
uint32_t count;
202201
bool is_complex;
203202

204203
RegisterContext *reg_ctx = thread->GetRegisterContext().get();
@@ -240,7 +239,7 @@ Status ABIMacOSX_i386::SetReturnValueObject(lldb::StackFrameSP &frame_sp,
240239
"We don't support returning longer than 64 bit "
241240
"integer values at present.");
242241
}
243-
} else if (compiler_type.IsFloatingPointType(count, is_complex)) {
242+
} else if (compiler_type.IsFloatingPointType(is_complex)) {
244243
if (is_complex)
245244
error = Status::FromErrorString(
246245
"We don't support returning complex values at present");

lldb/source/Plugins/ABI/X86/ABISysV_x86_64.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,6 @@ Status ABISysV_x86_64::SetReturnValueObject(lldb::StackFrameSP &frame_sp,
307307
Thread *thread = frame_sp->GetThread().get();
308308

309309
bool is_signed;
310-
uint32_t count;
311310
bool is_complex;
312311

313312
RegisterContext *reg_ctx = thread->GetRegisterContext().get();
@@ -337,7 +336,7 @@ Status ABISysV_x86_64::SetReturnValueObject(lldb::StackFrameSP &frame_sp,
337336
"We don't support returning longer than 64 bit "
338337
"integer values at present.");
339338
}
340-
} else if (compiler_type.IsFloatingPointType(count, is_complex)) {
339+
} else if (compiler_type.IsFloatingPointType(is_complex)) {
341340
if (is_complex)
342341
error = Status::FromErrorString(
343342
"We don't support returning complex values at present");
@@ -587,7 +586,6 @@ static bool FlattenAggregateType(
587586
for (uint32_t idx = 0; idx < num_children; ++idx) {
588587
std::string name;
589588
bool is_signed;
590-
uint32_t count;
591589
bool is_complex;
592590

593591
uint64_t field_bit_offset = 0;
@@ -606,7 +604,7 @@ static bool FlattenAggregateType(
606604
const uint32_t field_type_flags = field_compiler_type.GetTypeInfo();
607605
if (field_compiler_type.IsIntegerOrEnumerationType(is_signed) ||
608606
field_compiler_type.IsPointerType() ||
609-
field_compiler_type.IsFloatingPointType(count, is_complex)) {
607+
field_compiler_type.IsFloatingPointType(is_complex)) {
610608
aggregate_field_offsets.push_back(field_byte_offset);
611609
aggregate_compiler_types.push_back(field_compiler_type);
612610
} else if (field_type_flags & eTypeHasChildren) {
@@ -696,7 +694,6 @@ ValueObjectSP ABISysV_x86_64::GetReturnValueObjectImpl(
696694
is_memory = false;
697695
for (uint32_t idx = 0; idx < num_children; idx++) {
698696
bool is_signed;
699-
uint32_t count;
700697
bool is_complex;
701698

702699
CompilerType field_compiler_type = aggregate_compiler_types[idx];
@@ -736,7 +733,7 @@ ValueObjectSP ABISysV_x86_64::GetReturnValueObjectImpl(
736733
// return a nullptr return value object.
737734
return return_valobj_sp;
738735
}
739-
} else if (field_compiler_type.IsFloatingPointType(count, is_complex)) {
736+
} else if (field_compiler_type.IsFloatingPointType(is_complex)) {
740737
// Structs with long doubles are always passed in memory.
741738
if (field_bit_width == 128) {
742739
is_memory = true;

lldb/source/Plugins/ABI/X86/ABIWindows_x86_64.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,6 @@ Status ABIWindows_x86_64::SetReturnValueObject(lldb::StackFrameSP &frame_sp,
312312
Thread *thread = frame_sp->GetThread().get();
313313

314314
bool is_signed;
315-
uint32_t count;
316315
bool is_complex;
317316

318317
RegisterContext *reg_ctx = thread->GetRegisterContext().get();
@@ -342,7 +341,7 @@ Status ABIWindows_x86_64::SetReturnValueObject(lldb::StackFrameSP &frame_sp,
342341
"We don't support returning longer than 64 bit "
343342
"integer values at present.");
344343
}
345-
} else if (compiler_type.IsFloatingPointType(count, is_complex)) {
344+
} else if (compiler_type.IsFloatingPointType(is_complex)) {
346345
if (is_complex)
347346
error = Status::FromErrorString(
348347
"We don't support returning complex values at present");
@@ -558,7 +557,6 @@ static bool FlattenAggregateType(
558557
for (uint32_t idx = 0; idx < num_children; ++idx) {
559558
std::string name;
560559
bool is_signed;
561-
uint32_t count;
562560
bool is_complex;
563561

564562
uint64_t field_bit_offset = 0;
@@ -582,7 +580,7 @@ static bool FlattenAggregateType(
582580
const uint32_t field_type_flags = field_compiler_type.GetTypeInfo();
583581
if (field_compiler_type.IsIntegerOrEnumerationType(is_signed) ||
584582
field_compiler_type.IsPointerType() ||
585-
field_compiler_type.IsFloatingPointType(count, is_complex)) {
583+
field_compiler_type.IsFloatingPointType(is_complex)) {
586584
aggregate_field_offsets.push_back(field_byte_offset);
587585
aggregate_compiler_types.push_back(field_compiler_type);
588586
} else if (field_type_flags & eTypeHasChildren) {
@@ -672,7 +670,6 @@ ValueObjectSP ABIWindows_x86_64::GetReturnValueObjectImpl(
672670
for (uint32_t idx = 0; idx < num_children; idx++) {
673671
bool is_signed;
674672
bool is_complex;
675-
uint32_t count;
676673

677674
CompilerType field_compiler_type = aggregate_compiler_types[idx];
678675
uint32_t field_byte_width =
@@ -691,7 +688,7 @@ ValueObjectSP ABIWindows_x86_64::GetReturnValueObjectImpl(
691688
uint32_t copy_from_offset = 0;
692689
if (field_compiler_type.IsIntegerOrEnumerationType(is_signed) ||
693690
field_compiler_type.IsPointerType() ||
694-
field_compiler_type.IsFloatingPointType(count, is_complex)) {
691+
field_compiler_type.IsFloatingPointType(is_complex)) {
695692
copy_from_extractor = &rax_data;
696693
copy_from_offset = used_bytes;
697694
used_bytes += field_byte_width;

lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2032,11 +2032,10 @@ static std::optional<clang::APValue> MakeAPValue(const clang::ASTContext &ast,
20322032
if (is_integral)
20332033
return clang::APValue(apint);
20342034

2035-
uint32_t count;
20362035
bool is_complex;
20372036
// FIXME: we currently support a limited set of floating point types.
20382037
// E.g., 16-bit floats are not supported.
2039-
if (!clang_type.IsFloatingPointType(count, is_complex))
2038+
if (!clang_type.IsFloatingPointType(is_complex))
20402039
return std::nullopt;
20412040

20422041
return clang::APValue(llvm::APFloat(

lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3483,7 +3483,7 @@ bool TypeSystemClang::IsReferenceType(lldb::opaque_compiler_type_t type,
34833483
}
34843484

34853485
bool TypeSystemClang::IsFloatingPointType(lldb::opaque_compiler_type_t type,
3486-
uint32_t &count, bool &is_complex) {
3486+
bool &is_complex) {
34873487
if (type) {
34883488
clang::QualType qual_type(GetCanonicalQualType(type));
34893489

@@ -3492,30 +3492,26 @@ bool TypeSystemClang::IsFloatingPointType(lldb::opaque_compiler_type_t type,
34923492
clang::BuiltinType::Kind kind = BT->getKind();
34933493
if (kind >= clang::BuiltinType::Float &&
34943494
kind <= clang::BuiltinType::LongDouble) {
3495-
count = 1;
34963495
is_complex = false;
34973496
return true;
34983497
}
34993498
} else if (const clang::ComplexType *CT =
35003499
llvm::dyn_cast<clang::ComplexType>(
35013500
qual_type->getCanonicalTypeInternal())) {
3502-
if (IsFloatingPointType(CT->getElementType().getAsOpaquePtr(), count,
3501+
if (IsFloatingPointType(CT->getElementType().getAsOpaquePtr(),
35033502
is_complex)) {
3504-
count = 2;
35053503
is_complex = true;
35063504
return true;
35073505
}
35083506
} else if (const clang::VectorType *VT = llvm::dyn_cast<clang::VectorType>(
35093507
qual_type->getCanonicalTypeInternal())) {
3510-
if (IsFloatingPointType(VT->getElementType().getAsOpaquePtr(), count,
3508+
if (IsFloatingPointType(VT->getElementType().getAsOpaquePtr(),
35113509
is_complex)) {
3512-
count = VT->getNumElements();
35133510
is_complex = false;
35143511
return true;
35153512
}
35163513
}
35173514
}
3518-
count = 0;
35193515
is_complex = false;
35203516
return false;
35213517
}

lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ class TypeSystemClang : public TypeSystem {
651651

652652
bool IsDefined(lldb::opaque_compiler_type_t type) override;
653653

654-
bool IsFloatingPointType(lldb::opaque_compiler_type_t type, uint32_t &count,
654+
bool IsFloatingPointType(lldb::opaque_compiler_type_t type,
655655
bool &is_complex) override;
656656

657657
unsigned GetPtrAuthKey(lldb::opaque_compiler_type_t type) override;

lldb/source/Symbol/CompilerType.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -240,13 +240,11 @@ bool CompilerType::ShouldTreatScalarValueAsAddress() const {
240240
return false;
241241
}
242242

243-
bool CompilerType::IsFloatingPointType(uint32_t &count,
244-
bool &is_complex) const {
243+
bool CompilerType::IsFloatingPointType(bool &is_complex) const {
245244
if (IsValid()) {
246245
if (auto type_system_sp = GetTypeSystem())
247-
return type_system_sp->IsFloatingPointType(m_type, count, is_complex);
246+
return type_system_sp->IsFloatingPointType(m_type, is_complex);
248247
}
249-
count = 0;
250248
is_complex = false;
251249
return false;
252250
}
@@ -331,9 +329,8 @@ bool CompilerType::IsInteger() const {
331329
}
332330

333331
bool CompilerType::IsFloat() const {
334-
uint32_t count = 0;
335332
bool is_complex = false;
336-
return IsFloatingPointType(count, is_complex);
333+
return IsFloatingPointType(is_complex);
337334
}
338335

339336
bool CompilerType::IsEnumerationType() const {

0 commit comments

Comments
 (0)