Commit 3777f419 authored by Frank Tang's avatar Frank Tang Committed by Commit Bot

Remove unnecessary COUNT from enum

Bug: v8:9523
Change-Id: Ib9d6772d2025b0452ddcd777cc777276f9038e97
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1710960Reviewed-by: 's avatarAdam Klein <adamk@chromium.org>
Commit-Queue: Frank Tang <ftang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62836}
parent 27b68b8e
...@@ -25,7 +25,6 @@ inline JSV8BreakIterator::Type JSV8BreakIterator::type() const { ...@@ -25,7 +25,6 @@ inline JSV8BreakIterator::Type JSV8BreakIterator::type() const {
} }
inline void JSV8BreakIterator::set_type(Type type) { inline void JSV8BreakIterator::set_type(Type type) {
DCHECK_GT(JSV8BreakIterator::Type::COUNT, type);
set_raw_type(static_cast<int>(type)); set_raw_type(static_cast<int>(type));
} }
......
...@@ -146,9 +146,8 @@ Handle<String> JSV8BreakIterator::TypeAsString() const { ...@@ -146,9 +146,8 @@ Handle<String> JSV8BreakIterator::TypeAsString() const {
return GetReadOnlyRoots().sentence_string_handle(); return GetReadOnlyRoots().sentence_string_handle();
case Type::LINE: case Type::LINE:
return GetReadOnlyRoots().line_string_handle(); return GetReadOnlyRoots().line_string_handle();
case Type::COUNT:
UNREACHABLE();
} }
UNREACHABLE();
} }
Handle<Object> JSV8BreakIterator::Current( Handle<Object> JSV8BreakIterator::Current(
......
...@@ -51,7 +51,7 @@ class JSV8BreakIterator : public JSObject { ...@@ -51,7 +51,7 @@ class JSV8BreakIterator : public JSObject {
static String BreakType(Isolate* isolate, static String BreakType(Isolate* isolate,
Handle<JSV8BreakIterator> break_iterator); Handle<JSV8BreakIterator> break_iterator);
enum class Type { CHARACTER, WORD, SENTENCE, LINE, COUNT }; enum class Type { CHARACTER, WORD, SENTENCE, LINE };
inline void set_type(Type type); inline void set_type(Type type);
inline Type type() const; inline Type type() const;
......
...@@ -27,7 +27,7 @@ ACCESSORS(JSListFormat, icu_formatter, Managed<icu::ListFormatter>, ...@@ -27,7 +27,7 @@ ACCESSORS(JSListFormat, icu_formatter, Managed<icu::ListFormatter>,
SMI_ACCESSORS(JSListFormat, flags, kFlagsOffset) SMI_ACCESSORS(JSListFormat, flags, kFlagsOffset)
inline void JSListFormat::set_style(Style style) { inline void JSListFormat::set_style(Style style) {
DCHECK_GT(Style::COUNT, style); DCHECK_GE(StyleBits::kMax, style);
int hints = flags(); int hints = flags();
hints = StyleBits::update(hints, style); hints = StyleBits::update(hints, style);
set_flags(hints); set_flags(hints);
...@@ -38,7 +38,7 @@ inline JSListFormat::Style JSListFormat::style() const { ...@@ -38,7 +38,7 @@ inline JSListFormat::Style JSListFormat::style() const {
} }
inline void JSListFormat::set_type(Type type) { inline void JSListFormat::set_type(Type type) {
DCHECK_GT(Type::COUNT, type); DCHECK_GE(TypeBits::kMax, type);
int hints = flags(); int hints = flags();
hints = TypeBits::update(hints, type); hints = TypeBits::update(hints, type);
set_flags(hints); set_flags(hints);
......
...@@ -50,8 +50,6 @@ const char* GetIcuStyleString(JSListFormat::Style style, ...@@ -50,8 +50,6 @@ const char* GetIcuStyleString(JSListFormat::Style style,
return kStandardShort; return kStandardShort;
case JSListFormat::Style::NARROW: case JSListFormat::Style::NARROW:
return kStandardNarrow; return kStandardNarrow;
case JSListFormat::Style::COUNT:
UNREACHABLE();
} }
case JSListFormat::Type::DISJUNCTION: case JSListFormat::Type::DISJUNCTION:
switch (style) { switch (style) {
...@@ -61,8 +59,6 @@ const char* GetIcuStyleString(JSListFormat::Style style, ...@@ -61,8 +59,6 @@ const char* GetIcuStyleString(JSListFormat::Style style,
return kOrShort; return kOrShort;
case JSListFormat::Style::NARROW: case JSListFormat::Style::NARROW:
return kOrNarrow; return kOrNarrow;
case JSListFormat::Style::COUNT:
UNREACHABLE();
} }
case JSListFormat::Type::UNIT: case JSListFormat::Type::UNIT:
switch (style) { switch (style) {
...@@ -72,12 +68,9 @@ const char* GetIcuStyleString(JSListFormat::Style style, ...@@ -72,12 +68,9 @@ const char* GetIcuStyleString(JSListFormat::Style style,
return kUnitShort; return kUnitShort;
case JSListFormat::Style::NARROW: case JSListFormat::Style::NARROW:
return kUnitNarrow; return kUnitNarrow;
case JSListFormat::Style::COUNT:
UNREACHABLE();
} }
case JSListFormat::Type::COUNT:
UNREACHABLE();
} }
UNREACHABLE();
} }
} // namespace } // namespace
...@@ -238,9 +231,8 @@ Handle<String> JSListFormat::StyleAsString() const { ...@@ -238,9 +231,8 @@ Handle<String> JSListFormat::StyleAsString() const {
return GetReadOnlyRoots().short_string_handle(); return GetReadOnlyRoots().short_string_handle();
case Style::NARROW: case Style::NARROW:
return GetReadOnlyRoots().narrow_string_handle(); return GetReadOnlyRoots().narrow_string_handle();
case Style::COUNT:
UNREACHABLE();
} }
UNREACHABLE();
} }
Handle<String> JSListFormat::TypeAsString() const { Handle<String> JSListFormat::TypeAsString() const {
...@@ -251,9 +243,8 @@ Handle<String> JSListFormat::TypeAsString() const { ...@@ -251,9 +243,8 @@ Handle<String> JSListFormat::TypeAsString() const {
return GetReadOnlyRoots().disjunction_string_handle(); return GetReadOnlyRoots().disjunction_string_handle();
case Type::UNIT: case Type::UNIT:
return GetReadOnlyRoots().unit_string_handle(); return GetReadOnlyRoots().unit_string_handle();
case Type::COUNT:
UNREACHABLE();
} }
UNREACHABLE();
} }
namespace { namespace {
......
...@@ -64,10 +64,9 @@ class JSListFormat : public JSObject { ...@@ -64,10 +64,9 @@ class JSListFormat : public JSObject {
// //
// ecma402/#sec-properties-of-intl-listformat-instances // ecma402/#sec-properties-of-intl-listformat-instances
enum class Style { enum class Style {
LONG, // Everything spelled out. LONG, // Everything spelled out.
SHORT, // Abbreviations used when possible. SHORT, // Abbreviations used when possible.
NARROW, // Use the shortest possible form. NARROW // Use the shortest possible form.
COUNT
}; };
inline void set_style(Style style); inline void set_style(Style style);
inline Style style() const; inline Style style() const;
...@@ -78,8 +77,7 @@ class JSListFormat : public JSObject { ...@@ -78,8 +77,7 @@ class JSListFormat : public JSObject {
enum class Type { enum class Type {
CONJUNCTION, // for "and"-based lists (e.g., "A, B and C") CONJUNCTION, // for "and"-based lists (e.g., "A, B and C")
DISJUNCTION, // for "or"-based lists (e.g., "A, B or C"), DISJUNCTION, // for "or"-based lists (e.g., "A, B or C"),
UNIT, // for lists of values with units (e.g., "5 pounds, 12 ounces"). UNIT // for lists of values with units (e.g., "5 pounds, 12 ounces").
COUNT
}; };
inline void set_type(Type type); inline void set_type(Type type);
inline Type type() const; inline Type type() const;
......
...@@ -30,7 +30,7 @@ ACCESSORS(JSPluralRules, icu_number_formatter, ...@@ -30,7 +30,7 @@ ACCESSORS(JSPluralRules, icu_number_formatter,
kIcuNumberFormatterOffset) kIcuNumberFormatterOffset)
inline void JSPluralRules::set_type(Type type) { inline void JSPluralRules::set_type(Type type) {
DCHECK_LT(type, Type::COUNT); DCHECK_LE(type, TypeBits::kMax);
int hints = flags(); int hints = flags();
hints = TypeBits::update(hints, type); hints = TypeBits::update(hints, type);
set_flags(hints); set_flags(hints);
......
...@@ -55,9 +55,8 @@ Handle<String> JSPluralRules::TypeAsString() const { ...@@ -55,9 +55,8 @@ Handle<String> JSPluralRules::TypeAsString() const {
return GetReadOnlyRoots().cardinal_string_handle(); return GetReadOnlyRoots().cardinal_string_handle();
case Type::ORDINAL: case Type::ORDINAL:
return GetReadOnlyRoots().ordinal_string_handle(); return GetReadOnlyRoots().ordinal_string_handle();
case Type::COUNT:
UNREACHABLE();
} }
UNREACHABLE();
} }
// static // static
......
...@@ -47,12 +47,7 @@ class JSPluralRules : public JSObject { ...@@ -47,12 +47,7 @@ class JSPluralRules : public JSObject {
// [[Type]] is one of the values "cardinal" or "ordinal", // [[Type]] is one of the values "cardinal" or "ordinal",
// identifying the plural rules used. // identifying the plural rules used.
enum class Type { enum class Type { CARDINAL, ORDINAL };
CARDINAL,
ORDINAL,
COUNT
};
inline void set_type(Type type); inline void set_type(Type type);
inline Type type() const; inline Type type() const;
......
...@@ -27,7 +27,7 @@ ACCESSORS(JSRelativeTimeFormat, icu_formatter, ...@@ -27,7 +27,7 @@ ACCESSORS(JSRelativeTimeFormat, icu_formatter,
SMI_ACCESSORS(JSRelativeTimeFormat, flags, kFlagsOffset) SMI_ACCESSORS(JSRelativeTimeFormat, flags, kFlagsOffset)
inline void JSRelativeTimeFormat::set_style(Style style) { inline void JSRelativeTimeFormat::set_style(Style style) {
DCHECK_GT(Style::COUNT, style); DCHECK_GE(StyleBits::kMax, style);
int hints = flags(); int hints = flags();
hints = StyleBits::update(hints, style); hints = StyleBits::update(hints, style);
set_flags(hints); set_flags(hints);
...@@ -38,7 +38,7 @@ inline JSRelativeTimeFormat::Style JSRelativeTimeFormat::style() const { ...@@ -38,7 +38,7 @@ inline JSRelativeTimeFormat::Style JSRelativeTimeFormat::style() const {
} }
inline void JSRelativeTimeFormat::set_numeric(Numeric numeric) { inline void JSRelativeTimeFormat::set_numeric(Numeric numeric) {
DCHECK_GT(Numeric::COUNT, numeric); DCHECK_GE(NumericBits::kMax, numeric);
int hints = flags(); int hints = flags();
hints = NumericBits::update(hints, numeric); hints = NumericBits::update(hints, numeric);
set_flags(hints); set_flags(hints);
......
...@@ -34,9 +34,8 @@ UDateRelativeDateTimeFormatterStyle getIcuStyle( ...@@ -34,9 +34,8 @@ UDateRelativeDateTimeFormatterStyle getIcuStyle(
return UDAT_STYLE_SHORT; return UDAT_STYLE_SHORT;
case JSRelativeTimeFormat::Style::NARROW: case JSRelativeTimeFormat::Style::NARROW:
return UDAT_STYLE_NARROW; return UDAT_STYLE_NARROW;
case JSRelativeTimeFormat::Style::COUNT:
UNREACHABLE();
} }
UNREACHABLE();
} }
} // namespace } // namespace
...@@ -220,9 +219,8 @@ Handle<String> JSRelativeTimeFormat::StyleAsString() const { ...@@ -220,9 +219,8 @@ Handle<String> JSRelativeTimeFormat::StyleAsString() const {
return GetReadOnlyRoots().short_string_handle(); return GetReadOnlyRoots().short_string_handle();
case Style::NARROW: case Style::NARROW:
return GetReadOnlyRoots().narrow_string_handle(); return GetReadOnlyRoots().narrow_string_handle();
case Style::COUNT:
UNREACHABLE();
} }
UNREACHABLE();
} }
Handle<String> JSRelativeTimeFormat::NumericAsString() const { Handle<String> JSRelativeTimeFormat::NumericAsString() const {
...@@ -231,9 +229,8 @@ Handle<String> JSRelativeTimeFormat::NumericAsString() const { ...@@ -231,9 +229,8 @@ Handle<String> JSRelativeTimeFormat::NumericAsString() const {
return GetReadOnlyRoots().always_string_handle(); return GetReadOnlyRoots().always_string_handle();
case Numeric::AUTO: case Numeric::AUTO:
return GetReadOnlyRoots().auto_string_handle(); return GetReadOnlyRoots().auto_string_handle();
case Numeric::COUNT:
UNREACHABLE();
} }
UNREACHABLE();
} }
namespace { namespace {
......
...@@ -66,10 +66,9 @@ class JSRelativeTimeFormat : public JSObject { ...@@ -66,10 +66,9 @@ class JSRelativeTimeFormat : public JSObject {
// ecma402/#sec-properties-of-intl-relativetimeformat-instances // ecma402/#sec-properties-of-intl-relativetimeformat-instances
enum class Style { enum class Style {
LONG, // Everything spelled out. LONG, // Everything spelled out.
SHORT, // Abbreviations used when possible. SHORT, // Abbreviations used when possible.
NARROW, // Use the shortest possible form. NARROW // Use the shortest possible form.
COUNT
}; };
inline void set_style(Style style); inline void set_style(Style style);
inline Style style() const; inline Style style() const;
...@@ -81,9 +80,8 @@ class JSRelativeTimeFormat : public JSObject { ...@@ -81,9 +80,8 @@ class JSRelativeTimeFormat : public JSObject {
// ecma402/#sec-properties-of-intl-relativetimeformat-instances // ecma402/#sec-properties-of-intl-relativetimeformat-instances
enum class Numeric { enum class Numeric {
ALWAYS, // numerical descriptions are always used ("1 day ago") ALWAYS, // numerical descriptions are always used ("1 day ago")
AUTO, // numerical descriptions are used only when no more specific AUTO // numerical descriptions are used only when no more specific
// version is available ("yesterday") // version is available ("yesterday")
COUNT
}; };
inline void set_numeric(Numeric numeric); inline void set_numeric(Numeric numeric);
inline Numeric numeric() const; inline Numeric numeric() const;
......
...@@ -35,7 +35,7 @@ CAST_ACCESSOR(JSSegmentIterator) ...@@ -35,7 +35,7 @@ CAST_ACCESSOR(JSSegmentIterator)
inline void JSSegmentIterator::set_granularity( inline void JSSegmentIterator::set_granularity(
JSSegmenter::Granularity granularity) { JSSegmenter::Granularity granularity) {
DCHECK_GT(JSSegmenter::Granularity::COUNT, granularity); DCHECK_GE(GranularityBits::kMax, granularity);
int hints = flags(); int hints = flags();
hints = GranularityBits::update(hints, granularity); hints = GranularityBits::update(hints, granularity);
set_flags(hints); set_flags(hints);
......
...@@ -37,9 +37,8 @@ Handle<String> JSSegmentIterator::GranularityAsString() const { ...@@ -37,9 +37,8 @@ Handle<String> JSSegmentIterator::GranularityAsString() const {
return GetReadOnlyRoots().word_string_handle(); return GetReadOnlyRoots().word_string_handle();
case JSSegmenter::Granularity::SENTENCE: case JSSegmenter::Granularity::SENTENCE:
return GetReadOnlyRoots().sentence_string_handle(); return GetReadOnlyRoots().sentence_string_handle();
case JSSegmenter::Granularity::COUNT:
UNREACHABLE();
} }
UNREACHABLE();
} }
MaybeHandle<JSSegmentIterator> JSSegmentIterator::Create( MaybeHandle<JSSegmentIterator> JSSegmentIterator::Create(
...@@ -122,9 +121,8 @@ Handle<Object> JSSegmentIterator::BreakType() const { ...@@ -122,9 +121,8 @@ Handle<Object> JSSegmentIterator::BreakType() const {
return GetReadOnlyRoots().sep_string_handle(); return GetReadOnlyRoots().sep_string_handle();
} }
return GetReadOnlyRoots().undefined_value_handle(); return GetReadOnlyRoots().undefined_value_handle();
case JSSegmenter::Granularity::COUNT:
UNREACHABLE();
} }
UNREACHABLE();
} }
// ecma402 #sec-segment-iterator-prototype-index // ecma402 #sec-segment-iterator-prototype-index
......
...@@ -27,7 +27,7 @@ ACCESSORS(JSSegmenter, icu_break_iterator, Managed<icu::BreakIterator>, ...@@ -27,7 +27,7 @@ ACCESSORS(JSSegmenter, icu_break_iterator, Managed<icu::BreakIterator>,
SMI_ACCESSORS(JSSegmenter, flags, kFlagsOffset) SMI_ACCESSORS(JSSegmenter, flags, kFlagsOffset)
inline void JSSegmenter::set_granularity(Granularity granularity) { inline void JSSegmenter::set_granularity(Granularity granularity) {
DCHECK_GT(Granularity::COUNT, granularity); DCHECK_GE(GranularityBits::kMax, granularity);
int hints = flags(); int hints = flags();
hints = GranularityBits::update(hints, granularity); hints = GranularityBits::update(hints, granularity);
set_flags(hints); set_flags(hints);
......
...@@ -99,8 +99,6 @@ MaybeHandle<JSSegmenter> JSSegmenter::New(Isolate* isolate, Handle<Map> map, ...@@ -99,8 +99,6 @@ MaybeHandle<JSSegmenter> JSSegmenter::New(Isolate* isolate, Handle<Map> map,
icu_break_iterator.reset( icu_break_iterator.reset(
icu::BreakIterator::createSentenceInstance(icu_locale, status)); icu::BreakIterator::createSentenceInstance(icu_locale, status));
break; break;
case Granularity::COUNT:
UNREACHABLE();
} }
CHECK(U_SUCCESS(status)); CHECK(U_SUCCESS(status));
...@@ -161,9 +159,8 @@ Handle<String> JSSegmenter::GranularityAsString() const { ...@@ -161,9 +159,8 @@ Handle<String> JSSegmenter::GranularityAsString() const {
return GetReadOnlyRoots().word_string_handle(); return GetReadOnlyRoots().word_string_handle();
case Granularity::SENTENCE: case Granularity::SENTENCE:
return GetReadOnlyRoots().sentence_string_handle(); return GetReadOnlyRoots().sentence_string_handle();
case Granularity::COUNT:
UNREACHABLE();
} }
UNREACHABLE();
} }
const std::set<std::string>& JSSegmenter::GetAvailableLocales() { const std::set<std::string>& JSSegmenter::GetAvailableLocales() {
......
...@@ -56,8 +56,7 @@ class JSSegmenter : public JSObject { ...@@ -56,8 +56,7 @@ class JSSegmenter : public JSObject {
enum class Granularity { enum class Granularity {
GRAPHEME, // for character-breaks GRAPHEME, // for character-breaks
WORD, // for word-breaks WORD, // for word-breaks
SENTENCE, // for sentence-breaks SENTENCE // for sentence-breaks
COUNT
}; };
inline void set_granularity(Granularity granularity); inline void set_granularity(Granularity granularity);
inline Granularity granularity() const; inline Granularity granularity() const;
......
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