r240155 - Implement the 'null_resettable' attribute for Objective-C properties.
Douglas Gregor
dgregor at apple.com
Mon Jun 22 11:13:01 PDT 2015
> On Jun 20, 2015, at 12:10 PM, Aaron Ballman <aaron at aaronballman.com> wrote:
>
> On Fri, Jun 19, 2015 at 2:14 PM, Douglas Gregor <dgregor at apple.com <mailto:dgregor at apple.com>> wrote:
>
>> + for (const auto *propertyImpl : impDecl->property_impls()) {
>> + const auto *property = propertyImpl->getPropertyDecl();
>> +
>> + // Warn about null_resettable properties with synthesized setters,
>> + // because the setter won't properly handle nil.
>> + if (propertyImpl->getPropertyImplementation()
>> + == ObjCPropertyImplDecl::Synthesize &&
>> + (property->getPropertyAttributes() &
>> + ObjCPropertyDecl::OBJC_PR_null_resettable) &&
>
> The more I see the bitwise tests, the more I wonder if having a
> propertyAttributeIsSet() function might make sense?
Probably, yes.
>
>> + property->getGetterMethodDecl() &&
>> + property->getSetterMethodDecl()) {
>> + auto *getterMethod = property->getGetterMethodDecl();
>> + auto *setterMethod = property->getSetterMethodDecl();
>> + if (!impDecl->getInstanceMethod(setterMethod->getSelector()) &&
>> + !impDecl->getInstanceMethod(getterMethod->getSelector())) {
>> + SourceLocation loc = propertyImpl->getLocation();
>> + if (loc.isInvalid())
>> + loc = impDecl->getLocStart();
>
> Under what circumstances would loc be invalid here? (I may simply be
> unfamiliar with ObjC and that's not a problem.)
Getters and setters can be synthesized by the @implementation, which means they won’t have useful source locations.
(Comments appreciated and cleanup commits coming, thanks!)
- Doug
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150622/374fda00/attachment.html>
More information about the cfe-commits
mailing list