[cfe-dev] CFRefCount Problem #2: Region Invalidation

Ted Kremenek kremenek at apple.com
Sat Aug 27 15:17:33 PDT 2011


On Aug 27, 2011, at 2:32 PM, Jordy Rose wrote:

> It's to handle the "stop tracking" aspect of C++ constructors. checkRegionChanges() actually /doesn't/ invalidate the arguments to C++ constructors, because it treats them as top-level arguments, which maintain their retain counts.

Ah yes.  Makes perfect sense!

> It's the postStmt check that currently stops tracking the arguments to C++ methods.
> 
> I think it would actually be /great/ to allow annotations on C++ constructors, so that we could do retain-count checks for something like:
> 
> {
>  LocalObject x([[Foo alloc] init]);
>  [*x doSomething];
> } // *x is released by LocalObject's destructor
> {
>  LocalObject y([[[Foo alloc] init] autorelease]);
> } // expected-warning{{over-release of object}}
> 
> This is certainly a ways off (at the very least we need better destructor support, cf. PR3888), but including this post-statement check means that constructors are treated like any other C++ method calls -- they get a stop-tracking summary from the summary manager, and that's that.

WRM.

> If we add support for method calls, it'll apply to constructors for free.
> 
> If that's not what we want, we /still/ need to have a post-statement check for CXXConstructExprs to stop tracking all the arguments. Or we need to add the current Expr (or ProgramPoint, as you mentioned) to checkRegionChanges. Which do you think is better here?

I like the approach you have taken.  Keeps everything consistent.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110827/fd98c0b9/attachment.html>


More information about the cfe-dev mailing list