This is an archive of the discontinued LLVM Phabricator instance.

[analyzer] RetainCountChecker: be forgiving when ivars are accessed directly
ClosedPublic

Authored by jordan_rose on Jan 5 2015, 9:34 AM.

Details

Summary

A refinement of r204730, itself a refinement of r198953, to better handle cases where an object is accessed both through a property getter and through direct ivar access. An object accessed through a property should always be treated as +0, i.e. not owned by the caller. However, an object accessed through an ivar may be at +0 or at +1, depending on whether the ivar is a strong reference. Outside of ARC, we don't always have that information.

The previous attempt would clear out the +0 provided by a getter, but only if that +0 hadn't already participated in other retain counting operations. (That is, self.foo is okay, but [[self.foo retain] autorelease] is problematic.) This turned out to not be good enough when our synthesized getters get involved.

This commit drops the notion of "overridable" reference counting and instead just tracks whether a value ever came from a (strong) ivar. If it has, we allow one more release than we otherwise would. This has the added benefit of being able to catch /some/ overreleases of instance variables, though it's not likely to come up in practice.

We do still get some false negatives because we currently throw away refcount state upon assigning a value into an ivar. We should probably improve on that in the future, especially once we synthesize setters as well as getters.

rdar://problem/18075108

Diff Detail

Event Timeline

jordan_rose updated this revision to Diff 17807.Jan 5 2015, 9:34 AM
jordan_rose retitled this revision from to [analyzer] RetainCountChecker: be forgiving when ivars are accessed directly.
jordan_rose updated this object.
jordan_rose edited the test plan for this revision. (Show Details)
jordan_rose added a reviewer: zaks.anna.
jordan_rose added a subscriber: Unknown Object (MLST).
jordan_rose accepted this revision.Feb 4 2015, 11:27 AM
jordan_rose added a reviewer: jordan_rose.

Anna reviewed this offline; committed as r228174.

This revision is now accepted and ready to land.Feb 4 2015, 11:27 AM
jordan_rose closed this revision.Feb 4 2015, 11:27 AM