[llvm] ba1ee2b - [APInt] Enable APInt ctor assertion by default (#112670)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 18 00:23:29 PDT 2024
Author: Nikita Popov
Date: 2024-10-18T09:23:24+02:00
New Revision: ba1ee2bab7a4cdc0975686e5099461c0b12c5345
URL: https://github.com/llvm/llvm-project/commit/ba1ee2bab7a4cdc0975686e5099461c0b12c5345
DIFF: https://github.com/llvm/llvm-project/commit/ba1ee2bab7a4cdc0975686e5099461c0b12c5345.diff
LOG: [APInt] Enable APInt ctor assertion by default (#112670)
This enables the assertion introduced in
https://github.com/llvm/llvm-project/pull/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 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.
Added:
Modified:
llvm/include/llvm/ADT/APInt.h
Removed:
################################################################################
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