[clang]: Add support for "-fno-delete-null-pointer-checks"
authorManoj Gupta <manojgupta@google.com>
Thu, 19 Jul 2018 00:44:52 +0000 (00:44 +0000)
committerManoj Gupta <manojgupta@google.com>
Thu, 19 Jul 2018 00:44:52 +0000 (00:44 +0000)
commitda08f6ac16b6a53ab25ecb56e1be800c5f0095d9
tree658722ff7c2b281d8d6dd58b9d1e149f48f51d25
parentac1f9263d13eb8e96681d13777a9638e4672feb3
[clang]: Add support for "-fno-delete-null-pointer-checks"

Summary:
Support for this option is needed for building Linux kernel.
This is a very frequently requested feature by kernel developers.

More details : https://lkml.org/lkml/2018/4/4/601

GCC option description for -fdelete-null-pointer-checks:
This Assume that programs cannot safely dereference null pointers,
and that no code or data element resides at address zero.

-fno-delete-null-pointer-checks is the inverse of this implying that
null pointer dereferencing is not undefined.

This feature is implemented in as the function attribute
"null-pointer-is-valid"="true".
This CL only adds the attribute on the function.
It also strips "nonnull" attributes from function arguments but
keeps the related warnings unchanged.

Corresponding LLVM change rL336613 already updated the
optimizations to not treat null pointer dereferencing
as undefined if the attribute is present.

Reviewers: t.p.northover, efriedma, jyknight, chandlerc, rnk, srhines, void, george.burgess.iv

Reviewed By: jyknight

Subscribers: drinkcat, xbolva00, cfe-commits

Differential Revision: https://reviews.llvm.org/D47894

llvm-svn: 337433
14 files changed:
clang/docs/ClangCommandLineReference.rst
clang/include/clang/Driver/Options.td
clang/include/clang/Frontend/CodeGenOptions.def
clang/lib/CodeGen/CGCall.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/CodeGen/delete-null-pointer-checks.c [new file with mode: 0644]
clang/test/CodeGen/nonnull.c
clang/test/CodeGen/vla.c
clang/test/CodeGenCXX/address-space-ref.cpp
clang/test/CodeGenCXX/constructors.cpp
clang/test/CodeGenCXX/temporaries.cpp
clang/test/Driver/clang_f_opts.c
clang/test/Sema/nonnull.c