llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
27.92k stars 11.52k forks source link

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

Open llvmbot opened 15 years ago

llvmbot commented 15 years ago
Bugzilla Link 3958
Version unspecified
OS All
Reporter LLVM Bugzilla Contributor
CC @tkremenek

Extended Description

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;

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

} }

Clang revision: 68443

tkremenek commented 15 years ago

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.

llvmbot commented 15 years ago

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

llvmbot commented 15 years ago

assigned to @tkremenek