[PATCH] D22391: [Sema] Add warning for implicitly casting a null constant to a non null pointer type

Akira Hatanaka via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 25 17:24:37 PDT 2016


ahatanak updated this revision to Diff 65446.
ahatanak added a comment.

Addressed review comment and made a couple of other changes.

- Move Sema::diagnoseNullPtrToNonnullCast to SemaChecking.cpp.
- In diagnoseNullPtrToNonnullCast, call "Type::isAnyPointerType" instead of "Type::isPointerType" so that the function can diagnose objective-c pointers in addition to c/c++ pointers.
- Instead of adding the new warning to the existing "NullableToNonNullConversion" group, which would cause clang to warn about nil returns from objective-c methods (which is undesirable according to r240153's commit log), create a new diagnostic group for "-Wnull-const_to-nonnull".


https://reviews.llvm.org/D22391

Files:
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/Sema/Sema.cpp
  lib/Sema/SemaChecking.cpp
  lib/Sema/SemaExpr.cpp
  test/Sema/null_const_to_nonnull.c
  test/SemaObjC/null_const_to_nonnull.m

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D22391.65446.patch
Type: text/x-patch
Size: 4781 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160726/4c83f43c/attachment.bin>


More information about the cfe-commits mailing list