[cfe-dev] Analyzer do not see leaks in methods using @try {} @catch {} ?

Ted Kremenek kremenek at apple.com
Wed May 20 07:45:23 PDT 2009


It is a known issue.  CFG support for @try... at catch...@finally just  
hasn't been implemented yet, which means that functions and methods  
using these constructs are skipped.  There are several existing bugs  
tracking this.

On May 20, 2009, at 5:26 AM, Jean-Daniel Dupas  
<devlists at shadowlab.org> wrote:

> Is it a known issue, or should I fill a bug report (or did I miss  
> something) ?
>
> Example:
> > clang --analyze leak.m
> leak.m:5:19: warning: Potential leak of an object allocated on line  
> 5 and stored into 'str'
>   NSString *str = [[NSString alloc] initWithCString:"Hello leak"  
> encoding:NSUTF8StringEncoding];
>
> > clang --analyze leak.m -DEXCEPTION
> [nothing]
>
> --------------------------- leak.m
>
> #import <Foundation/Foundation.h>
>
> int test() {
>   NSString *str = [[NSString alloc] initWithCString:"Hello leak"  
> encoding:NSUTF8StringEncoding];
>
> #ifdef EXCEPTION
>   @try {
> #endif
>     NSLog(@"%@", str);
> #ifdef EXCEPTION
>   } @catch (NSException *exception) {
>     NSLog(@"%@", exception);
>   }
> #endif
>
>   return str != 0;
> }
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20090520/be1ebd9f/attachment.html>


More information about the cfe-dev mailing list