#include "llvm/ADT/APInt.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/Twine.h"
#include "llvm/Support/Alignment.h"
#include "gtest/gtest.h"
#include <array>
#include <climits>
#include <limits>
#include <optional>
usingnamespacellvm;
namespace {
TEST(APIntTest, ValueInit) { … }
TEST(APIntTest, ShiftLeftByZero) { … }
TEST(APIntTest, i64_ArithmeticRightShiftNegative) { … }
TEST(APIntTest, i128_NegativeCount) { … }
TEST(APIntTest, i33_Count) { … }
TEST(APIntTest, i61_Count) { … }
TEST(APIntTest, i65_Count) { … }
TEST(APIntTest, i128_PositiveCount) { … }
TEST(APIntTest, i256) { … }
TEST(APIntTest, i1) { … }
TEST(APIntTest, compare) { … }
TEST(APIntTest, compareWithRawIntegers) { … }
TEST(APIntTest, compareWithInt64Min) { … }
TEST(APIntTest, compareWithHalfInt64Max) { … }
TEST(APIntTest, compareLargeIntegers) { … }
TEST(APIntTest, binaryOpsWithRawIntegers) { … }
TEST(APIntTest, rvalue_arithmetic) { … }
TEST(APIntTest, rvalue_bitwise) { … }
TEST(APIntTest, rvalue_invert) { … }
void testDiv(APInt a, APInt b, APInt c) { … }
TEST(APIntTest, divrem_big1) { … }
TEST(APIntTest, divrem_big2) { … }
TEST(APIntTest, divrem_big3) { … }
TEST(APIntTest, divrem_big4) { … }
TEST(APIntTest, divrem_big5) { … }
TEST(APIntTest, divrem_big6) { … }
TEST(APIntTest, divrem_big7) { … }
void testDiv(APInt a, uint64_t b, APInt c) { … }
TEST(APIntTest, divremuint) { … }
TEST(APIntTest, divrem_simple) { … }
TEST(APIntTest, fromString) { … }
TEST(APIntTest, SaturatingMath) { … }
TEST(APIntTest, FromArray) { … }
TEST(APIntTest, StringBitsNeeded2) { … }
TEST(APIntTest, StringBitsNeeded8) { … }
TEST(APIntTest, StringBitsNeeded10) { … }
TEST(APIntTest, StringBitsNeeded16) { … }
TEST(APIntTest, toString) { … }
TEST(APIntTest, Log2) { … }
#ifdef GTEST_HAS_DEATH_TEST
#ifndef NDEBUG
TEST(APIntTest, StringDeath) {
EXPECT_DEATH((void)APInt(32, "", 0), "Invalid string length");
EXPECT_DEATH((void)APInt(32, "0", 0), "Radix should be 2, 8, 10, 16, or 36!");
EXPECT_DEATH((void)APInt(32, "", 10), "Invalid string length");
EXPECT_DEATH((void)APInt(32, "-", 10), "String is only a sign, needs a value.");
EXPECT_DEATH((void)APInt(1, "1234", 10), "Insufficient bit width");
EXPECT_DEATH((void)APInt(32, "\0", 10), "Invalid string length");
EXPECT_DEATH((void)APInt(32, StringRef("1\02", 3), 10), "Invalid character in digit string");
EXPECT_DEATH((void)APInt(32, "1L", 10), "Invalid character in digit string");
}
#endif
#endif
TEST(APIntTest, mul_clear) { … }
TEST(APIntTest, Rotate) { … }
TEST(APIntTest, Splat) { … }
TEST(APIntTest, tcDecrement) { … }
TEST(APIntTest, arrayAccess) { … }
TEST(APIntTest, LargeAPIntConstruction) { … }
TEST(APIntTest, nearestLogBase2) { … }
TEST(APIntTest, IsSplat) { … }
TEST(APIntTest, isMask) { … }
TEST(APIntTest, isShiftedMask) { … }
TEST(APIntTest, isOneBitSet) { … }
TEST(APIntTest, isPowerOf2) { … }
TEST(APIntTest, isNegatedPowerOf2) { … }
TEST(APIntTest, isAligned) { … }
#ifdef EXPENSIVE_CHECKS
#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunknown-pragmas"
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wself-move"
#endif
TEST(APIntTest, SelfMoveAssignment) {
APInt X(32, 0xdeadbeef);
X = std::move(X);
EXPECT_EQ(32u, X.getBitWidth());
EXPECT_EQ(0xdeadbeefULL, X.getLimitedValue());
uint64_t Bits[] = {0xdeadbeefdeadbeefULL, 0xdeadbeefdeadbeefULL};
APInt Y(128, Bits);
Y = std::move(Y);
EXPECT_EQ(128u, Y.getBitWidth());
EXPECT_EQ(~0ULL, Y.getLimitedValue());
const uint64_t *Raw = Y.getRawData();
EXPECT_EQ(2u, Y.getNumWords());
EXPECT_EQ(0xdeadbeefdeadbeefULL, Raw[0]);
EXPECT_EQ(0xdeadbeefdeadbeefULL, Raw[1]);
}
#if defined(__clang__)
#pragma clang diagnostic pop
#pragma clang diagnostic pop
#endif
#endif
TEST(APIntTest, byteSwap) { … }
TEST(APIntTest, reverseBits) { … }
TEST(APIntTest, insertBits) { … }
TEST(APIntTest, insertBitsUInt64) { … }
TEST(APIntTest, extractBits) { … }
TEST(APIntTest, extractBitsAsZExtValue) { … }
TEST(APIntTest, getLowBitsSet) { … }
TEST(APIntTest, getBitsSet) { … }
TEST(APIntTest, getBitsSetWithWrap) { … }
TEST(APIntTest, getHighBitsSet) { … }
TEST(APIntTest, getBitsSetFrom) { … }
TEST(APIntTest, setLowBits) { … }
TEST(APIntTest, setHighBits) { … }
TEST(APIntTest, setBitsFrom) { … }
TEST(APIntTest, setAllBits) { … }
TEST(APIntTest, getLoBits) { … }
TEST(APIntTest, getHiBits) { … }
TEST(APIntTest, clearLowBits) { … }
TEST(APIntTest, clearHighBits) { … }
TEST(APIntTest, abds) { … }
TEST(APIntTest, abdu) { … }
TEST(APIntTest, GCD) { … }
TEST(APIntTest, LogicalRightShift) { … }
TEST(APIntTest, ArithmeticRightShift) { … }
TEST(APIntTest, LeftShift) { … }
TEST(APIntTest, isSubsetOf) { … }
TEST(APIntTest, sext) { … }
TEST(APIntTest, trunc) { … }
TEST(APIntTest, concat) { … }
TEST(APIntTest, multiply) { … }
TEST(APIntOpsTest, Mulh) { … }
TEST(APIntTest, RoundingUDiv) { … }
TEST(APIntTest, RoundingSDiv) { … }
TEST(APIntTest, Average) { … }
TEST(APIntTest, umul_ov) { … }
TEST(APIntTest, smul_ov) { … }
TEST(APIntTest, sfloordiv_ov) { … }
TEST(APIntTest, SolveQuadraticEquationWrap) { … }
TEST(APIntTest, MultiplicativeInverseExaustive) { … }
TEST(APIntTest, GetMostSignificantDifferentBit) { … }
TEST(APIntTest, GetMostSignificantDifferentBitExaustive) { … }
TEST(APIntTest, SignbitZeroChecks) { … }
TEST(APIntTest, ZeroWidth) { … }
TEST(APIntTest, ScaleBitMask) { … }
TEST(APIntTest, DenseMap) { … }
TEST(APIntTest, TryExt) { … }
}