ICU-21669 UPRV_UNREACHABLE > UPRV_UNREACHABLE_EXIT/ASSERT, update usages

This commit is contained in:
Peter Edberg 2021-09-13 22:46:55 -07:00 committed by Peter Edberg
parent cd3721697a
commit e69f337f3c
46 changed files with 166 additions and 124 deletions

View file

@ -157,7 +157,7 @@ static void U_CALLCONV initSingletons(const char *what, UErrorCode &errorCode) {
} else if (uprv_strcmp(what, "nfkc_cf") == 0) {
nfkc_cfSingleton = Norm2AllModes::createInstance(NULL, "nfkc_cf", errorCode);
} else {
UPRV_UNREACHABLE; // Unknown singleton
UPRV_UNREACHABLE_EXIT; // Unknown singleton
}
ucln_common_registerCleanup(UCLN_COMMON_LOADED_NORMALIZER2, uprv_loaded_normalizer2_cleanup);
}

View file

@ -758,7 +758,7 @@ Vectorizer* createVectorizer(const LSTMData* data, UErrorCode &status) {
default:
break;
}
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
}
LSTMBreakEngine::LSTMBreakEngine(const LSTMData* data, const UnicodeSet& set, UErrorCode &status)

View file

@ -86,7 +86,7 @@ UChar32 codePointFromValidUTF8(const uint8_t *cpStart, const uint8_t *cpLimit) {
case 4:
return ((c&7)<<18) | ((cpStart[1]&0x3f)<<12) | ((cpStart[2]&0x3f)<<6) | (cpStart[3]&0x3f);
default:
UPRV_UNREACHABLE; // Should not occur.
UPRV_UNREACHABLE_EXIT; // Should not occur.
}
}

View file

@ -74,7 +74,7 @@ UBool RuleBasedBreakIterator::DictionaryCache::following(int32_t fromPos, int32_
return TRUE;
}
}
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
}
@ -114,7 +114,7 @@ UBool RuleBasedBreakIterator::DictionaryCache::preceding(int32_t fromPos, int32_
return TRUE;
}
}
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
}
void RuleBasedBreakIterator::DictionaryCache::populateDictionary(int32_t startPos, int32_t endPos,
@ -386,7 +386,7 @@ UBool RuleBasedBreakIterator::BreakCache::populateNear(int32_t position, UErrorC
// Add following position(s) to the cache.
while (fBoundaries[fEndBufIdx] < position) {
if (!populateFollowing()) {
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
}
}
fBufIdx = fEndBufIdx; // Set iterator position to the end of the buffer.

View file

@ -10,7 +10,7 @@
*
* File uassert.h
*
* Contains the U_ASSERT and UPRV_UNREACHABLE macros
* Contains the U_ASSERT and UPRV_UNREACHABLE_* macros
*
******************************************************************************
*/
@ -38,14 +38,34 @@
#endif
/**
* \def UPRV_UNREACHABLE
* \def UPRV_UNREACHABLE_ASSERT
* This macro is used in places that we had believed were unreachable, but
* experience has shown otherwise (possibly due to memory corruption, etc).
* In this case we call assert() in debug versions as with U_ASSERT, instead
* of unconditionally calling abort(). However we also allow redefinition as
* with UPRV_UNREACHABLE_EXIT.
* @internal
*/
#if defined(UPRV_UNREACHABLE_ASSERT)
// Use the predefined value.
#elif U_DEBUG
# include <assert.h>
# define UPRV_UNREACHABLE_ASSERT assert(false)
#elif U_CPLUSPLUS_VERSION
# define UPRV_UNREACHABLE_ASSERT (void)0
#else
# define UPRV_UNREACHABLE_ASSERT
#endif
/**
* \def UPRV_UNREACHABLE_EXIT
* This macro is used to unconditionally abort if unreachable code is ever executed.
* @internal
*/
#if defined(UPRV_UNREACHABLE)
#if defined(UPRV_UNREACHABLE_EXIT)
// Use the predefined value.
#else
# define UPRV_UNREACHABLE abort()
# define UPRV_UNREACHABLE_EXIT abort()
#endif
#endif

View file

@ -2047,7 +2047,7 @@ processPropertySeq(UBiDi *pBiDi, LevState *pLevState, uint8_t _prop,
break;
default: /* we should never get here */
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
}
}
if((addLevel) || (start < start0)) {
@ -2250,7 +2250,7 @@ resolveImplicitLevels(UBiDi *pBiDi,
start2=i;
break;
default: /* we should never get here */
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
}
}
}
@ -2724,7 +2724,7 @@ ubidi_setPara(UBiDi *pBiDi, const UChar *text, int32_t length,
break;
default:
/* we should never get here */
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
}
/*
* If there are no external levels specified and there

View file

@ -530,7 +530,7 @@ static int32_t getRunFromLogicalIndex(UBiDi *pBiDi, int32_t logicalIndex) {
visualStart+=length;
}
/* we should never get here */
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
}
/*

View file

@ -379,7 +379,7 @@ _uhash_find(const UHashtable *hash, UHashTok key,
* WILL NEVER HAPPEN as long as uhash_put() makes sure that
* count is always < length.
*/
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
}
return &(elements[theIndex]);
}

