From 0e301fd02386e01ca93a28e8c0484447fbb440a1 Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Thu, 20 Aug 2020 09:20:55 +0200 Subject: [PATCH] [lldb/Utility] Remove some Scalar type accessors Now that the number of Scalar "types" has been reduced, these don't make sense anymore. --- lldb/include/lldb/Utility/Scalar.h | 12 +----------- lldb/source/Utility/Scalar.cpp | 23 ++--------------------- 2 files changed, 3 insertions(+), 32 deletions(-) diff --git a/lldb/include/lldb/Utility/Scalar.h b/lldb/include/lldb/Utility/Scalar.h index 4e0505e..9d3a20c 100644 --- a/lldb/include/lldb/Utility/Scalar.h +++ b/lldb/include/lldb/Utility/Scalar.h @@ -75,11 +75,7 @@ public: llvm::APFloat::rmNearestTiesToEven, &ignore); } Scalar(llvm::APInt v) - : m_type(GetBestTypeForBitSize(v.getBitWidth(), true)), - m_integer(std::move(v)), m_float(0.0f) {} - - /// Return the most efficient Scalar::Type for the requested bit size. - static Type GetBestTypeForBitSize(size_t bit_size, bool sign); + : m_type(e_sint), m_integer(std::move(v)), m_float(0.0f) {} bool SignExtend(uint32_t bit_pos); @@ -126,12 +122,6 @@ public: static const char *GetValueTypeAsCString(Scalar::Type value_type); - static Scalar::Type - GetValueTypeForSignedIntegerWithByteSize(size_t byte_size); - - static Scalar::Type - GetValueTypeForUnsignedIntegerWithByteSize(size_t byte_size); - // All operators can benefits from the implicit conversions that will happen // automagically by the compiler, so no temporary objects will need to be // created. As a result, we currently don't need a variety of overloaded set diff --git a/lldb/source/Utility/Scalar.cpp b/lldb/source/Utility/Scalar.cpp index 1a27808..e5a1454 100644 --- a/lldb/source/Utility/Scalar.cpp +++ b/lldb/source/Utility/Scalar.cpp @@ -197,13 +197,9 @@ void Scalar::GetValue(Stream *s, bool show_type) const { } } -Scalar::Type Scalar::GetBestTypeForBitSize(size_t bit_size, bool sign) { - return sign ? e_sint : e_uint; -} - void Scalar::TruncOrExtendTo(uint16_t bits, bool sign) { m_integer = sign ? m_integer.sextOrTrunc(bits) : m_integer.zextOrTrunc(bits); - m_type = GetBestTypeForBitSize(bits, sign); + m_type = sign ? e_sint : e_uint; } bool Scalar::IntegralPromote(uint16_t bits, bool sign) { @@ -262,16 +258,6 @@ const char *Scalar::GetValueTypeAsCString(Scalar::Type type) { return "???"; } -Scalar::Type -Scalar::GetValueTypeForSignedIntegerWithByteSize(size_t byte_size) { - return e_sint; -} - -Scalar::Type -Scalar::GetValueTypeForUnsignedIntegerWithByteSize(size_t byte_size) { - return e_uint; -} - bool Scalar::MakeSigned() { bool success = false; @@ -768,12 +754,7 @@ Status Scalar::SetValueFromData(const DataExtractor &data, case lldb::eEncodingSint: { if (data.GetByteSize() < byte_size) return Status("insufficient data"); - Type type = GetBestTypeForBitSize(byte_size*8, encoding == lldb::eEncodingSint); - if (type == e_void) { - return Status("unsupported integer byte size: %" PRIu64 "", - static_cast(byte_size)); - } - m_type = type; + m_type = encoding == lldb::eEncodingSint ? e_sint : e_uint; if (data.GetByteOrder() == endian::InlHostByteOrder()) { m_integer = APInt::getNullValue(8 * byte_size); llvm::LoadIntFromMemory(m_integer, data.GetDataStart(), byte_size); -- 2.7.4