1 // UNSUPPORTED: system-windows
2 // RUN: %clang_analyze_cc1 -fobjc-arc -analyzer-checker=core,osx.cocoa.RunLoopAutoreleaseLeak %s -triple x86_64-darwin -verify
3 // RUN: %clang_analyze_cc1 -DEXTRA=1 -DAP1=1 -fobjc-arc -analyzer-checker=core,osx.cocoa.RunLoopAutoreleaseLeak %s -triple x86_64-darwin -verify
4 // RUN: %clang_analyze_cc1 -DEXTRA=1 -DAP2=1 -fobjc-arc -analyzer-checker=core,osx.cocoa.RunLoopAutoreleaseLeak %s -triple x86_64-darwin -verify
5 // RUN: %clang_analyze_cc1 -DEXTRA=1 -DAP3=1 -fobjc-arc -analyzer-checker=core,osx.cocoa.RunLoopAutoreleaseLeak %s -triple x86_64-darwin -verify
6 // RUN: %clang_analyze_cc1 -DEXTRA=1 -DAP4=1 -fobjc-arc -analyzer-checker=core,osx.cocoa.RunLoopAutoreleaseLeak %s -triple x86_64-darwin -verify
8 #include "../Inputs/system-header-simulator-for-objc-dealloc.h"
12 void just_runloop() { // No warning: no statements in between
14 [[NSRunLoop mainRunLoop] run]; // no-warning
18 void just_xpcmain() { // No warning: no statements in between
20 xpc_main(); // no-warning
24 void runloop_init_before() { // Warning: object created before the loop.
26 NSObject *object = [[NSObject alloc] init]; // expected-warning{{Temporary objects allocated in the autorelease pool followed by the launch of main run loop may never get released; consider moving them to a separate autorelease pool}}
28 [[NSRunLoop mainRunLoop] run];
32 void xpcmain_init_before() { // Warning: object created before the loop.
34 NSObject *object = [[NSObject alloc] init]; // expected-warning{{Temporary objects allocated in the autorelease pool followed by the launch of xpc_main may never get released; consider moving them to a separate autorelease pool}}
40 void runloop_init_before_two_objects() { // Warning: object created before the loop.
42 NSObject *object = [[NSObject alloc] init]; // expected-warning{{Temporary objects allocated in the autorelease pool followed by the launch of main run loop may never get released; consider moving them to a separate autorelease pool}}
43 NSObject *object2 = [[NSObject alloc] init]; // no-warning, warning on the first one is enough.
46 [[NSRunLoop mainRunLoop] run];
50 void runloop_no_autoreleasepool() {
51 NSObject *object = [[NSObject alloc] init]; // no-warning
53 [[NSRunLoop mainRunLoop] run];
56 void runloop_init_after() { // No warning: objects created after the loop
58 [[NSRunLoop mainRunLoop] run];
59 NSObject *object = [[NSObject alloc] init]; // no-warning
68 NSObject *object = [[NSObject alloc] init]; // expected-warning{{Temporary objects allocated in the autorelease pool of last resort followed by the launch of main run loop may never get released; consider moving them to a separate autorelease pool}}
70 [[NSRunLoop mainRunLoop] run];
76 // expected-no-diagnostics
78 NSObject *object = [[NSObject alloc] init]; // no-warning
81 [[NSRunLoop mainRunLoop] run];
88 // expected-no-diagnostics
90 [[NSRunLoop mainRunLoop] run];
91 NSObject *object = [[NSObject alloc] init]; // no-warning
99 NSObject *object = [[NSObject alloc] init]; // expected-warning{{Temporary objects allocated in the autorelease pool of last resort followed by the launch of xpc_main may never get released; consider moving them to a separate autorelease pool}}