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 =
......
......@@ -490,8 +490,8 @@ MaybeHandle<JSObject> JSDateTimeFormat::ResolvedOptions(
Handle<Object> resolved_obj;
Handle<String> locale = Handle<String>(date_time_format->locale(), isolate);
CHECK(!date_time_format->icu_locale().is_null());
CHECK_NOT_NULL(date_time_format->icu_locale().raw());
DCHECK(!date_time_format->icu_locale().is_null());
DCHECK_NOT_NULL(date_time_format->icu_locale().raw());
icu::Locale* icu_locale = date_time_format->icu_locale().raw();
icu::SimpleDateFormat* icu_simple_date_format =
......@@ -570,52 +570,60 @@ MaybeHandle<JSObject> JSDateTimeFormat::ResolvedOptions(
// [[Second]] "second"
// [[TimeZoneName]] "timeZoneName"
// [[FractionalSecondDigits]] "fractionalSecondDigits"
CHECK(JSReceiver::CreateDataProperty(isolate, options,
factory->locale_string(), locale,
Just(kDontThrow))
.FromJust());
CHECK(JSReceiver::CreateDataProperty(
Maybe<bool> maybe_create_locale = JSReceiver::CreateDataProperty(
isolate, options, factory->locale_string(), locale, Just(kDontThrow));
DCHECK(maybe_create_locale.FromJust());
USE(maybe_create_locale);
Maybe<bool> maybe_create_calendar = JSReceiver::CreateDataProperty(
isolate, options, factory->calendar_string(),
factory->NewStringFromAsciiChecked(calendar_str.c_str()),
Just(kDontThrow))
.FromJust());
Just(kDontThrow));
DCHECK(maybe_create_calendar.FromJust());
USE(maybe_create_calendar);
if (!numbering_system.empty()) {
CHECK(JSReceiver::CreateDataProperty(
Maybe<bool> maybe_create_numbering_system = JSReceiver::CreateDataProperty(
isolate, options, factory->numberingSystem_string(),
factory->NewStringFromAsciiChecked(numbering_system.c_str()),
Just(kDontThrow))
.FromJust());
Just(kDontThrow));
DCHECK(maybe_create_numbering_system.FromJust());
USE(maybe_create_numbering_system);
}
CHECK(JSReceiver::CreateDataProperty(isolate, options,
factory->timeZone_string(),
timezone_value, Just(kDontThrow))
.FromJust());
Maybe<bool> maybe_create_time_zone = JSReceiver::CreateDataProperty(
isolate, options, factory->timeZone_string(), timezone_value,
Just(kDontThrow));
DCHECK(maybe_create_time_zone.FromJust());
USE(maybe_create_time_zone);
// 5.b.i. Let hc be dtf.[[HourCycle]].
HourCycle hc = date_time_format->hour_cycle();
if (hc != HourCycle::kUndefined) {
CHECK(JSReceiver::CreateDataProperty(
Maybe<bool> maybe_create_hour_cycle = JSReceiver::CreateDataProperty(
isolate, options, factory->hourCycle_string(),
date_time_format->HourCycleAsString(), Just(kDontThrow))
.FromJust());
date_time_format->HourCycleAsString(), Just(kDontThrow));
DCHECK(maybe_create_hour_cycle.FromJust());
USE(maybe_create_hour_cycle);
switch (hc) {
// ii. If hc is "h11" or "h12", let v be true.
case HourCycle::kH11:
case HourCycle::kH12:
CHECK(JSReceiver::CreateDataProperty(
isolate, options, factory->hour12_string(),
factory->true_value(), Just(kDontThrow))
.FromJust());
break;
case HourCycle::kH12: {
Maybe<bool> maybe_create_hour12 = JSReceiver::CreateDataProperty(
isolate, options, factory->hour12_string(), factory->true_value(),
Just(kDontThrow));
DCHECK(maybe_create_hour12.FromJust());
USE(maybe_create_hour12);
} break;
// iii. Else if, hc is "h23" or "h24", let v be false.
case HourCycle::kH23:
case HourCycle::kH24:
CHECK(JSReceiver::CreateDataProperty(
isolate, options, factory->hour12_string(),
factory->false_value(), Just(kDontThrow))
.FromJust());
break;
case HourCycle::kH24: {
Maybe<bool> maybe_create_hour12 = JSReceiver::CreateDataProperty(
isolate, options, factory->hour12_string(), factory->false_value(),
Just(kDontThrow));
DCHECK(maybe_create_hour12.FromJust());
USE(maybe_create_hour12);
} break;
// iv. Else, let v be undefined.
case HourCycle::kUndefined:
break;
......@@ -630,41 +638,46 @@ MaybeHandle<JSObject> JSDateTimeFormat::ResolvedOptions(
for (const auto& item : GetPatternItems()) {
for (const auto& pair : item.pairs) {
if (pattern.find(pair.pattern) != std::string::npos) {
CHECK(JSReceiver::CreateDataProperty(
Maybe<bool> maybe_create_property = JSReceiver::CreateDataProperty(
isolate, options,
factory->NewStringFromAsciiChecked(item.property.c_str()),
factory->NewStringFromAsciiChecked(pair.value.c_str()),
Just(kDontThrow))
.FromJust());
Just(kDontThrow));
DCHECK(maybe_create_property.FromJust());
USE(maybe_create_property);
break;
}
}
}
int fsd = FractionalSecondDigitsFromPattern(pattern);
if (fsd > 0) {
CHECK(JSReceiver::CreateDataProperty(
Maybe<bool> maybe_create_fractional_seconds_digits =
JSReceiver::CreateDataProperty(
isolate, options, factory->fractionalSecondDigits_string(),
factory->NewNumberFromInt(fsd), Just(kDontThrow))
.FromJust());
factory->NewNumberFromInt(fsd), Just(kDontThrow));
DCHECK(maybe_create_fractional_seconds_digits.FromJust());
USE(maybe_create_fractional_seconds_digits);
}
}
// dateStyle
if (date_time_format->date_style() != DateTimeStyle::kUndefined) {
CHECK(JSReceiver::CreateDataProperty(
Maybe<bool> maybe_create_date_style = JSReceiver::CreateDataProperty(
isolate, options, factory->dateStyle_string(),
DateTimeStyleAsString(isolate, date_time_format->date_style()),
Just(kDontThrow))
.FromJust());
Just(kDontThrow));
DCHECK(maybe_create_date_style.FromJust());
USE(maybe_create_date_style);
}
// timeStyle
if (date_time_format->time_style() != DateTimeStyle::kUndefined) {
CHECK(JSReceiver::CreateDataProperty(
Maybe<bool> maybe_create_time_style = JSReceiver::CreateDataProperty(
isolate, options, factory->timeStyle_string(),
DateTimeStyleAsString(isolate, date_time_format->time_style()),
Just(kDontThrow))
.FromJust());
Just(kDontThrow));
DCHECK(maybe_create_time_style.FromJust());
USE(maybe_create_time_style);
}
return options;
}
......@@ -708,7 +721,7 @@ MaybeHandle<String> JSDateTimeFormat::DateTimeFormat(
// a. Let x be ? ToNumber(date).
ASSIGN_RETURN_ON_EXCEPTION(isolate, date, Object::ToNumber(isolate, date),
String);
CHECK(date->IsNumber());
DCHECK(date->IsNumber());
x = date->Number();
}
// 5. Return FormatDateTime(dtf, x).
......@@ -1030,8 +1043,8 @@ class CalendarCache {
UErrorCode status = U_ZERO_ERROR;
std::unique_ptr<icu::Calendar> calendar(
icu::Calendar::createInstance(tz, locale, status));
CHECK(U_SUCCESS(status));
CHECK_NOT_NULL(calendar.get());
DCHECK(U_SUCCESS(status));
DCHECK_NOT_NULL(calendar.get());
if (calendar->getDynamicClassID() ==
icu::GregorianCalendar::getStaticClassID()) {
......@@ -1126,7 +1139,7 @@ std::unique_ptr<icu::SimpleDateFormat> CreateICUDateFormat(
pattern = generator->getBestPattern(skeleton, UDATPG_MATCH_HOUR_FIELD_LENGTH,
status);
pattern = ReplaceHourCycleInPattern(pattern, hc);
CHECK(U_SUCCESS(status));
DCHECK(U_SUCCESS(status));
// Make formatter from skeleton. Calendar and numbering system are added
// to the locale as Unicode extension (if they were specified at all).
......@@ -1135,7 +1148,7 @@ std::unique_ptr<icu::SimpleDateFormat> CreateICUDateFormat(
new icu::SimpleDateFormat(pattern, icu_locale, status));
if (U_FAILURE(status)) return std::unique_ptr<icu::SimpleDateFormat>();
CHECK_NOT_NULL(date_format.get());
DCHECK_NOT_NULL(date_format.get());
return date_format;
}
......@@ -1188,7 +1201,7 @@ icu::UnicodeString SkeletonFromDateFormat(
UErrorCode status = U_ZERO_ERROR;
icu::UnicodeString skeleton =
icu::DateTimePatternGenerator::staticGetSkeleton(pattern, status);
CHECK(U_SUCCESS(status));
DCHECK(U_SUCCESS(status));
return skeleton;
}
......@@ -1380,7 +1393,7 @@ std::unique_ptr<icu::SimpleDateFormat> DateTimeStylePattern(
status = U_ZERO_ERROR;
icu::UnicodeString skeleton =
icu::DateTimePatternGenerator::staticGetSkeleton(pattern, status);
CHECK(U_SUCCESS(status));
DCHECK(U_SUCCESS(status));
// If the skeleton match the HourCycle, we just return it.
if (hc == HourCycleFromPattern(pattern)) {
......@@ -1410,7 +1423,7 @@ class DateTimePatternGeneratorCache {
map_[key].reset(
icu::DateTimePatternGenerator::createInstance("root", status));
}
CHECK(U_SUCCESS(status));
DCHECK(U_SUCCESS(status));
return map_[key]->clone();
}
......@@ -1523,7 +1536,7 @@ MaybeHandle<JSDateTimeFormat> JSDateTimeFormat::New(
if (ca_extension_it != r.extensions.end() &&
ca_extension_it->second != calendar_str.get()) {
icu_locale.setUnicodeKeywordValue("ca", nullptr, status);
CHECK(U_SUCCESS(status));
DCHECK(U_SUCCESS(status));
}
}
if (numbering_system_str != nullptr) {
......@@ -1531,7 +1544,7 @@ MaybeHandle<JSDateTimeFormat> JSDateTimeFormat::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));
}
}
......@@ -1542,13 +1555,13 @@ MaybeHandle<JSDateTimeFormat> JSDateTimeFormat::New(
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));
}
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));
}
static base::LazyInstance<DateTimePatternGeneratorCache>::type
......@@ -1559,7 +1572,7 @@ MaybeHandle<JSDateTimeFormat> JSDateTimeFormat::New(
// 15.Let hcDefault be dataLocaleData.[[hourCycle]].
HourCycle hc_default = ToHourCycle(generator->getDefaultHourCycle(status));
CHECK(U_SUCCESS(status));
DCHECK(U_SUCCESS(status));
// 16.Let hc be r.[[hc]].
HourCycle hc = HourCycle::kUndefined;
......@@ -1797,7 +1810,7 @@ MaybeHandle<JSDateTimeFormat> JSDateTimeFormat::New(
// Remove -hc- if it does not agree with what we used.
UErrorCode status = U_ZERO_ERROR;
resolved_locale.setUnicodeKeywordValue("hc", nullptr, status);
CHECK(U_SUCCESS(status));
DCHECK(U_SUCCESS(status));
}
}
}
......@@ -1906,7 +1919,7 @@ MaybeHandle<JSArray> JSDateTimeFormat::FormatToParts(
Factory* factory = isolate->factory();
icu::SimpleDateFormat* format =
date_time_format->icu_simple_date_format().raw();
CHECK_NOT_NULL(format);
DCHECK_NOT_NULL(format);
icu::UnicodeString formatted;
icu::FieldPositionIterator fp_iter;
......@@ -1986,7 +1999,7 @@ class SourceTracker {
public:
SourceTracker() { start_[0] = start_[1] = limit_[0] = limit_[1] = 0; }
void Add(int32_t field, int32_t start, int32_t limit) {
CHECK_LT(field, 2);
DCHECK_LT(field, 2);
start_[field] = start;
limit_[field] = limit;
}
......@@ -2006,7 +2019,7 @@ class SourceTracker {
int32_t limit_[2];
bool FieldContains(int32_t field, int32_t start, int32_t limit) const {
CHECK_LT(field, 2);
DCHECK_LT(field, 2);
return (start_[field] <= start) && (start <= limit_[field]) &&
(start_[field] <= limit) && (limit <= limit_[field]);
}
......@@ -2059,10 +2072,10 @@ MaybeHandle<JSArray> FormattedDateIntervalToJSArray(
int32_t limit = cfpos.getLimit();
if (category == UFIELD_CATEGORY_DATE_INTERVAL_SPAN) {
CHECK_LE(field, 2);
DCHECK_LE(field, 2);
tracker.Add(field, start, limit);
} else {
CHECK(category == UFIELD_CATEGORY_DATE);
DCHECK(category == UFIELD_CATEGORY_DATE);
if (start > previous_end_pos) {
// Add "literal" from the previous end position to the start if
// necessary.
......
......@@ -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