[lldb/Utility] Remove some Scalar type accessors
authorPavel Labath <pavel@labath.sk>
Thu, 20 Aug 2020 07:20:55 +0000 (09:20 +0200)
committerPavel Labath <pavel@labath.sk>
Mon, 24 Aug 2020 09:45:30 +0000 (11:45 +0200)
Now that the number of Scalar "types" has been reduced, these don't make
sense anymore.

lldb/include/lldb/Utility/Scalar.h
lldb/source/Utility/Scalar.cpp

index 4e0505e..9d3a20c 100644 (file)
@@ -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
index 1a27808..e5a1454 100644 (file)
@@ -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<uint64_t>(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);