aboutsummaryrefslogtreecommitdiff
path: root/objectivec/GPBDescriptor_PackagePrivate.h
diff options
context:
space:
mode:
authorThomas Van Lenten <thomasvl@google.com>2016-05-25 13:46:00 -0400
committerThomas Van Lenten <thomasvl@google.com>2016-05-25 16:42:31 -0400
commitc8a440dfb68074ff310e624928cd2dd61c101728 (patch)
tree6b2251c56e7ccd125a7cc7bcb9fc276266f5adc5 /objectivec/GPBDescriptor_PackagePrivate.h
parentd089f04ae53565aff77240172e1007f3959503f4 (diff)
downloadprotobuf-c8a440dfb68074ff310e624928cd2dd61c101728.tar.gz
protobuf-c8a440dfb68074ff310e624928cd2dd61c101728.tar.bz2
protobuf-c8a440dfb68074ff310e624928cd2dd61c101728.zip
Add more warnings to for the ObjC runtime build
Working on https://github.com/google/protobuf/issues/1599, specifically: - Turn on more warnings that the Xcode UI calls out with individual controls. - Manually add: -Wundef -Wswitch-enum - Manually add and then diable in the unittests because of XCTest's headers: -Wreserved-id-macro -Wdocumentation-unknown-command - Manually add -Wdirect-ivar-access, but disable it for the unittests and in the library code (via #pragmas to suppress it). This is done so proto users can enable the warning.
Diffstat (limited to 'objectivec/GPBDescriptor_PackagePrivate.h')
-rw-r--r--objectivec/GPBDescriptor_PackagePrivate.h30
1 files changed, 19 insertions, 11 deletions
diff --git a/objectivec/GPBDescriptor_PackagePrivate.h b/objectivec/GPBDescriptor_PackagePrivate.h
index e3d0a80f..c20ff6b0 100644
--- a/objectivec/GPBDescriptor_PackagePrivate.h
+++ b/objectivec/GPBDescriptor_PackagePrivate.h
@@ -245,6 +245,12 @@ typedef NS_OPTIONS(uint32_t, GPBDescriptorInitializationFlags) {
CF_EXTERN_C_BEGIN
+// Direct access is use for speed, to avoid even internally declaring things
+// read/write, etc. The warning is enabled in the project to ensure code calling
+// protos can turn on -Wdirect-ivar-access without issues.
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdirect-ivar-access"
+
GPB_INLINE BOOL GPBFieldIsMapOrArray(GPBFieldDescriptor *field) {
return (field->description_->flags &
(GPBFieldRepeated | GPBFieldMapKeyMask)) != 0;
@@ -262,6 +268,8 @@ GPB_INLINE uint32_t GPBFieldNumber(GPBFieldDescriptor *field) {
return field->description_->number;
}
+#pragma clang diagnostic pop
+
uint32_t GPBFieldTag(GPBFieldDescriptor *self);
// For repeated fields, alternateWireType is the wireType with the opposite
@@ -291,23 +299,23 @@ GPB_INLINE BOOL GPBExtensionIsWireFormat(GPBExtensionDescription *description) {
}
// Helper for compile time assets.
-#ifndef _GPBCompileAssert
+#ifndef GPBInternalCompileAssert
#if __has_feature(c_static_assert) || __has_extension(c_static_assert)
- #define _GPBCompileAssert(test, msg) _Static_assert((test), #msg)
+ #define GPBInternalCompileAssert(test, msg) _Static_assert((test), #msg)
#else
// Pre-Xcode 7 support.
- #define _GPBCompileAssertSymbolInner(line, msg) _GPBCompileAssert ## line ## __ ## msg
- #define _GPBCompileAssertSymbol(line, msg) _GPBCompileAssertSymbolInner(line, msg)
- #define _GPBCompileAssert(test, msg) \
- typedef char _GPBCompileAssertSymbol(__LINE__, msg) [ ((test) ? 1 : -1) ]
+ #define GPBInternalCompileAssertSymbolInner(line, msg) GPBInternalCompileAssert ## line ## __ ## msg
+ #define GPBInternalCompileAssertSymbol(line, msg) GPBInternalCompileAssertSymbolInner(line, msg)
+ #define GPBInternalCompileAssert(test, msg) \
+ typedef char GPBInternalCompileAssertSymbol(__LINE__, msg) [ ((test) ? 1 : -1) ]
#endif // __has_feature(c_static_assert) || __has_extension(c_static_assert)
-#endif // _GPBCompileAssert
+#endif // GPBInternalCompileAssert
// Sanity check that there isn't padding between the field description
// structures with and without a default.
-_GPBCompileAssert(sizeof(GPBMessageFieldDescriptionWithDefault) ==
- (sizeof(GPBGenericValue) +
- sizeof(GPBMessageFieldDescription)),
- DescriptionsWithDefault_different_size_than_expected);
+GPBInternalCompileAssert(sizeof(GPBMessageFieldDescriptionWithDefault) ==
+ (sizeof(GPBGenericValue) +
+ sizeof(GPBMessageFieldDescription)),
+ DescriptionsWithDefault_different_size_than_expected);
CF_EXTERN_C_END