Skip to content
Merged
Show file tree
Hide file tree
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
12 changes: 10 additions & 2 deletions clang/lib/AST/ByteCode/IntegralAP.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,16 @@ template <bool Signed> class IntegralAP final {
return !getValue().isNonNegative();
return false;
}
bool isMin() const { return getValue().isMinValue(); }
bool isMax() const { return getValue().isMaxValue(); }
bool isMin() const {
if constexpr (Signed)
return getValue().isMinSignedValue();
return getValue().isMinValue();
}
bool isMax() const {
if constexpr (Signed)
return getValue().isMaxSignedValue();
return getValue().isMaxValue();
}
static constexpr bool isSigned() { return Signed; }
bool isMinusOne() const { return Signed && getValue().isAllOnes(); }

Expand Down
7 changes: 7 additions & 0 deletions clang/test/AST/ByteCode/intap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ static_assert(DivA / DivB == 2, "");
constexpr _BitInt(4) DivC = DivA / 0; // both-error {{must be initialized by a constant expression}} \
// both-note {{division by zero}}

constexpr __int128 isMinDiv() {
return __int128{0} / __int128{-1};
}
static_assert(isMinDiv() == 0, "");



constexpr _BitInt(7) RemA = 47;
constexpr _BitInt(6) RemB = 9;
static_assert(RemA % RemB == 2, "");
Expand Down
Loading