aboutsummaryrefslogtreecommitdiffhomepage
path: root/objectivec/GPBUtilities.m
diff options
context:
space:
mode:
authorGravatar Thomas Van Lenten <thomasvl@google.com>2016-05-26 11:10:00 -0400
committerGravatar Thomas Van Lenten <thomasvl@google.com>2016-05-26 11:10:00 -0400
commit0f27cab4fb378b94a91c2b1522174ec21719df9d (patch)
tree6111cbd70b21027c678647381eba6d3974b51740 /objectivec/GPBUtilities.m
parented87c1fe2c6e1633cadb62cf54b2723b2b25c280 (diff)
parentc8a440dfb68074ff310e624928cd2dd61c101728 (diff)
Merge pull request #1600 from thomasvl/objc_tighter_warnings
Add more warnings to for the ObjC runtime build
Diffstat (limited to 'objectivec/GPBUtilities.m')
-rw-r--r--objectivec/GPBUtilities.m24
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