[analyzer] Nullability: Suppress return diagnostics in inlined functions.
authorDevin Coughlin <dcoughlin@apple.com>
Tue, 12 Apr 2016 19:29:52 +0000 (19:29 +0000)
committerDevin Coughlin <dcoughlin@apple.com>
Tue, 12 Apr 2016 19:29:52 +0000 (19:29 +0000)
commit49bd58f1ebe28d97e4949e9c757bc5dfd8b2d72f
treec3879d19b604cf8e066643666d9d51fa9553f78f
parentfd3e1ad0ce073e67c21833e56b74105ce8339ce3
[analyzer] Nullability: Suppress return diagnostics in inlined functions.

The nullability checker can sometimes miss detecting nullability precondition
violations in inlined functions because the binding for the parameter
that violated the precondition becomes dead before the return:

int * _Nonnull callee(int * _Nonnull p2) {
  if (!p2)
    // p2 becomes dead here, so binding removed.
    return 0; // warning here because value stored in p2 is symbolic.
  else
   return p2;
}

int *caller(int * _Nonnull p1) {
  return callee(p1);
}

The fix, which is quite blunt, is to not warn about null returns in inlined
methods/functions. This won’t lose much coverage for ObjC because the analyzer
always analyzes each ObjC method at the top level in addition to inlined. It
*will* lose coverage for C — but there aren’t that many codebases with C
nullability annotations.

rdar://problem/25615050

llvm-svn: 266109
clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
clang/test/Analysis/nullability.mm