[PATCH] D23236: When ARC is enabled, no warning will be generated when a method1. Returns 'nil' in a method that is attributed to return a 'nonnull'2. The return-statement is a ConditionalOperator, where the lhs is nil and rhs an objC-method-call (or the other...

Hendrik von Prince via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 4 14:15:24 PDT 2016


parallaxe added a comment.

In https://reviews.llvm.org/D23236#557898, @dcoughlin wrote:

> Upon reflection, I don't think this is the right approach.
>
> Desugaring any AttributedType in the return type seems like a really, really big hammer and could be an unexpected surprise for future attributed types where this is not the right behavior. I think a better approach for the nullability issue would be to update `lookThroughImplicitCasts()` in NullabilityChecker.cpp to look though `ExprWithCleanups` expressions just like it currently does for implicit casts.
>
> What do you think?


As far as I understand the code, I would leave my change as it is.
The part of the code I have changed tries to guess the return-type for the expression inside the return-stmt. At this point, no type could be computed (as RelatedRetType.isNull() is true). Assuming that any annotation that the return-type of the function has, will also apply to the return-type of the expression, might be misleading. The improvements of the warnings in nullability.m are a good sign of this (which would be lost when I would just make a change in the NullabilityChecker).

Does that sound sensible?


https://reviews.llvm.org/D23236





More information about the cfe-commits mailing list