[Lldb-commits] [lldb] 0e301fd - [lldb/Utility] Remove some Scalar type accessors
Pavel Labath via lldb-commits
lldb-commits at lists.llvm.org
Mon Aug 24 02:45:47 PDT 2020
Author: Pavel Labath
Date: 2020-08-24T11:45:30+02:00
New Revision: 0e301fd02386e01ca93a28e8c0484447fbb440a1
URL: https://github.com/llvm/llvm-project/commit/0e301fd02386e01ca93a28e8c0484447fbb440a1
DIFF: https://github.com/llvm/llvm-project/commit/0e301fd02386e01ca93a28e8c0484447fbb440a1.diff
LOG: [lldb/Utility] Remove some Scalar type accessors
Now that the number of Scalar "types" has been reduced, these don't make
sense anymore.
Added:
Modified:
lldb/include/lldb/Utility/Scalar.h
lldb/source/Utility/Scalar.cpp
Removed:
################################################################################
diff --git a/lldb/include/lldb/Utility/Scalar.h b/lldb/include/lldb/Utility/Scalar.h
index 4e0505e669dd..9d3a20c93898 100644
--- a/lldb/include/lldb/Utility/Scalar.h
+++ b/lldb/include/lldb/Utility/Scalar.h
@@ -75,11 +75,7 @@ class Scalar {
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 @@ class Scalar {
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 1a27808068d6..e5a1454561f2 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<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);
More information about the lldb-commits
mailing list