Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

-checker-cfref doesn't take the @finally block into account #4406

Open Quuxplusone opened 15 years ago

Quuxplusone commented 15 years ago
Bugzilla Link PR3958
Status NEW
Importance P normal
Reported by Nikita Zhuk (nikita@zhuk.fi)
Reported on 2009-04-07 02:30:38 -0700
Last modified on 2010-02-22 12:47:29 -0800
Version unspecified
Hardware Macintosh All
CC kremenek@apple.com, llvm-bugs@lists.llvm.org
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
When some objects are allocated before or inside a @try block,
-checker-cfref doesn't "see" the code in the @finally block which deallocates
these objects.

Test case, reporting false positives:

// RUN: clang-cc -analyze -checker-cfref -verify %s

#import <Foundation/Foundation.h>

void f1()
{
  int i = 1;
  while(i-- > 0)
  {
    NSAutoreleasePool *innerPool = [[NSAutoreleasePool alloc] init]; // no-warning. Currently produces: Potential leak of object allocated on line 10 and stored into 'innerPool'
    NSArray *array = nil;

    @try {
      array = [[NSMutableArray alloc] init]; // no-warning. Currently produces: Potential leak of object allocated on line 14 and stored into 'array'
      break;
    }
    @catch (NSException * e) {}
    @finally {
      [array release];
      [innerPool drain];
    }
  }
}

Clang revision: 68443
Quuxplusone commented 15 years ago

Based on Ted's commit message in r68492, this is a known issue.

Quuxplusone commented 15 years ago
(In reply to comment #1)
> Based on Ted's commit message in r68492, this is a known issue.
>

Indeed.  I've disabled analyzer support for @try...@finally until I have time
to implement it correctly.