[PATCH] D22391: [Sema] Add warning for implicitly casting a null constant to a non null pointer type

Akira Hatanaka via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 6 16:30:41 PDT 2018


ahatanak added inline comments.


================
Comment at: lib/Sema/SemaExpr.cpp:7117
+    if (E && S.checkNonNullExpr(E))
+      return NullabilityKind::Nullable;
+
----------------
jordan_rose wrote:
> This isn't quite correct, unfortunately. `(_Nonnull id)nil` should be considered non-nullable, since it's the canonical way to avoid all these warnings. It might just be good enough to move this check below the `getNullability` one, though.
Sema::CheckNonNullExpr checks the nullability of the type of the expression first and returns false if there is a cast to `_Nonnull`.


Repository:
  rC Clang

https://reviews.llvm.org/D22391





More information about the cfe-commits mailing list