Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 6 additions & 11 deletions clang/lib/AST/ByteCode/Integral.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,26 +202,21 @@ template <unsigned Bits, bool Signed> class Integral final {

static Integral min(unsigned NumBits) { return Integral(Min); }
static Integral max(unsigned NumBits) { return Integral(Max); }
static Integral zero(unsigned BitWidth = 0) { return from(0); }

template <typename ValT> static Integral from(ValT Value) {
if constexpr (std::is_integral<ValT>::value)
template <typename ValT>
static Integral from(ValT Value, unsigned NumBits = 0) {
if constexpr (std::is_integral_v<ValT>)
return Integral(Value);
else
return Integral::from(static_cast<Integral::ReprT>(Value));
return Integral(static_cast<Integral::ReprT>(Value));
}

template <unsigned SrcBits, bool SrcSign>
static std::enable_if_t<SrcBits != 0, Integral>
from(Integral<SrcBits, SrcSign> Value) {
static Integral from(Integral<SrcBits, SrcSign> Value) {
return Integral(Value.V);
}

static Integral zero(unsigned BitWidth = 0) { return from(0); }

template <typename T> static Integral from(T Value, unsigned NumBits) {
return Integral(Value);
}

static bool inRange(int64_t Value, unsigned NumBits) {
return CheckRange<ReprT, Min, Max>(Value);
}
Expand Down