+ // Either returns NULL with U_FAILURE(status), or non-NULL with U_SUCCESS(status)
+ }
+ // The use of *coll in setAttributesFromKeywords can cause the NULL check to be
+ // optimized out of the delete even though setAttributesFromKeywords returns
+ // immediately if U_FAILURE(status), so we add a check here.
+ if (U_FAILURE(status)) {
+ return NULL;
+ }
+ // makeInstance either returns NULL with U_FAILURE(status), or non-NULL with U_SUCCESS(status).
+ // The *coll in setAttributesFromKeywords causes the NULL check to be optimized out of the delete
+ // even though setAttributesFromKeywords returns immediately if U_FAILURE(status), so we add a
+ // check here and also log the locale name for failures. <rdar://problem/40930320>
+ if (U_FAILURE(status)) {
+#if U_PLATFORM_IS_DARWIN_BASED
+#if 0
+ // logging disabled for shipping system, can enable for internal debugging
+ const char* locname = desiredLocale.getName();
+ os_log(OS_LOG_DEFAULT, "Collator::createInstance fails with locale: %{public}s", locname? locname: "(NULL)");
+#endif
+#endif
+ return NULL;