diff options
| author | Meador Inge <meadori@codesourcery.com> | 2013-02-07 18:36:50 +0000 |
|---|---|---|
| committer | Meador Inge <meadori@codesourcery.com> | 2013-02-07 18:36:50 +0000 |
| commit | 32dc72492058af532fd6cfd9e5cf6364d6b421db (patch) | |
| tree | c19aad55a649d61f8e5ac38cfa1f2be92f6be65f /llvm/unittests/ADT | |
| parent | b31d71367bac0896dbde0f93a939ec7da19a7bf8 (diff) | |
| download | bcm5719-llvm-32dc72492058af532fd6cfd9e5cf6364d6b421db.tar.gz bcm5719-llvm-32dc72492058af532fd6cfd9e5cf6364d6b421db.zip | |
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.
llvm-svn: 174641
Diffstat (limited to 'llvm/unittests/ADT')
| -rw-r--r-- | llvm/unittests/ADT/APIntTest.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/unittests/ADT/APIntTest.cpp b/llvm/unittests/ADT/APIntTest.cpp index 2a4c5b4c494..2510bc738d4 100644 --- a/llvm/unittests/ADT/APIntTest.cpp +++ b/llvm/unittests/ADT/APIntTest.cpp @@ -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()); |

