Commit 9bd74b7f authored by Thomas Van Lenten's avatar Thomas Van Lenten

Merge pull request #1027 from thomasvl/more_nullable_support

Enable CLANG_WARN_NULLABLE_TO_NONNULL_CONVERSION for the projects.
parents b1b9c254 c27833b6
......@@ -127,7 +127,7 @@ CF_EXTERN_C_END
// Same as -[data], except a delimiter is added to the start of the data
// indicating the size of the message data that follows.
- (nullable NSData *)delimitedData;
- (NSData *)delimitedData;
// Returns the size of the object if it were serialized.
// This is not a cached value. If you are following a pattern like this:
......
......@@ -1212,7 +1212,8 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
NSLog(@"%@: Internal exception while building message delimitedData: %@",
[self class], exception);
#endif
data = nil;
// If it happens, truncate.
data.length = 0;
}
[stream release];
return data;
......@@ -1791,7 +1792,12 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
extensionMap_ = [[NSMutableDictionary alloc] init];
}
[extensionMap_ setObject:value forKey:extension];
// This pointless cast is for CLANG_WARN_NULLABLE_TO_NONNULL_CONVERSION.
// Without it, the compiler complains we're passing an id nullable when
// setObject:forKey: requires a id nonnull for the value. The check for
// !value at the start of the method ensures it isn't nil, but the check
// isn't smart enough to realize that.
[extensionMap_ setObject:(id)value forKey:extension];
GPBExtensionDescriptor *descriptor = extension;
......
......@@ -44,7 +44,7 @@ NS_ASSUME_NONNULL_BEGIN
// most likely won't exactly match the original .proto file.
NSString *GPBTextFormatForMessage(GPBMessage *message,
NSString * __nullable lineIndent);
NSString *GPBTextFormatForUnknownFieldSet(GPBUnknownFieldSet *unknownSet,
NSString *GPBTextFormatForUnknownFieldSet(GPBUnknownFieldSet * __nullable unknownSet,
NSString * __nullable lineIndent);
//
......
......@@ -787,6 +787,7 @@
CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES;
CLANG_STATIC_ANALYZER_MODE = deep;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_NULLABLE_TO_NONNULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES;
CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS = YES;
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES;
......@@ -831,6 +832,7 @@
CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES;
CLANG_STATIC_ANALYZER_MODE = deep;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_NULLABLE_TO_NONNULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES;
CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS = YES;
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES;
......
......@@ -949,6 +949,7 @@
CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES;
CLANG_STATIC_ANALYZER_MODE = deep;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_NULLABLE_TO_NONNULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES;
CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS = YES;
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES;
......@@ -994,6 +995,7 @@
CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES;
CLANG_STATIC_ANALYZER_MODE = deep;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_NULLABLE_TO_NONNULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES;
CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS = YES;
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES;
......
......@@ -225,8 +225,10 @@
// Serialize and parse it. Make sure to parse from an InputStream, not
// directly from a ByteString, so that CodedInputStream uses buffered
// reading.
NSData *messageData = message.data;
XCTAssertNotNil(messageData);
GPBCodedInputStream* stream =
[GPBCodedInputStream streamWithData:message.data];
[GPBCodedInputStream streamWithData:messageData];
TestAllTypes* message2 = [TestAllTypes parseFromCodedInputStream:stream
extensionRegistry:nil
error:NULL];
......
......@@ -195,7 +195,9 @@
// Test merging from data.
result = [self mergeExtensionsDestination];
[result mergeFromData:[[self mergeExtensionsSource] data]
NSData *data = [[self mergeExtensionsSource] data];
XCTAssertNotNil(data);
[result mergeFromData:data
extensionRegistry:[UnittestRoot extensionRegistry]];
resultData = [result data];
XCTAssertEqualObjects(resultData, mergeResultData);
......@@ -1884,7 +1886,9 @@
XCTAssertEqual(msg.bar, EnumTestMsg_MyEnum_One);
XCTAssertEqual(msg.baz, EnumTestMsg_MyEnum_NegOne);
// Bounce to wire and back.
EnumTestMsg *msgPrime = [EnumTestMsg parseFromData:[msg data] error:NULL];
NSData *data = [msg data];
XCTAssertNotNil(data);
EnumTestMsg *msgPrime = [EnumTestMsg parseFromData:data error:NULL];
XCTAssertEqualObjects(msgPrime, msg);
XCTAssertEqual(msgPrime.foo, EnumTestMsg_MyEnum_Zero);
XCTAssertEqual(msgPrime.bar, EnumTestMsg_MyEnum_One);
......@@ -1896,7 +1900,9 @@
XCTAssertEqual(msg.bar, EnumTestMsg_MyEnum_Two);
XCTAssertEqual(msg.baz, EnumTestMsg_MyEnum_NegTwo);
// Bounce to wire and back.
msgPrime = [EnumTestMsg parseFromData:[msg data] error:NULL];
data = [msg data];
XCTAssertNotNil(data);
msgPrime = [EnumTestMsg parseFromData:data error:NULL];
XCTAssertEqualObjects(msgPrime, msg);
XCTAssertEqual(msgPrime.foo, EnumTestMsg_MyEnum_Zero);
XCTAssertEqual(msgPrime.bar, EnumTestMsg_MyEnum_Two);
......@@ -1917,7 +1923,9 @@
XCTAssertEqual([msg.mumbleArray valueAtIndex:3], EnumTestMsg_MyEnum_NegOne);
XCTAssertEqual([msg.mumbleArray valueAtIndex:4], EnumTestMsg_MyEnum_NegTwo);
// Bounce to wire and back.
msgPrime = [EnumTestMsg parseFromData:[msg data] error:NULL];
data = [msg data];
XCTAssertNotNil(data);
msgPrime = [EnumTestMsg parseFromData:data error:NULL];
XCTAssertEqualObjects(msgPrime, msg);
XCTAssertEqual([msgPrime.mumbleArray valueAtIndex:0],
EnumTestMsg_MyEnum_Zero);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment