[PATCH] D47229: Make atomic non-member functions as nonnull

Richard Smith - zygoloid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu May 24 15:24:23 PDT 2018


rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

Either the previous version of this patch or a version with a `bool` factored out seem OK to me.



================
Comment at: lib/Sema/SemaChecking.cpp:3497
+        else if (Form == Copy || Form == Xchg) {
+          if (!IsC11 && !IsN)
+            // The value pointer is always dereferenced, a nullptr is undefined.
----------------
arphaman wrote:
> Nit: might make more sense to check if `ByValType` is a pointer here instead of duplicating the `if` condition from above.
I think the suggestion was to check `ByValType->isPointerType()` here. But... that doesn't work, because we could have a pointer value being passed by value (where a null is allowed), rather than a value being passed by address (where a null is disallowed). I think this comparison is actually less clear than the `!IsC11 && !IsN` check; factoring out a `bool IsPassedByAddress` or similar instead would aid readability here.


Repository:
  rC Clang

https://reviews.llvm.org/D47229





More information about the cfe-commits mailing list