xref: /llvm-project/clang/test/Analysis/path-notes-impl-param.m (revision 85d97aac80b8e7689a6d957441054aa817bbb192)
1// RUN: %clang_analyze_cc1 -analyzer-checker=core,osx.cocoa.RetainCount -analyzer-output=text -verify %s
2
3@protocol NSObject
4@end
5
6@interface NSObject <NSObject> {}
7- (id)init;
8+ (id)alloc;
9- (id)autorelease;
10@end
11
12@interface Foo : NSObject
13@property(nonatomic) int bar;
14@end
15
16@implementation Foo
17-(int)bar {
18  return 0;
19}
20@end
21
22int baz() {
23  Foo *f = [Foo alloc];
24  // expected-note@-1 {{'f' initialized here}}
25  // expected-note@-2 {{Method returns an instance of Foo with a +1 retain count}}
26
27  return f.bar;
28  // expected-warning@-1 {{Potential leak of an object stored into 'self' [osx.cocoa.RetainCount]}}
29  // expected-note@-2 {{Passing value via implicit parameter 'self'}}
30  // expected-note@-3 {{Object leaked: object allocated and stored into 'self' is not referenced later in this execution path and has a retain count of +1}}
31}
32