xref: /aosp_15_r20/external/clang/test/ARCMT/atautorelease-3.m (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result
2*67e74705SXin Li// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t
3*67e74705SXin Li// RUN: diff %t %s.result
4*67e74705SXin Li
5*67e74705SXin Li@interface NSAutoreleasePool
6*67e74705SXin Li- drain;
7*67e74705SXin Li+new;
8*67e74705SXin Li+alloc;
9*67e74705SXin Li-init;
10*67e74705SXin Li-autorelease;
11*67e74705SXin Li- release;
12*67e74705SXin Li@end
13*67e74705SXin Li
14*67e74705SXin Livoid NSLog(id, ...);
15*67e74705SXin Li
16*67e74705SXin Livoid test1(int x) {
17*67e74705SXin Li  // All this stuff get removed since nothing is happening inside.
18*67e74705SXin Li  NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
19*67e74705SXin Li  NSAutoreleasePool *chunkPool = [[NSAutoreleasePool alloc] init];
20*67e74705SXin Li  while (x) {
21*67e74705SXin Li    chunkPool = [[NSAutoreleasePool alloc] init];
22*67e74705SXin Li    [chunkPool release];
23*67e74705SXin Li  }
24*67e74705SXin Li
25*67e74705SXin Li  [chunkPool drain];
26*67e74705SXin Li  [pool drain];
27*67e74705SXin Li}
28*67e74705SXin Li
29*67e74705SXin Livoid test2(int x) {
30*67e74705SXin Li  NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
31*67e74705SXin Li  NSAutoreleasePool *chunkPool = [[NSAutoreleasePool alloc] init];
32*67e74705SXin Li  while (x) {
33*67e74705SXin Li    chunkPool = [[NSAutoreleasePool alloc] init];
34*67e74705SXin Li    ++x;
35*67e74705SXin Li    [chunkPool release];
36*67e74705SXin Li  }
37*67e74705SXin Li
38*67e74705SXin Li  [chunkPool drain];
39*67e74705SXin Li  [pool drain];
40*67e74705SXin Li}
41