mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-06 22:15:31 +00:00
ICU-22621 Clang-Tidy: readability-qualified-auto
https://releases.llvm.org/17.0.1/tools/clang/tools/extra/docs/clang-tidy/checks/readability/qualified-auto.html
This commit is contained in:
parent
4f2cefb7ca
commit
e017edc97d
44 changed files with 118 additions and 114 deletions
|
@ -21,13 +21,13 @@ U_NAMESPACE_BEGIN
|
|||
namespace {
|
||||
|
||||
int32_t hashLocale(const UHashTok token) {
|
||||
auto *locale = static_cast<const Locale *>(token.pointer);
|
||||
const auto* locale = static_cast<const Locale*>(token.pointer);
|
||||
return locale->hashCode();
|
||||
}
|
||||
|
||||
UBool compareLocales(const UHashTok t1, const UHashTok t2) {
|
||||
auto *l1 = static_cast<const Locale *>(t1.pointer);
|
||||
auto *l2 = static_cast<const Locale *>(t2.pointer);
|
||||
const auto* l1 = static_cast<const Locale*>(t1.pointer);
|
||||
const auto* l2 = static_cast<const Locale*>(t2.pointer);
|
||||
return *l1 == *l2;
|
||||
}
|
||||
|
||||
|
|
|
@ -2203,7 +2203,7 @@ static void U_CALLCONV initIsoCodes(UErrorCode &status) {
|
|||
|
||||
static void populateCurrSymbolsEquiv(icu::Hashtable *hash, UErrorCode &status) {
|
||||
if (U_FAILURE(status)) { return; }
|
||||
for (auto& entry : unisets::kCurrencyEntries) {
|
||||
for (const auto& entry : unisets::kCurrencyEntries) {
|
||||
UnicodeString exemplar(entry.exemplar);
|
||||
const UnicodeSet* set = unisets::get(entry.key);
|
||||
if (set == nullptr) { return; }
|
||||
|
|
|
@ -279,7 +279,7 @@ UnicodeString&
|
|||
DateFormat::format(UDate date, UnicodeString& appendTo, FieldPosition& fieldPosition) const {
|
||||
if (fCalendar != nullptr) {
|
||||
UErrorCode ec = U_ZERO_ERROR;
|
||||
auto calType = fCalendar->getType();
|
||||
const auto* calType = fCalendar->getType();
|
||||
// Avoid a heap allocation and corresponding free for the common case
|
||||
if (uprv_strcmp(calType, "gregorian") == 0) {
|
||||
GregorianCalendar cal(*static_cast<GregorianCalendar*>(fCalendar));
|
||||
|
@ -309,7 +309,7 @@ DateFormat::format(UDate date, UnicodeString& appendTo, FieldPositionIterator* p
|
|||
UErrorCode& status) const {
|
||||
if (fCalendar != nullptr) {
|
||||
UErrorCode ec = U_ZERO_ERROR;
|
||||
auto calType = fCalendar->getType();
|
||||
const auto* calType = fCalendar->getType();
|
||||
// Avoid a heap allocation and corresponding free for the common case
|
||||
if (uprv_strcmp(calType, "gregorian") == 0) {
|
||||
GregorianCalendar cal(*static_cast<GregorianCalendar*>(fCalendar));
|
||||
|
|
|
@ -498,7 +498,7 @@ DecimalFormat* DecimalFormat::clone() const {
|
|||
}
|
||||
|
||||
bool DecimalFormat::operator==(const Format& other) const {
|
||||
auto* otherDF = dynamic_cast<const DecimalFormat*>(&other);
|
||||
const auto* otherDF = dynamic_cast<const DecimalFormat*>(&other);
|
||||
if (otherDF == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -72,8 +72,8 @@ FormattedStringBuilder &FormattedStringBuilder::operator=(const FormattedStringB
|
|||
if (capacity > DEFAULT_CAPACITY) {
|
||||
// FIXME: uprv_malloc
|
||||
// C++ note: malloc appears in two places: here and in prepareForInsertHelper.
|
||||
auto newChars = static_cast<char16_t *> (uprv_malloc(sizeof(char16_t) * capacity));
|
||||
auto newFields = static_cast<Field *>(uprv_malloc(sizeof(Field) * capacity));
|
||||
auto* newChars = static_cast<char16_t*>(uprv_malloc(sizeof(char16_t) * capacity));
|
||||
auto* newFields = static_cast<Field*>(uprv_malloc(sizeof(Field) * capacity));
|
||||
if (newChars == nullptr || newFields == nullptr) {
|
||||
// UErrorCode is not available; fail silently.
|
||||
uprv_free(newChars);
|
||||
|
@ -153,8 +153,8 @@ FormattedStringBuilder::insertCodePoint(int32_t index, UChar32 codePoint, Field
|
|||
if (U_FAILURE(status)) {
|
||||
return count;
|
||||
}
|
||||
auto charPtr = getCharPtr();
|
||||
auto fieldPtr = getFieldPtr();
|
||||
auto* charPtr = getCharPtr();
|
||||
auto* fieldPtr = getFieldPtr();
|
||||
if (count == 1) {
|
||||
charPtr[position] = (char16_t) codePoint;
|
||||
fieldPtr[position] = field;
|
||||
|
@ -308,8 +308,10 @@ int32_t FormattedStringBuilder::prepareForInsertHelper(int32_t index, int32_t co
|
|||
newZero = (newCapacity - newLength) / 2;
|
||||
|
||||
// C++ note: malloc appears in two places: here and in the assignment operator.
|
||||
auto newChars = static_cast<char16_t *> (uprv_malloc(sizeof(char16_t) * static_cast<size_t>(newCapacity)));
|
||||
auto newFields = static_cast<Field *>(uprv_malloc(sizeof(Field) * static_cast<size_t>(newCapacity)));
|
||||
auto* newChars =
|
||||
static_cast<char16_t*>(uprv_malloc(sizeof(char16_t) * static_cast<size_t>(newCapacity)));
|
||||
auto* newFields =
|
||||
static_cast<Field*>(uprv_malloc(sizeof(Field) * static_cast<size_t>(newCapacity)));
|
||||
if (newChars == nullptr || newFields == nullptr) {
|
||||
uprv_free(newChars);
|
||||
uprv_free(newFields);
|
||||
|
|
|
@ -501,14 +501,14 @@ UnicodeString &MeasureFormat::formatMeasurePerUnit(
|
|||
if (U_FAILURE(status)) {
|
||||
return appendTo;
|
||||
}
|
||||
auto* df = dynamic_cast<const DecimalFormat*>(&getNumberFormatInternal());
|
||||
const auto* df = dynamic_cast<const DecimalFormat*>(&getNumberFormatInternal());
|
||||
if (df == nullptr) {
|
||||
// Don't know how to handle other types of NumberFormat
|
||||
status = U_UNSUPPORTED_ERROR;
|
||||
return appendTo;
|
||||
}
|
||||
UFormattedNumberData result;
|
||||
if (auto* lnf = df->toNumberFormatter(status)) {
|
||||
if (const auto* lnf = df->toNumberFormatter(status)) {
|
||||
result.quantity.setToDouble(measure.getNumber().getDouble(status));
|
||||
lnf->unit(measure.getUnit())
|
||||
.perUnit(perUnit)
|
||||
|
@ -691,7 +691,7 @@ UnicodeString &MeasureFormat::formatMeasure(
|
|||
pos,
|
||||
status);
|
||||
}
|
||||
auto* df = dynamic_cast<const DecimalFormat*>(&nf);
|
||||
const auto* df = dynamic_cast<const DecimalFormat*>(&nf);
|
||||
if (df == nullptr) {
|
||||
// Handle other types of NumberFormat using the ICU 63 code, modified to
|
||||
// get the unitPattern from LongNameHandler and handle fallback to OTHER.
|
||||
|
@ -708,7 +708,7 @@ UnicodeString &MeasureFormat::formatMeasure(
|
|||
return QuantityFormatter::format(formatter, formattedNumber, appendTo, pos, status);
|
||||
}
|
||||
UFormattedNumberData result;
|
||||
if (auto* lnf = df->toNumberFormatter(status)) {
|
||||
if (const auto* lnf = df->toNumberFormatter(status)) {
|
||||
result.quantity.setToDouble(amtNumber.getDouble(status));
|
||||
lnf->unit(amtUnit)
|
||||
.unitWidth(getUnitWidth(fWidth))
|
||||
|
@ -761,7 +761,7 @@ UnicodeString &MeasureFormat::formatNumeric(
|
|||
return appendTo;
|
||||
}
|
||||
number::LocalizedNumberFormatter numberFormatter2;
|
||||
if (auto* lnf = numberFormatter->toNumberFormatter(status)) {
|
||||
if (const auto* lnf = numberFormatter->toNumberFormatter(status)) {
|
||||
numberFormatter2 = lnf->integerWidth(number::IntegerWidth::zeroFillTo(2));
|
||||
} else {
|
||||
return appendTo;
|
||||
|
|
|
@ -801,8 +801,8 @@ private:
|
|||
// Sorting function wrapping SingleUnitImpl::compareTo for use with uprv_sortArray.
|
||||
int32_t U_CALLCONV
|
||||
compareSingleUnits(const void* /*context*/, const void* left, const void* right) {
|
||||
auto realLeft = static_cast<const SingleUnitImpl* const*>(left);
|
||||
auto realRight = static_cast<const SingleUnitImpl* const*>(right);
|
||||
const auto* realLeft = static_cast<const SingleUnitImpl* const*>(left);
|
||||
const auto* realRight = static_cast<const SingleUnitImpl* const*>(right);
|
||||
return (*realLeft)->compareTo(**realRight);
|
||||
}
|
||||
|
||||
|
|
|
@ -1983,7 +1983,7 @@ UnicodeString MessageFormat::PluralSelectorProvider::select(void *ctx, double nu
|
|||
return UnicodeString(false, OTHER_STRING, 5);
|
||||
}
|
||||
context.formatter->format(context.number, context.numberString, ec);
|
||||
auto* decFmt = dynamic_cast<const DecimalFormat *>(context.formatter);
|
||||
const auto* decFmt = dynamic_cast<const DecimalFormat*>(context.formatter);
|
||||
if(decFmt != nullptr) {
|
||||
number::impl::DecimalQuantity dq;
|
||||
decFmt->formatToDecimalQuantity(context.number, dq, ec);
|
||||
|
|
|
@ -33,7 +33,7 @@ LocalizedNumberFormatterAsFormat::LocalizedNumberFormatterAsFormat(
|
|||
LocalizedNumberFormatterAsFormat::~LocalizedNumberFormatterAsFormat() = default;
|
||||
|
||||
bool LocalizedNumberFormatterAsFormat::operator==(const Format& other) const {
|
||||
auto* _other = dynamic_cast<const LocalizedNumberFormatterAsFormat*>(&other);
|
||||
const auto* _other = dynamic_cast<const LocalizedNumberFormatterAsFormat*>(&other);
|
||||
if (_other == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -96,7 +96,7 @@ UPRV_FORMATTED_VALUE_CAPI_NO_IMPLTYPE_AUTO_IMPL(
|
|||
|
||||
const DecimalQuantity* icu::number::impl::validateUFormattedNumberToDecimalQuantity(
|
||||
const UFormattedNumber* uresult, UErrorCode& status) {
|
||||
auto* result = UFormattedNumberApiHelper::validate(uresult, status);
|
||||
const auto* result = UFormattedNumberApiHelper::validate(uresult, status);
|
||||
if (U_FAILURE(status)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -355,7 +355,7 @@ usnumf_format(
|
|||
USimpleNumber* unumber,
|
||||
UFormattedNumber* uresult,
|
||||
UErrorCode* ec) {
|
||||
auto* formatter = USimpleNumberFormatterData::validate(uformatter, *ec);
|
||||
const auto* formatter = USimpleNumberFormatterData::validate(uformatter, *ec);
|
||||
auto* number = USimpleNumberData::validate(unumber, *ec);
|
||||
auto* result = UFormattedNumberApiHelper::validate(uresult, *ec);
|
||||
if (U_FAILURE(*ec)) {
|
||||
|
@ -374,7 +374,7 @@ usnumf_formatInt64(
|
|||
int64_t value,
|
||||
UFormattedNumber* uresult,
|
||||
UErrorCode* ec) {
|
||||
auto* formatter = USimpleNumberFormatterData::validate(uformatter, *ec);
|
||||
const auto* formatter = USimpleNumberFormatterData::validate(uformatter, *ec);
|
||||
auto* result = UFormattedNumberApiHelper::validate(uresult, *ec);
|
||||
if (U_FAILURE(*ec)) {
|
||||
return;
|
||||
|
|
|
@ -143,7 +143,7 @@ void CompactData::getUniquePatterns(UVector &output, UErrorCode &status) const {
|
|||
U_ASSERT(output.isEmpty());
|
||||
// NOTE: In C++, this is done more manually with a UVector.
|
||||
// In Java, we can take advantage of JDK HashSet.
|
||||
for (auto pattern : patterns) {
|
||||
for (const auto* pattern : patterns) {
|
||||
if (pattern == nullptr || pattern == USE_FALLBACK) {
|
||||
continue;
|
||||
}
|
||||
|
@ -279,7 +279,7 @@ void CompactHandler::precomputeAllModifiers(MutablePatternModifier &buildReferen
|
|||
}
|
||||
|
||||
for (int32_t i = 0; i < precomputedModsLength; i++) {
|
||||
auto patternString = static_cast<const char16_t *>(allPatterns[i]);
|
||||
const auto* patternString = static_cast<const char16_t*>(allPatterns[i]);
|
||||
UnicodeString hello(patternString);
|
||||
CompactModInfo &info = precomputedMods[i];
|
||||
ParsedPatternInfo patternInfo;
|
||||
|
|
|
@ -1322,7 +1322,7 @@ void DecimalQuantity::ensureCapacity(int32_t capacity) {
|
|||
// Initialize the byte array to zeros (this is done automatically in Java)
|
||||
uprv_memset(fBCD.bcdBytes.ptr, 0, capacity * sizeof(int8_t));
|
||||
} else if (oldCapacity < capacity) {
|
||||
auto bcd1 = static_cast<int8_t*>(uprv_malloc(capacity * 2 * sizeof(int8_t)));
|
||||
auto* bcd1 = static_cast<int8_t*>(uprv_malloc(capacity * 2 * sizeof(int8_t)));
|
||||
uprv_memcpy(bcd1, fBCD.bcdBytes.ptr, oldCapacity * sizeof(int8_t));
|
||||
// Initialize the rest of the byte array to zeros (this is done automatically in Java)
|
||||
uprv_memset(bcd1 + oldCapacity, 0, (capacity - oldCapacity) * sizeof(int8_t));
|
||||
|
|
|
@ -573,7 +573,7 @@ LocalizedNumberFormatter UnlocalizedNumberFormatter::locale(const Locale& locale
|
|||
|
||||
FormattedNumber LocalizedNumberFormatter::formatInt(int64_t value, UErrorCode& status) const {
|
||||
if (U_FAILURE(status)) { return FormattedNumber(U_ILLEGAL_ARGUMENT_ERROR); }
|
||||
auto results = new UFormattedNumberData();
|
||||
auto* results = new UFormattedNumberData();
|
||||
if (results == nullptr) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return FormattedNumber(status);
|
||||
|
@ -592,7 +592,7 @@ FormattedNumber LocalizedNumberFormatter::formatInt(int64_t value, UErrorCode& s
|
|||
|
||||
FormattedNumber LocalizedNumberFormatter::formatDouble(double value, UErrorCode& status) const {
|
||||
if (U_FAILURE(status)) { return FormattedNumber(U_ILLEGAL_ARGUMENT_ERROR); }
|
||||
auto results = new UFormattedNumberData();
|
||||
auto* results = new UFormattedNumberData();
|
||||
if (results == nullptr) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return FormattedNumber(status);
|
||||
|
@ -611,7 +611,7 @@ FormattedNumber LocalizedNumberFormatter::formatDouble(double value, UErrorCode&
|
|||
|
||||
FormattedNumber LocalizedNumberFormatter::formatDecimal(StringPiece value, UErrorCode& status) const {
|
||||
if (U_FAILURE(status)) { return FormattedNumber(U_ILLEGAL_ARGUMENT_ERROR); }
|
||||
auto results = new UFormattedNumberData();
|
||||
auto* results = new UFormattedNumberData();
|
||||
if (results == nullptr) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return FormattedNumber(status);
|
||||
|
@ -631,7 +631,7 @@ FormattedNumber LocalizedNumberFormatter::formatDecimal(StringPiece value, UErro
|
|||
FormattedNumber
|
||||
LocalizedNumberFormatter::formatDecimalQuantity(const DecimalQuantity& dq, UErrorCode& status) const {
|
||||
if (U_FAILURE(status)) { return FormattedNumber(U_ILLEGAL_ARGUMENT_ERROR); }
|
||||
auto results = new UFormattedNumberData();
|
||||
auto* results = new UFormattedNumberData();
|
||||
if (results == nullptr) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return FormattedNumber(status);
|
||||
|
|
|
@ -229,7 +229,7 @@ NumberFormatterImpl::macrosToMicroGenerator(const MacroProps& macros, bool safe,
|
|||
return nullptr;
|
||||
}
|
||||
}
|
||||
auto patternInfo = new ParsedPatternInfo();
|
||||
auto* patternInfo = new ParsedPatternInfo();
|
||||
if (patternInfo == nullptr) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return nullptr;
|
||||
|
@ -252,12 +252,12 @@ NumberFormatterImpl::macrosToMicroGenerator(const MacroProps& macros, bool safe,
|
|||
status = U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return nullptr;
|
||||
}
|
||||
auto usagePrefsHandler =
|
||||
auto* usagePrefsHandler =
|
||||
new UsagePrefsHandler(macros.locale, macros.unit, macros.usage.fValue, chain, status);
|
||||
fUsagePrefsHandler.adoptInsteadAndCheckErrorCode(usagePrefsHandler, status);
|
||||
chain = fUsagePrefsHandler.getAlias();
|
||||
} else if (isMixedUnit) {
|
||||
auto unitConversionHandler = new UnitConversionHandler(macros.unit, chain, status);
|
||||
auto* unitConversionHandler = new UnitConversionHandler(macros.unit, chain, status);
|
||||
fUnitConversionHandler.adoptInsteadAndCheckErrorCode(unitConversionHandler, status);
|
||||
chain = fUnitConversionHandler.getAlias();
|
||||
}
|
||||
|
@ -333,7 +333,8 @@ NumberFormatterImpl::macrosToMicroGenerator(const MacroProps& macros, bool safe,
|
|||
|
||||
// Inner modifier (scientific notation)
|
||||
if (macros.notation.fType == Notation::NTN_SCIENTIFIC) {
|
||||
auto newScientificHandler = new ScientificHandler(¯os.notation, fMicros.simple.symbols, chain);
|
||||
auto* newScientificHandler =
|
||||
new ScientificHandler(¯os.notation, fMicros.simple.symbols, chain);
|
||||
if (newScientificHandler == nullptr) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return nullptr;
|
||||
|
@ -346,7 +347,7 @@ NumberFormatterImpl::macrosToMicroGenerator(const MacroProps& macros, bool safe,
|
|||
}
|
||||
|
||||
// Middle modifier (patterns, positive/negative, currency symbols, percent)
|
||||
auto patternModifier = new MutablePatternModifier(false);
|
||||
auto* patternModifier = new MutablePatternModifier(false);
|
||||
if (patternModifier == nullptr) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return nullptr;
|
||||
|
@ -444,7 +445,7 @@ NumberFormatterImpl::macrosToMicroGenerator(const MacroProps& macros, bool safe,
|
|||
if (isCompactNotation) {
|
||||
CompactType compactType = (isCurrency && unitWidth != UNUM_UNIT_WIDTH_FULL_NAME)
|
||||
? CompactType::TYPE_CURRENCY : CompactType::TYPE_DECIMAL;
|
||||
auto newCompactHandler = new CompactHandler(
|
||||
auto* newCompactHandler = new CompactHandler(
|
||||
macros.notation.fUnion.compactStyle,
|
||||
macros.locale,
|
||||
nsName,
|
||||
|
|
|
@ -140,9 +140,9 @@ class AutoAffixPatternProvider {
|
|||
}
|
||||
|
||||
inline void setTo(const AffixPatternProvider* provider, UErrorCode& status) {
|
||||
if (auto ptr = dynamic_cast<const PropertiesAffixPatternProvider*>(provider)) {
|
||||
if (const auto* ptr = dynamic_cast<const PropertiesAffixPatternProvider*>(provider)) {
|
||||
propertiesAPP = *ptr;
|
||||
} else if (auto ptr = dynamic_cast<const CurrencyPluralInfoAffixProvider*>(provider)) {
|
||||
} else if (const auto* ptr = dynamic_cast<const CurrencyPluralInfoAffixProvider*>(provider)) {
|
||||
currencyPluralInfoAPP = *ptr;
|
||||
} else {
|
||||
status = U_INTERNAL_PROGRAM_ERROR;
|
||||
|
|
|
@ -74,8 +74,8 @@ bool Modifier::semanticallyEquivalent(const Modifier& other) const {
|
|||
auto signum = static_cast<Signum>(i);
|
||||
for (size_t j=0; j<StandardPlural::COUNT; j++) {
|
||||
auto plural = static_cast<StandardPlural::Form>(j);
|
||||
auto mod1 = paramsThis.obj->getModifier(signum, plural);
|
||||
auto mod2 = paramsOther.obj->getModifier(signum, plural);
|
||||
const auto* mod1 = paramsThis.obj->getModifier(signum, plural);
|
||||
const auto* mod2 = paramsOther.obj->getModifier(signum, plural);
|
||||
if (mod1 == mod2) {
|
||||
// Equal pointers
|
||||
continue;
|
||||
|
@ -146,7 +146,7 @@ void ConstantAffixModifier::getParameters(Parameters& output) const {
|
|||
}
|
||||
|
||||
bool ConstantAffixModifier::strictEquals(const Modifier& other) const {
|
||||
auto* _other = dynamic_cast<const ConstantAffixModifier*>(&other);
|
||||
const auto* _other = dynamic_cast<const ConstantAffixModifier*>(&other);
|
||||
if (_other == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
@ -233,7 +233,7 @@ void SimpleModifier::getParameters(Parameters& output) const {
|
|||
}
|
||||
|
||||
bool SimpleModifier::strictEquals(const Modifier& other) const {
|
||||
auto* _other = dynamic_cast<const SimpleModifier*>(&other);
|
||||
const auto* _other = dynamic_cast<const SimpleModifier*>(&other);
|
||||
if (_other == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
@ -360,7 +360,7 @@ void ConstantMultiFieldModifier::getParameters(Parameters& output) const {
|
|||
}
|
||||
|
||||
bool ConstantMultiFieldModifier::strictEquals(const Modifier& other) const {
|
||||
auto* _other = dynamic_cast<const ConstantMultiFieldModifier*>(&other);
|
||||
const auto* _other = dynamic_cast<const ConstantMultiFieldModifier*>(&other);
|
||||
if (_other == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ ImmutablePatternModifier* MutablePatternModifier::createImmutable(UErrorCode& st
|
|||
StandardPlural::Form::MANY,
|
||||
StandardPlural::Form::OTHER};
|
||||
|
||||
auto pm = new AdoptingModifierStore();
|
||||
auto* pm = new AdoptingModifierStore();
|
||||
if (pm == nullptr) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return nullptr;
|
||||
|
@ -176,7 +176,7 @@ void MutablePatternModifier::processQuantity(DecimalQuantity& fq, MicroProps& mi
|
|||
}
|
||||
// The unsafe code path performs self-mutation, so we need a const_cast.
|
||||
// This method needs to be const because it overrides a const method in the parent class.
|
||||
auto nonConstThis = const_cast<MutablePatternModifier*>(this);
|
||||
auto* nonConstThis = const_cast<MutablePatternModifier*>(this);
|
||||
if (needsPlurals()) {
|
||||
StandardPlural::Form pluralForm = utils::getPluralSafe(micros.rounder, fRules, fq, status);
|
||||
nonConstThis->setNumberProperties(fq.signum(), pluralForm);
|
||||
|
@ -190,7 +190,7 @@ int32_t MutablePatternModifier::apply(FormattedStringBuilder& output, int32_t le
|
|||
UErrorCode& status) const {
|
||||
// The unsafe code path performs self-mutation, so we need a const_cast.
|
||||
// This method needs to be const because it overrides a const method in the parent class.
|
||||
auto nonConstThis = const_cast<MutablePatternModifier*>(this);
|
||||
auto* nonConstThis = const_cast<MutablePatternModifier*>(this);
|
||||
int32_t prefixLen = nonConstThis->insertPrefix(output, leftIndex, status);
|
||||
int32_t suffixLen = nonConstThis->insertSuffix(output, rightIndex + prefixLen, status);
|
||||
// If the pattern had no decimal stem body (like #,##0.00), overwrite the value.
|
||||
|
@ -219,7 +219,7 @@ int32_t MutablePatternModifier::apply(FormattedStringBuilder& output, int32_t le
|
|||
int32_t MutablePatternModifier::getPrefixLength() const {
|
||||
// The unsafe code path performs self-mutation, so we need a const_cast.
|
||||
// This method needs to be const because it overrides a const method in the parent class.
|
||||
auto nonConstThis = const_cast<MutablePatternModifier*>(this);
|
||||
auto* nonConstThis = const_cast<MutablePatternModifier*>(this);
|
||||
|
||||
// Enter and exit CharSequence Mode to get the length.
|
||||
UErrorCode status = U_ZERO_ERROR; // status fails only with an iilegal argument exception
|
||||
|
@ -231,7 +231,7 @@ int32_t MutablePatternModifier::getPrefixLength() const {
|
|||
int32_t MutablePatternModifier::getCodePointCount() const {
|
||||
// The unsafe code path performs self-mutation, so we need a const_cast.
|
||||
// This method needs to be const because it overrides a const method in the parent class.
|
||||
auto nonConstThis = const_cast<MutablePatternModifier*>(this);
|
||||
auto* nonConstThis = const_cast<MutablePatternModifier*>(this);
|
||||
|
||||
// Render the affixes to get the length
|
||||
UErrorCode status = U_ZERO_ERROR; // status fails only with an iilegal argument exception
|
||||
|
|
|
@ -105,7 +105,7 @@ void ScientificModifier::getParameters(Parameters& output) const {
|
|||
}
|
||||
|
||||
bool ScientificModifier::strictEquals(const Modifier& other) const {
|
||||
auto* _other = dynamic_cast<const ScientificModifier*>(&other);
|
||||
const auto* _other = dynamic_cast<const ScientificModifier*>(&other);
|
||||
if (_other == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ SimpleNumber::forInt64(int64_t value, UErrorCode& status) {
|
|||
if (U_FAILURE(status)) {
|
||||
return SimpleNumber();
|
||||
}
|
||||
auto results = new UFormattedNumberData();
|
||||
auto* results = new UFormattedNumberData();
|
||||
if (results == nullptr) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return SimpleNumber();
|
||||
|
@ -176,7 +176,7 @@ void SimpleNumberFormatter::initialize(
|
|||
}
|
||||
fMicros->symbols = &symbols;
|
||||
|
||||
auto pattern = utils::getPatternForStyle(
|
||||
const auto* pattern = utils::getPatternForStyle(
|
||||
locale,
|
||||
symbols.getNumberingSystemName(),
|
||||
CLDR_PATTERN_STYLE_DECIMAL,
|
||||
|
@ -211,7 +211,7 @@ FormattedNumber SimpleNumberFormatter::format(SimpleNumber value, UErrorCode &st
|
|||
|
||||
// Do not save the results object if we encountered a failure.
|
||||
if (U_SUCCESS(status)) {
|
||||
auto temp = value.fData;
|
||||
auto* temp = value.fData;
|
||||
value.fData = nullptr;
|
||||
return FormattedNumber(temp);
|
||||
} else {
|
||||
|
|
|
@ -1344,7 +1344,7 @@ bool blueprint_helpers::parseFracSigOption(const StringSegment& segment, MacroPr
|
|||
// @, @@, @@@
|
||||
maxSig = minSig;
|
||||
}
|
||||
auto& oldPrecision = static_cast<const FractionPrecision&>(macros.precision);
|
||||
const auto& oldPrecision = static_cast<const FractionPrecision&>(macros.precision);
|
||||
if (offset < segment.length()) {
|
||||
UNumberRoundingPriority priority;
|
||||
if (maxSig == -1) {
|
||||
|
|
|
@ -24,7 +24,7 @@ bool SeriesMatcher::match(StringSegment& segment, ParsedNumber& result, UErrorCo
|
|||
|
||||
int32_t initialOffset = segment.getOffset();
|
||||
bool maybeMore = true;
|
||||
for (auto* it = begin(); it < end();) {
|
||||
for (const auto* it = begin(); it < end();) {
|
||||
const NumberParseMatcher* matcher = *it;
|
||||
int matcherOffset = segment.getOffset();
|
||||
if (segment.length() != 0) {
|
||||
|
@ -64,7 +64,7 @@ bool SeriesMatcher::match(StringSegment& segment, ParsedNumber& result, UErrorCo
|
|||
bool SeriesMatcher::smokeTest(const StringSegment& segment) const {
|
||||
// NOTE: The range-based for loop calls the virtual begin() and end() methods.
|
||||
// NOTE: We only want the first element. Use the for loop for boundary checking.
|
||||
for (auto& matcher : *this) {
|
||||
for (const auto& matcher : *this) {
|
||||
// SeriesMatchers are never allowed to start with a Flexible matcher.
|
||||
U_ASSERT(!matcher->isFlexible());
|
||||
return matcher->smokeTest(segment);
|
||||
|
@ -74,7 +74,7 @@ bool SeriesMatcher::smokeTest(const StringSegment& segment) const {
|
|||
|
||||
void SeriesMatcher::postProcess(ParsedNumber& result) const {
|
||||
// NOTE: The range-based for loop calls the virtual begin() and end() methods.
|
||||
for (auto* matcher : *this) {
|
||||
for (const auto* matcher : *this) {
|
||||
matcher->postProcess(result);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ DecimalMatcher::DecimalMatcher(const DecimalFormatSymbols& symbols, const Groupe
|
|||
UChar32 cpZero = symbols.getCodePointZero();
|
||||
if (cpZero == -1 || !u_isdigit(cpZero) || u_digit(cpZero, 10) != 0) {
|
||||
// Uncommon case: okay to allocate.
|
||||
auto digitStrings = new UnicodeString[10];
|
||||
auto* digitStrings = new UnicodeString[10];
|
||||
fLocalDigitStrings.adoptInstead(digitStrings);
|
||||
for (int32_t i = 0; i <= 9; i++) {
|
||||
digitStrings[i] = symbols.getConstDigitSymbol(i);
|
||||
|
|
|
@ -71,7 +71,7 @@ UPRV_FORMATTED_VALUE_CAPI_NO_IMPLTYPE_AUTO_IMPL(
|
|||
|
||||
const UFormattedNumberRangeData* number::impl::validateUFormattedNumberRange(
|
||||
const UFormattedNumberRange* uresult, UErrorCode& status) {
|
||||
auto* result = UFormattedNumberRangeApiHelper::validate(uresult, status);
|
||||
const auto* result = UFormattedNumberRangeApiHelper::validate(uresult, status);
|
||||
if (U_FAILURE(status)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -145,7 +145,7 @@ U_CAPI UNumberRangeIdentityResult U_EXPORT2
|
|||
unumrf_resultGetIdentityResult(
|
||||
const UFormattedNumberRange* uresult,
|
||||
UErrorCode* ec) {
|
||||
auto* result = UFormattedNumberRangeApiHelper::validate(uresult, *ec);
|
||||
const auto* result = UFormattedNumberRangeApiHelper::validate(uresult, *ec);
|
||||
if (U_FAILURE(*ec)) {
|
||||
return UNUM_IDENTITY_RESULT_COUNT;
|
||||
}
|
||||
|
|
|
@ -313,7 +313,7 @@ FormattedNumberRange LocalizedNumberRangeFormatter::formatFormattableRange(
|
|||
return FormattedNumberRange(U_ILLEGAL_ARGUMENT_ERROR);
|
||||
}
|
||||
|
||||
auto results = new UFormattedNumberRangeData();
|
||||
auto* results = new UFormattedNumberRangeData();
|
||||
if (results == nullptr) {
|
||||
status = U_MEMORY_ALLOCATION_ERROR;
|
||||
return FormattedNumberRange(status);
|
||||
|
@ -342,7 +342,7 @@ FormattedNumberRange LocalizedNumberRangeFormatter::formatFormattableRange(
|
|||
|
||||
void LocalizedNumberRangeFormatter::formatImpl(
|
||||
UFormattedNumberRangeData& results, bool equalBeforeRounding, UErrorCode& status) const {
|
||||
auto* impl = getFormatter(status);
|
||||
const auto* impl = getFormatter(status);
|
||||
if (U_FAILURE(status)) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1380,7 +1380,7 @@ ureldatefmt_formatNumericToResult(
|
|||
if (U_FAILURE(*status)) {
|
||||
return;
|
||||
}
|
||||
auto* fmt = reinterpret_cast<const RelativeDateTimeFormatter*>(reldatefmt);
|
||||
const auto* fmt = reinterpret_cast<const RelativeDateTimeFormatter*>(reldatefmt);
|
||||
auto* resultImpl = UFormattedRelativeDateTimeApiHelper::validate(result, *status);
|
||||
resultImpl->fImpl = fmt->formatNumericToValue(offset, unit, *status);
|
||||
}
|
||||
|
@ -1423,7 +1423,7 @@ ureldatefmt_formatToResult(
|
|||
if (U_FAILURE(*status)) {
|
||||
return;
|
||||
}
|
||||
auto* fmt = reinterpret_cast<const RelativeDateTimeFormatter*>(reldatefmt);
|
||||
const auto* fmt = reinterpret_cast<const RelativeDateTimeFormatter*>(reldatefmt);
|
||||
auto* resultImpl = UFormattedRelativeDateTimeApiHelper::validate(result, *status);
|
||||
resultImpl->fImpl = fmt->formatToValue(offset, unit, *status);
|
||||
}
|
||||
|
|
|
@ -1308,7 +1308,7 @@ SimpleDateFormat::initSimpleNumberFormatter(UErrorCode &status) {
|
|||
if (U_FAILURE(status)) {
|
||||
return;
|
||||
}
|
||||
auto* df = dynamic_cast<const DecimalFormat*>(fNumberFormat);
|
||||
const auto* df = dynamic_cast<const DecimalFormat*>(fNumberFormat);
|
||||
if (df == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
@ -1523,7 +1523,7 @@ SimpleDateFormat::subFormat(UnicodeString &appendTo,
|
|||
// "GGGG" is wide era name, "GGGGG" is narrow era name, anything else is abbreviated name
|
||||
case UDAT_ERA_FIELD:
|
||||
{
|
||||
auto calType = cal.getType();
|
||||
const auto* calType = cal.getType();
|
||||
if (uprv_strcmp(calType,"chinese") == 0 || uprv_strcmp(calType,"dangi") == 0) {
|
||||
zeroPaddingNumber(currentNumberFormat,appendTo, value, 1, 9); // as in ICU4J
|
||||
} else {
|
||||
|
@ -2178,7 +2178,7 @@ SimpleDateFormat::zeroPaddingNumber(
|
|||
}
|
||||
|
||||
// Check for RBNF (no clone necessary)
|
||||
auto* rbnf = dynamic_cast<const RuleBasedNumberFormat*>(currentNumberFormat);
|
||||
const auto* rbnf = dynamic_cast<const RuleBasedNumberFormat*>(currentNumberFormat);
|
||||
if (rbnf != nullptr) {
|
||||
FieldPosition pos(FieldPosition::DONT_CARE);
|
||||
rbnf->format(value, appendTo, pos); // 3rd arg is there to speed up processing
|
||||
|
@ -3914,7 +3914,7 @@ void SimpleDateFormat::parseInt(const UnicodeString& text,
|
|||
UBool allowNegative,
|
||||
const NumberFormat *fmt) const {
|
||||
UnicodeString oldPrefix;
|
||||
auto* fmtAsDF = dynamic_cast<const DecimalFormat*>(fmt);
|
||||
const auto* fmtAsDF = dynamic_cast<const DecimalFormat*>(fmt);
|
||||
LocalPointer<DecimalFormat> df;
|
||||
if (!allowNegative && fmtAsDF != nullptr) {
|
||||
df.adoptInstead(fmtAsDF->clone());
|
||||
|
|
|
@ -180,7 +180,7 @@ void addFactorElement(Factor &factor, StringPiece elementStr, Signum signum, UEr
|
|||
Factor extractFactorConversions(StringPiece stringFactor, UErrorCode &status) {
|
||||
Factor result;
|
||||
Signum signum = Signum::POSITIVE;
|
||||
auto factorData = stringFactor.data();
|
||||
const auto* factorData = stringFactor.data();
|
||||
for (int32_t i = 0, start = 0, n = stringFactor.length(); i < n; i++) {
|
||||
if (factorData[i] == '*' || factorData[i] == '/') {
|
||||
StringPiece factorElement = stringFactor.substr(start, i - start);
|
||||
|
@ -202,7 +202,7 @@ Factor extractFactorConversions(StringPiece stringFactor, UErrorCode &status) {
|
|||
|
||||
// Load factor for a single source
|
||||
Factor loadSingleFactor(StringPiece source, const ConversionRates &ratesInfo, UErrorCode &status) {
|
||||
const auto conversionUnit = ratesInfo.extractConversionInfo(source, status);
|
||||
const auto* const conversionUnit = ratesInfo.extractConversionInfo(source, status);
|
||||
if (U_FAILURE(status)) return Factor();
|
||||
if (conversionUnit == nullptr) {
|
||||
status = U_INTERNAL_PROGRAM_ERROR;
|
||||
|
@ -280,7 +280,8 @@ CharString getSpecialMappingName(const MeasureUnitImpl &simpleUnit, const Conver
|
|||
return CharString();
|
||||
}
|
||||
SingleUnitImpl singleUnit = *simpleUnit.singleUnits[0];
|
||||
const auto conversionUnit = ratesInfo.extractConversionInfo(singleUnit.getSimpleUnitID(), status);
|
||||
const auto* const conversionUnit =
|
||||
ratesInfo.extractConversionInfo(singleUnit.getSimpleUnitID(), status);
|
||||
if (U_FAILURE(status)) {
|
||||
return CharString();
|
||||
}
|
||||
|
@ -477,7 +478,7 @@ MeasureUnitImpl U_I18N_API extractCompoundBaseUnit(const MeasureUnitImpl &source
|
|||
const auto &singleUnit = *singleUnits[i];
|
||||
// Extract `ConversionRateInfo` using the absolute unit. For example: in case of `square-meter`,
|
||||
// we will use `meter`
|
||||
const auto rateInfo =
|
||||
const auto* const rateInfo =
|
||||
conversionRates.extractConversionInfo(singleUnit.getSimpleUnitID(), status);
|
||||
if (U_FAILURE(status)) {
|
||||
return result;
|
||||
|
|
|
@ -77,7 +77,7 @@ void UnitsRouter::init(const MeasureUnit &inputUnit, const Locale &locale, Strin
|
|||
prefs.getPreferencesFor(category.toStringPiece(), usage, locale, status);
|
||||
for (int32_t i = 0, n = unitPrefs.length(); i < n; ++i) {
|
||||
U_ASSERT(unitPrefs[i] != nullptr);
|
||||
const auto preference = unitPrefs[i];
|
||||
const auto* const preference = unitPrefs[i];
|
||||
|
||||
MeasureUnitImpl complexTargetUnitImpl =
|
||||
MeasureUnitImpl::forIdentifier(preference->unit.data(), status);
|
||||
|
|
|
@ -108,7 +108,7 @@ USpoofChecker *SpoofImpl::asUSpoofChecker() {
|
|||
// received from the C API.
|
||||
//
|
||||
const SpoofImpl *SpoofImpl::validateThis(const USpoofChecker *sc, UErrorCode &status) {
|
||||
auto* This = validate(sc, status);
|
||||
const auto* This = validate(sc, status);
|
||||
if (U_FAILURE(status)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
|||
|
||||
int32_t dst_size = size * 2;
|
||||
std::unique_ptr<char[]> dst(new char[dst_size]);
|
||||
auto src = reinterpret_cast<const char*>(fuzzbuff.get());
|
||||
const auto* src = reinterpret_cast<const char*>(fuzzbuff.get());
|
||||
|
||||
switch (rnd8 % 4) {
|
||||
case 0: ucasemap_utf8ToLower(csm.get(), dst.get(), dst_size, src, size,
|
||||
|
|
|
@ -1191,10 +1191,10 @@ void IntlTestDecimalFormatAPI::testInvalidObject() {
|
|||
assertTrue(WHERE, dfAssignmentBogus != dfBogus);
|
||||
|
||||
// Verify that cloning our original invalid object gives nullptr.
|
||||
auto dfBogusClone = dfBogus.clone();
|
||||
auto* dfBogusClone = dfBogus.clone();
|
||||
assertTrue(WHERE, dfBogusClone == nullptr);
|
||||
// Verify that cloning our assigned invalid object gives nullptr.
|
||||
auto dfBogusClone2 = dfAssignmentBogus.clone();
|
||||
auto* dfBogusClone2 = dfAssignmentBogus.clone();
|
||||
assertTrue(WHERE, dfBogusClone2 == nullptr);
|
||||
|
||||
// Verify copy constructing from an invalid object is also invalid.
|
||||
|
@ -1206,8 +1206,8 @@ void IntlTestDecimalFormatAPI::testInvalidObject() {
|
|||
assertTrue(WHERE, dfCopyAssign != dfGood);
|
||||
assertTrue(WHERE, dfCopyAssign != dfGood2);
|
||||
assertTrue(WHERE, dfCopyAssign != dfBogus);
|
||||
auto dfBogusCopyClone1 = dfCopy.clone();
|
||||
auto dfBogusCopyClone2 = dfCopyAssign.clone();
|
||||
auto* dfBogusCopyClone1 = dfCopy.clone();
|
||||
auto* dfBogusCopyClone2 = dfCopyAssign.clone();
|
||||
assertTrue(WHERE, dfBogusCopyClone1 == nullptr);
|
||||
assertTrue(WHERE, dfBogusCopyClone2 == nullptr);
|
||||
}
|
||||
|
@ -1252,7 +1252,7 @@ void IntlTestDecimalFormatAPI::testInvalidObject() {
|
|||
|
||||
df->setLenient(true);
|
||||
|
||||
auto dfClone = df->clone();
|
||||
auto* dfClone = df->clone();
|
||||
assertTrue(WHERE, dfClone == nullptr);
|
||||
|
||||
UnicodeString dest;
|
||||
|
|
|
@ -716,7 +716,7 @@ void IntlTestDateTimePatternGeneratorAPI::testAPI(/*char *par*/)
|
|||
resultDate.remove();
|
||||
resultDate = sdf.format(testDate, resultDate);
|
||||
if ( resultDate != patternResults[localeIndex][resultIndex] ) {
|
||||
auto* calendar = sdf.getCalendar();
|
||||
const auto* calendar = sdf.getCalendar();
|
||||
errln(UnicodeString("\nERROR: Test various skeletons[") + (dataIndex-1) + UnicodeString("], localeIndex ") + localeIndex +
|
||||
u". Got: \"" + resultDate +
|
||||
u"\" with calendar " + calendar->getType() +
|
||||
|
@ -1434,7 +1434,7 @@ void IntlTestDateTimePatternGeneratorAPI::test20640_HourCyclArsEnNH() {
|
|||
{"ja_TRADITIONAL", u"H時", u"H:mm", UDAT_HOUR_CYCLE_23},
|
||||
};
|
||||
|
||||
for (auto& cas : cases) {
|
||||
for (const auto& cas : cases) {
|
||||
status.setScope(cas.localeName);
|
||||
|
||||
Locale loc(cas.localeName);
|
||||
|
|
|
@ -838,7 +838,7 @@ void IntlTestSpoof::testCombiningDot() {
|
|||
{false, u"iz\u0307"},
|
||||
};
|
||||
|
||||
for (auto& cas : cases) {
|
||||
for (const auto& cas : cases) {
|
||||
int32_t failedChecks = uspoof_check2(sc.getAlias(), cas.input, -1, nullptr, &status);
|
||||
TEST_ASSERT_SUCCESS(status);
|
||||
int32_t expected = cas.shouldFail ? USPOOF_HIDDEN_OVERLAY : 0;
|
||||
|
|
|
@ -1685,7 +1685,7 @@ void LocaleTest::Test20639_DeprecatesISO3Language() {
|
|||
{"ro", "ron"},
|
||||
{"mo", "mol"},
|
||||
};
|
||||
for (auto& cas : cases) {
|
||||
for (const auto& cas : cases) {
|
||||
Locale loc(cas.localeName);
|
||||
const char* actual = loc.getISO3Language();
|
||||
assertEquals(cas.localeName, cas.expectedISO3Language, actual);
|
||||
|
|
|
@ -5836,7 +5836,7 @@ void MeasureFormatTest::TestParseToBuiltIn() {
|
|||
{"square-yard-yard", MeasureUnit::getCubicYard()},
|
||||
};
|
||||
|
||||
for (auto &cas : cases) {
|
||||
for (const auto& cas : cases) {
|
||||
MeasureUnit fromIdent = MeasureUnit::forIdentifier(cas.identifier, status);
|
||||
status.assertSuccess();
|
||||
assertEquals("forIdentifier returns a normal built-in unit when it exists",
|
||||
|
|
|
@ -1346,7 +1346,7 @@ void NumberFormatterApiTest::unitSkeletons() {
|
|||
u"unit/kibijoule-per-furlong", //
|
||||
u"unit/kibijoule-per-furlong"},
|
||||
};
|
||||
for (auto &cas : cases) {
|
||||
for (const auto& cas : cases) {
|
||||
IcuTestErrorCode status(*this, cas.msg);
|
||||
auto nf = NumberFormatter::forSkeleton(cas.inputSkeleton, status);
|
||||
if (status.errIfFailureAndReset("NumberFormatter::forSkeleton failed")) {
|
||||
|
@ -1390,7 +1390,7 @@ void NumberFormatterApiTest::unitSkeletons() {
|
|||
U_NUMBER_SKELETON_SYNTAX_ERROR, //
|
||||
U_ZERO_ERROR},
|
||||
};
|
||||
for (auto &cas : failCases) {
|
||||
for (const auto& cas : failCases) {
|
||||
IcuTestErrorCode status(*this, cas.msg);
|
||||
auto nf = NumberFormatter::forSkeleton(cas.inputSkeleton, status);
|
||||
if (status.expectErrorAndReset(cas.expectedForSkelStatus, cas.msg)) {
|
||||
|
@ -3019,7 +3019,7 @@ void NumberFormatterApiTest::unitLocaleTags() {
|
|||
Locale locale(testCase.locale);
|
||||
auto inputUnit = MeasureUnit::forIdentifier(testCase.inputUnit, status);
|
||||
auto inputValue = testCase.inputValue;
|
||||
auto usage = testCase.usage;
|
||||
const auto* usage = testCase.usage;
|
||||
auto expectedOutputUnit = MeasureUnit::forIdentifier(testCase.expectedOutputUnit, status);
|
||||
UnicodeString expectedFormattedNumber = testCase.expectedFormattedNumber;
|
||||
|
||||
|
@ -3050,9 +3050,9 @@ void NumberFormatterApiTest::percentParity() {
|
|||
UnlocalizedNumberFormatter uMeasurePermille = NumberFormatter::with().unit(MeasureUnit::getPermille());
|
||||
|
||||
int32_t localeCount;
|
||||
auto locales = Locale::getAvailableLocales(localeCount);
|
||||
const auto* locales = Locale::getAvailableLocales(localeCount);
|
||||
for (int32_t i=0; i<localeCount; i++) {
|
||||
auto& locale = locales[i];
|
||||
const auto& locale = locales[i];
|
||||
UnicodeString sNoUnitPercent = uNoUnitPercent.locale(locale)
|
||||
.formatDouble(50, status).toString(status);
|
||||
UnicodeString sNoUnitPermille = uNoUnitPermille.locale(locale)
|
||||
|
@ -4971,10 +4971,10 @@ void NumberFormatterApiTest::signNearZero() {
|
|||
{ UNUM_SIGN_NEGATIVE, -0.9, u"-1" },
|
||||
{ UNUM_SIGN_NEGATIVE, -1.1, u"-1" },
|
||||
};
|
||||
for (auto& cas : cases) {
|
||||
for (const auto& cas : cases) {
|
||||
auto sign = cas.sign;
|
||||
auto input = cas.input;
|
||||
auto expected = cas.expected;
|
||||
const auto* expected = cas.expected;
|
||||
auto actual = NumberFormatter::with()
|
||||
.sign(sign)
|
||||
.precision(Precision::integer())
|
||||
|
@ -5003,11 +5003,11 @@ void NumberFormatterApiTest::signCoverage() {
|
|||
const double inputs[] = {
|
||||
-uprv_getInfinity(), -1, -0.0, 0, 1, uprv_getInfinity(), uprv_getNaN(), negNaN
|
||||
};
|
||||
for (auto& cas : cases) {
|
||||
for (const auto& cas : cases) {
|
||||
auto sign = cas.sign;
|
||||
for (int32_t i = 0; i < UPRV_LENGTHOF(inputs); i++) {
|
||||
auto input = inputs[i];
|
||||
auto expected = cas.expectedStrings[i];
|
||||
const auto* expected = cas.expectedStrings[i];
|
||||
auto actual = NumberFormatter::with()
|
||||
.sign(sign)
|
||||
.locale(Locale::getUS())
|
||||
|
|
|
@ -353,7 +353,7 @@ void DecimalQuantityTest::testHardDoubleConversion() {
|
|||
{ 4096.000000000006, u"4096.000000000006" },
|
||||
{ 4096.000000000007, u"4096.000000000007" } };
|
||||
|
||||
for (auto& cas : cases) {
|
||||
for (const auto& cas : cases) {
|
||||
DecimalQuantity q;
|
||||
q.setToDouble(cas.input);
|
||||
q.roundToInfinity();
|
||||
|
@ -410,7 +410,7 @@ void DecimalQuantityTest::testToDouble() {
|
|||
{ "514.23", 514.23 },
|
||||
{ "-3.142E-271", -3.142e-271 } };
|
||||
|
||||
for (auto& cas : cases) {
|
||||
for (const auto& cas : cases) {
|
||||
status.setScope(cas.input);
|
||||
DecimalQuantity q;
|
||||
q.setToDecNumber({cas.input, -1}, status);
|
||||
|
|
|
@ -126,7 +126,7 @@ void NumberParserTest::testBasic() {
|
|||
{3, u"0", u"0", 1, 0.0}};
|
||||
|
||||
parse_flags_t parseFlags = PARSE_FLAG_IGNORE_CASE | PARSE_FLAG_INCLUDE_UNPAIRED_AFFIXES;
|
||||
for (auto& cas : cases) {
|
||||
for (const auto& cas : cases) {
|
||||
UnicodeString inputString(cas.inputString);
|
||||
UnicodeString patternString(cas.patternString);
|
||||
LocalPointer<const NumberParserImpl> parser(
|
||||
|
@ -227,7 +227,7 @@ void NumberParserTest::testSeriesMatcher() {
|
|||
{u"+- % ", 7, true},
|
||||
{u"+-%$", 3, false}};
|
||||
|
||||
for (auto& cas : cases) {
|
||||
for (const auto& cas : cases) {
|
||||
UnicodeString input(cas.input);
|
||||
|
||||
StringSegment segment(input, false);
|
||||
|
@ -275,7 +275,7 @@ void NumberParserTest::testCombinedCurrencyMatcher() {
|
|||
{u"euros", u"EUR", u""},
|
||||
{u"ICU", u"ICU", u"ICU"},
|
||||
{u"IU$", u"ICU", u"ICU"}};
|
||||
for (auto& cas : cases) {
|
||||
for (const auto& cas : cases) {
|
||||
UnicodeString input(cas.input);
|
||||
|
||||
{
|
||||
|
@ -333,7 +333,7 @@ void NumberParserTest::testAffixPatternMatcher() {
|
|||
{true, u"abc", 3, u"abc"},
|
||||
{false, u"hello-to+this%very¤long‰string", 59, u"hello-to+this%very USD long‰string"}};
|
||||
|
||||
for (auto& cas : cases) {
|
||||
for (const auto& cas : cases) {
|
||||
UnicodeString affixPattern(cas.affixPattern);
|
||||
UnicodeString sampleParseableString(cas.sampleParseableString);
|
||||
int parseFlags = cas.exactMatch ? PARSE_FLAG_EXACT_AFFIX : 0;
|
||||
|
|
|
@ -100,7 +100,7 @@ void PatternStringTest::testExceptionOnInvalid() {
|
|||
u"0,,0,",
|
||||
u"#,##0E0"};
|
||||
|
||||
for (auto pattern : invalidPatterns) {
|
||||
for (const auto* pattern : invalidPatterns) {
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
ParsedPatternInfo patternInfo;
|
||||
PatternParser::parseToPatternInfo(pattern, patternInfo, status);
|
||||
|
|
|
@ -1128,7 +1128,7 @@ void NumberRangeFormatterTest::test21683_StateLeak() {
|
|||
unumrf_formatDoubleRange(nrf, range.start, range.end, result, status);
|
||||
if (status.errIfFailureAndReset("unumrf_formatDoubleRange")) { goto cleanup; }
|
||||
|
||||
auto* formattedValue = unumrf_resultAsValue(result, status);
|
||||
const auto* formattedValue = unumrf_resultAsValue(result, status);
|
||||
if (status.errIfFailureAndReset("unumrf_resultAsValue")) { goto cleanup; }
|
||||
|
||||
int32_t utf16Length;
|
||||
|
|
|
@ -9909,7 +9909,7 @@ void NumberFormatTest::Test21134_ToNumberFormatter() {
|
|||
{
|
||||
// Case 1: new formatter object
|
||||
DecimalFormat inner(u"a0b", {"en", status}, status);
|
||||
if (auto ptr = inner.toNumberFormatter(status)) {
|
||||
if (const auto* ptr = inner.toNumberFormatter(status)) {
|
||||
// Copy assignment
|
||||
outer1 = *ptr;
|
||||
} else {
|
||||
|
@ -9924,7 +9924,7 @@ void NumberFormatTest::Test21134_ToNumberFormatter() {
|
|||
inner.format(100, dummy);
|
||||
inner.format(100, dummy);
|
||||
inner.format(100, dummy);
|
||||
if (auto ptr = inner.toNumberFormatter(status)) {
|
||||
if (const auto* ptr = inner.toNumberFormatter(status)) {
|
||||
// Copy assignment
|
||||
outer2 = *ptr;
|
||||
} else {
|
||||
|
@ -9936,7 +9936,7 @@ void NumberFormatTest::Test21134_ToNumberFormatter() {
|
|||
// Case 3: currency plural info (different code path)
|
||||
LocalPointer<DecimalFormat> inner(dynamic_cast<DecimalFormat*>(
|
||||
DecimalFormat::createInstance("en-US", UNUM_CURRENCY_PLURAL, status)));
|
||||
if (auto ptr = inner->toNumberFormatter(status)) {
|
||||
if (const auto* ptr = inner->toNumberFormatter(status)) {
|
||||
// Copy constructor
|
||||
outer3.adoptInsteadAndCheckErrorCode(new LocalizedNumberFormatter(*ptr), status);
|
||||
} else {
|
||||
|
@ -10009,7 +10009,7 @@ void NumberFormatTest::Test13733_StrictAndLenient() {
|
|||
{u"12$", u"0 ¤¤", 0, 12},
|
||||
{u"12$", u"0 ¤¤¤", 0, 12},
|
||||
{u"12$", u"¤¤¤¤0", 0, 12} };
|
||||
for (auto& cas : cases) {
|
||||
for (const auto& cas : cases) {
|
||||
UnicodeString inputString(cas.inputString);
|
||||
UnicodeString patternString(cas.patternString);
|
||||
int64_t parsedStrictValue = 0;
|
||||
|
|
|
@ -2019,7 +2019,7 @@ void TestMessageFormat::TestMessageFormatNumberSkeleton() {
|
|||
{ u"{0,number,'::'0.00}", "en", 50, u"::50.00" }, // pattern literal
|
||||
};
|
||||
|
||||
for (auto& cas : cases) {
|
||||
for (const auto& cas : cases) {
|
||||
status.setScope(cas.messagePattern);
|
||||
MessageFormat msgf(cas.messagePattern, cas.localeName, status);
|
||||
UnicodeString sb;
|
||||
|
|
|
@ -134,8 +134,8 @@ void UnitsDataTest::testGetPreferencesFor() {
|
|||
};
|
||||
IcuTestErrorCode status(*this, "testGetPreferencesFor");
|
||||
UnitPreferencesOpenedUp preferences(status);
|
||||
auto *metadata = preferences.getInternalMetadata();
|
||||
auto *unitPrefs = preferences.getInternalUnitPrefs();
|
||||
const auto* metadata = preferences.getInternalMetadata();
|
||||
const auto* unitPrefs = preferences.getInternalUnitPrefs();
|
||||
assertTrue(UnicodeString("Metadata count: ") + metadata->length() + " > 200",
|
||||
metadata->length() > 200);
|
||||
assertTrue(UnicodeString("Preferences count: ") + unitPrefs->length() + " > 250",
|
||||
|
|
|
@ -60,7 +60,7 @@ const std::list<std::string>& ResKeyPath::pieces() const {
|
|||
std::ostream& operator<<(std::ostream& out, const ResKeyPath& value) {
|
||||
if (value.pieces().empty()) {
|
||||
out << "/";
|
||||
} else for (auto& key : value.pieces()) {
|
||||
} else for (const auto& key : value.pieces()) {
|
||||
out << "/" << key;
|
||||
}
|
||||
return out;
|
||||
|
@ -109,7 +109,7 @@ PathFilter::EInclusion SimpleRuleBasedPathFilter::match(const ResKeyPath& path)
|
|||
// even if additional subpaths are added to the given key
|
||||
bool isLeaf = false;
|
||||
|
||||
for (auto& key : path.pieces()) {
|
||||
for (const auto& key : path.pieces()) {
|
||||
auto child = node->fChildren.find(key);
|
||||
// Leaf case 1: input path descends outside the filter tree
|
||||
if (child == node->fChildren.end()) {
|
||||
|
@ -178,7 +178,7 @@ void SimpleRuleBasedPathFilter::Tree::applyRule(
|
|||
}
|
||||
|
||||
// Recursive Step
|
||||
auto& key = *it;
|
||||
const auto& key = *it;
|
||||
if (key == "*") {
|
||||
// Case 1: Wildcard
|
||||
if (!fWildcard) {
|
||||
|
@ -212,7 +212,7 @@ void SimpleRuleBasedPathFilter::Tree::applyRule(
|
|||
void SimpleRuleBasedPathFilter::Tree::print(std::ostream& out, int32_t indent) const {
|
||||
for (int32_t i=0; i<indent; i++) out << "\t";
|
||||
out << "included: " << kEInclusionNames[fIncluded] << std::endl;
|
||||
for (auto& child : fChildren) {
|
||||
for (const auto& child : fChildren) {
|
||||
for (int32_t i=0; i<indent; i++) out << "\t";
|
||||
out << child.first << ": {" << std::endl;
|
||||
child.second.print(out, indent + 1);
|
||||
|
|
Loading…
Add table
Reference in a new issue