ICU-22621 Clang-Tidy: readability-static-definition-in-anonymous-namespace

https://releases.llvm.org/17.0.1/tools/clang/tools/extra/docs/clang-tidy/checks/readability/static-definition-in-anonymous-namespace.html
This commit is contained in:
Fredrik Roubert 2024-03-18 17:56:54 +01:00 committed by Fredrik Roubert
parent 6ad78a08c7
commit ade671e252
11 changed files with 47 additions and 47 deletions

View file

@ -106,7 +106,7 @@ uniset_getUnicode32Instance(UErrorCode &errorCode) {
// caseCompare(), but they also make UnicodeSet work for simple patterns when
// no Unicode properties data is available - when caseCompare() fails
static inline UBool
inline UBool
isPerlOpen(const UnicodeString &pattern, int32_t pos) {
char16_t c;
return pattern.charAt(pos)==u'\\' && ((c=pattern.charAt(pos+1))==u'p' || c==u'P');
@ -117,12 +117,12 @@ isPerlClose(const UnicodeString &pattern, int32_t pos) {
return pattern.charAt(pos)==u'}';
}*/
static inline UBool
inline UBool
isNameOpen(const UnicodeString &pattern, int32_t pos) {
return pattern.charAt(pos)==u'\\' && pattern.charAt(pos+1)==u'N';
}
static inline UBool
inline UBool
isPOSIXOpen(const UnicodeString &pattern, int32_t pos) {
return pattern.charAt(pos)==u'[' && pattern.charAt(pos+1)==u':';
}
@ -657,16 +657,16 @@ void UnicodeSet::applyPattern(RuleCharacterIterator& chars,
namespace {
static UBool numericValueFilter(UChar32 ch, void* context) {
UBool numericValueFilter(UChar32 ch, void* context) {
return u_getNumericValue(ch) == *(double*)context;
}
static UBool generalCategoryMaskFilter(UChar32 ch, void* context) {
UBool generalCategoryMaskFilter(UChar32 ch, void* context) {
int32_t value = *(int32_t*)context;
return (U_GET_GC_MASK((UChar32) ch) & value) != 0;
}
static UBool versionFilter(UChar32 ch, void* context) {
UBool versionFilter(UChar32 ch, void* context) {
static const UVersionInfo none = { 0, 0, 0, 0 };
UVersionInfo v;
u_charAge(ch, v);
@ -679,12 +679,12 @@ typedef struct {
int32_t value;
} IntPropertyContext;
static UBool intPropertyFilter(UChar32 ch, void* context) {
UBool intPropertyFilter(UChar32 ch, void* context) {
IntPropertyContext* c = (IntPropertyContext*)context;
return u_getIntPropertyValue((UChar32) ch, c->prop) == c->value;
}
static UBool scriptExtensionsFilter(UChar32 ch, void* context) {
UBool scriptExtensionsFilter(UChar32 ch, void* context) {
return uscript_hasScript(ch, *(UScriptCode*)context);
}
@ -744,7 +744,7 @@ void UnicodeSet::applyFilter(UnicodeSet::Filter filter,
namespace {
static UBool mungeCharName(char* dst, const char* src, int32_t dstCapacity) {
UBool mungeCharName(char* dst, const char* src, int32_t dstCapacity) {
/* Note: we use ' ' in compiler code page */
int32_t j = 0;
char ch;

View file

@ -261,7 +261,7 @@ static UBool isAvailableLocaleListInitialized(UErrorCode &status) {
namespace {
static const struct {
const struct {
const char *name;
UColAttribute attr;
} collAttributes[] = {
@ -274,7 +274,7 @@ static const struct {
{ "colNumeric", UCOL_NUMERIC_COLLATION }
};
static const struct {
const struct {
const char *name;
UColAttributeValue value;
} collAttributeValues[] = {
@ -292,7 +292,7 @@ static const struct {
{ "upper", UCOL_UPPER_FIRST }
};
static const char *collReorderCodes[UCOL_REORDER_CODE_LIMIT - UCOL_REORDER_CODE_FIRST] = {
const char* collReorderCodes[UCOL_REORDER_CODE_LIMIT - UCOL_REORDER_CODE_FIRST] = {
"space", "punct", "symbol", "currency", "digit"
};

View file

@ -33,8 +33,8 @@ U_NAMESPACE_BEGIN
namespace {
static const CollationCacheEntry *rootSingleton = nullptr;
static UInitOnce initOnce {};
const CollationCacheEntry *rootSingleton = nullptr;
UInitOnce initOnce{};
} // namespace

View file

@ -41,7 +41,7 @@ U_NAMESPACE_BEGIN
namespace {
static const char16_t BEFORE[] = { 0x5b, 0x62, 0x65, 0x66, 0x6f, 0x72, 0x65, 0 }; // "[before"
const char16_t BEFORE[] = { 0x5b, 0x62, 0x65, 0x66, 0x6f, 0x72, 0x65, 0 }; // "[before"
const int32_t BEFORE_LENGTH = 7;
} // namespace
@ -438,7 +438,7 @@ CollationRuleParser::parseString(int32_t i, UnicodeString &raw, UErrorCode &erro
namespace {
static const char *const positions[] = {
const char* const positions[] = {
"first tertiary ignorable",
"last tertiary ignorable",
"first secondary ignorable",

View file

@ -1454,35 +1454,35 @@ DateFormatSymbols::setLocalPatternChars(const UnicodeString& newLocalPatternChar
namespace {
// Constants declarations
static const char16_t kCalendarAliasPrefixUChar[] = {
const char16_t kCalendarAliasPrefixUChar[] = {
SOLIDUS, CAP_L, CAP_O, CAP_C, CAP_A, CAP_L, CAP_E, SOLIDUS,
LOW_C, LOW_A, LOW_L, LOW_E, LOW_N, LOW_D, LOW_A, LOW_R, SOLIDUS
};
static const char16_t kGregorianTagUChar[] = {
const char16_t kGregorianTagUChar[] = {
LOW_G, LOW_R, LOW_E, LOW_G, LOW_O, LOW_R, LOW_I, LOW_A, LOW_N
};
static const char16_t kVariantTagUChar[] = {
const char16_t kVariantTagUChar[] = {
PERCENT, LOW_V, LOW_A, LOW_R, LOW_I, LOW_A, LOW_N, LOW_T
};
static const char16_t kLeapTagUChar[] = {
const char16_t kLeapTagUChar[] = {
LOW_L, LOW_E, LOW_A, LOW_P
};
static const char16_t kCyclicNameSetsTagUChar[] = {
const char16_t kCyclicNameSetsTagUChar[] = {
LOW_C, LOW_Y, LOW_C, LOW_L, LOW_I, LOW_C, CAP_N, LOW_A, LOW_M, LOW_E, CAP_S, LOW_E, LOW_T, LOW_S
};
static const char16_t kYearsTagUChar[] = {
const char16_t kYearsTagUChar[] = {
SOLIDUS, LOW_Y, LOW_E, LOW_A, LOW_R, LOW_S
};
static const char16_t kZodiacsUChar[] = {
const char16_t kZodiacsUChar[] = {
SOLIDUS, LOW_Z, LOW_O, LOW_D, LOW_I, LOW_A, LOW_C, LOW_S
};
static const char16_t kDayPartsTagUChar[] = {
const char16_t kDayPartsTagUChar[] = {
SOLIDUS, LOW_D, LOW_A, LOW_Y, CAP_P, LOW_A, LOW_R, LOW_T, LOW_S
};
static const char16_t kFormatTagUChar[] = {
const char16_t kFormatTagUChar[] = {
SOLIDUS, LOW_F, LOW_O, LOW_R, LOW_M, LOW_A, LOW_T
};
static const char16_t kAbbrTagUChar[] = {
const char16_t kAbbrTagUChar[] = {
SOLIDUS, LOW_A, LOW_B, LOW_B, LOW_R, LOW_E, LOW_V, LOW_I, LOW_A, LOW_T, LOW_E, LOW_D
};

View file

@ -121,16 +121,16 @@ private:
ContextualHandler::~ContextualHandler() {
}
static const char16_t *spanishY = u"{0} y {1}";
static const char16_t *spanishE = u"{0} e {1}";
static const char16_t *spanishO = u"{0} o {1}";
static const char16_t *spanishU = u"{0} u {1}";
static const char16_t *hebrewVav = u"{0} \u05D5{1}";
static const char16_t *hebrewVavDash = u"{0} \u05D5-{1}";
const char16_t* spanishY = u"{0} y {1}";
const char16_t* spanishE = u"{0} e {1}";
const char16_t* spanishO = u"{0} o {1}";
const char16_t* spanishU = u"{0} u {1}";
const char16_t* hebrewVav = u"{0} \u05D5{1}";
const char16_t* hebrewVavDash = u"{0} \u05D5-{1}";
// Condiction to change to e.
// Starts with "hi" or "i" but not with "hie" nor "hia"
static bool shouldChangeToE(const UnicodeString& text) {
bool shouldChangeToE(const UnicodeString& text) {
int32_t len = text.length();
if (len == 0) { return false; }
// Case insensitive match hi but not hie nor hia.
@ -147,7 +147,7 @@ static bool shouldChangeToE(const UnicodeString& text) {
// Condiction to change to u.
// Starts with "o", "ho", and "8". Also "11" by itself.
// re: ^((o|ho|8).*|11)$
static bool shouldChangeToU(const UnicodeString& text) {
bool shouldChangeToU(const UnicodeString& text) {
int32_t len = text.length();
if (len == 0) { return false; }
// Case insensitive match o.* and 8.*
@ -164,7 +164,7 @@ static bool shouldChangeToU(const UnicodeString& text) {
// Condiction to change to VAV follow by a dash.
// Starts with non Hebrew letter.
static bool shouldChangeToVavDash(const UnicodeString& text) {
bool shouldChangeToVavDash(const UnicodeString& text) {
if (text.isEmpty()) { return false; }
UErrorCode status = U_ZERO_ERROR;
return uscript_getScript(text.char32At(0), &status) != USCRIPT_HEBREW;

View file

@ -44,7 +44,7 @@ inline int32_t safeSubtract(int32_t a, int32_t b) {
return diff;
}
static double DOUBLE_MULTIPLIERS[] = {
double DOUBLE_MULTIPLIERS[] = {
1e0,
1e1,
1e2,

View file

@ -89,7 +89,7 @@ const char *getGenderString(UnicodeString uGender, UErrorCode status) {
}
// Returns the array index that corresponds to the given pluralKeyword.
static int32_t getIndex(const char* pluralKeyword, UErrorCode& status) {
int32_t getIndex(const char* pluralKeyword, UErrorCode& status) {
// pluralKeyword can also be "dnam", "per", or "gender"
switch (*pluralKeyword) {
case 'd':
@ -119,7 +119,7 @@ static int32_t getIndex(const char* pluralKeyword, UErrorCode& status) {
//
// The `strings` array must have ARRAY_LENGTH items: one corresponding to each
// of the plural forms, plus a display name ("dnam") and a "per" form.
static UnicodeString getWithPlural(
UnicodeString getWithPlural(
const UnicodeString* strings,
StandardPlural::Form plural,
UErrorCode& status) {

View file

@ -29,7 +29,7 @@ namespace {
* Either both arguments must be null or the pattern string inside the AffixPatternMatcher must equal
* the given pattern string.
*/
static bool matched(const AffixPatternMatcher* affix, const UnicodeString& patternString) {
bool matched(const AffixPatternMatcher* affix, const UnicodeString& patternString) {
return (affix == nullptr && patternString.isBogus()) ||
(affix != nullptr && affix->getPattern() == patternString);
}
@ -37,7 +37,7 @@ static bool matched(const AffixPatternMatcher* affix, const UnicodeString& patte
/**
* Helper method to return the length of the given AffixPatternMatcher. Returns 0 for null.
*/
static int32_t length(const AffixPatternMatcher* matcher) {
int32_t length(const AffixPatternMatcher* matcher) {
return matcher == nullptr ? 0 : matcher->getPattern().length();
}
@ -45,7 +45,7 @@ static int32_t length(const AffixPatternMatcher* matcher) {
* Helper method to return whether (1) both lhs and rhs are null/invalid, or (2) if they are both
* valid, whether they are equal according to operator==. Similar to Java Objects.equals()
*/
static bool equals(const AffixPatternMatcher* lhs, const AffixPatternMatcher* rhs) {
bool equals(const AffixPatternMatcher* lhs, const AffixPatternMatcher* rhs) {
if (lhs == nullptr && rhs == nullptr) {
return true;
}

View file

@ -59,10 +59,10 @@ U_NAMESPACE_BEGIN
namespace {
static const char16_t *rootRules = nullptr;
static int32_t rootRulesLength = 0;
static UResourceBundle *rootBundle = nullptr;
static UInitOnce gInitOnceUcolRes {};
const char16_t* rootRules = nullptr;
int32_t rootRulesLength = 0;
UResourceBundle* rootBundle = nullptr;
UInitOnce gInitOnceUcolRes{};
} // namespace

View file

@ -668,7 +668,7 @@ parseAlias(ParseState* state, char *tag, uint32_t startline, const struct UStrin
namespace {
static struct SResource* resLookup(struct SResource* res, const char* key){
struct SResource* resLookup(struct SResource* res, const char* key) {
if (res == res_none() || !res->isTable()) {
return nullptr;
}
@ -794,7 +794,7 @@ GenrbImporter::getRules(
// Quick-and-dirty escaping function.
// Assumes that we are on an ASCII-based platform.
static void
void
escape(const char16_t *s, char *buffer, size_t n) {
int32_t length = u_strlen(s);
int32_t i = 0;