Follow-up fix for nonnull atomic non-member functions

Handling of the third parameter was only checking for *_n and not for the C11 variant, which means that cmpxchg of a 'desired' 0 value was erroneously warning. Handle C11 properly, and add extgensive tests for this as well as NULL pointers in a bunch of places.

Fixes r333246 from D47229.

llvm-svn: 333290
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 6f956b4..2f15c51 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -3519,8 +3519,8 @@
         break;
       case 2:
         // The third argument to compare_exchange / GNU exchange is the desired
-        // value, either by-value (for the *_n variant) or as a pointer.
-        if (!IsN)
+        // value, either by-value (for the C11 and *_n variant) or as a pointer.
+        if (IsPassedByAddress)
           CheckNonNullArgument(*this, TheCall->getArg(i), DRE->getLocStart());
         Ty = ByValType;
         break;