should, rather than giving a broken value that doesn't even zero/sign-extend
properly.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@246836
91177308-0d34-0410-b5e6-
96231b3b80d8
- /// \brief Default constructor that creates an uninitialized APInt.
+ /// \brief Default constructor that creates an uninteresting APInt
+ /// representing a 1-bit zero value.
///
/// This is useful for object deserialization (pair this with the static
/// method Read).
///
/// This is useful for object deserialization (pair this with the static
/// method Read).
- explicit APInt() : BitWidth(1) {}
+ explicit APInt() : BitWidth(1), VAL(0) {}
/// \brief Returns whether this instance allocated memory.
bool needsCleanup() const { return !isSingleWord(); }
/// \brief Returns whether this instance allocated memory.
bool needsCleanup() const { return !isSingleWord(); }
+TEST(APIntTest, ValueInit) {
+ APInt Zero = APInt();
+ EXPECT_TRUE(!Zero);
+ EXPECT_TRUE(!Zero.zext(64));
+ EXPECT_TRUE(!Zero.sext(64));
+}
+
// Test that APInt shift left works when bitwidth > 64 and shiftamt == 0
TEST(APIntTest, ShiftLeftByZero) {
APInt One = APInt::getNullValue(65) + 1;
// Test that APInt shift left works when bitwidth > 64 and shiftamt == 0
TEST(APIntTest, ShiftLeftByZero) {
APInt One = APInt::getNullValue(65) + 1;