diff options
author | Thomas Van Lenten <thomasvl@google.com> | 2016-05-25 13:46:00 -0400 |
---|---|---|
committer | Thomas Van Lenten <thomasvl@google.com> | 2016-05-25 16:42:31 -0400 |
commit | c8a440dfb68074ff310e624928cd2dd61c101728 (patch) | |
tree | 6b2251c56e7ccd125a7cc7bcb9fc276266f5adc5 /objectivec/GPBUtilities.m | |
parent | d089f04ae53565aff77240172e1007f3959503f4 (diff) | |
download | protobuf-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/GPBUtilities.m')
-rw-r--r-- | objectivec/GPBUtilities.m | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/objectivec/GPBUtilities.m b/objectivec/GPBUtilities.m index 447c749a..89deb2e7 100644 --- a/objectivec/GPBUtilities.m +++ b/objectivec/GPBUtilities.m @@ -39,6 +39,12 @@ #import "GPBUnknownField.h" #import "GPBUnknownFieldSet.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" + static void AppendTextFormatForMessage(GPBMessage *message, NSMutableString *toStr, NSString *lineIndent); @@ -891,7 +897,7 @@ void GPBSetMessageGroupField(GPBMessage *self, // Only exists for public api, no core code should use this. id GPBGetMessageRepeatedField(GPBMessage *self, GPBFieldDescriptor *field) { -#if DEBUG +#if defined(DEBUG) && DEBUG if (field.fieldType != GPBFieldTypeRepeated) { [NSException raise:NSInvalidArgumentException format:@"%@.%@ is not a repeated field.", @@ -903,7 +909,7 @@ id GPBGetMessageRepeatedField(GPBMessage *self, GPBFieldDescriptor *field) { // Only exists for public api, no core code should use this. void GPBSetMessageRepeatedField(GPBMessage *self, GPBFieldDescriptor *field, id array) { -#if DEBUG +#if defined(DEBUG) && DEBUG if (field.fieldType != GPBFieldTypeRepeated) { [NSException raise:NSInvalidArgumentException format:@"%@.%@ is not a repeated field.", @@ -957,7 +963,7 @@ void GPBSetMessageRepeatedField(GPBMessage *self, GPBFieldDescriptor *field, id GPBSetObjectIvarWithField(self, field, array); } -#if DEBUG +#if defined(DEBUG) && DEBUG static NSString *TypeToStr(GPBDataType dataType) { switch (dataType) { case GPBDataTypeBool: @@ -993,7 +999,7 @@ static NSString *TypeToStr(GPBDataType dataType) { // Only exists for public api, no core code should use this. id GPBGetMessageMapField(GPBMessage *self, GPBFieldDescriptor *field) { -#if DEBUG +#if defined(DEBUG) && DEBUG if (field.fieldType != GPBFieldTypeMap) { [NSException raise:NSInvalidArgumentException format:@"%@.%@ is not a map<> field.", @@ -1006,7 +1012,7 @@ id GPBGetMessageMapField(GPBMessage *self, GPBFieldDescriptor *field) { // Only exists for public api, no core code should use this. void GPBSetMessageMapField(GPBMessage *self, GPBFieldDescriptor *field, id dictionary) { -#if DEBUG +#if defined(DEBUG) && DEBUG if (field.fieldType != GPBFieldTypeMap) { [NSException raise:NSInvalidArgumentException format:@"%@.%@ is not a map<> field.", @@ -1133,6 +1139,8 @@ static void AppendTextFormatForMapMessageField( [toStr appendString:@"\n"]; [toStr appendString:valueLine]; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wswitch-enum" switch (valueDataType) { case GPBDataTypeString: AppendStringEscaped(value, toStr); @@ -1153,6 +1161,7 @@ static void AppendTextFormatForMapMessageField( NSCAssert(NO, @"Can't happen"); break; } +#pragma clang diagnostic pop [toStr appendString:@"\n"]; [toStr appendString:msgEnd]; @@ -1174,6 +1183,8 @@ static void AppendTextFormatForMapMessageField( } [toStr appendString:valueLine]; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wswitch-enum" switch (valueDataType) { case GPBDataTypeString: AppendStringEscaped(valueObj, toStr); @@ -1211,6 +1222,7 @@ static void AppendTextFormatForMapMessageField( [toStr appendString:valueObj]; break; } +#pragma clang diagnostic pop [toStr appendString:@"\n"]; [toStr appendString:msgEnd]; @@ -1706,6 +1718,8 @@ NSString *GPBDecodeTextFormatName(const uint8_t *decodeData, int32_t key, return result; } +#pragma clang diagnostic pop + #pragma mark - GPBMessageSignatureProtocol // A series of selectors that are used solely to get @encoding values |