There is a problem, that assign attribute very often getting out of attention. For example, consider this code:
@property(nonatomic, strong, readonly, nullable) SomeObjcClassType1* foo; @property(nonatomic, strong, readwrite) SomeObjcClassType2* bar; @property(nonatomic, assign, readonly) SomeObjcClassType* property; @property(nonatomic, assign, readonly) SomeCStructType state;
It is very easy to miss that assign keyword, and it leads to hard to find and reproduce bugs. Most of the time, we found such bugs in crash reports from already in production code.
Now, consider this code:
@property(nonatomic, strong, readonly, nullable) SomeObjcClassType1* foo; @property(nonatomic, strong, readwrite) SomeObjcClassType2* bar; @property(nonatomic, unsafe_unretained, readonly) SomeObjcClassType* property; @property(nonatomic, assign, readonly) SomeCStructType state;
It is now much harder to even make that mistake and it will be much obvious during code review.
As there is no difference in behaviour between assign and unsafe_unretained attribute, but second is much more verbose, saying "think twice when doing this", I suggest to have, at least, optional warning, that will catch such constructs.
This is my first revision in llvm, so any help would be very much appreciated.
"must" is rather strong for a warning. Maybe something more like "'assign' attribute on property of object type could be 'unsafe_unretained'"?