View file

@ -168,11 +168,13 @@ initFromResourceBundle(UErrorCode& sts) {
}
// look up type map for the key, and walk through the mapping data
tmpSts = U_ZERO_ERROR;
LocalUResourceBundlePointer typeMapResByKey(ures_getByKey(typeMapRes.getAlias(), legacyKeyId, NULL, &tmpSts));
if (U_FAILURE(tmpSts)) {
// type map for each key must exist
UPRV_UNREACHABLE;
LocalUResourceBundlePointer typeMapResByKey(ures_getByKey(typeMapRes.getAlias(), legacyKeyId, NULL, &sts));
if (U_FAILURE(sts)) {
// We fail here if typeMap does not have an entry corresponding to every entry in keyMap (should
// not happen for valid keyTypeData), or if ures_getByKeyfails fails for some other reason
// (e.g. data file cannot be loaded, using stubdata, over-aggressive data filtering has removed
// something like timezoneTypes.res, etc.). Error code is already set. See ICU-21669.
UPRV_UNREACHABLE_ASSERT;
} else {
LocalUResourceBundlePointer typeMapEntry;

View file

@ -77,7 +77,7 @@ bool WholeStringBreakIterator::operator==(const BreakIterator&) const { return f
WholeStringBreakIterator *WholeStringBreakIterator::clone() const { return nullptr; }
CharacterIterator &WholeStringBreakIterator::getText() const {
UPRV_UNREACHABLE; // really should not be called
UPRV_UNREACHABLE_EXIT; // really should not be called
}
UText *WholeStringBreakIterator::getUText(UText * /*fillIn*/, UErrorCode &errorCode) const {
if (U_SUCCESS(errorCode)) {
@ -100,7 +100,7 @@ void WholeStringBreakIterator::setText(UText *text, UErrorCode &errorCode) {
}
}
void WholeStringBreakIterator::adoptText(CharacterIterator*) {
UPRV_UNREACHABLE; // should not be called
UPRV_UNREACHABLE_EXIT; // should not be called
}
int32_t WholeStringBreakIterator::first() { return 0; }

View file

@ -67,7 +67,7 @@ utrace_exit(int32_t fnNumber, int32_t returnType, ...) {
fmt = gExitFmtPtrStatus;
break;
default:
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
}
va_start(args, returnType);

View file

@ -577,7 +577,7 @@ CollationBuilder::getSpecialResetPosition(const UnicodeString &str,
parserErrorReason = "LDML forbids tailoring to U+FFFF";
return 0;
default:
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
}
int32_t index = findOrInsertNodeForRootCE(ce, strength, errorCode);

View file

@ -858,7 +858,7 @@ CollationDataBuilder::copyFromBaseCE32(UChar32 c, uint32_t ce32, UBool withConte
ce32 = encodeOneCE(Collation::unassignedCEFromCodePoint(c), errorCode);
break;
default:
UPRV_UNREACHABLE; // require ce32 == base->getFinalCE32(ce32)
UPRV_UNREACHABLE_EXIT; // require ce32 == base->getFinalCE32(ce32)
}
return ce32;
}

View file

@ -745,7 +745,7 @@ DateTimePatternGenerator::getDefaultHourCycle(UErrorCode& status) const {
case LOW_K:
return UDAT_HOUR_CYCLE_24;
default:
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
}
}
@ -1945,7 +1945,7 @@ PatternMap::copyFrom(const PatternMap& other, UErrorCode& status) {
if (prevElem != nullptr) {
prevElem->next.adoptInstead(curElem);
} else {
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
}
}
prevElem = curElem;

View file

@ -49,7 +49,7 @@ UBool ConstrainedFieldPosition::matchesField(int32_t category, int32_t field) co
case UCFPOS_CONSTRAINT_FIELD:
return fCategory == category && fField == field;
default:
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
}
}

