[lldb/Utility] Simplify and generalize Scalar class
authorPavel Labath <pavel@labath.sk>
Mon, 27 Jul 2020 13:06:48 +0000 (15:06 +0200)
committerPavel Labath <pavel@labath.sk>
Mon, 17 Aug 2020 09:09:56 +0000 (11:09 +0200)
commit67cdb899c6b3ec231f35ca17a00023758ef127ba
treeb5a5ce34c288ec96e8ed7cb363cf6d38357e70af
parent2d89a3ba121b96a4af9aecaf52205eab200394c3
[lldb/Utility] Simplify and generalize Scalar class

The class contains an enum listing all host integer types as well as
some non-host types. This setup is a remnant of a time when this class
was actually implemented in terms of host integer types. Now that we are
using llvm::APInt, they are mostly useless and mean that each function
needs to enumerate all of these cases even though it treats most of them
identically.

I only leave e_sint and e_uint to denote the integer signedness, but I
want to remove that in a follow-up as well.

Removing these cases simplifies most of these functions, with the only
exception being PromoteToMaxType, which can no longer rely on a simple
enum comparison to determine what needs to be promoted.

This also makes the class ready to work with arbitrary integer sizes, so
it does not need to be modified when someone needs to add a larger
integer size.

Differential Revision: https://reviews.llvm.org/D85836
lldb/include/lldb/Utility/Scalar.h
lldb/source/Utility/Scalar.cpp
lldb/unittests/Utility/ScalarTest.cpp