CGColorSpace.c revision c037eac3bda3c636c961aab6377beea3242e81e4
1// RUN: clang-cc -analyze -checker-cfref -analyzer-store=basic -analyzer-constraints=basic -verify %s &&
2// RUN: clang-cc -analyze -checker-cfref -analyzer-store=basic-old-cast -analyzer-constraints=basic -verify %s &&
3// RUN: clang-cc -analyze -checker-cfref -analyzer-store=basic -analyzer-constraints=range -verify %s &&
4// RUN: clang-cc -analyze -checker-cfref -analyzer-store=basic-old-cast -analyzer-constraints=range -verify %s &&
5// RUN: clang-cc -analyze -checker-cfref -analyzer-store=region -analyzer-constraints=basic -verify %s &&
6// RUN: clang-cc -analyze -checker-cfref -analyzer-store=region -analyzer-constraints=range -verify %s
7
8typedef struct CGColorSpace *CGColorSpaceRef;
9extern CGColorSpaceRef CGColorSpaceCreateDeviceRGB(void);
10extern CGColorSpaceRef CGColorSpaceRetain(CGColorSpaceRef space);
11extern void CGColorSpaceRelease(CGColorSpaceRef space);
12
13void f() {
14  CGColorSpaceRef X = CGColorSpaceCreateDeviceRGB(); // expected-warning{{leak}}
15  CGColorSpaceRetain(X);
16}
17
18void fb() {
19  CGColorSpaceRef X = CGColorSpaceCreateDeviceRGB();
20  CGColorSpaceRetain(X);
21  CGColorSpaceRelease(X);
22  CGColorSpaceRelease(X);  // no-warning
23}
24