View file

@ -222,7 +222,7 @@ const char *IslamicCalendar::getType() const {
sType = "islamic-umalqura";
break;
default:
UPRV_UNREACHABLE; // out of range
UPRV_UNREACHABLE_EXIT; // out of range
}
return sType;
}
@ -675,7 +675,7 @@ void IslamicCalendar::handleComputeFields(int32_t julianDay, UErrorCode &status)
month = m;
}
} else { // invalid 'civil'
UPRV_UNREACHABLE; // should not get here, out of range
UPRV_UNREACHABLE_EXIT; // should not get here, out of range
}
dayOfMonth = (days - monthStart(year, month)) + 1;

View file

@ -64,7 +64,7 @@ int32_t AffixUtils::estimateLength(const UnicodeString &patternString, UErrorCod
}
break;
default:
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
}
offset += U16_LENGTH(cp);
@ -154,7 +154,7 @@ Field AffixUtils::getFieldForType(AffixPatternType type) {
case TYPE_CURRENCY_OVERFLOW:
return {UFIELD_CATEGORY_NUMBER, UNUM_CURRENCY_FIELD};
default:
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
}
}
@ -390,7 +390,7 @@ AffixTag AffixUtils::nextToken(AffixTag tag, const UnicodeString &patternString,
return makeTag(offset, TYPE_CURRENCY_OVERFLOW, STATE_BASE, 0);
}
default:
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
}
}
// End of string
@ -419,7 +419,7 @@ AffixTag AffixUtils::nextToken(AffixTag tag, const UnicodeString &patternString,
case STATE_OVERFLOW_CURR:
return makeTag(offset, TYPE_CURRENCY_OVERFLOW, STATE_BASE, 0);
default:
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
}
}

View file

@ -47,7 +47,7 @@ Grouper Grouper::forStrategy(UNumberGroupingStrategy grouping) {
case UNUM_GROUPING_THOUSANDS:
return {3, 3, 1, grouping};
default:
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
}
}

View file

@ -1680,7 +1680,7 @@ const Modifier *MixedUnitLongNameHandler::getModifier(Signum /*signum*/,
// TODO(icu-units#28): investigate this method when investigating where
// ModifierStore::getModifier() gets used. To be sure it remains
// unreachable:
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
return nullptr;
}

View file

