[LLVMbugs] [Bug 10794] New: REGRESSION: ObjC objects passed to C++ 'new' are still retain-count-tracked

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sat Aug 27 15:59:48 PDT 2011


http://llvm.org/bugs/show_bug.cgi?id=10794

           Summary: REGRESSION: ObjC objects passed to C++ 'new' are still
                    retain-count-tracked
           Product: clang
           Version: trunk
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: regression
          Severity: normal
          Priority: P
         Component: Static Analyzer
        AssignedTo: kremenek at apple.com
        ReportedBy: jediknil at belkadan.com
                CC: llvmbugs at cs.uiuc.edu


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:
1. Add CXXNewExpr to CallOrObjCMessage.
2. Add a post-statement hook for CXXNewExpr.
3. Implement check::PostStmt<CXXNewExpr> 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;
}

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list