1 // RUN: %clang_analyze_cc1 -analyzer-checker=core,osx.cocoa.RetainCount -fblocks -verify %s
2 // RUN: %clang_analyze_cc1 -analyzer-checker=core,osx.cocoa.RetainCount -fblocks -analyzer-output=plist-multi-file %s -o %t
3 // RUN: %normalize_plist <%t | diff -ub %S/Inputs/expected-plists/objc-radar17039661.m.plist -
6 typedef long NSInteger;
7 typedef unsigned char BOOL;
15 @interface NSNumber : NSObject
16 + (NSNumber *)numberWithInteger:(NSInteger)value __attribute__((availability(ios,introduced=2.0)));
18 NSInteger *inoutIntegerValueGlobal;
19 NSInteger *inoutIntegerValueGlobal2;
20 NSString *traitNameGlobal;
23 static inline void reallyPerformAction(void (^integerHandler)(NSInteger *inoutIntegerValue, NSString *traitName)) {
24 integerHandler(inoutIntegerValueGlobal, traitNameGlobal); // expected-warning {{Potential leak of an object}}
25 integerHandler(inoutIntegerValueGlobal2,traitNameGlobal);
28 static inline BOOL performAction(NSNumber *(^action)(NSNumber *traitValue)) {
29 __attribute__((__blocks__(byref))) BOOL didFindTrait = 0;
30 reallyPerformAction(^(NSInteger *inoutIntegerValue,NSString *traitName) {
34 NSNumber *traitValue = @(*inoutIntegerValue);
36 NSNumber *newTraitValue = action(traitValue);
38 if (traitValue != newTraitValue) {
39 *inoutIntegerValue = newTraitValue ? *inoutIntegerValue : *inoutIntegerValue;
49 __attribute__((__blocks__(byref))) NSNumber *builtinResult = ((NSNumber *)0);
50 BOOL wasBuiltinTrait = performAction(^(NSNumber *traitValue) {
51 builtinResult = [traitValue retain];
55 if (wasBuiltinTrait) {
56 [builtinResult autorelease];