@ -92,13 +92,13 @@ bool ConstantAffixModifier::isStrong() const {
bool ConstantAffixModifier::containsField(Field field) const {
(void)field;
// This method is not currently used.
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
}
void ConstantAffixModifier::getParameters(Parameters& output) const {
(void)output;
// This method is not currently used.
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
}
bool ConstantAffixModifier::semanticallyEquivalent(const Modifier& other) const {
@ -181,7 +181,7 @@ bool SimpleModifier::isStrong() const {
bool SimpleModifier::containsField(Field field) const {
(void)field;
// This method is not currently used.
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
}
void SimpleModifier::getParameters(Parameters& output) const {

View file

@ -248,19 +248,19 @@ bool MutablePatternModifier::isStrong() const {
bool MutablePatternModifier::containsField(Field field) const {
(void)field;
// This method is not currently used.
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
}
void MutablePatternModifier::getParameters(Parameters& output) const {
(void)output;
// This method is not currently used.
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
}
bool MutablePatternModifier::semanticallyEquivalent(const Modifier& other) const {
(void)other;
// This method is not currently used.
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
}
int32_t MutablePatternModifier::insertPrefix(FormattedStringBuilder& sb, int position, UErrorCode& status) {
@ -331,13 +331,13 @@ UnicodeString MutablePatternModifier::getSymbol(AffixPatternType type) const {
case AffixPatternType::TYPE_CURRENCY_QUINT:
return UnicodeString(u"\uFFFD");
default:
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
}
}
UnicodeString MutablePatternModifier::toUnicodeString() const {
// Never called by AffixUtils
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
}
#endif /* #if !UCONFIG_NO_FORMATTING */

View file

@ -50,7 +50,7 @@ PatternParser::parseToExistingProperties(const UnicodeString& pattern, DecimalFo
char16_t ParsedPatternInfo::charAt(int32_t flags, int32_t index) const {
const Endpoints& endpoints = getEndpoints(flags);
if (index < 0 || index >= endpoints.end - endpoints.start) {
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
}
return pattern.charAt(endpoints.start + index);
}
@ -1148,7 +1148,7 @@ PatternSignType PatternStringUtils::resolveSignDisplay(UNumberSignDisplay signDi
break;
}
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
return PATTERN_SIGN_TYPE_POS;
}

View file

@ -498,10 +498,10 @@ void RoundingImpl::apply(impl::DecimalQuantity &value, UErrorCode& status) const
case Precision::RND_CURRENCY:
// Call .withCurrency() before .apply()!
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
default:
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
}
if (fPrecision.fTrailingZeroDisplay == UNUM_TRAILING_ZERO_AUTO ||

View file

@ -96,7 +96,7 @@ bool ScientificModifier::isStrong() const {
bool ScientificModifier::containsField(Field field) const {
(void)field;
// This method is not used for inner modifiers.
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
}
void ScientificModifier::getParameters(Parameters& output) const {

View file

@ -177,7 +177,7 @@ Notation stem_to_object::notation(skeleton::StemEnum stem) {
case STEM_NOTATION_SIMPLE:
return Notation::simple();
default:
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
}
}
@ -190,7 +190,7 @@ MeasureUnit stem_to_object::unit(skeleton::StemEnum stem) {
case STEM_PERMILLE:
return MeasureUnit::getPermille();
default:
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
}
}
@ -205,7 +205,7 @@ Precision stem_to_object::precision(skeleton::StemEnum stem) {
case STEM_PRECISION_CURRENCY_CASH:
return Precision::currency(UCURR_USAGE_CASH);
default:
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
}
}
@ -234,7 +234,7 @@ UNumberFormatRoundingMode stem_to_object::roundingMode(skeleton::StemEnum stem)
case STEM_ROUNDING_MODE_UNNECESSARY:
return UNUM_ROUND_UNNECESSARY;
default:
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
}
}
@ -349,7 +349,7 @@ void enum_to_stem_string::roundingMode(UNumberFormatRoundingMode value, UnicodeS
sb.append(u"rounding-mode-unnecessary", -1);
break;
default:
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
}
}
@ -371,7 +371,7 @@ void enum_to_stem_string::groupingStrategy(UNumberGroupingStrategy value, Unicod
sb.append(u"group-thousands", -1);
break;
default:
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
}
}
@ -399,7 +399,7 @@ void enum_to_stem_string::unitWidth(UNumberUnitWidth value, UnicodeString& sb) {
sb.append(u"unit-width-hidden", -1);
break;
default:
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
}
}
@ -433,7 +433,7 @@ void enum_to_stem_string::signDisplay(UNumberSignDisplay value, UnicodeString& s
sb.append(u"sign-accounting-negative", -1);
break;
default:
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
}
}
@ -447,7 +447,7 @@ enum_to_stem_string::decimalSeparatorDisplay(UNumberDecimalSeparatorDisplay valu
sb.append(u"decimal-always", -1);
break;
default:
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
}
}
@ -791,7 +791,7 @@ skeleton::parseStem(const StringSegment& segment, const UCharsTrie& stemTrie, Se
return STATE_SCALE;
default:
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
}
}

View file

