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

Jean-Daniel Dupas devlists at shadowlab.org
Wed May 20 05:26:09 PDT 2009


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;
}

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20090520/3c76ffd8/attachment.html>


More information about the cfe-dev mailing list