Commit 410a5cf9 authored by Al Muthanna Athamina's avatar Al Muthanna Athamina Committed by V8 LUCI CQ

Skip the readability/check rule on bigint directory

We want to skip the readability/check rule on the
bigint directory while keeping the rest of the linting.

Bug: v8:12024
Change-Id: I56f84554af9aa44d4436249916269b5441d4fbaa
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3264221Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Reviewed-by: 's avatarMichael Achenbach <machenbach@chromium.org>
Commit-Queue: Almothana Athamneh <almuthanna@chromium.org>
Cr-Commit-Position: refs/heads/main@{#77796}
parent 2b3df06b
filter=-readability/check
\ No newline at end of file
......@@ -52,7 +52,7 @@ void ProcessorImpl::Multiply(RWDigits Z, Digits X, Digits Y) {
void ProcessorImpl::Divide(RWDigits Q, Digits A, Digits B) {
A.Normalize();
B.Normalize();
DCHECK(B.len() > 0); // NOLINT(readability/check)
DCHECK(B.len() > 0);
int cmp = Compare(A, B);
if (cmp < 0) return Q.Clear();
if (cmp == 0) {
......@@ -82,7 +82,7 @@ void ProcessorImpl::Divide(RWDigits Q, Digits A, Digits B) {
void ProcessorImpl::Modulo(RWDigits R, Digits A, Digits B) {
A.Normalize();
B.Normalize();
DCHECK(B.len() > 0); // NOLINT(readability/check)
DCHECK(B.len() > 0);
int cmp = Compare(A, B);
if (cmp < 0) {
for (int i = 0; i < B.len(); i++) R[i] = B[i];
......
......@@ -33,8 +33,8 @@ void BitwiseAnd_NegNeg(RWDigits Z, Digits X, Digits Y) {
// (At least) one of the next two loops will perform zero iterations:
for (; i < X.len(); i++) Z[i] = digit_sub(X[i], x_borrow, &x_borrow);
for (; i < Y.len(); i++) Z[i] = digit_sub(Y[i], y_borrow, &y_borrow);
DCHECK(x_borrow == 0); // NOLINT(readability/check)
DCHECK(y_borrow == 0); // NOLINT(readability/check)
DCHECK(x_borrow == 0);
DCHECK(y_borrow == 0);
for (; i < Z.len(); i++) Z[i] = 0;
Add(Z, 1);
}
......@@ -83,7 +83,7 @@ void BitwiseOr_PosNeg(RWDigits Z, Digits X, Digits Y) {
int i = 0;
for (; i < pairs; i++) Z[i] = digit_sub(Y[i], borrow, &borrow) & ~X[i];
for (; i < Y.len(); i++) Z[i] = digit_sub(Y[i], borrow, &borrow);
DCHECK(borrow == 0); // NOLINT(readability/check)
DCHECK(borrow == 0);
for (; i < Z.len(); i++) Z[i] = 0;
Add(Z, 1);
}
......@@ -114,8 +114,8 @@ void BitwiseXor_NegNeg(RWDigits Z, Digits X, Digits Y) {
// (At least) one of the next two loops will perform zero iterations:
for (; i < X.len(); i++) Z[i] = digit_sub(X[i], x_borrow, &x_borrow);
for (; i < Y.len(); i++) Z[i] = digit_sub(Y[i], y_borrow, &y_borrow);
DCHECK(x_borrow == 0); // NOLINT(readability/check)
DCHECK(y_borrow == 0); // NOLINT(readability/check)
DCHECK(x_borrow == 0);
DCHECK(y_borrow == 0);
for (; i < Z.len(); i++) Z[i] = 0;
}
......@@ -128,7 +128,7 @@ void BitwiseXor_PosNeg(RWDigits Z, Digits X, Digits Y) {
// (At least) one of the next two loops will perform zero iterations:
for (; i < X.len(); i++) Z[i] = X[i];
for (; i < Y.len(); i++) Z[i] = digit_sub(Y[i], borrow, &borrow);
DCHECK(borrow == 0); // NOLINT(readability/check)
DCHECK(borrow == 0);
for (; i < Z.len(); i++) Z[i] = 0;
Add(Z, 1);
}
......@@ -175,7 +175,7 @@ void TruncateAndSubFromPowerOfTwo(RWDigits Z, Digits X, int n) {
msd = (msd << drop) >> drop;
digit_t minuend_msd = static_cast<digit_t>(1) << bits;
digit_t result_msd = digit_sub2(minuend_msd, msd, borrow, &borrow);
DCHECK(borrow == 0); // result < 2^n. NOLINT(readability/check)
DCHECK(borrow == 0); // result < 2^n.
// If all subtracted bits were zero, we have to get rid of the
// materialized minuend_msd again.
Z[last] = result_msd & (minuend_msd - 1);
......@@ -203,9 +203,8 @@ int AsIntNResultLength(Digits X, bool x_negative, int n) {
}
bool AsIntN(RWDigits Z, Digits X, bool x_negative, int n) {
DCHECK(X.len() > 0); // NOLINT(readability/check)
DCHECK(n > 0); // NOLINT(readability/check)
// NOLINTNEXTLINE(readability/check)
DCHECK(X.len() > 0);
DCHECK(n > 0);
DCHECK(AsIntNResultLength(X, x_negative, n) > 0);
int needed_digits = DIV_CEIL(n, kDigitBits);
digit_t top_digit = X[needed_digits - 1];
......@@ -250,7 +249,7 @@ int AsUintN_Pos_ResultLength(Digits X, int n) {
}
void AsUintN_Pos(RWDigits Z, Digits X, int n) {
DCHECK(AsUintN_Pos_ResultLength(X, n) > 0); // NOLINT(readability/check)
DCHECK(AsUintN_Pos_ResultLength(X, n) > 0);
TruncateToNBits(Z, X, n);
}
......
......@@ -118,7 +118,7 @@ static inline digit_t digit_div(digit_t high, digit_t low, digit_t divisor,
digit_t* remainder) {
#if defined(DCHECK)
DCHECK(high < divisor);
DCHECK(divisor != 0); // NOLINT(readability/check)
DCHECK(divisor != 0);
#endif
#if __x86_64__ && (__GNUC__ || __clang__)
digit_t quotient;
......
......@@ -41,7 +41,7 @@ void DcheckIntegerPartRange(Digits X, digit_t min, digit_t max) {
// See comments at {Invert} and {InvertNewton} below for details.
void ProcessorImpl::InvertBasecase(RWDigits Z, Digits V, RWDigits scratch) {
DCHECK(Z.len() > V.len());
DCHECK(V.len() > 0); // NOLINT(readability/check)
DCHECK(V.len() > 0);
DCHECK(scratch.len() >= 2 * V.len());
int n = V.len();
RWDigits X(scratch, 0, 2 * n);
......@@ -49,7 +49,7 @@ void ProcessorImpl::InvertBasecase(RWDigits Z, Digits V, RWDigits scratch) {
int i = 0;
for (; i < n; i++) X[i] = 0;
for (; i < 2 * n; i++) X[i] = digit_sub2(0, V[i - n], borrow, &borrow);
DCHECK(borrow == 1); // NOLINT(readability/check)
DCHECK(borrow == 1);
RWDigits R(nullptr, 0); // We don't need the remainder.
if (n < kBurnikelThreshold) {
DivideSchoolbook(Z, R, X, V);
......@@ -76,7 +76,7 @@ void ProcessorImpl::InvertNewton(RWDigits Z, Digits V, RWDigits scratch) {
const int kUOffset = vn + kInvertNewtonExtraSpace;
// The base case won't work otherwise.
DCHECK(V.len() >= 3); // NOLINT(readability/check)
DCHECK(V.len() >= 3);
constexpr int kBasecasePrecision = kNewtonInversionThreshold - 1;
// V must have more digits than the basecase.
......@@ -147,17 +147,17 @@ void ProcessorImpl::InvertNewton(RWDigits Z, Digits V, RWDigits scratch) {
if (U.len() <= vn) {
// Normal subtraction.
// This is not the last iteration.
DCHECK(iteration > 0); // NOLINT(readability/check)
DCHECK(iteration > 0);
Z.set_len(U.len());
digit_t borrow = SubtractAndReturnBorrow(Z, W, U);
DCHECK(borrow == 0); // NOLINT(readability/check)
DCHECK(borrow == 0);
USE(borrow);
DcheckIntegerPartRange(Z, 1, 2);
} else {
// Truncate some least significant digits so that we get vn
// fraction digits, and compute the integer digit separately.
// This is the last iteration.
DCHECK(iteration == 0); // NOLINT(readability/check)
DCHECK(iteration == 0);
Z.set_len(vn);
Digits W_part(W, W.len() - vn - 1, vn);
Digits U_part(U, U.len() - vn - 1, vn);
......@@ -186,7 +186,7 @@ void ProcessorImpl::InvertNewton(RWDigits Z, Digits V, RWDigits scratch) {
// Needs InvertScratchSpace(V.len) digits of scratch space.
void ProcessorImpl::Invert(RWDigits Z, Digits V, RWDigits scratch) {
DCHECK(Z.len() > V.len());
DCHECK(V.len() >= 1); // NOLINT(readability/check)
DCHECK(V.len() >= 1);
DCHECK(IsBitNormalized(V));
DCHECK(scratch.len() >= InvertScratchSpace(V.len()));
......@@ -218,7 +218,7 @@ void ProcessorImpl::DivideBarrett(RWDigits Q, RWDigits R, Digits A, Digits B,
DCHECK(R.len() >= B.len());
DCHECK(A.len() > B.len()); // Careful: This is *not* '>=' !
DCHECK(A.len() <= 2 * B.len());
DCHECK(B.len() > 0); // NOLINT(readability/check)
DCHECK(B.len() > 0);
DCHECK(IsBitNormalized(B));
DCHECK(I.len() == A.len() - B.len());
DCHECK(scratch.len() >= DivideBarrettScratchSpace(A.len()));
......@@ -257,7 +257,7 @@ void ProcessorImpl::DivideBarrett(RWDigits Q, RWDigits R, Digits A, Digits B,
do {
r_high += AddAndReturnCarry(R, R, B);
q_sub++;
DCHECK(q_sub <= 5); // NOLINT(readability/check)
DCHECK(q_sub <= 5);
} while (r_high != 0);
Subtract(Q, q_sub);
} else {
......@@ -266,7 +266,7 @@ void ProcessorImpl::DivideBarrett(RWDigits Q, RWDigits R, Digits A, Digits B,
// (5c): R >= B, so R -= B
r_high -= SubtractAndReturnBorrow(R, R, B);
q_add++;
DCHECK(q_add <= 5); // NOLINT(readability/check)
DCHECK(q_add <= 5);
}
Add(Q, q_add);
}
......@@ -281,7 +281,7 @@ void ProcessorImpl::DivideBarrett(RWDigits Q, RWDigits R, Digits A, Digits B) {
DCHECK(Q.len() > A.len() - B.len());
DCHECK(R.len() >= B.len());
DCHECK(A.len() > B.len()); // Careful: This is *not* '>=' !
DCHECK(B.len() > 0); // NOLINT(readability/check)
DCHECK(B.len() > 0);
// Normalize B, and shift A by the same amount.
ShiftedDigits b_normalized(B);
......@@ -312,7 +312,7 @@ void ProcessorImpl::DivideBarrett(RWDigits Q, RWDigits R, Digits A, Digits B) {
int n = B.len(); // Chunk length.
// (5): {t} is the number of B-sized chunks of A.
int t = DIV_CEIL(A.len(), n);
DCHECK(t >= 3); // NOLINT(readability/check)
DCHECK(t >= 3);
// (6)/(7): Z is used for the current 2-chunk block to be divided by B,
// initialized to the two topmost chunks of A.
int z_len = n * 2;
......@@ -334,7 +334,7 @@ void ProcessorImpl::DivideBarrett(RWDigits Q, RWDigits R, Digits A, Digits B) {
for (int j = to_copy; j < target.len(); j++) target[j] = 0;
#if DEBUG
for (int j = to_copy; j < Qi.len(); j++) {
DCHECK(Qi[j] == 0); // NOLINT(readability/check)
DCHECK(Qi[j] == 0);
}
#endif
}
......@@ -346,7 +346,7 @@ void ProcessorImpl::DivideBarrett(RWDigits Q, RWDigits R, Digits A, Digits B) {
PutAt(Z, A + n * i, n);
// (8a): Compute Qi, Ri such that Zi = B*Qi + Ri.
DivideBarrett(Qi, Ri, Z, B, I, scratch);
DCHECK(Qi[qi_len - 1] == 0); // NOLINT(readability/check)
DCHECK(Qi[qi_len - 1] == 0);
if (should_terminate()) return;
// (9): Return Q = [Q_(t-2), ..., Q_0]...
PutAt(Q + n * i, Qi, n);
......
......@@ -70,7 +70,7 @@ class BZ {
void BZ::DivideBasecase(RWDigits Q, RWDigits R, Digits A, Digits B) {
A.Normalize();
B.Normalize();
DCHECK(B.len() > 0); // NOLINT(readability/check)
DCHECK(B.len() > 0);
int cmp = Compare(A, B);
if (cmp <= 0) {
Q.Clear();
......@@ -94,11 +94,11 @@ void BZ::DivideBasecase(RWDigits Q, RWDigits R, Digits A, Digits B) {
// Returns Q(uotient) and R(emainder) for A/B, with B having two thirds
// the size of A = [A1, A2, A3].
void BZ::D3n2n(RWDigits Q, RWDigits R, Digits A1A2, Digits A3, Digits B) {
DCHECK((B.len() & 1) == 0); // NOLINT(readability/check)
DCHECK((B.len() & 1) == 0);
int n = B.len() / 2;
DCHECK(A1A2.len() == 2 * n);
// Actual condition is stricter than length: A < B * 2^(kDigitBits * n)
DCHECK(Compare(A1A2, B) < 0); // NOLINT(readability/check)
DCHECK(Compare(A1A2, B) < 0);
DCHECK(A3.len() == n);
DCHECK(Q.len() == n);
DCHECK(R.len() == 2 * n);
......@@ -126,7 +126,7 @@ void BZ::D3n2n(RWDigits Q, RWDigits R, Digits A1A2, Digits A3, Digits B) {
RWDigits temp = R1;
Subtract(temp, A1, B1);
temp.Normalize();
DCHECK(temp.len() <= 1); // NOLINT(readability/check)
DCHECK(temp.len() <= 1);
if (temp.len() > 0) r1_high = temp[0];
// Step 2: compute A2 + B1.
Digits A2(A1A2, 0, n);
......@@ -149,7 +149,7 @@ void BZ::D3n2n(RWDigits Q, RWDigits R, Digits A1A2, Digits A3, Digits B) {
// 5. Compute Rhat = R1*2^(kDigitBits * n) + A3 - D = [R1, A3] - D.
digit_t borrow = SubtractAndReturnBorrow(R, R, D);
DCHECK(borrow == r1_high);
DCHECK(Compare(R, B) < 0); // NOLINT(readability/check)
DCHECK(Compare(R, B) < 0);
(void)borrow;
// 7. Return R = Rhat, Q = Qhat.
}
......@@ -160,7 +160,7 @@ void BZ::D2n1n(RWDigits Q, RWDigits R, Digits A, Digits B) {
int n = B.len();
DCHECK(A.len() <= 2 * n);
// A < B * 2^(kDigitsBits * n)
DCHECK(Compare(Digits(A, n, n), B) < 0); // NOLINT(readability/check)
DCHECK(Compare(Digits(A, n, n), B) < 0);
DCHECK(Q.len() == n);
DCHECK(R.len() == n);
// 1. If n is odd or smaller than some convenient constant, compute Q and R
......@@ -264,7 +264,7 @@ void ProcessorImpl::DivideBurnikelZiegler(RWDigits Q, RWDigits R, Digits A,
// 9. Return Q = [Q_(t-2), ..., Q_0] and R = R_0 * 2^(-sigma).
#if DEBUG
for (int i = 0; i < digit_shift; i++) {
DCHECK(Ri[i] == 0); // NOLINT(readability/check)
DCHECK(Ri[i] == 0);
}
#endif
if (R.len() != 0) {
......
......@@ -23,7 +23,7 @@ void Copy(RWDigits Z, Digits X) {
// Z := X << shift
// Z and X may alias for an in-place shift.
void LeftShift(RWDigits Z, Digits X, int shift) {
DCHECK(shift >= 0); // NOLINT(readability/check)
DCHECK(shift >= 0);
DCHECK(shift < kDigitBits);
DCHECK(Z.len() >= X.len());
if (shift == 0) return Copy(Z, X);
......@@ -37,7 +37,7 @@ void LeftShift(RWDigits Z, Digits X, int shift) {
if (i < Z.len()) {
Z[i++] = carry;
} else {
DCHECK(carry == 0); // NOLINT(readability/check)
DCHECK(carry == 0);
}
for (; i < Z.len(); i++) Z[i] = 0;
}
......@@ -45,7 +45,7 @@ void LeftShift(RWDigits Z, Digits X, int shift) {
// Z := X >> shift
// Z and X may alias for an in-place shift.
void RightShift(RWDigits Z, Digits X, int shift) {
DCHECK(shift >= 0); // NOLINT(readability/check)
DCHECK(shift >= 0);
DCHECK(shift < kDigitBits);
X.Normalize();
DCHECK(Z.len() >= X.len());
......
......@@ -28,8 +28,8 @@ namespace bigint {
// Q may be the same as A for an in-place division.
void ProcessorImpl::DivideSingle(RWDigits Q, digit_t* remainder, Digits A,
digit_t b) {
DCHECK(b != 0); // NOLINT(readability/check)
DCHECK(A.len() > 0); // NOLINT(readability/check)
DCHECK(b != 0);
DCHECK(A.len() > 0);
*remainder = 0;
int length = A.len();
if (Q.len() != 0) {
......@@ -93,7 +93,6 @@ bool QLengthOK(Digits Q, Digits A, Digits B) {
// See Knuth, Volume 2, section 4.3.1, Algorithm D.
void ProcessorImpl::DivideSchoolbook(RWDigits Q, RWDigits R, Digits A,
Digits B) {
// NOLINTNEXTLINE(readability/check)
DCHECK(B.len() >= 2); // Use DivideSingle otherwise.
DCHECK(A.len() >= B.len()); // No-op otherwise.
DCHECK(Q.len() == 0 || QLengthOK(Q, A, B));
......@@ -173,7 +172,7 @@ void ProcessorImpl::DivideSchoolbook(RWDigits Q, RWDigits R, Digits A,
if (Q.len() != 0) {
if (j >= Q.len()) {
DCHECK(qhat == 0); // NOLINT(readability/check)
DCHECK(qhat == 0);
} else {
Q[j] = qhat;
}
......
......@@ -13,7 +13,7 @@ namespace bigint {
void ProcessorImpl::FromStringClassic(RWDigits Z,
FromStringAccumulator* accumulator) {
// We always have at least one part to process.
DCHECK(accumulator->stack_parts_used_ > 0); // NOLINT(readability/check)
DCHECK(accumulator->stack_parts_used_ > 0);
Z[0] = accumulator->stack_parts_[0];
RWDigits already_set(Z, 0, 1);
for (int i = 1; i < Z.len(); i++) Z[i] = 0;
......@@ -89,7 +89,7 @@ void ProcessorImpl::FromStringClassic(RWDigits Z,
void ProcessorImpl::FromStringLarge(RWDigits Z,
FromStringAccumulator* accumulator) {
int num_parts = static_cast<int>(accumulator->heap_parts_.size());
DCHECK(num_parts >= 2); // NOLINT(readability/check)
DCHECK(num_parts >= 2);
DCHECK(Z.len() >= num_parts);
RWDigits parts(accumulator->heap_parts_.data(), num_parts);
Storage multipliers_storage(num_parts);
......@@ -160,7 +160,7 @@ void ProcessorImpl::FromStringLarge(RWDigits Z,
Multiply(p_out, p_in, m_in2);
if (should_terminate()) return;
digit_t overflow = AddAndReturnOverflow(p_out, p_in2);
DCHECK(overflow == 0); // NOLINT(readability/check)
DCHECK(overflow == 0);
USE(overflow);
// m[j] = m[i] * m[i+1]
if (i > 0) {
......@@ -240,7 +240,7 @@ void ProcessorImpl::FromStringLarge(RWDigits Z,
void ProcessorImpl::FromStringBasePowerOfTwo(
RWDigits Z, FromStringAccumulator* accumulator) {
const int num_parts = accumulator->ResultLength();
DCHECK(num_parts >= 1); // NOLINT(readability/check)
DCHECK(num_parts >= 1);
DCHECK(Z.len() >= num_parts);
Digits parts(accumulator->heap_parts_.size() > 0
? accumulator->heap_parts_.data()
......@@ -259,7 +259,7 @@ void ProcessorImpl::FromStringBasePowerOfTwo(
// If the last part is fully populated, then all parts must be, and we can
// simply copy them (in reversed order).
if (unused_last_part_bits == 0) {
DCHECK(kDigitBits % char_bits == 0); // NOLINT(readability/check)
DCHECK(kDigitBits % char_bits == 0);
while (part_index >= 0) {
Z[z_index++] = parts[part_index--];
}
......
......@@ -207,7 +207,7 @@ void ShiftModFn(digit_t* result, const digit_t* input, int power_of_two, int K,
}
// Any remaining work can hard-code the knowledge that input[i] == 0.
for (; i < K - digit_shift; i++) {
DCHECK(input[i] == 0); // NOLINT(readability/check)
DCHECK(input[i] == 0);
result[i + digit_shift] = 0;
}
// Second phase: subtract input digits [iX] to [iK] from (virtually) zero-
......@@ -219,7 +219,7 @@ void ShiftModFn(digit_t* result, const digit_t* input, int power_of_two, int K,
}
// Any remaining work can hard-code the knowledge that input[i] == 0.
for (; i < K; i++) {
DCHECK(input[i] == 0); // NOLINT(readability/check)
DCHECK(input[i] == 0);
result[i - K + digit_shift] = digit_sub(0, borrow, &borrow);
}
// Last step: subtract [iK] from [i0] and store at result index digit_shift.
......@@ -238,7 +238,7 @@ void ShiftModFn(digit_t* result, const digit_t* input, int power_of_two, int K,
}
// Any remaining work can hard-code the knowledge that input[i] == 0.
for (; i < K - digit_shift; i++) {
DCHECK(input[i] == 0); // NOLINT(readability/check)
DCHECK(input[i] == 0);
result[i + digit_shift] = carry;
carry = 0;
}
......@@ -252,13 +252,13 @@ void ShiftModFn(digit_t* result, const digit_t* input, int power_of_two, int K,
}
// Any remaining work can hard-code the knowledge that input[i] == 0.
if (i < K) {
DCHECK(input[i] == 0); // NOLINT(readability/check)
DCHECK(input[i] == 0);
result[i - K + digit_shift] = digit_sub2(0, carry, borrow, &borrow);
carry = 0;
i++;
}
for (; i < K; i++) {
DCHECK(input[i] == 0); // NOLINT(readability/check)
DCHECK(input[i] == 0);
result[i - K + digit_shift] = digit_sub(0, borrow, &borrow);
}
// Last step: compute result[digit_shift].
......@@ -266,7 +266,7 @@ void ShiftModFn(digit_t* result, const digit_t* input, int power_of_two, int K,
result[digit_shift] = digit_sub2(
result[digit_shift], (d << bits_shift) | carry, borrow, &borrow);
// No carry left.
DCHECK((d >> (kDigitBits - bits_shift)) == 0); // NOLINT(readability/check)
DCHECK((d >> (kDigitBits - bits_shift)) == 0);
}
result[K] = 0;
for (int i = digit_shift + 1; i <= K && borrow > 0; i++) {
......@@ -324,8 +324,8 @@ void ComputeParameters(int N, int m, Parameters* params) {
K_tz = CountTrailingZeros(K);
}
DCHECK(K % kDigitBits == 0); // NOLINT(readability/check)
DCHECK(s % kDigitBits == 0); // NOLINT(readability/check)
DCHECK(K % kDigitBits == 0);
DCHECK(s % kDigitBits == 0);
params->K = K / kDigitBits;
params->s = s / kDigitBits;
params->n = n;
......@@ -347,8 +347,8 @@ void ComputeParameters_Inner(int N, Parameters* params) {
K = RoundUp(K, n); // ...and a multiple of n and kDigitBits.
K = RoundUp(K, kDigitBits);
params->r = K >> m; // Which multiple?
DCHECK(K % kDigitBits == 0); // NOLINT(readability/check)
DCHECK(s % kDigitBits == 0); // NOLINT(readability/check)
DCHECK(K % kDigitBits == 0);
DCHECK(s % kDigitBits == 0);
params->K = K / kDigitBits;
params->s = s / kDigitBits;
params->n = n;
......@@ -502,7 +502,7 @@ void FFTContainer::Start_Default(Digits X, int chunk_size, int theta,
// corner case where X[n_ * chunk_size] == 1. Detect that case, and handle
// the extra bit as part of the last chunk; we always have the space.
if (i == n_ - 1 && len == chunk_size + 1) {
DCHECK(X[n_ * chunk_size] <= 1); // NOLINT(readability/check)
DCHECK(X[n_ * chunk_size] <= 1);
DCHECK(length_ >= chunk_size + 1);
chunk_size++;
}
......@@ -517,7 +517,7 @@ void FFTContainer::Start_Default(Digits X, int chunk_size, int theta,
pointer += chunk_size;
len -= chunk_size;
}
DCHECK(len == 0); // NOLINT(readability/check)
DCHECK(len == 0);
for (; i < n_; i++) {
memset(part_[i], 0, part_length_in_bytes);
}
......@@ -531,7 +531,7 @@ void FFTContainer::Start(Digits X, int chunk_size, int theta, int omega) {
if (len > n_ * chunk_size / 2) {
return Start_Default(X, chunk_size, theta, omega);
}
DCHECK(theta == 0); // NOLINT(readability/check)
DCHECK(theta == 0);
const digit_t* pointer = X.digits();
const size_t part_length_in_bytes = length_ * sizeof(digit_t);
int nhalf = n_ / 2;
......@@ -562,7 +562,7 @@ void FFTContainer::Start(Digits X, int chunk_size, int theta, int omega) {
// need as input for the "DIT" aka "decimation in time" backwards transform.
void FFTContainer::FFT_ReturnShuffledThreadsafe(int start, int len, int omega,
digit_t* temp) {
DCHECK((len & 1) == 0); // {len} must be even. NOLINT(readability/check)
DCHECK((len & 1) == 0); // {len} must be even.
int half = len / 2;
SumDiff(part_[start], part_[start + half], part_[start], part_[start + half],
length_);
......@@ -592,7 +592,7 @@ void FFTContainer::BackwardFFT(int start, int len, int omega) {
void FFTContainer::BackwardFFT_Threadsafe(int start, int len, int omega,
digit_t* temp) {
DCHECK((len & 1) == 0); // {len} must be even. NOLINT(readability/check)
DCHECK((len & 1) == 0); // {len} must be even.
int half = len / 2;
// Don't recurse for half == 2, as PointwiseMultiply already performed
// the first level of the backwards FFT.
......@@ -626,7 +626,7 @@ void FFTContainer::NormalizeAndRecombine(int omega, int m, RWDigits Z,
Z[zi] = digit_add3(Z[zi], temp_[j], carry, &carry);
}
for (; j < length_; j++) {
DCHECK(temp_[j] == 0); // NOLINT(readability/check)
DCHECK(temp_[j] == 0);
}
if (carry != 0) {
DCHECK(zi < Z.len());
......@@ -654,7 +654,7 @@ void FFTContainer::CounterWeightAndRecombine(int theta, int m, RWDigits Z,
for (int k = 0; k < n_; k++, z_index += s) {
int shift = -theta * k - m;
if (shift < 0) shift += 2 * n_ * theta;
DCHECK(shift >= 0); // NOLINT(readability/check)
DCHECK(shift >= 0);
digit_t* input = part_[k];
ShiftModFn(temp_, input, shift, K_);
int remaining_z = Z.len() - z_index;
......@@ -679,7 +679,7 @@ void FFTContainer::CounterWeightAndRecombine(int theta, int m, RWDigits Z,
digit_t d = digit_sub2(1, temp_[i], borrow_Fn, &borrow_Fn);
Z[z_index + i] = digit_sub2(Z[z_index + i], d, borrow_z, &borrow_z);
}
DCHECK(borrow_Fn == 0); // NOLINT(readability/check)
DCHECK(borrow_Fn == 0);
for (; borrow_z > 0 && i < remaining_z; i++) {
Z[z_index + i] = digit_sub(Z[z_index + i], borrow_z, &borrow_z);
}
......@@ -690,7 +690,7 @@ void FFTContainer::CounterWeightAndRecombine(int theta, int m, RWDigits Z,
Z[z_index + i] = digit_add3(Z[z_index + i], temp_[i], carry, &carry);
}
for (; i < length_; i++) {
DCHECK(temp_[i] == 0); // NOLINT(readability/check)
DCHECK(temp_[i] == 0);
}
for (; carry > 0 && i < remaining_z; i++) {
Z[z_index + i] = digit_add2(Z[z_index + i], carry, &carry);
......
......@@ -82,7 +82,7 @@ void KaratsubaSubtractionHelper(RWDigits result, Digits X, Digits Y,
for (; i < X.len(); i++) {
result[i] = digit_sub(X[i], borrow, &borrow);
}
DCHECK(borrow == 0); // NOLINT(readability/check)
DCHECK(borrow == 0);
for (; i < result.len(); i++) result[i] = 0;
}
......@@ -160,7 +160,7 @@ void ProcessorImpl::KaratsubaMain(RWDigits Z, Digits X, Digits Y,
}
}
DCHECK(scratch.len() >= 4 * n);
DCHECK((n & 1) == 0); // NOLINT(readability/check)
DCHECK((n & 1) == 0);
int n2 = n >> 1;
Digits X0(X, 0, n2);
Digits X1(X, n2, n2);
......@@ -178,7 +178,7 @@ void ProcessorImpl::KaratsubaMain(RWDigits Z, Digits X, Digits Y,
int end = std::min(Z2.len(), P2.len());
for (int i = 0; i < end; i++) Z2[i] = P2[i];
for (int i = end; i < n; i++) {
DCHECK(P2[i] == 0); // NOLINT(readability/check)
DCHECK(P2[i] == 0);
}
// The intermediate result can be one digit too large; the subtraction
// below will fix this.
......@@ -197,7 +197,7 @@ void ProcessorImpl::KaratsubaMain(RWDigits Z, Digits X, Digits Y,
overflow -= SubAndReturnBorrow(Z + n2, P1);
}
// The intermediate result may have been bigger, but the final result fits.
DCHECK(overflow == 0); // NOLINT(readability/check)
DCHECK(overflow == 0);
USE(overflow);
}
......
......@@ -11,7 +11,7 @@ namespace bigint {
// Z := X * y, where y is a single digit.
void ProcessorImpl::MultiplySingle(RWDigits Z, Digits X, digit_t y) {
DCHECK(y != 0); // NOLINT(readability/check)
DCHECK(y != 0);
digit_t carry = 0;
digit_t high = 0;
for (int i = 0; i < X.len(); i++) {
......@@ -87,7 +87,7 @@ void ProcessorImpl::MultiplySchoolbook(RWDigits Z, Digits X, Digits Y) {
}
// Write the last digit, and zero out any extra space in Z.
Z[i++] = digit_add2(next, carry, &carry);
DCHECK(carry == 0); // NOLINT(readability/check)
DCHECK(carry == 0);
for (; i < Z.len(); i++) Z[i] = 0;
}
......
......@@ -56,7 +56,7 @@ constexpr digit_t digit_pow_rec(digit_t base, digit_t exponent) {
template <int radix>
char* BasecaseFixedLast(digit_t chunk, char* out) {
while (chunk != 0) {
DCHECK(*(out - 1) == kStringZapValue); // NOLINT(readability/check)
DCHECK(*(out - 1) == kStringZapValue);
if (radix <= 10) {
*(--out) = '0' + (chunk % radix);
} else {
......@@ -94,7 +94,7 @@ char* DivideByMagic(RWDigits rest, Digits input, char* output) {
}
// {remainder} is now the current chunk to be written out.
for (int i = 0; i < chunk_chars; i++) {
DCHECK(*(output - 1) == kStringZapValue); // NOLINT(readability/check)
DCHECK(*(output - 1) == kStringZapValue);
if (radix <= 10) {
*(--output) = '0' + (remainder % radix);
} else {
......@@ -102,7 +102,7 @@ char* DivideByMagic(RWDigits rest, Digits input, char* output) {
}
remainder /= radix;
}
DCHECK(remainder == 0); // NOLINT(readability/check)
DCHECK(remainder == 0);
return output;
}
......@@ -182,7 +182,7 @@ class ToStringFormatter {
char* BasecaseLast(digit_t digit, char* out) {
if (radix_ == 10) return BasecaseFixedLast<10>(digit, out);
do {
DCHECK(*(out - 1) == kStringZapValue); // NOLINT(readability/check)
DCHECK(*(out - 1) == kStringZapValue);
*(--out) = kConversionChars[digit % radix_];
digit /= radix_;
} while (digit > 0);
......@@ -193,11 +193,11 @@ class ToStringFormatter {
// same number of characters (as many '0' as necessary).
char* BasecaseMiddle(digit_t digit, char* out) {
for (int i = 0; i < chunk_chars_; i++) {
DCHECK(*(out - 1) == kStringZapValue); // NOLINT(readability/check)
DCHECK(*(out - 1) == kStringZapValue);
*(--out) = kConversionChars[digit % radix_];
digit /= radix_;
}
DCHECK(digit == 0); // NOLINT(readability/check)
DCHECK(digit == 0);
return out;
}
......@@ -221,7 +221,7 @@ void ToStringFormatter::Start() {
chunk_chars_ = kDigitBits * kBitsPerCharTableMultiplier / max_bits_per_char_;
chunk_divisor_ = digit_pow(radix_, chunk_chars_);
// By construction of chunk_chars_, there can't have been overflow.
DCHECK(chunk_divisor_ != 0); // NOLINT(readability/check)
DCHECK(chunk_divisor_ != 0);
}
int ToStringFormatter::Finish() {
......@@ -411,7 +411,7 @@ void RecursionLevel::ComputeInverse(ProcessorImpl* processor,
}
Digits RecursionLevel::GetInverse(int dividend_length) {
DCHECK(inverse_.len() != 0); // NOLINT(readability/check)
DCHECK(inverse_.len() != 0);
int inverse_len = dividend_length - divisor_.len();
DCHECK(inverse_len <= inverse_.len());
return inverse_ + (inverse_.len() - inverse_len);
......@@ -484,7 +484,7 @@ char* ToStringFormatter::ProcessLevel(RecursionLevel* level, Digits chunk,
chunk = original_chunk;
out = ProcessLevel(level->next_, chunk, out, is_last_on_level);
} else {
DCHECK(comparison == 0); // NOLINT(readability/check)
DCHECK(comparison == 0);
// If the chunk is equal to the divisor, we know that the right half
// is all '0', and the left half is '...0001'.
// Handling this case specially is an optimization; we could also
......
......@@ -68,7 +68,7 @@ void Subtract(RWDigits Z, Digits X, Digits Y) {
for (; i < X.len(); i++) {
Z[i] = digit_sub(X[i], borrow, &borrow);
}
DCHECK(borrow == 0); // NOLINT(readability/check)
DCHECK(borrow == 0);
for (; i < Z.len(); i++) Z[i] = 0;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment