aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/ADT/APIntTest.cpp
diff options
context:
space:
mode:
authorNikita Popov <npopov@redhat.com>2024-10-15 09:33:44 +0200
committerGitHub <noreply@github.com>2024-10-15 09:33:44 +0200
commitc180da93e0257a92b0bb428f70c1b0de083ebf72 (patch)
tree10fee0cf137a2bb24c4602c87791ec0183135830 /llvm/unittests/ADT/APIntTest.cpp
parent708b15413b02e5a24342898eb0e16cd905038860 (diff)
downloadllvm-c180da93e0257a92b0bb428f70c1b0de083ebf72.zip
llvm-c180da93e0257a92b0bb428f70c1b0de083ebf72.tar.gz
llvm-c180da93e0257a92b0bb428f70c1b0de083ebf72.tar.bz2
[APInt] Fix getAllOnes() with zero width (#112227)
This makes sure that APInt::getAllOnes() keeps working after the APInt constructor assertions are enabled. I'm relaxing the requirement for the signed case to either an all zeros or all ones integer. This is basically saying that we can interpret the zero-width integer as either positive or negative.
Diffstat (limited to 'llvm/unittests/ADT/APIntTest.cpp')
-rw-r--r--llvm/unittests/ADT/APIntTest.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/llvm/unittests/ADT/APIntTest.cpp b/llvm/unittests/ADT/APIntTest.cpp
index 7a9ac55..4d5553f 100644
--- a/llvm/unittests/ADT/APIntTest.cpp
+++ b/llvm/unittests/ADT/APIntTest.cpp
@@ -3423,6 +3423,7 @@ TEST(APIntTest, ZeroWidth) {
EXPECT_EQ(0U, ZW.getBitWidth());
EXPECT_EQ(0U, APInt(0, ArrayRef<uint64_t>({0, 1, 2})).getBitWidth());
EXPECT_EQ(0U, APInt(0, "0", 10).getBitWidth());
+ EXPECT_EQ(0U, APInt::getAllOnes(0).getBitWidth());
// Default constructor is single bit wide.
EXPECT_EQ(1U, APInt().getBitWidth());