[lldb/Utility] Merge Scalar::Get(Value)TypeAsCString
authorPavel Labath <pavel@labath.sk>
Mon, 6 Jul 2020 08:32:55 +0000 (10:32 +0200)
committerPavel Labath <pavel@labath.sk>
Mon, 6 Jul 2020 08:34:12 +0000 (10:34 +0200)
lldb/include/lldb/Utility/Scalar.h
lldb/source/Utility/Scalar.cpp
lldb/unittests/Utility/ScalarTest.cpp

index 275df4d..f215fa7 100644 (file)
@@ -125,7 +125,7 @@ public:
     m_integer.clearAllBits();
   }
 
-  const char *GetTypeAsCString() const;
+  const char *GetTypeAsCString() const { return GetValueTypeAsCString(m_type); }
 
   void GetValue(Stream *s, bool show_type) const;
 
index c36ccab..7397744 100644 (file)
@@ -229,44 +229,6 @@ void Scalar::GetValue(Stream *s, bool show_type) const {
   }
 }
 
-const char *Scalar::GetTypeAsCString() const {
-  switch (m_type) {
-  case e_void:
-    return "void";
-  case e_sint:
-    return "int";
-  case e_uint:
-    return "unsigned int";
-  case e_slong:
-    return "long";
-  case e_ulong:
-    return "unsigned long";
-  case e_slonglong:
-    return "long long";
-  case e_ulonglong:
-    return "unsigned long long";
-  case e_sint128:
-    return "int128_t";
-  case e_uint128:
-    return "unsigned int128_t";
-  case e_sint256:
-    return "int256_t";
-  case e_uint256:
-    return "unsigned int256_t";
-  case e_sint512:
-    return "int512_t";
-  case e_uint512:
-    return "unsigned int512_t";
-  case e_float:
-    return "float";
-  case e_double:
-    return "double";
-  case e_long_double:
-    return "long double";
-  }
-  return "<invalid Scalar type>";
-}
-
 Scalar::~Scalar() = default;
 
 Scalar::Type Scalar::GetBestTypeForBitSize(size_t bit_size, bool sign) {
index afbb761..910ff17 100644 (file)
@@ -362,7 +362,7 @@ TEST(ScalarTest, Scalar_512) {
 
   ASSERT_TRUE(S.MakeUnsigned());
   EXPECT_EQ(S.GetType(), Scalar::e_uint512);
-  ASSERT_STREQ(S.GetTypeAsCString(), "unsigned int512_t");
+  ASSERT_STREQ(S.GetTypeAsCString(), "uint512_t");
   ASSERT_STREQ(S.GetValueTypeAsCString(Scalar::e_uint512), "uint512_t");
   EXPECT_EQ(S.GetByteSize(), 64U);