@ -133,7 +133,7 @@ void mixedMeasuresToMicros(const MaybeStackVector<Measure> &measures, DecimalQua
default:
U_ASSERT(0 == "Found a Measure Number which is neither a double nor an int");
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
break;
}

View file

@ -70,7 +70,7 @@ const char16_t* utils::getPatternForStyle(const Locale& locale, const char* nsNa
break;
default:
patternKey = "decimalFormat"; // silence compiler error
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
}
LocalUResourceBundlePointer res(ures_open(nullptr, locale.getName(), &status));
if (U_FAILURE(status)) { return u""; }

View file

@ -101,7 +101,7 @@ void AffixPatternMatcherBuilder::consumeToken(AffixPatternType type, UChar32 cp,
addMatcher(fWarehouse.currency(status));
break;
default:
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
}
} else if (fIgnorables != nullptr && fIgnorables->getSet()->contains(cp)) {

View file

@ -285,7 +285,7 @@ void NumberParserImpl::parseGreedy(StringSegment& segment, ParsedNumber& result,
i++;
continue;
}
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
}
// NOTE: If we get here, the greedy parse completed without consuming the entire string.

View file

@ -229,7 +229,7 @@ void NumberRangeFormatterImpl::format(UFormattedNumberRangeData& data, bool equa
break;
default:
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
}
}

View file

@ -1616,7 +1616,7 @@ PluralOperand tokenTypeToPluralOperand(tokenType tt) {
case tVariableC:
return PLURAL_OPERAND_E;
default:
UPRV_UNREACHABLE; // unexpected.
UPRV_UNREACHABLE_EXIT; // unexpected.
}
}
@ -1889,7 +1889,7 @@ double FixedDecimal::getPluralOperand(PluralOperand operand) const {
case PLURAL_OPERAND_E: return exponent;
case PLURAL_OPERAND_C: return exponent;
default:
UPRV_UNREACHABLE; // unexpected.
UPRV_UNREACHABLE_EXIT; // unexpected.
}
}

View file

