[AMDGPU][AsmParser][NFC] Get rid of custom default operand handlers.
[llvm-project.git] / clang / test / Analysis / refcnt_naming.m
blob1b53e84814dad3c3ff29d850b3f9ec760deaa310
1 // RUN: %clang_analyze_cc1 -analyzer-checker=core,osx.cocoa.RetainCount,alpha.core -analyzer-config ipa=none -verify %s
3 typedef const struct __CFString * CFStringRef;
4 typedef const struct __CFAllocator * CFAllocatorRef;
5 typedef const struct __CFURL * CFURLRef;
6 extern CFURLRef CFURLCreateWithString(CFAllocatorRef allocator, CFStringRef URLString, CFURLRef baseURL);
7 typedef signed char BOOL;
8 @protocol NSObject  - (BOOL)isEqual:(id)object; @end
9 @interface NSObject <NSObject> {} @end
10 @class NSArray, NSString, NSURL;
12 @interface NamingTest : NSObject {}
13 -(NSObject*)copyPhoto;
14 -(NSObject*)mutableCopyPhoto;
15 -(NSObject*)mutable;
16 -(NSObject*)mutableCopying;
17 -(NSObject*)photocopy;    // read as "photocopy"
18 -(NSObject*)photoCopy;    // read as "photo Copy"
19 -(NSObject*)__blebPRCopy; // read as "bleb PRCopy"
20 -(NSObject*)__blebPRcopy; // read as "bleb P Rcopy"
21 -(NSObject*)new_theprefixdoescount; // read as "new theprefixdoescount"
22 -(NSObject*)newestAwesomeStuff; // read as "newest awesome stuff"
24 @end
26 @interface MyClass : NSObject
28   id myObject;
30 - (NSURL *)myMethod:(NSString *)inString;
31 - (NSURL *)getMethod:(NSString*)inString;
32 - (NSURL *)getMethod2:(NSString*)inString;
33 - (void)addObject:(id) __attribute__((ns_consumed)) X;
34 - (void)addObject2:(id) X;
35 @end
37 @implementation MyClass
39 - (NSURL *)myMethod:(NSString *)inString
41   NSURL *url = (NSURL *)CFURLCreateWithString(0, (CFStringRef)inString, 0); // expected-warning{{leak}}
42   return url;
45 - (NSURL *)getMethod:(NSString *)inString
47   NSURL *url = (NSURL *)CFURLCreateWithString(0, (CFStringRef)inString, 0);
48   [self addObject:url];
49   return url; // no-warning
52 - (NSURL *)getMethod2:(NSString *)inString
54   NSURL *url = (NSURL *)CFURLCreateWithString(0, (CFStringRef)inString, 0); // expected-warning{{leak}}
55   [self addObject2:url];
56   return url;
59 void testNames(NamingTest* x) {
60   [x copyPhoto]; // expected-warning{{leak}}
61   [x mutableCopyPhoto]; // expected-warning{{leak}}
62   [x mutable]; // no-warning
63   [x mutableCopying]; // no-warning
64   [x photocopy]; // no-warning
65   [x photoCopy]; // no-warning
66   [x __blebPRCopy]; // no-warning
67   [x __blebPRcopy]; // no-warning
68   [x new_theprefixdoescount]; // expected-warning{{leak}}
69   [x newestAwesomeStuff]; // no-warning
73 - (void)addObject:(id)X
75   myObject = X;
78 - (void)addObject2:(id)X
80   myObject = X;
83 @end