From 8b182cc45575117d19f0695cbde80f6e43b722d5 Mon Sep 17 00:00:00 2001 From: Sergio Campamá Date: Wed, 1 Mar 2017 11:00:56 -0800 Subject: Disable static analyzer for message semaphore creation (#2748) Disable static analyzer for message semaphore creation --- objectivec/GPBMessage_PackagePrivate.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'objectivec/GPBMessage_PackagePrivate.h') diff --git a/objectivec/GPBMessage_PackagePrivate.h b/objectivec/GPBMessage_PackagePrivate.h index 02d0e16e..9324cf8d 100644 --- a/objectivec/GPBMessage_PackagePrivate.h +++ b/objectivec/GPBMessage_PackagePrivate.h @@ -108,9 +108,17 @@ CF_EXTERN_C_BEGIN NS_INLINE void GPBPrepareReadOnlySemaphore(GPBMessage *self) { #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdirect-ivar-access" + +// Starting on Xcode 8.3, the static analyzer complains that the dispatch_once_t +// variable passed to dispatch_once should not be allocated on the heap or +// stack. Given that the semaphore is also an instance variable of the message, +// both variables are cleared at the same time, so this is safe. +#if !defined(__clang_analyzer__) dispatch_once(&self->readOnlySemaphoreCreationOnce_, ^{ self->readOnlySemaphore_ = dispatch_semaphore_create(1); }); +#endif // !defined(__clang_analyzer__) + #pragma clang diagnostic pop } -- cgit v1.2.3