HomePhabricator

[analyzer] Nullability: Treat nil _Nonnull ivar as invariant violation.

Description

[analyzer] Nullability: Treat nil _Nonnull ivar as invariant violation.

Treat a _Nonnull ivar that is nil as an invariant violation in a similar
fashion to how a nil _Nonnull parameter is treated as a precondition violation.

This avoids warning on defensive returns of nil on defensive internal
checks, such as the following common idiom:

@class InternalImplementation
@interface PublicClass {

InternalImplementation * _Nonnull _internal;

}
-(id _Nonnull)foo;
@end

@implementation PublicClass
-(id _Nonnull)foo {

if (!_internal)
  return nil; // no-warning

return [_internal foo];

}
@end

rdar://problem/24485171

Details

Committed
dcoughlinApr 12 2016, 5:41 PM
Parents
rL266156: AMDGPU: Add test for m0 initialization in basic loop
Branches
Unknown
Tags
Unknown