[analyzer] ObjCDeallocChecker: Only operate on classes with retained properties.
authorDevin Coughlin <dcoughlin@apple.com>
Wed, 27 Jan 2016 01:41:58 +0000 (01:41 +0000)
committerDevin Coughlin <dcoughlin@apple.com>
Wed, 27 Jan 2016 01:41:58 +0000 (01:41 +0000)
commit3075134739edc9cd16d5ca7b9a78d8b4d5fbff3e
treece46cbcdad87a0e0baf8b3c2a41a2290b92f58c5
parentece881d5182873dd780b53387047fb8300cd5c7d
[analyzer] ObjCDeallocChecker: Only operate on classes with retained properties.

Previously the ObjC Dealloc Checker only checked classes with ivars, not
retained properties, which caused three bugs:

- False positive warnings about a missing -dealloc method in classes with only
ivars.
- Missing warnings about a missing -dealloc method on classes with only
properties.
- Missing warnings about an over-released or under-released ivar associated with
a retained property in classes with only properties.

The fix is to check only classes with at least one retained synthesized
property.

This also exposed a bug when reporting an over-released or under-released
property that did not contain a synthesize statement. The checker tried to
associate the warning with an @synthesize statement that did not exist, which
caused an assertion failure in debug builds. The fix is to fall back to the
@property statement in this case.

A patch by David Kilzer!

Part of rdar://problem/6927496

Differential Revision: http://reviews.llvm.org/D5023

llvm-svn: 258896
clang/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp
clang/test/Analysis/DeallocMissingRelease.m [new file with mode: 0644]
clang/test/Analysis/MissingDealloc.m
clang/test/Analysis/PR2978.m