Skip to content

Commit 0e301fd

Browse files
committed
[lldb/Utility] Remove some Scalar type accessors
Now that the number of Scalar "types" has been reduced, these don't make sense anymore.
1 parent 2e194fe commit 0e301fd

File tree

2 files changed

+3
-32
lines changed

2 files changed

+3
-32
lines changed

lldb/include/lldb/Utility/Scalar.h

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,7 @@ class Scalar {
7575
llvm::APFloat::rmNearestTiesToEven, &ignore);
7676
}
7777
Scalar(llvm::APInt v)
78-
: m_type(GetBestTypeForBitSize(v.getBitWidth(), true)),
79-
m_integer(std::move(v)), m_float(0.0f) {}
80-
81-
/// Return the most efficient Scalar::Type for the requested bit size.
82-
static Type GetBestTypeForBitSize(size_t bit_size, bool sign);
78+
: m_type(e_sint), m_integer(std::move(v)), m_float(0.0f) {}
8379

8480
bool SignExtend(uint32_t bit_pos);
8581

@@ -126,12 +122,6 @@ class Scalar {
126122

127123
static const char *GetValueTypeAsCString(Scalar::Type value_type);
128124

129-
static Scalar::Type
130-
GetValueTypeForSignedIntegerWithByteSize(size_t byte_size);
131-
132-
static Scalar::Type
133-
GetValueTypeForUnsignedIntegerWithByteSize(size_t byte_size);
134-
135125
// All operators can benefits from the implicit conversions that will happen
136126
// automagically by the compiler, so no temporary objects will need to be
137127
// created. As a result, we currently don't need a variety of overloaded set

lldb/source/Utility/Scalar.cpp

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -197,13 +197,9 @@ void Scalar::GetValue(Stream *s, bool show_type) const {
197197
}
198198
}
199199

200-
Scalar::Type Scalar::GetBestTypeForBitSize(size_t bit_size, bool sign) {
201-
return sign ? e_sint : e_uint;
202-
}
203-
204200
void Scalar::TruncOrExtendTo(uint16_t bits, bool sign) {
205201
m_integer = sign ? m_integer.sextOrTrunc(bits) : m_integer.zextOrTrunc(bits);
206-
m_type = GetBestTypeForBitSize(bits, sign);
202+
m_type = sign ? e_sint : e_uint;
207203
}
208204

209205
bool Scalar::IntegralPromote(uint16_t bits, bool sign) {
@@ -262,16 +258,6 @@ const char *Scalar::GetValueTypeAsCString(Scalar::Type type) {
262258
return "???";
263259
}
264260

265-
Scalar::Type
266-
Scalar::GetValueTypeForSignedIntegerWithByteSize(size_t byte_size) {
267-
return e_sint;
268-
}
269-
270-
Scalar::Type
271-
Scalar::GetValueTypeForUnsignedIntegerWithByteSize(size_t byte_size) {
272-
return e_uint;
273-
}
274-
275261
bool Scalar::MakeSigned() {
276262
bool success = false;
277263

@@ -768,12 +754,7 @@ Status Scalar::SetValueFromData(const DataExtractor &data,
768754
case lldb::eEncodingSint: {
769755
if (data.GetByteSize() < byte_size)
770756
return Status("insufficient data");
771-
Type type = GetBestTypeForBitSize(byte_size*8, encoding == lldb::eEncodingSint);
772-
if (type == e_void) {
773-
return Status("unsupported integer byte size: %" PRIu64 "",
774-
static_cast<uint64_t>(byte_size));
775-
}
776-
m_type = type;
757+
m_type = encoding == lldb::eEncodingSint ? e_sint : e_uint;
777758
if (data.GetByteOrder() == endian::InlHostByteOrder()) {
778759
m_integer = APInt::getNullValue(8 * byte_size);
779760
llvm::LoadIntFromMemory(m_integer, data.GetDataStart(), byte_size);

0 commit comments

Comments
 (0)