aboutsummaryrefslogtreecommitdiff
path: root/objectivec/GPBMessage.m
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/GPBMessage.m
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/GPBMessage.m')
-rw-r--r--objectivec/GPBMessage.m22
1 files changed, 15 insertions, 7 deletions
diff --git a/objectivec/GPBMessage.m b/objectivec/GPBMessage.m
index 8134e259..77b9dbd3 100644
--- a/objectivec/GPBMessage.m
+++ b/objectivec/GPBMessage.m
@@ -44,6 +44,12 @@
#import "GPBUnknownFieldSet_PackagePrivate.h"
#import "GPBUtilities_PackagePrivate.h"
+// 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"
+
NSString *const GPBMessageErrorDomain =
GPBNSStringifySymbol(GPBMessageErrorDomain);
@@ -694,7 +700,7 @@ void GPBClearMessageAutocreator(GPBMessage *self) {
return;
}
-#if DEBUG && !defined(NS_BLOCK_ASSERTIONS)
+#if defined(DEBUG) && DEBUG && !defined(NS_BLOCK_ASSERTIONS)
// Either the autocreator must have its "has" flag set to YES, or it must be
// NO and not equal to ourselves.
BOOL autocreatorHas =
@@ -1736,7 +1742,7 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
}
- (BOOL)hasExtension:(GPBExtensionDescriptor *)extension {
-#if DEBUG
+#if defined(DEBUG) && DEBUG
CheckExtension(self, extension);
#endif // DEBUG
return nil != [extensionMap_ objectForKey:extension];
@@ -2621,7 +2627,7 @@ static void MergeRepeatedNotPackedFieldFromCodedInputStream(
case GPBDataTypeFixed32:
case GPBDataTypeUInt32:
case GPBDataTypeFloat: {
- _GPBCompileAssert(sizeof(float) == sizeof(uint32_t), float_not_32_bits);
+ GPBInternalCompileAssert(sizeof(float) == sizeof(uint32_t), float_not_32_bits);
// These are all 32bit, signed/unsigned doesn't matter for equality.
uint32_t *selfValPtr = (uint32_t *)&selfStorage[fieldOffset];
uint32_t *otherValPtr = (uint32_t *)&otherStorage[fieldOffset];
@@ -2636,7 +2642,7 @@ static void MergeRepeatedNotPackedFieldFromCodedInputStream(
case GPBDataTypeFixed64:
case GPBDataTypeUInt64:
case GPBDataTypeDouble: {
- _GPBCompileAssert(sizeof(double) == sizeof(uint64_t), double_not_64_bits);
+ GPBInternalCompileAssert(sizeof(double) == sizeof(uint64_t), double_not_64_bits);
// These are all 64bit, signed/unsigned doesn't matter for equality.
uint64_t *selfValPtr = (uint64_t *)&selfStorage[fieldOffset];
uint64_t *otherValPtr = (uint64_t *)&otherStorage[fieldOffset];
@@ -2733,7 +2739,7 @@ static void MergeRepeatedNotPackedFieldFromCodedInputStream(
case GPBDataTypeFixed32:
case GPBDataTypeUInt32:
case GPBDataTypeFloat: {
- _GPBCompileAssert(sizeof(float) == sizeof(uint32_t), float_not_32_bits);
+ GPBInternalCompileAssert(sizeof(float) == sizeof(uint32_t), float_not_32_bits);
// These are all 32bit, just mix it in.
uint32_t *valPtr = (uint32_t *)&storage[fieldOffset];
result = prime * result + *valPtr;
@@ -2745,7 +2751,7 @@ static void MergeRepeatedNotPackedFieldFromCodedInputStream(
case GPBDataTypeFixed64:
case GPBDataTypeUInt64:
case GPBDataTypeDouble: {
- _GPBCompileAssert(sizeof(double) == sizeof(uint64_t), double_not_64_bits);
+ GPBInternalCompileAssert(sizeof(double) == sizeof(uint64_t), double_not_64_bits);
// These are all 64bit, just mix what fits into an NSUInteger in.
uint64_t *valPtr = (uint64_t *)&storage[fieldOffset];
result = prime * result + (NSUInteger)(*valPtr);
@@ -2792,7 +2798,7 @@ static void MergeRepeatedNotPackedFieldFromCodedInputStream(
return description;
}
-#if DEBUG
+#if defined(DEBUG) && DEBUG
// Xcode 5.1 added support for custom quick look info.
// https://developer.apple.com/library/ios/documentation/IDEs/Conceptual/CustomClassDisplay_in_QuickLook/CH01-quick_look_for_custom_objects/CH01-quick_look_for_custom_objects.html#//apple_ref/doc/uid/TP40014001-CH2-SW1
@@ -3182,3 +3188,5 @@ static void ResolveIvarSet(GPBFieldDescriptor *field,
}
@end
+
+#pragma clang diagnostic pop