]> granicus.if.org Git - clang/commit
[analyzer] Suppress nullability warning for _Nonnull locals zero-initialized by ObjC...
authorDevin Coughlin <dcoughlin@apple.com>
Tue, 29 Dec 2015 23:44:19 +0000 (23:44 +0000)
committerDevin Coughlin <dcoughlin@apple.com>
Tue, 29 Dec 2015 23:44:19 +0000 (23:44 +0000)
commita5b27b8fe57e8a60e56c1edfaa8a2f37c51e3a6c
tree7e40ea7cd8342ae3ba6fa62a70010d91af7695ab
parent13e4061bde5ca7929d35b763ff2b32888e62d0b1
[analyzer] Suppress nullability warning for _Nonnull locals zero-initialized by ObjC ARC.

Prevent the analyzer from warning when a _Nonnnull local variable is implicitly
zero-initialized because of Objective-C automated reference counting. This avoids false
positives in cases where a _Nonnull local variable cannot be initialized with an
initialization expression, such as:
  NSString * _Nonnull s; // no-warning
  @autoreleasepool {
    s = ...;
  }

The nullability checker will still warn when a _Nonnull local variable is explicitly
initialized with nil.

This suppression introduces the potential for false negatives if the local variable
is used before it is assigned a _Nonnull value. Based on a discussion with Anna Zaks,
Jordan Rose, and John McCall, I've added a FIXME to treat implicitly zero-initialized
_Nonnull locals as uninitialized in Sema's UninitializedValues analysis to avoid these
false negatives.

rdar://problem/23522311

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@256603 91177308-0d34-0410-b5e6-96231b3b80d8
lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
test/Analysis/nullability.mm