[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / ARCMT / check-with-serialized-diag.m
blob6102be037fcc1aa76af2cfbba64732a3fc1718ab
2 @protocol NSObject
3 - (id)retain;
4 - (unsigned)retainCount;
5 - (oneway void)release;
6 - (id)autorelease;
7 @end
9 @interface NSObject <NSObject> {}
10 - (id)init;
12 + (id)new;
13 + (id)alloc;
14 - (void)dealloc;
16 - (void)finalize;
18 - (id)copy;
19 - (id)mutableCopy;
20 @end
22 @interface A : NSObject
23 @end
25 struct UnsafeS {
26   A *__unsafe_unretained unsafeObj;
29 id global_foo;
31 void test1(A *a, struct UnsafeS *unsafeS) {
32   [unsafeS->unsafeObj retain];
33   id foo = [unsafeS->unsafeObj retain]; // no warning.
34   [global_foo retain];
35   [a retainCount];
38 // RUN: not %clang_cc1 -arcmt-action=check -triple x86_64-apple-darwin10 %s -serialize-diagnostic-file %t.diag
39 // RUN: c-index-test -read-diagnostics %t.diag > %t 2>&1
40 // RUN: FileCheck --input-file=%t %s
42 // CHECK: {{.*}}check-with-serialized-diag.m:32:4: error: [rewriter] it is not safe to remove 'retain' message on an __unsafe_unretained type
43 // CHECK-NEXT: Number FIXITs = 0
44 // CHECK-NEXT: {{.*}}check-with-serialized-diag.m:34:4: error: [rewriter] it is not safe to remove 'retain' message on a global variable
45 // CHECK-NEXT: Number FIXITs = 0
46 // CHECK-NEXT: {{.*}}check-with-serialized-diag.m:32:23: error: ARC forbids explicit message send of 'retain'
47 // CHECK-NEXT: Range: {{.*}}check-with-serialized-diag.m:32:4 {{.*}}check-with-serialized-diag.m:32:22
48 // CHECK-NEXT: Number FIXITs = 0
49 // CHECK-NEXT: {{.*}}check-with-serialized-diag.m:34:15: error: ARC forbids explicit message send of 'retain'
50 // CHECK-NEXT: Range: {{.*}}check-with-serialized-diag.m:34:4 {{.*}}check-with-serialized-diag.m:34:14
51 // CHECK-NEXT: Number FIXITs = 0
52 // CHECK-NEXT: {{.*}}check-with-serialized-diag.m:35:6: error: ARC forbids explicit message send of 'retainCount'
53 // CHECK-NEXT: Range: {{.*}}check-with-serialized-diag.m:35:4 {{.*}}check-with-serialized-diag.m:35:5
54 // CHECK-NEXT: Number FIXITs = 0