Commit 5fc196ac authored by Frank Tang's avatar Frank Tang Committed by Commit Bot

Change CHECK to DCHECK

Bug: v8:10753
Change-Id: Icbdc6d7ee0634d32b262860dd64c4bfccebdcc00
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2317064Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Frank Tang <ftang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69053}
parent 3cbe36a7
......@@ -438,7 +438,7 @@ Maybe<icu::Locale> CreateICULocale(const std::string& bcp47_locale) {
UErrorCode status = U_ZERO_ERROR;
icu::Locale icu_locale = icu::Locale::forLanguageTag(bcp47_locale, status);
CHECK(U_SUCCESS(status));
DCHECK(U_SUCCESS(status));
if (icu_locale.isBogus()) {
return Nothing<icu::Locale>();
}
......@@ -586,7 +586,7 @@ Maybe<std::string> Intl::ToLanguageTag(const icu::Locale& locale) {
if (U_FAILURE(status)) {
return Nothing<std::string>();
}
CHECK(U_SUCCESS(status));
DCHECK(U_SUCCESS(status));
// Hack to remove -true and -yes from unicode extensions
// Address https://crbug.com/v8/8565
......@@ -1371,7 +1371,7 @@ ParsedLocale ParseBCP47Locale(const std::string& locale) {
// Check to make sure that this really is a grandfathered or
// privateuse extension. ICU can sometimes mess up the
// canonicalization.
CHECK(locale[0] == 'x' || locale[0] == 'i');
DCHECK(locale[0] == 'x' || locale[0] == 'i');
parsed_locale.no_extensions_locale = locale;
return parsed_locale;
}
......@@ -1452,7 +1452,7 @@ icu::LocaleMatcher BuildLocaleMatcher(
UErrorCode* status) {
icu::Locale default_locale =
icu::Locale::forLanguageTag(DefaultLocale(isolate), *status);
CHECK(U_SUCCESS(*status));
DCHECK(U_SUCCESS(*status));
icu::LocaleMatcher::Builder builder;
builder.setDefaultLocale(&default_locale);
for (auto it = available_locales.begin(); it != available_locales.end();
......@@ -1476,7 +1476,7 @@ class Iterator : public icu::Locale::Iterator {
const icu::Locale& next() override {
UErrorCode status = U_ZERO_ERROR;
locale_ = icu::Locale::forLanguageTag(iter_->c_str(), status);
CHECK(U_SUCCESS(status));
DCHECK(U_SUCCESS(status));
++iter_;
return locale_;
}
......@@ -1509,7 +1509,7 @@ std::string BestFitMatcher(Isolate* isolate,
UErrorCode status = U_ZERO_ERROR;
icu::LocaleMatcher matcher =
BuildLocaleMatcher(isolate, available_locales, &status);
CHECK(U_SUCCESS(status));
DCHECK(U_SUCCESS(status));
Iterator iter(requested_locales.cbegin(), requested_locales.cend());
std::string bestfit =
......@@ -1535,7 +1535,7 @@ std::vector<std::string> BestFitSupportedLocales(
UErrorCode status = U_ZERO_ERROR;
icu::LocaleMatcher matcher =
BuildLocaleMatcher(isolate, available_locales, &status);
CHECK(U_SUCCESS(status));
DCHECK(U_SUCCESS(status));
std::string default_locale = DefaultLocale(isolate);
std::vector<std::string> result;
......@@ -1951,7 +1951,7 @@ MaybeHandle<String> Intl::Normalize(Isolate* isolate, Handle<String> string,
const icu::Normalizer2* normalizer =
icu::Normalizer2::getInstance(nullptr, form_name, form_mode, status);
DCHECK(U_SUCCESS(status));
CHECK_NOT_NULL(normalizer);
DCHECK_NOT_NULL(normalizer);
int32_t normalized_prefix_length =
normalizer->spanQuickCheckYes(input, status);
// Quick return if the input is already normalized.
......
......@@ -192,7 +192,7 @@ void JSV8BreakIterator::AdoptText(
Handle<String> text) {
icu::BreakIterator* break_iterator =
break_iterator_holder->break_iterator().raw();
CHECK_NOT_NULL(break_iterator);
DCHECK_NOT_NULL(break_iterator);
Handle<Managed<icu::UnicodeString>> unicode_string =
Intl::SetTextToBreakIterator(isolate, text, break_iterator);
break_iterator_holder->set_unicode_string(*unicode_string);
......
......@@ -52,15 +52,16 @@ Maybe<CaseFirst> GetCaseFirst(Isolate* isolate, Handle<JSReceiver> options,
// TODO(gsathya): Consider internalizing the value strings.
void CreateDataPropertyForOptions(Isolate* isolate, Handle<JSObject> options,
Handle<String> key, const char* value) {
CHECK_NOT_NULL(value);
DCHECK_NOT_NULL(value);
Handle<String> value_str =
isolate->factory()->NewStringFromAsciiChecked(value);
// This is a brand new JSObject that shouldn't already have the same
// key so this shouldn't fail.
CHECK(JSReceiver::CreateDataProperty(isolate, options, key, value_str,
Just(kDontThrow))
.FromJust());
Maybe<bool> maybe = JSReceiver::CreateDataProperty(
isolate, options, key, value_str, Just(kDontThrow));
DCHECK(maybe.FromJust());
USE(maybe);
}
void CreateDataPropertyForOptions(Isolate* isolate, Handle<JSObject> options,
......@@ -69,9 +70,10 @@ void CreateDataPropertyForOptions(Isolate* isolate, Handle<JSObject> options,
// This is a brand new JSObject that shouldn't already have the same
// key so this shouldn't fail.
CHECK(JSReceiver::CreateDataProperty(isolate, options, key, value_obj,
Just(kDontThrow))
.FromJust());
Maybe<bool> maybe = JSReceiver::CreateDataProperty(
isolate, options, key, value_obj, Just(kDontThrow));
DCHECK(maybe.FromJust());
USE(maybe);
}
} // anonymous namespace
......@@ -83,12 +85,12 @@ Handle<JSObject> JSCollator::ResolvedOptions(Isolate* isolate,
isolate->factory()->NewJSObject(isolate->object_function());
icu::Collator* icu_collator = collator->icu_collator().raw();
CHECK_NOT_NULL(icu_collator);
DCHECK_NOT_NULL(icu_collator);
UErrorCode status = U_ZERO_ERROR;
bool numeric =
icu_collator->getAttribute(UCOL_NUMERIC_COLLATION, status) == UCOL_ON;
CHECK(U_SUCCESS(status));
DCHECK(U_SUCCESS(status));
const char* case_first = nullptr;
status = U_ZERO_ERROR;
......@@ -102,13 +104,13 @@ Handle<JSObject> JSCollator::ResolvedOptions(Isolate* isolate,
default:
case_first = "false";
}
CHECK(U_SUCCESS(status));
DCHECK(U_SUCCESS(status));
const char* sensitivity = nullptr;
status = U_ZERO_ERROR;
switch (icu_collator->getAttribute(UCOL_STRENGTH, status)) {
case UCOL_PRIMARY: {
CHECK(U_SUCCESS(status));
DCHECK(U_SUCCESS(status));
status = U_ZERO_ERROR;
// case level: true + s1 -> case, s1 -> base.
if (UCOL_ON == icu_collator->getAttribute(UCOL_CASE_LEVEL, status)) {
......@@ -116,7 +118,7 @@ Handle<JSObject> JSCollator::ResolvedOptions(Isolate* isolate,
} else {
sensitivity = "base";
}
CHECK(U_SUCCESS(status));
DCHECK(U_SUCCESS(status));
break;
}
case UCOL_SECONDARY:
......@@ -133,17 +135,17 @@ Handle<JSObject> JSCollator::ResolvedOptions(Isolate* isolate,
default:
sensitivity = "variant";
}
CHECK(U_SUCCESS(status));
DCHECK(U_SUCCESS(status));
status = U_ZERO_ERROR;
bool ignore_punctuation = icu_collator->getAttribute(UCOL_ALTERNATE_HANDLING,
status) == UCOL_SHIFTED;
CHECK(U_SUCCESS(status));
DCHECK(U_SUCCESS(status));
status = U_ZERO_ERROR;
icu::Locale icu_locale(icu_collator->getLocale(ULOC_VALID_LOCALE, status));
CHECK(U_SUCCESS(status));
DCHECK(U_SUCCESS(status));
const char* collation = "default";
const char* usage = "sort";
......@@ -172,7 +174,7 @@ Handle<JSObject> JSCollator::ResolvedOptions(Isolate* isolate,
// locale tag, so let's filter it out.
status = U_ZERO_ERROR;
new_icu_locale.setUnicodeKeywordValue(collation_key, nullptr, status);
CHECK(U_SUCCESS(status));
DCHECK(U_SUCCESS(status));
locale = Intl::ToLanguageTag(new_icu_locale).FromJust();
} else {
......@@ -234,19 +236,19 @@ UColAttributeValue ToUColAttributeValue(CaseFirst case_first) {
}
void SetNumericOption(icu::Collator* icu_collator, bool numeric) {
CHECK_NOT_NULL(icu_collator);
DCHECK_NOT_NULL(icu_collator);
UErrorCode status = U_ZERO_ERROR;
icu_collator->setAttribute(UCOL_NUMERIC_COLLATION,
numeric ? UCOL_ON : UCOL_OFF, status);
CHECK(U_SUCCESS(status));
DCHECK(U_SUCCESS(status));
}
void SetCaseFirstOption(icu::Collator* icu_collator, CaseFirst case_first) {
CHECK_NOT_NULL(icu_collator);
DCHECK_NOT_NULL(icu_collator);
UErrorCode status = U_ZERO_ERROR;
icu_collator->setAttribute(UCOL_CASE_FIRST, ToUColAttributeValue(case_first),
status);
CHECK(U_SUCCESS(status));
DCHECK(U_SUCCESS(status));
}
} // anonymous namespace
......@@ -367,7 +369,7 @@ MaybeHandle<JSCollator> JSCollator::New(Isolate* isolate, Handle<Map> map,
if (co_extension_it != r.extensions.end() &&
co_extension_it->second != collation_str.get()) {
icu_locale.setUnicodeKeywordValue("co", nullptr, status);
CHECK(U_SUCCESS(status));
DCHECK(U_SUCCESS(status));
}
}
......@@ -390,12 +392,12 @@ MaybeHandle<JSCollator> JSCollator::New(Isolate* isolate, Handle<Map> map,
if (usage == Usage::SEARCH) {
UErrorCode status = U_ZERO_ERROR;
icu_locale.setUnicodeKeywordValue("co", "search", status);
CHECK(U_SUCCESS(status));
DCHECK(U_SUCCESS(status));
} else {
if (collation_str != nullptr &&
Intl::IsValidCollation(icu_locale, collation_str.get())) {
icu_locale.setUnicodeKeywordValue("co", collation_str.get(), status);
CHECK(U_SUCCESS(status));
DCHECK(U_SUCCESS(status));
}
}
......@@ -459,7 +461,7 @@ MaybeHandle<JSCollator> JSCollator::New(Isolate* isolate, Handle<Map> map,
// that right now).
status = U_ZERO_ERROR;
icu_collator->setAttribute(UCOL_NORMALIZATION_MODE, UCOL_ON, status);
CHECK(U_SUCCESS(status));
DCHECK(U_SUCCESS(status));
// 24. Let sensitivity be ? GetOption(options, "sensitivity",
// "string", « "base", "accent", "case", "variant" », undefined).
......@@ -492,7 +494,7 @@ MaybeHandle<JSCollator> JSCollator::New(Isolate* isolate, Handle<Map> map,
icu_collator->setStrength(icu::Collator::PRIMARY);
status = U_ZERO_ERROR;
icu_collator->setAttribute(UCOL_CASE_LEVEL, UCOL_ON, status);
CHECK(U_SUCCESS(status));
DCHECK(U_SUCCESS(status));
break;
case Sensitivity::kVariant:
icu_collator->setStrength(icu::Collator::TERTIARY);
......@@ -512,7 +514,7 @@ MaybeHandle<JSCollator> JSCollator::New(Isolate* isolate, Handle<Map> map,
if (found_ignore_punctuation.FromJust() && ignore_punctuation) {
status = U_ZERO_ERROR;
icu_collator->setAttribute(UCOL_ALTERNATE_HANDLING, UCOL_SHIFTED, status);
CHECK(U_SUCCESS(status));
DCHECK(U_SUCCESS(status));
}
Handle<Managed<icu::Collator>> managed_collator =
......
This diff is collapsed.
......@@ -266,7 +266,7 @@ class DateTimeFieldNames : public DisplayNamesInternal {
UErrorCode status = U_ZERO_ERROR;
generator_.reset(
icu::DateTimePatternGenerator::createInstance(locale_, status));
CHECK(U_SUCCESS(status));
DCHECK(U_SUCCESS(status));
}
~DateTimeFieldNames() override = default;
const char* type() const override { return "dateTimeField"; }
......@@ -566,7 +566,7 @@ MaybeHandle<JSDisplayNames> JSDisplayNames::New(Isolate* isolate,
if (calendar_str != nullptr &&
Intl::IsValidCalendar(icu_locale, calendar_str.get())) {
icu_locale.setUnicodeKeywordValue("ca", calendar_str.get(), status);
CHECK(U_SUCCESS(status));
DCHECK(U_SUCCESS(status));
}
// 10. Let s be ? GetOption(options, "style", "string",
......@@ -689,35 +689,39 @@ Handle<JSObject> JSDisplayNames::ResolvedOptions(
DisplayNamesInternal* internal = display_names->internal().raw();
Maybe<std::string> maybe_locale = Intl::ToLanguageTag(internal->locale());
CHECK(maybe_locale.IsJust());
DCHECK(maybe_locale.IsJust());
Handle<String> locale = isolate->factory()->NewStringFromAsciiChecked(
maybe_locale.FromJust().c_str());
Handle<String> style = display_names->StyleAsString();
Handle<String> type = factory->NewStringFromAsciiChecked(internal->type());
Handle<String> fallback = display_names->FallbackAsString();
CHECK(JSReceiver::CreateDataProperty(isolate, options,
factory->locale_string(), locale,
Just(kDontThrow))
.FromJust());
Maybe<bool> maybe_create_locale = JSReceiver::CreateDataProperty(
isolate, options, factory->locale_string(), locale, Just(kDontThrow));
DCHECK(maybe_create_locale.FromJust());
USE(maybe_create_locale);
if (internal->calendar() != nullptr) {
CHECK(JSReceiver::CreateDataProperty(
Maybe<bool> maybe_create_calendar = JSReceiver::CreateDataProperty(
isolate, options, factory->calendar_string(),
factory->NewStringFromAsciiChecked(internal->calendar()),
Just(kDontThrow))
.FromJust());
}
CHECK(JSReceiver::CreateDataProperty(
isolate, options, factory->style_string(), style, Just(kDontThrow))
.FromJust());
CHECK(JSReceiver::CreateDataProperty(isolate, options, factory->type_string(),
type, Just(kDontThrow))
.FromJust());
CHECK(JSReceiver::CreateDataProperty(isolate, options,
factory->fallback_string(), fallback,
Just(kDontThrow))
.FromJust());
Just(kDontThrow));
DCHECK(maybe_create_calendar.FromJust());
USE(maybe_create_calendar);
}
Maybe<bool> maybe_create_style = JSReceiver::CreateDataProperty(
isolate, options, factory->style_string(), style, Just(kDontThrow));
DCHECK(maybe_create_style.FromJust());
USE(maybe_create_style);
Maybe<bool> maybe_create_type = JSReceiver::CreateDataProperty(
isolate, options, factory->type_string(), type, Just(kDontThrow));
DCHECK(maybe_create_type.FromJust());
USE(maybe_create_type);
Maybe<bool> maybe_create_fallback = JSReceiver::CreateDataProperty(
isolate, options, factory->fallback_string(), fallback, Just(kDontThrow));
DCHECK(maybe_create_fallback.FromJust());
USE(maybe_create_fallback);
return options;
}
......
......@@ -254,7 +254,7 @@ MaybeHandle<T> FormatListCommon(
std::vector<icu::UnicodeString> array = maybe_array.FromJust();
icu::ListFormatter* formatter = format->icu_formatter().raw();
CHECK_NOT_NULL(formatter);
DCHECK_NOT_NULL(formatter);
UErrorCode status = U_ZERO_ERROR;
icu::FormattedList formatted = formatter->formatStringsToValue(
......
......@@ -42,7 +42,7 @@ struct OptionData {
Maybe<bool> InsertOptionsIntoLocale(Isolate* isolate,
Handle<JSReceiver> options,
icu::LocaleBuilder* builder) {
CHECK(isolate);
DCHECK(isolate);
const std::vector<const char*> hour_cycle_values = {"h11", "h12", "h23",
"h24"};
......@@ -234,8 +234,8 @@ Maybe<bool> ApplyOptionsToTag(Isolate* isolate, Handle<String> tag,
v8::String::Utf8Value bcp47_tag(v8_isolate, v8::Utils::ToLocal(tag));
builder->setLanguageTag({*bcp47_tag, bcp47_tag.length()});
CHECK_LT(0, bcp47_tag.length());
CHECK_NOT_NULL(*bcp47_tag);
DCHECK_LT(0, bcp47_tag.length());
DCHECK_NOT_NULL(*bcp47_tag);
// 2. If IsStructurallyValidLanguageTag(tag) is false, throw a RangeError
// exception.
if (!JSLocale::StartsWithUnicodeLanguageId(*bcp47_tag)) {
......
......@@ -33,7 +33,7 @@ bool CreateICUPluralRules(Isolate* isolate, const icu::Locale& icu_locale,
if (type == JSPluralRules::Type::ORDINAL) {
icu_type = UPLURAL_TYPE_ORDINAL;
} else {
CHECK_EQ(JSPluralRules::Type::CARDINAL, type);
DCHECK_EQ(JSPluralRules::Type::CARDINAL, type);
}
std::unique_ptr<icu::PluralRules> plural_rules(
......@@ -41,7 +41,7 @@ bool CreateICUPluralRules(Isolate* isolate, const icu::Locale& icu_locale,
if (U_FAILURE(status)) {
return false;
}
CHECK_NOT_NULL(plural_rules.get());
DCHECK_NOT_NULL(plural_rules.get());
*pl = std::move(plural_rules);
return true;
......@@ -184,20 +184,20 @@ MaybeHandle<JSPluralRules> JSPluralRules::New(Isolate* isolate, Handle<Map> map,
MaybeHandle<String> JSPluralRules::ResolvePlural(
Isolate* isolate, Handle<JSPluralRules> plural_rules, double number) {
icu::PluralRules* icu_plural_rules = plural_rules->icu_plural_rules().raw();
CHECK_NOT_NULL(icu_plural_rules);
DCHECK_NOT_NULL(icu_plural_rules);
icu::number::LocalizedNumberFormatter* fmt =
plural_rules->icu_number_formatter().raw();
CHECK_NOT_NULL(fmt);
DCHECK_NOT_NULL(fmt);
UErrorCode status = U_ZERO_ERROR;
icu::number::FormattedNumber formatted_number =
fmt->formatDouble(number, status);
CHECK(U_SUCCESS(status));
DCHECK(U_SUCCESS(status));
icu::UnicodeString result =
icu_plural_rules->select(formatted_number, status);
CHECK(U_SUCCESS(status));
DCHECK(U_SUCCESS(status));
return Intl::ToString(isolate, result);
}
......@@ -210,9 +210,10 @@ void CreateDataPropertyForOptions(Isolate* isolate, Handle<JSObject> options,
// This is a brand new JSObject that shouldn't already have the same
// key so this shouldn't fail.
CHECK(JSReceiver::CreateDataProperty(isolate, options, key_str, value,
Just(kDontThrow))
.FromJust());
Maybe<bool> maybe = JSReceiver::CreateDataProperty(isolate, options, key_str,
value, Just(kDontThrow));
DCHECK(maybe.FromJust());
USE(maybe);
}
void CreateDataPropertyForOptions(Isolate* isolate, Handle<JSObject> options,
......@@ -238,7 +239,7 @@ Handle<JSObject> JSPluralRules::ResolvedOptions(
icu::number::LocalizedNumberFormatter* icu_number_formatter =
plural_rules->icu_number_formatter().raw();
icu::UnicodeString skeleton = icu_number_formatter->toSkeleton(status);
CHECK(U_SUCCESS(status));
DCHECK(U_SUCCESS(status));
CreateDataPropertyForOptions(
isolate, options,
......@@ -262,19 +263,19 @@ Handle<JSObject> JSPluralRules::ResolvedOptions(
// 6. Let pluralCategories be a List of Strings representing the
// possible results of PluralRuleSelect for the selected locale pr.
icu::PluralRules* icu_plural_rules = plural_rules->icu_plural_rules().raw();
CHECK_NOT_NULL(icu_plural_rules);
DCHECK_NOT_NULL(icu_plural_rules);
std::unique_ptr<icu::StringEnumeration> categories(
icu_plural_rules->getKeywords(status));
CHECK(U_SUCCESS(status));
DCHECK(U_SUCCESS(status));
int32_t count = categories->count(status);
CHECK(U_SUCCESS(status));
DCHECK(U_SUCCESS(status));
Handle<FixedArray> plural_categories =
isolate->factory()->NewFixedArray(count);
for (int32_t i = 0; i < count; i++) {
const icu::UnicodeString* category = categories->snext(status);
CHECK(U_SUCCESS(status));
DCHECK(U_SUCCESS(status));
if (category == nullptr) break;
std::string keyword;
......@@ -301,7 +302,7 @@ class PluralRulesAvailableLocales {
UErrorCode status = U_ZERO_ERROR;
std::unique_ptr<icu::StringEnumeration> locales(
icu::PluralRules::getAvailableLocales(status));
CHECK(U_SUCCESS(status));
DCHECK(U_SUCCESS(status));
int32_t len = 0;
const char* locale = nullptr;
while ((locale = locales->next(&len, status)) != nullptr &&
......
......@@ -131,7 +131,7 @@ MaybeHandle<JSRelativeTimeFormat> JSRelativeTimeFormat::New(
if (nu_extension_it != r.extensions.end() &&
nu_extension_it->second != numbering_system_str.get()) {
icu_locale.setUnicodeKeywordValue("nu", nullptr, status);
CHECK(U_SUCCESS(status));
DCHECK(U_SUCCESS(status));
}
}
// 12. Let locale be r.[[Locale]].
......@@ -146,7 +146,7 @@ MaybeHandle<JSRelativeTimeFormat> JSRelativeTimeFormat::New(
if (numbering_system_str != nullptr &&
Intl::IsValidNumberingSystem(numbering_system_str.get())) {
icu_locale.setUnicodeKeywordValue("nu", numbering_system_str.get(), status);
CHECK(U_SUCCESS(status));
DCHECK(U_SUCCESS(status));
}
// 15. Let dataLocale be r.[[DataLocale]].
......@@ -184,7 +184,7 @@ MaybeHandle<JSRelativeTimeFormat> JSRelativeTimeFormat::New(
delete number_format;
status = U_ZERO_ERROR;
icu_locale.setUnicodeKeywordValue("nu", nullptr, status);
CHECK(U_SUCCESS(status));
DCHECK(U_SUCCESS(status));
number_format =
icu::NumberFormat::createInstance(icu_locale, UNUM_DECIMAL, status);
}
......@@ -256,7 +256,7 @@ Handle<JSObject> JSRelativeTimeFormat::ResolvedOptions(
Factory* factory = isolate->factory();
icu::RelativeDateTimeFormatter* formatter =
format_holder->icu_formatter().raw();
CHECK_NOT_NULL(formatter);
DCHECK_NOT_NULL(formatter);
Handle<JSObject> result = factory->NewJSObject(isolate->object_function());
Handle<String> locale(format_holder->locale(), isolate);
Handle<String> numberingSystem(format_holder->numberingSystem(), isolate);
......@@ -366,7 +366,7 @@ MaybeHandle<T> FormatCommon(
T);
}
icu::RelativeDateTimeFormatter* formatter = format->icu_formatter().raw();
CHECK_NOT_NULL(formatter);
DCHECK_NOT_NULL(formatter);
URelativeDateTimeUnit unit_enum;
if (!GetURelativeDateTimeUnit(unit, &unit_enum)) {
THROW_NEW_ERROR(
......
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