@ -1485,8 +1485,8 @@ UBool RegexCompile::doParseActions(int32_t action)
case 0x78: /* 'x' */ bit = UREGEX_COMMENTS; break;
case 0x2d: /* '-' */ fSetModeFlag = FALSE; break;
default:
UPRV_UNREACHABLE; // Should never happen. Other chars are filtered out
// by the scanner.
UPRV_UNREACHABLE_EXIT; // Should never happen. Other chars are filtered out
// by the scanner.
}
if (fSetModeFlag) {
fNewModeFlags |= bit;
@ -1863,7 +1863,7 @@ UBool RegexCompile::doParseActions(int32_t action)
}
default:
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
}
if (U_FAILURE(*fStatus)) {
@ -1970,17 +1970,17 @@ int32_t RegexCompile::buildOp(int32_t type, int32_t val) {
return 0;
}
if (type < 0 || type > 255) {
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
}
if (val > 0x00ffffff) {
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
}
if (val < 0) {
if (!(type == URX_RESERVED_OP_N || type == URX_RESERVED_OP)) {
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
}
if (URX_TYPE(val) != 0xff) {
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
}
type = URX_RESERVED_OP_N;
}
@ -2376,7 +2376,7 @@ void RegexCompile::handleCloseParen() {
default:
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
}
// remember the next location in the compiled pattern.
@ -2637,7 +2637,7 @@ void RegexCompile::findCaseInsensitiveStarters(UChar32 c, UnicodeSet *starterCh
if (c < UCHAR_MIN_VALUE || c > UCHAR_MAX_VALUE) {
// This function should never be called with an invalid input character.
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
} else if (u_hasBinaryProperty(c, UCHAR_CASE_SENSITIVE)) {
UChar32 caseFoldedC = u_foldCase(c, U_FOLD_CASE_DEFAULT);
starterChars->set(caseFoldedC, caseFoldedC);
@ -3130,10 +3130,10 @@ void RegexCompile::matchStartType() {
case URX_LB_END:
case URX_LBN_CONT:
case URX_LBN_END:
UPRV_UNREACHABLE; // Shouldn't get here. These ops should be
// consumed by the scan in URX_LA_START and LB_START
UPRV_UNREACHABLE_EXIT; // Shouldn't get here. These ops should be
// consumed by the scan in URX_LA_START and LB_START
default:
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
}
}
@ -3453,7 +3453,7 @@ int32_t RegexCompile::minMatchLength(int32_t start, int32_t end) {
break;
default:
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
}
}
@ -3699,7 +3699,7 @@ int32_t RegexCompile::maxMatchLength(int32_t start, int32_t end) {
case URX_CTR_LOOP_NG:
// These opcodes will be skipped over by code for URX_CTR_INIT.
// We shouldn't encounter them here.
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
case URX_LOOP_SR_I:
case URX_LOOP_DOT_I:
@ -3719,7 +3719,7 @@ int32_t RegexCompile::maxMatchLength(int32_t start, int32_t end) {
// End of look-ahead ops should always be consumed by the processing at
// the URX_LA_START op.
// UPRV_UNREACHABLE;
// UPRV_UNREACHABLE_EXIT;
case URX_LB_START:
{
@ -3738,7 +3738,7 @@ int32_t RegexCompile::maxMatchLength(int32_t start, int32_t end) {
break;
default:
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
}
@ -3893,7 +3893,7 @@ void RegexCompile::stripNOPs() {
default:
// Some op is unaccounted for.
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
}
}
@ -4644,7 +4644,7 @@ void RegexCompile::setEval(int32_t nextOp) {
delete rightOperand;
break;
default:
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
}
}
}

View file

@ -719,7 +719,7 @@ UBool RegexMatcher::find(UErrorCode &status) {
if (findProgressInterrupt(startPos, status))
return FALSE;
}
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
case START_START:
// Matches are only possible at the start of the input string
@ -767,7 +767,7 @@ UBool RegexMatcher::find(UErrorCode &status) {
return FALSE;
}
}
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
case START_STRING:
case START_CHAR:
@ -799,7 +799,7 @@ UBool RegexMatcher::find(UErrorCode &status) {
return FALSE;
}
}
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
case START_LINE:
{
@ -879,10 +879,15 @@ UBool RegexMatcher::find(UErrorCode &status) {
}
default:
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_ASSERT;
// Unknown value in fPattern->fStartType, should be from StartOfMatch enum. But
// we have reports of this in production code, don't use UPRV_UNREACHABLE_EXIT.
// See ICU-21669.
status = U_INTERNAL_PROGRAM_ERROR;
return FALSE;
}
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
}
@ -993,7 +998,7 @@ UBool RegexMatcher::findUsingChunk(UErrorCode &status) {
if (findProgressInterrupt(startPos, status))
return FALSE;
}
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
case START_START:
// Matches are only possible at the start of the input string
@ -1035,7 +1040,7 @@ UBool RegexMatcher::findUsingChunk(UErrorCode &status) {
return FALSE;
}
}
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
case START_STRING:
case START_CHAR:
@ -1064,7 +1069,7 @@ UBool RegexMatcher::findUsingChunk(UErrorCode &status) {
return FALSE;
}
}
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
case START_LINE:
{
@ -1135,10 +1140,15 @@ UBool RegexMatcher::findUsingChunk(UErrorCode &status) {
}
default:
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_ASSERT;
// Unknown value in fPattern->fStartType, should be from StartOfMatch enum. But
// we have reports of this in production code, don't use UPRV_UNREACHABLE_EXIT.
// See ICU-21669.
status = U_INTERNAL_PROGRAM_ERROR;
return FALSE;
}
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
}
@ -4234,7 +4244,11 @@ void RegexMatcher::MatchAt(int64_t startIdx, UBool toEnd, UErrorCode &status) {
default:
// Trouble. The compiled pattern contains an entry with an
// unrecognized type tag.
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_ASSERT;
// Unknown opcode type in opType = URX_TYPE(pat[fp->fPatIdx]). But we have
// reports of this in production code, don't use UPRV_UNREACHABLE_EXIT.
// See ICU-21669.
status = U_INTERNAL_PROGRAM_ERROR;
}
if (U_FAILURE(status)) {
@ -5672,7 +5686,11 @@ void RegexMatcher::MatchChunkAt(int32_t startIdx, UBool toEnd, UErrorCode &statu
default:
// Trouble. The compiled pattern contains an entry with an
// unrecognized type tag.
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_ASSERT;
// Unknown opcode type in opType = URX_TYPE(pat[fp->fPatIdx]). But we have
// reports of this in production code, don't use UPRV_UNREACHABLE_EXIT.
// See ICU-21669.
status = U_INTERNAL_PROGRAM_ERROR;
}
if (U_FAILURE(status)) {

View file

@ -1874,7 +1874,7 @@ SimpleDateFormat::subFormat(UnicodeString &appendTo,
}
}
else {
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
}
}
appendTo += zoneString;

