Commit ecfd167d authored by Jakob Kummerow's avatar Jakob Kummerow Committed by V8 LUCI CQ

[cleanup] Fix -Wshadow in src/numbers/

Bug: v8:12244,v8:12245
Change-Id: Ida2dc91b10f708ded9cb71d140bf26673b1442bc
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3183166
Auto-Submit: Jakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/main@{#77078}
parent 3530299c
......@@ -670,19 +670,19 @@ double InternalStringToDouble(Iterator current, EndMark end, int flags,
int insignificant_digits = 0;
bool nonzero_digit_dropped = false;
enum Sign { NONE, NEGATIVE, POSITIVE };
enum class Sign { kNone, kNegative, kPositive };
Sign sign = NONE;
Sign sign = Sign::kNone;
if (*current == '+') {
// Ignore leading sign.
++current;
if (current == end) return JunkStringValue();
sign = POSITIVE;
sign = Sign::kPositive;
} else if (*current == '-') {
++current;
if (current == end) return JunkStringValue();
sign = NEGATIVE;
sign = Sign::kNegative;
}
static const char kInfinityString[] = "Infinity";
......@@ -696,20 +696,20 @@ double InternalStringToDouble(Iterator current, EndMark end, int flags,
}
DCHECK_EQ(buffer_pos, 0);
return (sign == NEGATIVE) ? -V8_INFINITY : V8_INFINITY;
return (sign == Sign::kNegative) ? -V8_INFINITY : V8_INFINITY;
}
bool leading_zero = false;
if (*current == '0') {
++current;
if (current == end) return SignedZero(sign == NEGATIVE);
if (current == end) return SignedZero(sign == Sign::kNegative);
leading_zero = true;
// It could be hexadecimal value.
if ((flags & ALLOW_HEX) && (*current == 'x' || *current == 'X')) {
++current;
if (current == end || !isDigit(*current, 16) || sign != NONE) {
if (current == end || !isDigit(*current, 16) || sign != Sign::kNone) {
return JunkStringValue(); // "0x".
}
......@@ -719,7 +719,7 @@ double InternalStringToDouble(Iterator current, EndMark end, int flags,
// It could be an explicit octal value.
} else if ((flags & ALLOW_OCTAL) && (*current == 'o' || *current == 'O')) {
++current;
if (current == end || !isDigit(*current, 8) || sign != NONE) {
if (current == end || !isDigit(*current, 8) || sign != Sign::kNone) {
return JunkStringValue(); // "0o".
}
......@@ -729,7 +729,7 @@ double InternalStringToDouble(Iterator current, EndMark end, int flags,
// It could be a binary value.
} else if ((flags & ALLOW_BINARY) && (*current == 'b' || *current == 'B')) {
++current;
if (current == end || !isBinaryDigit(*current) || sign != NONE) {
if (current == end || !isBinaryDigit(*current) || sign != Sign::kNone) {
return JunkStringValue(); // "0b".
}
......@@ -740,7 +740,7 @@ double InternalStringToDouble(Iterator current, EndMark end, int flags,
// Ignore leading zeros in the integer part.
while (*current == '0') {
++current;
if (current == end) return SignedZero(sign == NEGATIVE);
if (current == end) return SignedZero(sign == Sign::kNegative);
}
}
......@@ -785,7 +785,7 @@ double InternalStringToDouble(Iterator current, EndMark end, int flags,
// leading zeros (if any).
while (*current == '0') {
++current;
if (current == end) return SignedZero(sign == NEGATIVE);
if (current == end) return SignedZero(sign == Sign::kNegative);
exponent--; // Move this 0 into the exponent.
}
}
......@@ -826,9 +826,9 @@ double InternalStringToDouble(Iterator current, EndMark end, int flags,
return JunkStringValue();
}
}
char sign = '+';
char exponent_sign = '+';
if (*current == '+' || *current == '-') {
sign = static_cast<char>(*current);
exponent_sign = static_cast<char>(*current);
++current;
if (current == end) {
if (allow_trailing_junk) {
......@@ -862,7 +862,7 @@ double InternalStringToDouble(Iterator current, EndMark end, int flags,
++current;
} while (current != end && *current >= '0' && *current <= '9');
exponent += (sign == '-' ? -num : num);
exponent += (exponent_sign == '-' ? -num : num);
}
if (!allow_trailing_junk && AdvanceToNonspace(&current, end)) {
......@@ -874,7 +874,8 @@ parsing_done:
if (octal) {
return InternalStringToIntDouble<3>(buffer, buffer + buffer_pos,
sign == NEGATIVE, allow_trailing_junk);
sign == Sign::kNegative,
allow_trailing_junk);
}
if (nonzero_digit_dropped) {
......@@ -887,7 +888,7 @@ parsing_done:
double converted =
Strtod(base::Vector<const char>(buffer, buffer_pos), exponent);
return (sign == NEGATIVE) ? -converted : converted;
return (sign == Sign::kNegative) ? -converted : converted;
}
double StringToDouble(const char* str, int flags, double empty_string_val) {
......@@ -1363,7 +1364,7 @@ char* DoubleToRadixCString(double value, int radix) {
}
char c = buffer[fraction_cursor];
// Reconstruct digit.
int digit = c > '9' ? (c - 'a' + 10) : (c - '0');
digit = c > '9' ? (c - 'a' + 10) : (c - '0');
if (digit + 1 < radix) {
buffer[fraction_cursor++] = chars[digit + 1];
break;
......
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