[llvm] Reapply [APInt] Enable APInt ctor assertion by default (PR #114539)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 1 06:48:59 PDT 2024
https://github.com/nikic created https://github.com/llvm/llvm-project/pull/114539
This enables the assertion introduced in
https://github.com/llvm/llvm-project/pull/106524, which checks that the value passed to the constructor is indeed a valid N-bit signed or unsigned integer.
Places that previously violated the assertion were updated in advance, e.g. in https://github.com/llvm/llvm-project/pull/80309.
It is possible to opt-out of the check and restore the previous behavior by setting implicitTrunc=true.
-----
The buildbot failures from the previous attempt should be fixed by a18dd29077c84fc076a4ed431d9e815a3d0b6f24 and
e2074c60bb3982cd8afb6408670332ea27da6383.
>From 87b25f7d096c4735dc3f0dd7f4c75703ccced43a Mon Sep 17 00:00:00 2001
From: Nikita Popov <npopov at redhat.com>
Date: Thu, 17 Oct 2024 09:04:28 +0200
Subject: [PATCH] Reapply [APInt] Enable APInt ctor assertion by default
This enables the assertion introduced in
https://github.com/llvm/llvm-project/pull/106524, which checks
that the value passed to the constructor is indeed a valid
N-bit signed or unsigned integer.
Places that previously violated the assertion were updated in
advance, e.g. in https://github.com/llvm/llvm-project/pull/80309.
It is possible to opt-out of the check and restore the previous
behavior by setting implicitTrunc=true.
-----
The buildbot failures from the previous attempt should be fixed
by a18dd29077c84fc076a4ed431d9e815a3d0b6f24 and
e2074c60bb3982cd8afb6408670332ea27da6383.
---
llvm/include/llvm/ADT/APInt.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/llvm/include/llvm/ADT/APInt.h b/llvm/include/llvm/ADT/APInt.h
index 63a138527b32e1..953b2a27b71526 100644
--- a/llvm/include/llvm/ADT/APInt.h
+++ b/llvm/include/llvm/ADT/APInt.h
@@ -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) {
More information about the llvm-commits
mailing list