Skip to content

Commit 6670a5c

Browse files
kateinoigakukunetcwilde
authored andcommitted
Stop assuming CFSTR is a constant-time expression with Clang 15 (swiftlang#4872)
From Clang 15, nested static initializer inside statement-expression is no longer a constant-time expression (See https://reviews.llvm.org/D127201). OSS Foundation defines `CFSTR` as a macro rather than `__builtin___CFStringMakeConstantString` and it uses nested static initializer inside statement-expression, so we can't assume `CFSTR` itself is always a constant-time expression. This patch removes some `static` qualifiers associated with `CFSTR` to make them acceptable with Clang 15 and later.
1 parent 19e5eb0 commit 6670a5c

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

CoreFoundation/Locale.subproj/CFLocale.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1274,7 +1274,7 @@ static bool __CFLocaleCopyLocaleID(CFLocaleRef locale, bool user, CFTypeRef *cf,
12741274

12751275

12761276
static bool __CFLocaleCopyCodes(CFLocaleRef locale, bool user, CFTypeRef *cf, CFStringRef context) {
1277-
static CFStringRef const kCFLocaleCodesKey = CFSTR("__kCFLocaleCodes");
1277+
CFStringRef const kCFLocaleCodesKey = CFSTR("__kCFLocaleCodes");
12781278

12791279
bool codesWasAllocated = false;
12801280
CFDictionaryRef codes = NULL;

CoreFoundation/PlugIn.subproj/CFBundle_Locale.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ const char * const __CFBundleLanguageAbbreviationsArray =
148148
static CFStringRef _CFBundleGetAlternateNameForLanguage(CFStringRef language) {
149149
// These are not necessarily common localizations per se, but localizations for which the full language name is still in common use.
150150
// These are used to provide a fast path for it (other localizations usually use the abbreviation, which is even faster).
151-
static CFStringRef const __CFBundleCommonLanguageNamesArray[] = {CFSTR("English"), CFSTR("French"), CFSTR("German"), CFSTR("Italian"), CFSTR("Dutch"), CFSTR("Spanish"), CFSTR("Japanese")};
152-
static CFStringRef const __CFBundleCommonLanguageAbbreviationsArray[] = {CFSTR("en"), CFSTR("fr"), CFSTR("de"), CFSTR("it"), CFSTR("nl"), CFSTR("es"), CFSTR("ja")};
151+
CFStringRef const __CFBundleCommonLanguageNamesArray[] = {CFSTR("English"), CFSTR("French"), CFSTR("German"), CFSTR("Italian"), CFSTR("Dutch"), CFSTR("Spanish"), CFSTR("Japanese")};
152+
CFStringRef const __CFBundleCommonLanguageAbbreviationsArray[] = {CFSTR("en"), CFSTR("fr"), CFSTR("de"), CFSTR("it"), CFSTR("nl"), CFSTR("es"), CFSTR("ja")};
153153

154154
for (CFIndex idx = 0; idx < sizeof(__CFBundleCommonLanguageNamesArray) / sizeof(CFStringRef); idx++) {
155155
if (CFEqual(language, __CFBundleCommonLanguageAbbreviationsArray[idx])) {

0 commit comments

Comments
 (0)