-
Notifications
You must be signed in to change notification settings - Fork 15.1k
Description
| Bugzilla Link | 10794 |
| Resolution | FIXED |
| Resolved on | Mar 16, 2012 21:40 |
| Version | trunk |
| OS | All |
Extended Description
Currently, RetainReleaseChecker is supposed to stop tracking the retain counts of objects that are passed to C++ methods, or generally into C++-land, at least until we've established what the right behavior should be. This works for regular methods and for stack constructors, but not for heap constructors, i.e. C++ objects allocated with 'new'.
Previously this worked almost coincidentally; /every/ argument's retain count was invalidated /except/ those explicitly whitelisted by the CFRefCount transfer functions. And CFRefCount never handled C++-only expressions anyway.
One fix is as follows:
- Add CXXNewExpr to CallOrObjCMessage.
- Add a post-statement hook for CXXNewExpr.
- Implement check::PostStmt on RetainReleaseChecker with the exact same code as for CXXConstructExprs.
This change occurred (deliberately) in r138716.
Test case (for retain-release.mm):
void test_smartpointer_4() {
id x = [[NSObject alloc] init]; // no-warning
SmartPointer *foo = new SmartPointer(x);
delete foo;
}