mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-19 18:24:00 +00:00
ADT: Correct APInt::getActiveWords for zero values
PR15138 was opened because of a segfault in the Bitcode writer. The actual issue ended up being a bug in APInt where calls to APInt::getActiveWords returns a bogus value when the APInt value is 0. This patch fixes the problem by ensuring that getActiveWords returns 1 for 0 valued APInts. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174641 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -56,6 +56,14 @@ TEST(APIntTest, i33_Count) {
|
||||
#endif
|
||||
|
||||
TEST(APIntTest, i65_Count) {
|
||||
APInt i65(65, 0, true);
|
||||
EXPECT_EQ(65u, i65.countLeadingZeros());
|
||||
EXPECT_EQ(0u, i65.countLeadingOnes());
|
||||
EXPECT_EQ(0u, i65.getActiveBits());
|
||||
EXPECT_EQ(1u, i65.getActiveWords());
|
||||
EXPECT_EQ(65u, i65.countTrailingZeros());
|
||||
EXPECT_EQ(0u, i65.countPopulation());
|
||||
|
||||
APInt i65minus(65, 0, true);
|
||||
i65minus.setBit(64);
|
||||
EXPECT_EQ(0u, i65minus.countLeadingZeros());
|
||||
|
Reference in New Issue
Block a user