[PATCH] D92495: [clang] Add a new nullability annotation for swift async: _Nullable_result

Erik Pilkington via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 4 07:38:47 PST 2020


erik.pilkington added inline comments.


================
Comment at: clang/lib/Basic/IdentifierTable.cpp:718-719
+  case NullabilityKind::NullableResult:
+    assert(!isContextSensitive &&
+           "_Nullable_result isn't supported as context-sensitive keyword");
+    return "_Nullable_result";
----------------
aaron.ballman wrote:
> Can you explain why it differs from `_Nullable` in this case?
Sure, _Nullable can be written like `nullable` in an `@property` or method return/param type i.e.:

```
@property(nullable) id x;
```

`_Nullable_result` isn't really useful in these contexts (you should always use `nullable` there), so I didn't add parsing support for it. 


================
Comment at: clang/lib/Sema/SemaExprObjC.cpp:1566
   unsigned receiverNullabilityIdx = 0;
-  if (auto nullability = ReceiverType->getNullability(Context))
+  if (auto nullability = ReceiverType->getNullability(Context)) {
+    if (*nullability == NullabilityKind::NullableResult)
----------------
aaron.ballman wrote:
> Should that be `auto *`?
Its an `Optional<NullabilityKind>`, so I guess it should really be written out. New patch drops the auto.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92495/new/

https://reviews.llvm.org/D92495



More information about the cfe-commits mailing list