Diagnose unsafe uses of nil and __nonnull pointers.
authorDouglas Gregor <dgregor@apple.com>
Fri, 19 Jun 2015 18:13:19 +0000 (18:13 +0000)
committerDouglas Gregor <dgregor@apple.com>
Fri, 19 Jun 2015 18:13:19 +0000 (18:13 +0000)
commitb4866e85e5ffa0d352d496958582f0983172dc01
treebfc790bef93a450379f8936f20589b99a524657b
parentbb3a01cfaf679413b5e9ee3f3187e06bb246dcf3
Diagnose unsafe uses of nil and __nonnull pointers.

This generalizes the checking of null arguments to also work with
values of pointer-to-function, reference-to-function, and block
pointer type, using the nullability information within the underling
function prototype to extend non-null checking, and diagnoses returns
of 'nil' within a function with a __nonnull return type.

Note that we don't warn about nil returns from Objective-C methods,
because it's common for Objective-C methods to mimic the nil-swallowing
behavior of the receiver by checking ostensibly non-null parameters
and returning nil from otherwise non-null methods in that
case.

It also diagnoses (via a separate flag) conversions from nullable to
nonnull pointers. It's a separate flag because this warning can be noisy.

llvm-svn: 240153
clang/include/clang/Basic/DiagnosticGroups.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Sema/Sema.h
clang/lib/Sema/Sema.cpp
clang/lib/Sema/SemaChecking.cpp
clang/lib/Sema/SemaOverload.cpp
clang/test/Sema/non-null-warning.c
clang/test/Sema/nullability.c
clang/test/SemaCXX/nullability.cpp
clang/test/SemaObjC/nullability-arc.m [new file with mode: 0644]
clang/test/SemaObjC/nullability.m