Skip to content

Commit 8396d4c

Browse files
authored
[clang][bytecode][NFC] Clean up Integral::from() functions (#169513)
1 parent a57fe84 commit 8396d4c

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

clang/lib/AST/ByteCode/Integral.h

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -202,26 +202,21 @@ template <unsigned Bits, bool Signed> class Integral final {
202202

203203
static Integral min(unsigned NumBits) { return Integral(Min); }
204204
static Integral max(unsigned NumBits) { return Integral(Max); }
205+
static Integral zero(unsigned BitWidth = 0) { return from(0); }
205206

206-
template <typename ValT> static Integral from(ValT Value) {
207-
if constexpr (std::is_integral<ValT>::value)
207+
template <typename ValT>
208+
static Integral from(ValT Value, unsigned NumBits = 0) {
209+
if constexpr (std::is_integral_v<ValT>)
208210
return Integral(Value);
209211
else
210-
return Integral::from(static_cast<Integral::ReprT>(Value));
212+
return Integral(static_cast<Integral::ReprT>(Value));
211213
}
212214

213215
template <unsigned SrcBits, bool SrcSign>
214-
static std::enable_if_t<SrcBits != 0, Integral>
215-
from(Integral<SrcBits, SrcSign> Value) {
216+
static Integral from(Integral<SrcBits, SrcSign> Value) {
216217
return Integral(Value.V);
217218
}
218219

219-
static Integral zero(unsigned BitWidth = 0) { return from(0); }
220-
221-
template <typename T> static Integral from(T Value, unsigned NumBits) {
222-
return Integral(Value);
223-
}
224-
225220
static bool inRange(int64_t Value, unsigned NumBits) {
226221
return CheckRange<ReprT, Min, Max>(Value);
227222
}

0 commit comments

Comments
 (0)