View file

@ -1263,7 +1263,7 @@ TimeZone::getDisplayName(UBool inDaylight, EDisplayType style, const Locale& loc
tzfmt->format(UTZFMT_STYLE_GENERIC_SHORT, *this, date, result, &timeType);
break;
default:
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
}
// Generic format many use Localized GMT as the final fallback.
// When Localized GMT format is used, the result might not be
@ -1291,7 +1291,7 @@ TimeZone::getDisplayName(UBool inDaylight, EDisplayType style, const Locale& loc
tzfmt->formatOffsetISO8601Basic(offset, FALSE, FALSE, FALSE, result, status);
break;
default:
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
}
} else {
@ -1306,7 +1306,7 @@ TimeZone::getDisplayName(UBool inDaylight, EDisplayType style, const Locale& loc
nameType = inDaylight ? UTZNM_SHORT_DAYLIGHT : UTZNM_SHORT_STANDARD;
break;
default:
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
}
LocalPointer<TimeZoneNames> tznames(TimeZoneNames::createInstance(locale, status));
if (U_FAILURE(status)) {

View file

@ -94,7 +94,7 @@ TimeUnit::TimeUnit(TimeUnit::UTimeUnitFields timeUnitField) {
initTime("second");
break;
default:
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
}
}

View file

@ -187,7 +187,7 @@ Transliterator* TransliteratorAlias::create(UParseError& pe,
}
break;
case RULES:
UPRV_UNREACHABLE; // don't call create() if isRuleBased() returns TRUE!
UPRV_UNREACHABLE_EXIT; // don't call create() if isRuleBased() returns TRUE!
}
return t;
}
@ -1402,7 +1402,7 @@ Transliterator* TransliteratorRegistry::instantiateEntry(const UnicodeString& ID
}
return 0;
default:
UPRV_UNREACHABLE; // can't get here
UPRV_UNREACHABLE_EXIT; // can't get here
}
}
U_NAMESPACE_END

View file

@ -270,7 +270,7 @@ GMTOffsetField::isValid(FieldType type, int32_t width) {
case SECOND:
return (width == 2);
default:
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
}
return (width > 0);
}
@ -595,7 +595,7 @@ TimeZoneFormat::setGMTOffsetPattern(UTimeZoneFormatGMTOffsetPatternType type, co
required = FIELDS_HMS;
break;
default:
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
}
UVector* patternItems = parseOffsetPattern(pattern, required, status);
@ -1033,7 +1033,7 @@ TimeZoneFormat::parse(UTimeZoneFormatStyle style, const UnicodeString& text, Par
break;
default:
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
}
int32_t len = 0;

View file

@ -463,7 +463,7 @@ umsg_vformat( const UMessageFormat *fmt,
default:
// Unknown/unsupported argument type.
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
}
}
UnicodeString resultStr;
@ -590,11 +590,11 @@ umsg_vparse(const UMessageFormat *fmt,
// support kObject. When MessageFormat is changed to
// understand MeasureFormats, modify this code to do the
// right thing. [alan]
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
// better not happen!
case Formattable::kArray:
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
}
}

View file

