aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergio Campamá <kaipi@google.com>2017-03-01 11:00:56 -0800
committerBo Yang <paulyang1211@gmail.com>2017-03-03 10:14:44 -0800
commitcc99e1293cd1d88f113d239ccf41f73cb238f307 (patch)
treeca4f8592199fffaa8fac8855306a3e354e7a3835
parent4020fe427cf71f616e00bc39f8155b9bed8fd47c (diff)
downloadprotobuf-cc99e1293cd1d88f113d239ccf41f73cb238f307.tar.gz
protobuf-cc99e1293cd1d88f113d239ccf41f73cb238f307.tar.bz2
protobuf-cc99e1293cd1d88f113d239ccf41f73cb238f307.zip
Disable static analyzer for message semaphore creation (#2748)
Disable static analyzer for message semaphore creation
-rw-r--r--objectivec/GPBMessage_PackagePrivate.h8
1 files changed, 8 insertions, 0 deletions
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
}