Skip to content

Commit

Permalink
[APInt] Enable APInt ctor assertion by default (llvm#112670)
Browse files Browse the repository at this point in the history
This enables the assertion introduced in
llvm#106524, which checks that the
value passed to the APInt constructor is indeed a valid N-bit signed or
unsigned integer.

Places that previously violated the assertion were updated in advance,
e.g. in llvm#80309.

It is possible to opt-out of the check and restore the previous behavior
by setting implicitTrunc=true.
  • Loading branch information
nikic authored Oct 18, 2024
1 parent 5a09ce9 commit ba1ee2b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion llvm/include/llvm/ADT/APInt.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class [[nodiscard]] APInt {
/// \param implicitTrunc allow implicit truncation of non-zero/sign bits of
/// val beyond the range of numBits
APInt(unsigned numBits, uint64_t val, bool isSigned = false,
bool implicitTrunc = true)
bool implicitTrunc = false)
: BitWidth(numBits) {
if (!implicitTrunc) {
if (isSigned) {
Expand Down

0 comments on commit ba1ee2b

Please sign in to comment.