[PATCH] D17993: [CodeGen] Apply 'nonnull' to 'this' pointer arguments.

Benjamin Kramer via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 9 07:32:07 PST 2016


bkramer created this revision.
bkramer added reviewers: rsmith, rjmccall.
bkramer added a subscriber: cfe-commits.

Also thread -f(no-)delete-null-pointer-checks through to CodeGen and
make it disable this behavior. It's not a full implementation of that
flag but it would be good to stay compatible with GCC. GCC 6 started
deleting null checks for 'this' pointers.

This is going to break code that relies on this undefined behavior,
which is a common pattern. We already have -Wnull-dereference for
obvious cases, ubsan catches it, and there's always the flag to
disable it, so I believe it's time to be more aggressive about this.

http://reviews.llvm.org/D17993

Files:
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/CGCall.cpp
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGenCXX/debug-info-class.cpp
  test/CodeGenCXX/stack-reuse-miscompile.cpp
  test/CodeGenCXX/this-nonnull.cpp
  test/Driver/clang_f_opts.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D17993.50136.patch
Type: text/x-patch
Size: 8156 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160309/7ea1442f/attachment.bin>


More information about the cfe-commits mailing list