[PATCH] D11468: [Static Analyzer] The first implementation of nullability checker.

Gábor Horváth xazax.hun at gmail.com
Thu Jul 23 11:55:41 PDT 2015


xazax.hun created this revision.
xazax.hun added reviewers: zaks.anna, dcoughlin, krememek, jordan_rose.
xazax.hun added a subscriber: cfe-commits.

This is the first implementation of a checker that supposed to catch nullability errors.
Unfortunately the nullability qualifiers do not have well defined meaning, one can not assume that nonnull implies that the pointer can not be null.
In fact, the contract is, when the nullability preconditions on the parameter is not violated, then the nullability postconditions of the return value must not be violated either.
Right now the checker only checks simple rules, for example nullable pointers must be checked before dereferenced, should not pass null or unchecked nullable pointer to nonnul parameter, should not return null or unchecked nullable pointer from a nonnull returning function. The check will probably be relaxed, if one of the (not nullable) parameters known to be null, it will be ok to return null or unchecked nonnull pointer from a nonnull returning function.

Some details are still being worked out, how to define the nullability rules (in terms of this checker) to be able to both discover real issues and avoid false positives, while making it possible for users to suppress warnings (possibly using explicit casts). Once the rules are clear, supporting documentation will be provided.

http://reviews.llvm.org/D11468

Files:
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
  test/Analysis/nullability.mm

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D11468.30510.patch
Type: text/x-patch
Size: 25396 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150723/e7356bd2/attachment.bin>


More information about the cfe-commits mailing list