@ -1432,10 +1432,11 @@ const CEI *CEIBuffer::get(int32_t index) {
// Verify that it is the next one in sequence, which is all
// that is allowed.
if (index != limitIx) {
U_ASSERT(FALSE);
// TODO: In ICU 64 the above assert was changed to use UPRV_UNREACHABLE instead
// which unconditionally calls abort(). However, there were cases where this was
// being hit. This change is reverted for now, restoring the existing behavior.
UPRV_UNREACHABLE_ASSERT;
// TODO: In ICU 64 the above was changed from U_ASSERT to UPRV_UNREACHABLE,
// which unconditionally called abort(). However, there were cases in which it
// was being hit, so it was changed back to U_ASSERT per ICU-20680. In ICU 70,
// we now use the new UPRV_UNREACHABLE_ASSERT to better indicate the situation.
// ICU-20792 tracks the follow-up work/further investigation on this.
return NULL;
}
@ -1474,10 +1475,11 @@ const CEI *CEIBuffer::getPrevious(int32_t index) {
// Verify that it is the next one in sequence, which is all
// that is allowed.
if (index != limitIx) {
U_ASSERT(FALSE);
// TODO: In ICU 64 the above assert was changed to use UPRV_UNREACHABLE instead
// which unconditionally calls abort(). However, there were cases where this was
// being hit. This change is reverted for now, restoring the existing behavior.
UPRV_UNREACHABLE_ASSERT;
// TODO: In ICU 64 the above was changed from U_ASSERT to UPRV_UNREACHABLE,
// which unconditionally called abort(). However, there were cases in which it
// was being hit, so it was changed back to U_ASSERT per ICU-20680. In ICU 70,
// we now use the new UPRV_UNREACHABLE_ASSERT to better indicate the situation.
// ICU-20792 tracks the follow-up work/further investigation on this.
return NULL;
}

View file

@ -729,7 +729,7 @@ void *SpoofData::reserveSpace(int32_t numBytes, UErrorCode &status) {
return NULL;
}
if (!fDataOwned) {
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
}
numBytes = (numBytes + 15) & ~15; // Round up to a multiple of 16

View file

@ -558,7 +558,7 @@ static void TestGetDefaultHourCycle() {
}
}
// Ensure that calling udatpg_getDefaultHourCycle on an empty instance doesn't call UPRV_UNREACHABLE/abort.
// Ensure that calling udatpg_getDefaultHourCycle on an empty instance doesn't call UPRV_UNREACHABLE_EXIT/abort.
static void TestGetDefaultHourCycleOnEmptyInstance() {
UErrorCode status = U_ZERO_ERROR;
UDateTimePatternGenerator * dtpgen = udatpg_openEmpty(&status);

View file

@ -1487,7 +1487,7 @@ void IntlTestDateTimePatternGeneratorAPI::testFallbackWithDefaultRootLocale() {
}
}
// ICU-21000 Ensure that calling getDefaultHourCycle on an empty instance doesn't call UPRV_UNREACHABLE/abort.
// ICU-21000 Ensure that calling getDefaultHourCycle on an empty instance doesn't call UPRV_UNREACHABLE_EXIT/abort.
void IntlTestDateTimePatternGeneratorAPI::testGetDefaultHourCycle_OnEmptyInstance() {
UErrorCode status = U_ZERO_ERROR;

View file

@ -56,7 +56,7 @@ UScriptCode getScriptFromModelName(const std::string& modelName) {
return USCRIPT_MYANMAR;
}
// Add for other script codes.
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
}
// Read file generated by

View file

@ -44,7 +44,7 @@ class DefaultSymbolProvider : public SymbolProvider {
case TYPE_CURRENCY_OVERFLOW:
return u"\uFFFD";
default:
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
}
}
};

View file

@ -340,7 +340,7 @@ usrc_writeUCPTrie(FILE *f, const char *name, const UCPTrie *pTrie, UTargetSyntax
sprintf(line3, "\n]\n");
break;
default:
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
}
usrc_writeUCPTrieArrays(f, line, line2, pTrie, line3, syntax);
@ -358,7 +358,7 @@ usrc_writeUCPTrie(FILE *f, const char *name, const UCPTrie *pTrie, UTargetSyntax
line4[0] = 0;
break;
default:
UPRV_UNREACHABLE;
UPRV_UNREACHABLE_EXIT;
}
usrc_writeUCPTrieStruct(f, line, pTrie, line2, line3, line4, syntax);
}