diff options
Diffstat (limited to 'test/ARCMT')
156 files changed, 0 insertions, 14266 deletions
diff --git a/test/ARCMT/Common.h b/test/ARCMT/Common.h deleted file mode 100644 index b388ecab7410..000000000000 --- a/test/ARCMT/Common.h +++ /dev/null @@ -1,110 +0,0 @@ -#if __has_feature(objc_arr) -#define NS_AUTOMATED_REFCOUNT_UNAVAILABLE __attribute__((unavailable("not available in automatic reference counting mode"))) -#else -#define NS_AUTOMATED_REFCOUNT_UNAVAILABLE -#endif - -#define NS_RETURNS_RETAINED __attribute__((ns_returns_retained)) -#define CF_CONSUMED __attribute__((cf_consumed)) -#define CF_RETURNS_RETAINED __attribute__((cf_returns_retained)) - -#define NS_INLINE static __inline__ __attribute__((always_inline)) -#define nil ((void*) 0) -#define NULL ((void*)0) - -typedef int BOOL; -typedef unsigned NSUInteger; -typedef int int32_t; -typedef unsigned char uint8_t; -typedef int32_t UChar32; -typedef unsigned char UChar; - -typedef struct _NSZone NSZone; - -typedef const void * CFTypeRef; -CFTypeRef CFRetain(CFTypeRef cf); -CFTypeRef CFMakeCollectable(CFTypeRef cf) NS_AUTOMATED_REFCOUNT_UNAVAILABLE; - -NS_INLINE NS_RETURNS_RETAINED id NSMakeCollectable(CFTypeRef CF_CONSUMED cf) NS_AUTOMATED_REFCOUNT_UNAVAILABLE; - -@protocol NSObject -- (BOOL)isEqual:(id)object; -- (NSZone *)zone NS_AUTOMATED_REFCOUNT_UNAVAILABLE; -- (id)retain NS_AUTOMATED_REFCOUNT_UNAVAILABLE; -- (NSUInteger)retainCount NS_AUTOMATED_REFCOUNT_UNAVAILABLE; -- (oneway void)release NS_AUTOMATED_REFCOUNT_UNAVAILABLE; -- (id)autorelease NS_AUTOMATED_REFCOUNT_UNAVAILABLE; -@end - -@interface NSObject <NSObject> {} -- (id)init; - -+ (id)new; -+ (id)alloc; -- (void)dealloc; - -- (void)finalize; - -- (id)copy; -- (id)mutableCopy; -@end - -NS_AUTOMATED_REFCOUNT_UNAVAILABLE -@interface NSAutoreleasePool : NSObject { -@private - void *_token; - void *_reserved3; - void *_reserved2; - void *_reserved; -} - -+ (void)addObject:(id)anObject; - -- (void)addObject:(id)anObject; - -- (void)drain; - -@end - -typedef const void* objc_objectptr_t; -extern __attribute__((ns_returns_retained)) id objc_retainedObject(objc_objectptr_t __attribute__((cf_consumed)) pointer); -extern __attribute__((ns_returns_not_retained)) id objc_unretainedObject(objc_objectptr_t pointer); -extern objc_objectptr_t objc_unretainedPointer(id object); - -#define dispatch_retain(object) ({ dispatch_object_t _o = (object); _dispatch_object_validate(_o); (void)[_o retain]; }) -#define dispatch_release(object) ({ dispatch_object_t _o = (object); _dispatch_object_validate(_o); [_o release]; }) -#define xpc_retain(object) ({ xpc_object_t _o = (object); _xpc_object_validate(_o); [_o retain]; }) -#define xpc_release(object) ({ xpc_object_t _o = (object); _xpc_object_validate(_o); [_o release]; }) - -typedef id dispatch_object_t; -typedef id xpc_object_t; - -void _dispatch_object_validate(dispatch_object_t object); -void _xpc_object_validate(xpc_object_t object); - -#if __has_feature(objc_arc) - -NS_INLINE CF_RETURNS_RETAINED CFTypeRef CFBridgingRetain(id X) { - return (__bridge_retained CFTypeRef)X; -} - -NS_INLINE id CFBridgingRelease(CFTypeRef CF_CONSUMED X) { - return (__bridge_transfer id)X; -} - -#else - -NS_INLINE CF_RETURNS_RETAINED CFTypeRef CFBridgingRetain(id X) { - return X ? CFRetain((CFTypeRef)X) : NULL; -} - -NS_INLINE id CFBridgingRelease(CFTypeRef CF_CONSUMED X) { - return [(id)CFMakeCollectable(X) autorelease]; -} - -#endif - -void *_Block_copy(const void *aBlock); -void _Block_release(const void *aBlock); -#define Block_copy(...) ((__typeof(__VA_ARGS__))_Block_copy((const void *)(__VA_ARGS__))) -#define Block_release(...) _Block_release((const void *)(__VA_ARGS__)) diff --git a/test/ARCMT/GC-check-warn-nsalloc.m b/test/ARCMT/GC-check-warn-nsalloc.m deleted file mode 100644 index 44ccc95e3f7c..000000000000 --- a/test/ARCMT/GC-check-warn-nsalloc.m +++ /dev/null @@ -1,11 +0,0 @@ -// RUN: %clang_cc1 -arcmt-check -no-ns-alloc-error -triple x86_64-apple-darwin10 -fobjc-gc-only %s 2>&1 | grep 'warning: \[rewriter\] call returns pointer to GC managed memory' -// RUN: %clang_cc1 -arcmt-check -no-ns-alloc-error -triple x86_64-apple-darwin10 -fobjc-gc-only -x objective-c++ %s 2>&1 | grep 'warning: \[rewriter\] call returns pointer to GC managed memory' -// TODO: Investigate VerifyDiagnosticConsumer failures on these tests when using -verify. -// rdar://10532541 - -typedef unsigned NSUInteger; -void *__strong NSAllocateCollectable(NSUInteger size, NSUInteger options); - -void test1() { - NSAllocateCollectable(100, 0); -} diff --git a/test/ARCMT/GC-check.m b/test/ARCMT/GC-check.m deleted file mode 100644 index 9864354228be..000000000000 --- a/test/ARCMT/GC-check.m +++ /dev/null @@ -1,19 +0,0 @@ -// RUN: %clang_cc1 -arcmt-check -verify -triple x86_64-apple-darwin10 -fobjc-gc-only %s -// RUN: %clang_cc1 -arcmt-check -verify -triple x86_64-apple-darwin10 -fobjc-gc-only -x objective-c++ %s - -#define CF_AUTOMATED_REFCOUNT_UNAVAILABLE __attribute__((unavailable("not available in automatic reference counting mode"))) -typedef unsigned NSUInteger; -typedef const void * CFTypeRef; -CFTypeRef CFMakeCollectable(CFTypeRef cf) CF_AUTOMATED_REFCOUNT_UNAVAILABLE; // expected-note {{unavailable}} -void *__strong NSAllocateCollectable(NSUInteger size, NSUInteger options); - -void test1(CFTypeRef *cft) { - CFTypeRef c = CFMakeCollectable(cft); // expected-error {{CFMakeCollectable will leak the object that it receives in ARC}} \ - // expected-error {{unavailable}} - NSAllocateCollectable(100, 0); // expected-error {{call returns pointer to GC managed memory; it will become unmanaged in ARC}} -} - -@interface I1 { - __strong void *gcVar; // expected-error {{GC managed memory will become unmanaged in ARC}} -} -@end; diff --git a/test/ARCMT/GC-no-arc-runtime.m b/test/ARCMT/GC-no-arc-runtime.m deleted file mode 100644 index 99ba2eb5f7ae..000000000000 --- a/test/ARCMT/GC-no-arc-runtime.m +++ /dev/null @@ -1,80 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-macosx10.6 -fsyntax-only -fobjc-runtime-has-weak -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-macosx10.6 -fsyntax-only -fobjc-gc-only -x objective-c %s > %t -// RUN: diff %t %s.result -// RUN: arcmt-test --args -triple x86_64-apple-macosx10.6 -fsyntax-only -fobjc-gc-only -x objective-c++ %s > %t -// RUN: diff %t %s.result - -// MRC __weak broke this test somehow. -// XFAIL: * - -#include "Common.h" -#include "GC.h" - -void test1(CFTypeRef *cft) { - id x = NSMakeCollectable(cft); -} - -@interface I1 -@end - -@implementation I1 --(void)dealloc { - // dealloc - test1(0); -} - --(void)finalize { - // finalize - test1(0); -} -@end - -@interface I2 -@property (retain) id prop; -@end - -@implementation I2 -@synthesize prop; - --(void)finalize { - self.prop = 0; - // finalize - test1(0); -} -@end - -__attribute__((objc_arc_weak_reference_unavailable)) -@interface QQ { - __weak id s; - __weak QQ *q; -} -@end - -@interface I3 -@property (assign) I3 *__weak pw1, *__weak pw2; -@property (assign) I3 *__strong ps; -@property (assign) I3 * pds; -@end - -@interface I4Impl { - I4Impl *pds2; -} -@property (assign) I4Impl *__weak pw1, *__weak pw2; -@property (assign) I4Impl *__strong ps; -@property (assign) I4Impl * pds; -@property (assign) I4Impl * pds2; -@end - -@implementation I4Impl -@synthesize pw1, pw2, ps, pds, pds2; - --(void)test1:(CFTypeRef *)cft { - id x = NSMakeCollectable(cft); -} -@end - -@interface I5 { - __weak id prop; -} -@property (readonly) __weak id prop; -@end diff --git a/test/ARCMT/GC-no-arc-runtime.m.result b/test/ARCMT/GC-no-arc-runtime.m.result deleted file mode 100644 index c338bdb2ed47..000000000000 --- a/test/ARCMT/GC-no-arc-runtime.m.result +++ /dev/null @@ -1,72 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-macosx10.6 -fsyntax-only -fobjc-runtime-has-weak -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-macosx10.6 -fsyntax-only -fobjc-gc-only -x objective-c %s > %t -// RUN: diff %t %s.result -// RUN: arcmt-test --args -triple x86_64-apple-macosx10.6 -fsyntax-only -fobjc-gc-only -x objective-c++ %s > %t -// RUN: diff %t %s.result - -#include "Common.h" -#include "GC.h" - -void test1(CFTypeRef *cft) { - id x = CFBridgingRelease(cft); -} - -@interface I1 -@end - -@implementation I1 --(void)dealloc { - // dealloc - test1(0); -} - -@end - -@interface I2 -@property (strong) id prop; -@end - -@implementation I2 -@synthesize prop; - --(void)dealloc { - // finalize - test1(0); -} -@end - -__attribute__((objc_arc_weak_reference_unavailable)) -@interface QQ { - __unsafe_unretained id s; - __unsafe_unretained QQ *q; -} -@end - -@interface I3 -@property (unsafe_unretained) I3 * pw1, * pw2; -@property (strong) I3 * ps; -@property (assign) I3 * pds; -@end - -@interface I4Impl { - I4Impl *__strong pds2; -} -@property (unsafe_unretained) I4Impl * pw1, * pw2; -@property (strong) I4Impl * ps; -@property (strong) I4Impl * pds; -@property (strong) I4Impl * pds2; -@end - -@implementation I4Impl -@synthesize pw1, pw2, ps, pds, pds2; - --(void)test1:(CFTypeRef *)cft { - id x = CFBridgingRelease(cft); -} -@end - -@interface I5 { - __unsafe_unretained id prop; -} -@property (unsafe_unretained, readonly) id prop; -@end diff --git a/test/ARCMT/GC-no-finalize-removal.m b/test/ARCMT/GC-no-finalize-removal.m deleted file mode 100644 index a8db819d90b8..000000000000 --- a/test/ARCMT/GC-no-finalize-removal.m +++ /dev/null @@ -1,89 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-macosx10.7 -fsyntax-only -fobjc-runtime-has-weak -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-macosx10.7 -fsyntax-only -fobjc-gc-only -no-finalize-removal -x objective-c %s > %t -// RUN: diff %t %s.result -// RUN: arcmt-test --args -triple x86_64-apple-macosx10.7 -fsyntax-only -fobjc-gc-only -no-finalize-removal -x objective-c++ %s > %t -// RUN: diff %t %s.result - -#include "Common.h" -#include "GC.h" - -void test1(CFTypeRef *cft) { - id x = NSMakeCollectable(cft); -} - -@interface I1 -@end - -@implementation I1 --(void)dealloc { - // dealloc - test1(0); -} - --(void)finalize { - // finalize - test1(0); -} -@end - -@interface I2 -@property (retain) id prop; -@end - -@implementation I2 -@synthesize prop; - --(void)finalize { - self.prop = 0; - // finalize - test1(0); -} -@end - -__attribute__((objc_arc_weak_reference_unavailable)) -@interface QQ { - __weak id s; - __weak QQ *q; -} -@end - -@interface I3 -@property (assign) I3 *__weak pw1, *__weak pw2; -@property (assign) I3 *__strong ps; -@property (assign) I3 * pds; -@end - -@interface I4Impl { - I4Impl *pds2; - I4Impl *pds3; - __weak I4Impl *pw3; - __weak I4Impl *pw4; -} -@property (assign) I4Impl *__weak pw1, *__weak pw2; -@property (assign) I4Impl *__strong ps; -@property (assign) I4Impl * pds; -@property (assign) I4Impl * pds2; -@property (readwrite) I4Impl * pds3; -@property (readonly) I4Impl * pds4; -@property (readonly) __weak I4Impl *pw3; -@property (assign) __weak I4Impl *pw4; -@end - -@implementation I4Impl -@synthesize pw1, pw2, pw3, pw4, ps, pds, pds2, pds3, pds4; - --(void)test1:(CFTypeRef *)cft { - id x = NSMakeCollectable(cft); -} -@end - -// rdar://10532449 -@interface rdar10532449 -@property (assign) id assign_prop; -@property (assign, readonly) id __strong strong_readonly_prop; -@property (assign) id __weak weak_prop; -@end - -@implementation rdar10532449 -@synthesize assign_prop, strong_readonly_prop, weak_prop; -@end diff --git a/test/ARCMT/GC-no-finalize-removal.m.result b/test/ARCMT/GC-no-finalize-removal.m.result deleted file mode 100644 index b563d196ee65..000000000000 --- a/test/ARCMT/GC-no-finalize-removal.m.result +++ /dev/null @@ -1,97 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-macosx10.7 -fsyntax-only -fobjc-runtime-has-weak -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-macosx10.7 -fsyntax-only -fobjc-gc-only -no-finalize-removal -x objective-c %s > %t -// RUN: diff %t %s.result -// RUN: arcmt-test --args -triple x86_64-apple-macosx10.7 -fsyntax-only -fobjc-gc-only -no-finalize-removal -x objective-c++ %s > %t -// RUN: diff %t %s.result - -#include "Common.h" -#include "GC.h" - -void test1(CFTypeRef *cft) { - id x = CFBridgingRelease(cft); -} - -@interface I1 -@end - -@implementation I1 --(void)dealloc { - // dealloc - test1(0); -} - -#if !__has_feature(objc_arc) --(void)finalize { - // finalize - test1(0); -} -#endif -@end - -@interface I2 -@property (strong) id prop; -@end - -@implementation I2 -@synthesize prop; - -#if !__has_feature(objc_arc) --(void)finalize { - self.prop = 0; - // finalize - test1(0); -} -#endif --(void)dealloc { - // finalize - test1(0); -} -@end - -__attribute__((objc_arc_weak_reference_unavailable)) -@interface QQ { - __weak id s; - __unsafe_unretained QQ *q; -} -@end - -@interface I3 -@property (weak) I3 * pw1, * pw2; -@property (strong) I3 * ps; -@property (assign) I3 * pds; -@end - -@interface I4Impl { - I4Impl *__strong pds2; - I4Impl *pds3; - __weak I4Impl *pw3; - __weak I4Impl *pw4; -} -@property (weak) I4Impl * pw1, * pw2; -@property (strong) I4Impl * ps; -@property (strong) I4Impl * pds; -@property (strong) I4Impl * pds2; -@property (readwrite) I4Impl * pds3; -@property (readonly) I4Impl * pds4; -@property (weak, readonly) I4Impl *pw3; -@property (weak) I4Impl *pw4; -@end - -@implementation I4Impl -@synthesize pw1, pw2, pw3, pw4, ps, pds, pds2, pds3, pds4; - --(void)test1:(CFTypeRef *)cft { - id x = CFBridgingRelease(cft); -} -@end - -// rdar://10532449 -@interface rdar10532449 -@property (strong) id assign_prop; -@property (strong, readonly) id strong_readonly_prop; -@property (weak) id weak_prop; -@end - -@implementation rdar10532449 -@synthesize assign_prop, strong_readonly_prop, weak_prop; -@end diff --git a/test/ARCMT/GC.h b/test/ARCMT/GC.h deleted file mode 100644 index 4301baf27246..000000000000 --- a/test/ARCMT/GC.h +++ /dev/null @@ -1,6 +0,0 @@ - -@interface ExtInterface { - __strong ExtInterface *myivar; - __strong void *gcVar; -} -@end diff --git a/test/ARCMT/GC.m b/test/ARCMT/GC.m deleted file mode 100644 index 2c9ea9ca3324..000000000000 --- a/test/ARCMT/GC.m +++ /dev/null @@ -1,94 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-macosx10.7 -fsyntax-only -fobjc-runtime-has-weak -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-macosx10.7 -fsyntax-only -fobjc-gc-only -x objective-c %s > %t -// RUN: diff %t %s.result -// RUN: arcmt-test --args -triple x86_64-apple-macosx10.7 -fsyntax-only -fobjc-gc-only -x objective-c++ %s > %t -// RUN: diff %t %s.result - -#include "Common.h" -#include "GC.h" - -void test1(CFTypeRef *cft) { - id x = NSMakeCollectable(cft); -} - -@interface I1 -@end - -@implementation I1 --(void)dealloc { - // dealloc - test1(0); -} - --(void)finalize { - // finalize - test1(0); -} -@end - -@interface I2 -@property (retain) id prop; -@end - -@implementation I2 -@synthesize prop; - --(void)finalize { - self.prop = 0; - // finalize - test1(0); -} -@end - -__attribute__((objc_arc_weak_reference_unavailable)) -@interface QQ { - __weak id s; - __weak QQ *q; -} -@end - -@interface I3 -@property (assign) I3 *__weak pw1, *__weak pw2; -@property (assign) I3 *__strong ps; -@property (assign) I3 * pds; -@end - -@interface I4Impl { - I4Impl *pds2; - I4Impl *pds3; - __weak I4Impl *pw3; - __weak I4Impl *pw4; -} -@property (assign) I4Impl *__weak pw1, *__weak pw2; -@property (assign) I4Impl *__strong ps; -@property (assign) I4Impl * pds; -@property (assign) I4Impl * pds2; -@property (readwrite) I4Impl * pds3; -@property (readonly) I4Impl * pds4; -@property (readonly) __weak I4Impl *pw3; -@property (assign) __weak I4Impl *pw4; -@end - -@implementation I4Impl -@synthesize pw1, pw2, pw3, pw4, ps, pds, pds2, pds3, pds4; - --(void)test1:(CFTypeRef *)cft { - id x = NSMakeCollectable(cft); -} -@end - -// rdar://10532449 -@interface rdar10532449 -@property (assign) id assign_prop; -@property (assign, readonly) id __strong strong_readonly_prop; -@property (assign) id __weak weak_prop; -@end - -@implementation rdar10532449 -@synthesize assign_prop, strong_readonly_prop, weak_prop; -@end - -void test2(id p, __strong I1 *ap[]) { - for (__strong I1 *specRule in p) { - } -} diff --git a/test/ARCMT/GC.m.result b/test/ARCMT/GC.m.result deleted file mode 100644 index 595ff23a7259..000000000000 --- a/test/ARCMT/GC.m.result +++ /dev/null @@ -1,89 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-macosx10.7 -fsyntax-only -fobjc-runtime-has-weak -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-macosx10.7 -fsyntax-only -fobjc-gc-only -x objective-c %s > %t -// RUN: diff %t %s.result -// RUN: arcmt-test --args -triple x86_64-apple-macosx10.7 -fsyntax-only -fobjc-gc-only -x objective-c++ %s > %t -// RUN: diff %t %s.result - -#include "Common.h" -#include "GC.h" - -void test1(CFTypeRef *cft) { - id x = CFBridgingRelease(cft); -} - -@interface I1 -@end - -@implementation I1 --(void)dealloc { - // dealloc - test1(0); -} - -@end - -@interface I2 -@property (strong) id prop; -@end - -@implementation I2 -@synthesize prop; - --(void)dealloc { - // finalize - test1(0); -} -@end - -__attribute__((objc_arc_weak_reference_unavailable)) -@interface QQ { - __weak id s; - __unsafe_unretained QQ *q; -} -@end - -@interface I3 -@property (weak) I3 * pw1, * pw2; -@property (strong) I3 * ps; -@property (assign) I3 * pds; -@end - -@interface I4Impl { - I4Impl *__strong pds2; - I4Impl *pds3; - __weak I4Impl *pw3; - __weak I4Impl *pw4; -} -@property (weak) I4Impl * pw1, * pw2; -@property (strong) I4Impl * ps; -@property (strong) I4Impl * pds; -@property (strong) I4Impl * pds2; -@property (readwrite) I4Impl * pds3; -@property (readonly) I4Impl * pds4; -@property (weak, readonly) I4Impl *pw3; -@property (weak) I4Impl *pw4; -@end - -@implementation I4Impl -@synthesize pw1, pw2, pw3, pw4, ps, pds, pds2, pds3, pds4; - --(void)test1:(CFTypeRef *)cft { - id x = CFBridgingRelease(cft); -} -@end - -// rdar://10532449 -@interface rdar10532449 -@property (strong) id assign_prop; -@property (strong, readonly) id strong_readonly_prop; -@property (weak) id weak_prop; -@end - -@implementation rdar10532449 -@synthesize assign_prop, strong_readonly_prop, weak_prop; -@end - -void test2(id p, __strong I1 *ap[]) { - for (__strong I1 *specRule in p) { - } -} diff --git a/test/ARCMT/Inputs/Module.framework/Frameworks/SubFramework.framework/Headers/SubFramework.h b/test/ARCMT/Inputs/Module.framework/Frameworks/SubFramework.framework/Headers/SubFramework.h deleted file mode 100644 index f7f9fb66c9e9..000000000000 --- a/test/ARCMT/Inputs/Module.framework/Frameworks/SubFramework.framework/Headers/SubFramework.h +++ /dev/null @@ -1,5 +0,0 @@ -#ifndef MODULE_SUBFRAMEWORK_H -#define MODULE_SUBFRAMEWORK_H -#__private_macro MODULE_SUBFRAMEWORK_H -char *module_subframework; -#endif diff --git a/test/ARCMT/Inputs/Module.framework/Headers/Buried/Treasure.h b/test/ARCMT/Inputs/Module.framework/Headers/Buried/Treasure.h deleted file mode 100644 index 6e81adcb2b60..000000000000 --- a/test/ARCMT/Inputs/Module.framework/Headers/Buried/Treasure.h +++ /dev/null @@ -1 +0,0 @@ -unsigned *Buried_Treasure; diff --git a/test/ARCMT/Inputs/Module.framework/Headers/Module.h b/test/ARCMT/Inputs/Module.framework/Headers/Module.h deleted file mode 100644 index 3d2476b20431..000000000000 --- a/test/ARCMT/Inputs/Module.framework/Headers/Module.h +++ /dev/null @@ -1,28 +0,0 @@ -// expected-warning 0-1 {{umbrella header}} - -// FIXME: The "umbrella header" warning should be moved to a separate test. -// This "0-1" is only here because the warning is only emitted when the -// module is (otherwise) successfully included. - -#ifndef MODULE_H -#define MODULE_H -const char *getModuleVersion(void); - -#ifdef FOO -# error Module should have been built without -DFOO -#endif - -@interface Module -+(const char *)version; // retrieve module version -+alloc; -@end - -#define MODULE_H_MACRO 1 -#__private_macro MODULE_H_MACRO - -#include <Module/Sub.h> -#include <Module/Buried/Treasure.h> - -__asm("foo"); - -#endif // MODULE_H diff --git a/test/ARCMT/Inputs/Module.framework/Headers/NotInModule.h b/test/ARCMT/Inputs/Module.framework/Headers/NotInModule.h deleted file mode 100644 index 6b15791eb2c7..000000000000 --- a/test/ARCMT/Inputs/Module.framework/Headers/NotInModule.h +++ /dev/null @@ -1 +0,0 @@ -int not_in_module; diff --git a/test/ARCMT/Inputs/Module.framework/Headers/Sub.h b/test/ARCMT/Inputs/Module.framework/Headers/Sub.h deleted file mode 100644 index dea76e764617..000000000000 --- a/test/ARCMT/Inputs/Module.framework/Headers/Sub.h +++ /dev/null @@ -1,3 +0,0 @@ -#include <Module/Sub2.h> -int *Module_Sub; - diff --git a/test/ARCMT/Inputs/Module.framework/Headers/Sub2.h b/test/ARCMT/Inputs/Module.framework/Headers/Sub2.h deleted file mode 100644 index beed4a862dca..000000000000 --- a/test/ARCMT/Inputs/Module.framework/Headers/Sub2.h +++ /dev/null @@ -1 +0,0 @@ -int *Module_Sub2; diff --git a/test/ARCMT/Inputs/Module.framework/Module b/test/ARCMT/Inputs/Module.framework/Module deleted file mode 100644 index e69de29bb2d1..000000000000 --- a/test/ARCMT/Inputs/Module.framework/Module +++ /dev/null diff --git a/test/ARCMT/Inputs/Module.framework/PrivateHeaders/ModulePrivate.h b/test/ARCMT/Inputs/Module.framework/PrivateHeaders/ModulePrivate.h deleted file mode 100644 index 0782336df9de..000000000000 --- a/test/ARCMT/Inputs/Module.framework/PrivateHeaders/ModulePrivate.h +++ /dev/null @@ -1 +0,0 @@ -int module_private; diff --git a/test/ARCMT/Inputs/module.map b/test/ARCMT/Inputs/module.map deleted file mode 100644 index 061abbd24d57..000000000000 --- a/test/ARCMT/Inputs/module.map +++ /dev/null @@ -1,309 +0,0 @@ -module c_library [extern_c] { module inner { header "c-header.h" } } -module cxx_library { header "cxx-header.h" requires cplusplus } -module c_library_bad [extern_c] { header "c-header-bad.h" } -module diamond_top { header "diamond_top.h" } -module diamond_left { - header "diamond_left.h" - export diamond_top -} -module diamond_right { - header "diamond_right.h" - export diamond_top -} -module diamond_bottom { - header "diamond_bottom.h" - export * -} -module irgen { header "irgen.h" } -module cxx_irgen_top { header "cxx-irgen-top.h" } -module cxx_irgen_left { header "cxx-irgen-left.h" } -module cxx_irgen_right { header "cxx-irgen-right.h" } -module lookup_left_objc { header "lookup_left.h" } -module lookup_right_objc { header "lookup_right.h" } -module lookup_left_cxx { header "lookup_left.hpp" } -module lookup_right_cxx { header "lookup_right.hpp" } -module module_private_left { header "module_private_left.h" } -module module_private_right { header "module_private_right.h" } -module macros_top { - header "macros_top.h" - explicit module b { header "macros_top_b.h" } - explicit module c { header "macros_top_c.h" } -} -module macros_left { - header "macros_left.h" - export * -} -module macros_right { - header "macros_right.h" - export * - explicit module undef { - header "macros_right_undef.h" - } -} -module macros { header "macros.h" } -module macros_other { header "macros_other.h" } -module category_top { header "category_top.h" } -module category_left { - header "category_left.h" - export category_top - - explicit module sub { - header "category_left_sub.h" - } -} -module category_right { - header "category_right.h" - export category_top - - explicit module sub { - header "category_right_sub.h" - } -} -module category_bottom { - header "category_bottom.h" - export category_left - export category_right -} -module category_other { header "category_other.h" } -module redeclarations_left { header "redeclarations_left.h" } -module redeclarations_right { header "redeclarations_right.h" } -module redecl_namespaces_left { header "redecl_namespaces_left.h" } -module redecl_namespaces_right { header "redecl_namespaces_right.h" } -module redecl_add_after_load_top { header "redecl-add-after-load-top.h" } -module redecl_add_after_load { header "redecl-add-after-load.h" } -module load_failure { header "load_failure.h" } - -module decldef { - explicit module Decl { header "decl.h" } - explicit module Decl2 { header "decl2.h" } - explicit module Def { header "def.h" } -} - -module redecl_merge_top { - header "redecl-merge-top.h" - explicit module Explicit { header "redecl-merge-top-explicit.h" } - exclude header "nonexistent.h" -} -module redecl_merge_left { - header "redecl-merge-left.h" - export * -} -module redecl_merge_left_left { - header "redecl-merge-left-left.h" - export * -} -module redecl_merge_right { - header "redecl-merge-right.h" - export * -} -module redecl_merge_bottom { - explicit module prefix { - header "redecl-merge-bottom-prefix.h" - } - - header "redecl-merge-bottom.h" - export * -} -module namespaces_top { - header "namespaces-top.h" - export * -} -module namespaces_left { - header "namespaces-left.h" - export * -} -module namespaces_right { - header "namespaces-right.h" - export * -} -module templates_top { - header "templates-top.h" - export * -} -module templates_left { - header "templates-left.h" - export * -} -module templates_right { - header "templates-right.h" - export * -} -module MethodPoolA { - header "MethodPoolA.h" - - explicit module Sub2 { - header "MethodPoolASub2.h" - } - - explicit module Sub { - header "MethodPoolASub.h" - } -} -module MethodPoolB { - header "MethodPoolB.h" - - explicit module Sub2 { - header "MethodPoolBSub2.h" - } - - explicit module Sub { - header "MethodPoolBSub.h" - } -} -module import_decl { - header "import-decl.h" -} - -framework module * { - exclude NotAModule -} - -module linkage_merge_left { - explicit module sub { - header "linkage-merge-sub.h" - } -} - -module autolink { - header "autolink.h" - link "autolink" - - explicit module sub { - header "autolink-sub.h" - link "autolink_sub" - } - - explicit module sub2 { - header "autolink-sub2.h" - link framework "autolink_framework" - } - - explicit module sub3 { - header "autolink-sub3.h" - link "autolink_from_pch" - } -} - -module weird_objc { - header "weird_objc.h" -} - -module ignored_macros { - header "ignored_macros.h" -} - -module cxx_many_overloads { - header "cxx-many-overloads.h" -} - -module cxx_inline_namespace { - header "cxx-inline-namespace.h" -} - -module cxx_inline_namespace_b { - header "cxx-inline-namespace-b.h" -} - -module cxx_linkage_cache { - header "cxx-linkage-cache.h" -} - -module cxx_templates_common { - header "cxx-templates-common.h" -} - -module cxx_templates_a { - header "cxx-templates-a.h" -} - -module cxx_templates_b_impl { - header "cxx-templates-b-impl.h" -} - -module cxx_templates_b { - header "cxx-templates-b.h" -} - -module cxx_templates_c { - header "cxx-templates-c.h" -} - -module cxx_decls { - module unimported { - header "cxx-decls-unimported.h" - } - module imported { - header "cxx-decls-imported.h" - } -} - -module config { - header "config.h" - config_macros [exhaustive] WANT_FOO, WANT_BAR -} - -module diag_pragma { - header "diag_pragma.h" -} - -module dummy { - header "dummy.h" -} - -module builtin { - header "builtin.h" - explicit module sub { - header "builtin_sub.h" - } -} - -module linkage_merge { - explicit module foo { - header "linkage-merge-foo.h" - } - explicit module bar { - header "linkage-merge-bar.h" - } - -} - -module incomplete_mod { - header "incomplete_mod.h" -} - -module warning { - header "warning.h" -} - -module initializer_list { - header "initializer_list" -} - -module using_decl { - module a { header "using-decl-a.h" export * } - module b { header "using-decl-b.h" export * } -} - -module recursive_visibility_a1 { - module inner { header "recursive_visibility_a1_inner.h" } -} -module recursive_visibility_a2 { - module inner { - module more_inner { - header "recursive_visibility_a2_more_inner.h" - } - } -} -module recursive_visibility_b { - header "recursive_visibility_b.h" - export * -} -module recursive_visibility_c { - header "recursive_visibility_c.h" -} -module recursive1 { - header "recursive1.h" -} -module recursive2 { - header "recursive2.h" -} diff --git a/test/ARCMT/Inputs/test.h b/test/ARCMT/Inputs/test.h deleted file mode 100644 index 756295f27e69..000000000000 --- a/test/ARCMT/Inputs/test.h +++ /dev/null @@ -1,15 +0,0 @@ -@protocol NSObject -- (oneway void)release; -@end - -#ifdef PART1 -static inline void part1(id p) { - [p release]; -} -#endif - -#ifdef PART2 -static inline void part2(id p) { - [p release]; -} -#endif diff --git a/test/ARCMT/Inputs/test.h.result b/test/ARCMT/Inputs/test.h.result deleted file mode 100644 index 0638a3378c1c..000000000000 --- a/test/ARCMT/Inputs/test.h.result +++ /dev/null @@ -1,13 +0,0 @@ -@protocol NSObject -- (oneway void)release; -@end - -#ifdef PART1 -static inline void part1(id p) { -} -#endif - -#ifdef PART2 -static inline void part2(id p) { -} -#endif diff --git a/test/ARCMT/Inputs/test1.m.in b/test/ARCMT/Inputs/test1.m.in deleted file mode 100644 index 44a3c4cf3d93..000000000000 --- a/test/ARCMT/Inputs/test1.m.in +++ /dev/null @@ -1,16 +0,0 @@ -#define PART1 -#include "test.h" - -void test1(id p) { - [p release]; -} - -@interface Test2 -@property (strong) id prop; -@end - -@implementation Test2 --(id)init { - _prop = 0; -} -@end diff --git a/test/ARCMT/Inputs/test1.m.in.result b/test/ARCMT/Inputs/test1.m.in.result deleted file mode 100644 index 1db9bf7ad65c..000000000000 --- a/test/ARCMT/Inputs/test1.m.in.result +++ /dev/null @@ -1,15 +0,0 @@ -#define PART1 -#include "test.h" - -void test1(id p) { -} - -@interface Test2 -@property (strong) id prop; -@end - -@implementation Test2 --(id)init { - _prop = 0; -} -@end diff --git a/test/ARCMT/Inputs/test2.m.in b/test/ARCMT/Inputs/test2.m.in deleted file mode 100644 index 99f87b072171..000000000000 --- a/test/ARCMT/Inputs/test2.m.in +++ /dev/null @@ -1,6 +0,0 @@ -#define PART2 -#include "test.h" - -void test2(id p) { - [p release]; -} diff --git a/test/ARCMT/Inputs/test2.m.in.result b/test/ARCMT/Inputs/test2.m.in.result deleted file mode 100644 index f8e918ce2598..000000000000 --- a/test/ARCMT/Inputs/test2.m.in.result +++ /dev/null @@ -1,5 +0,0 @@ -#define PART2 -#include "test.h" - -void test2(id p) { -} diff --git a/test/ARCMT/Inputs/with space/test.h b/test/ARCMT/Inputs/with space/test.h deleted file mode 100644 index 756295f27e69..000000000000 --- a/test/ARCMT/Inputs/with space/test.h +++ /dev/null @@ -1,15 +0,0 @@ -@protocol NSObject -- (oneway void)release; -@end - -#ifdef PART1 -static inline void part1(id p) { - [p release]; -} -#endif - -#ifdef PART2 -static inline void part2(id p) { - [p release]; -} -#endif diff --git a/test/ARCMT/Inputs/with space/test.h.result b/test/ARCMT/Inputs/with space/test.h.result deleted file mode 100644 index 0638a3378c1c..000000000000 --- a/test/ARCMT/Inputs/with space/test.h.result +++ /dev/null @@ -1,13 +0,0 @@ -@protocol NSObject -- (oneway void)release; -@end - -#ifdef PART1 -static inline void part1(id p) { -} -#endif - -#ifdef PART2 -static inline void part2(id p) { -} -#endif diff --git a/test/ARCMT/Inputs/with space/test1.m.in b/test/ARCMT/Inputs/with space/test1.m.in deleted file mode 100644 index 8416a8896569..000000000000 --- a/test/ARCMT/Inputs/with space/test1.m.in +++ /dev/null @@ -1,6 +0,0 @@ -#define PART1 -#include "test.h" - -void test1(id p) { - [p release]; -} diff --git a/test/ARCMT/Inputs/with space/test1.m.in.result b/test/ARCMT/Inputs/with space/test1.m.in.result deleted file mode 100644 index f351fe6c8355..000000000000 --- a/test/ARCMT/Inputs/with space/test1.m.in.result +++ /dev/null @@ -1,5 +0,0 @@ -#define PART1 -#include "test.h" - -void test1(id p) { -} diff --git a/test/ARCMT/Inputs/with space/test2.m.in b/test/ARCMT/Inputs/with space/test2.m.in deleted file mode 100644 index 99f87b072171..000000000000 --- a/test/ARCMT/Inputs/with space/test2.m.in +++ /dev/null @@ -1,6 +0,0 @@ -#define PART2 -#include "test.h" - -void test2(id p) { - [p release]; -} diff --git a/test/ARCMT/Inputs/with space/test2.m.in.result b/test/ARCMT/Inputs/with space/test2.m.in.result deleted file mode 100644 index f8e918ce2598..000000000000 --- a/test/ARCMT/Inputs/with space/test2.m.in.result +++ /dev/null @@ -1,5 +0,0 @@ -#define PART2 -#include "test.h" - -void test2(id p) { -} diff --git a/test/ARCMT/api.m b/test/ARCMT/api.m deleted file mode 100644 index b186ec724745..000000000000 --- a/test/ARCMT/api.m +++ /dev/null @@ -1,9 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t -// RUN: diff %t %s.result - -#include "Common.h" - -void test(NSObject *o) { - NSZone *z = [o zone]; -} diff --git a/test/ARCMT/api.m.result b/test/ARCMT/api.m.result deleted file mode 100644 index e3093751b626..000000000000 --- a/test/ARCMT/api.m.result +++ /dev/null @@ -1,9 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t -// RUN: diff %t %s.result - -#include "Common.h" - -void test(NSObject *o) { - NSZone *z = nil; -} diff --git a/test/ARCMT/assign-prop-no-arc-runtime.m b/test/ARCMT/assign-prop-no-arc-runtime.m deleted file mode 100644 index de1c456b3d19..000000000000 --- a/test/ARCMT/assign-prop-no-arc-runtime.m +++ /dev/null @@ -1,15 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-macosx10.6 -fsyntax-only %s > %t -// RUN: diff %t %s.result - -#include "Common.h" - -@interface Foo : NSObject { - NSObject *x; -} -@property (readonly,assign) id x; -@end - -@implementation Foo -@synthesize x; -@end diff --git a/test/ARCMT/assign-prop-no-arc-runtime.m.result b/test/ARCMT/assign-prop-no-arc-runtime.m.result deleted file mode 100644 index 23848d357268..000000000000 --- a/test/ARCMT/assign-prop-no-arc-runtime.m.result +++ /dev/null @@ -1,15 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-macosx10.6 -fsyntax-only %s > %t -// RUN: diff %t %s.result - -#include "Common.h" - -@interface Foo : NSObject { - NSObject *__unsafe_unretained x; -} -@property (readonly,unsafe_unretained) id x; -@end - -@implementation Foo -@synthesize x; -@end diff --git a/test/ARCMT/assign-prop-with-arc-runtime.m b/test/ARCMT/assign-prop-with-arc-runtime.m deleted file mode 100644 index a00538cd6197..000000000000 --- a/test/ARCMT/assign-prop-with-arc-runtime.m +++ /dev/null @@ -1,72 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -fobjc-runtime-has-weak -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-macosx10.7 -fsyntax-only %s > %t -// RUN: diff %t %s.result - -#include "Common.h" - -__attribute__((objc_arc_weak_reference_unavailable)) -@interface WeakOptOut -@end - -@class _NSCachedAttributedString; -typedef _NSCachedAttributedString *BadClassForWeak; - -@class Forw; - -@interface Foo : NSObject { - Foo *x, *w, *q1, *q2; - WeakOptOut *oo; - BadClassForWeak bcw; - id not_safe1; - NSObject *not_safe2; - Forw *not_safe3; - Foo *assign_plus1; -} -@property (readonly) Foo *x; -@property (assign) Foo *w; -@property Foo *q1, *q2; -@property (assign) WeakOptOut *oo; -@property (assign) BadClassForWeak bcw; -@property (assign) id not_safe1; -@property () NSObject *not_safe2; -@property Forw *not_safe3; -@property (readonly) Foo *assign_plus1; -@property (readonly) Foo *assign_plus2; -@property (readonly) Foo *assign_plus3; - -@property (assign) Foo *no_user_ivar1; -@property (readonly) Foo *no_user_ivar2; - -@property (retain) id def1; -@property (atomic,retain) id def2; -@property (retain,atomic) id def3; - -@end - -@implementation Foo -@synthesize x,w,q1,q2,oo,bcw,not_safe1,not_safe2,not_safe3; -@synthesize no_user_ivar1, no_user_ivar2; -@synthesize assign_plus1, assign_plus2, assign_plus3; -@synthesize def1, def2, def3; - --(void)test:(Foo *)parm { - assign_plus1 = [[Foo alloc] init]; - assign_plus2 = [Foo new]; - assign_plus3 = [parm retain]; -} -@end - -@interface TestExt -@property (retain,readonly) TestExt *x1; -@property (readonly) TestExt *x2; -@end - -@interface TestExt() -@property (retain,readwrite) TestExt *x1; -@property (readwrite) TestExt *x2; -@property (retain) TestExt *x3; -@end - -@implementation TestExt -@synthesize x1, x2, x3; -@end diff --git a/test/ARCMT/assign-prop-with-arc-runtime.m.result b/test/ARCMT/assign-prop-with-arc-runtime.m.result deleted file mode 100644 index 8bb684f79a33..000000000000 --- a/test/ARCMT/assign-prop-with-arc-runtime.m.result +++ /dev/null @@ -1,72 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -fobjc-runtime-has-weak -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-macosx10.7 -fsyntax-only %s > %t -// RUN: diff %t %s.result - -#include "Common.h" - -__attribute__((objc_arc_weak_reference_unavailable)) -@interface WeakOptOut -@end - -@class _NSCachedAttributedString; -typedef _NSCachedAttributedString *BadClassForWeak; - -@class Forw; - -@interface Foo : NSObject { - Foo *__weak x, *__weak w, *__weak q1, *__weak q2; - WeakOptOut *__unsafe_unretained oo; - BadClassForWeak __unsafe_unretained bcw; - id __unsafe_unretained not_safe1; - NSObject *__unsafe_unretained not_safe2; - Forw *__unsafe_unretained not_safe3; - Foo *assign_plus1; -} -@property (weak, readonly) Foo *x; -@property (weak) Foo *w; -@property (weak) Foo *q1, *q2; -@property (unsafe_unretained) WeakOptOut *oo; -@property (unsafe_unretained) BadClassForWeak bcw; -@property (unsafe_unretained) id not_safe1; -@property (unsafe_unretained) NSObject *not_safe2; -@property (unsafe_unretained) Forw *not_safe3; -@property (readonly) Foo *assign_plus1; -@property (readonly) Foo *assign_plus2; -@property (readonly) Foo *assign_plus3; - -@property (weak) Foo *no_user_ivar1; -@property (weak, readonly) Foo *no_user_ivar2; - -@property (strong) id def1; -@property (atomic,strong) id def2; -@property (strong,atomic) id def3; - -@end - -@implementation Foo -@synthesize x,w,q1,q2,oo,bcw,not_safe1,not_safe2,not_safe3; -@synthesize no_user_ivar1, no_user_ivar2; -@synthesize assign_plus1, assign_plus2, assign_plus3; -@synthesize def1, def2, def3; - --(void)test:(Foo *)parm { - assign_plus1 = [[Foo alloc] init]; - assign_plus2 = [Foo new]; - assign_plus3 = parm; -} -@end - -@interface TestExt -@property (strong,readonly) TestExt *x1; -@property (weak, readonly) TestExt *x2; -@end - -@interface TestExt() -@property (strong,readwrite) TestExt *x1; -@property (weak, readwrite) TestExt *x2; -@property (strong) TestExt *x3; -@end - -@implementation TestExt -@synthesize x1, x2, x3; -@end diff --git a/test/ARCMT/atautorelease-2.m b/test/ARCMT/atautorelease-2.m deleted file mode 100644 index b9bc10655325..000000000000 --- a/test/ARCMT/atautorelease-2.m +++ /dev/null @@ -1,29 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t -// RUN: diff %t %s.result - -@interface NSAutoreleasePool -- drain; -+new; -+alloc; --init; --autorelease; --release; -@end - -void NSLog(id, ...); - -int main (int argc, const char * argv[]) { - NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; - NSAutoreleasePool *chunkPool = [[NSAutoreleasePool alloc] init]; - - while (argc) { - [chunkPool release]; - return 0; - } - - [chunkPool drain]; - [pool drain]; - - return 0; -} diff --git a/test/ARCMT/atautorelease-2.m.result b/test/ARCMT/atautorelease-2.m.result deleted file mode 100644 index 205473380b73..000000000000 --- a/test/ARCMT/atautorelease-2.m.result +++ /dev/null @@ -1,28 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t -// RUN: diff %t %s.result - -@interface NSAutoreleasePool -- drain; -+new; -+alloc; --init; --autorelease; --release; -@end - -void NSLog(id, ...); - -int main (int argc, const char * argv[]) { - @autoreleasepool { - @autoreleasepool { - - while (argc) { - return 0; - } - - } - } - - return 0; -} diff --git a/test/ARCMT/atautorelease-3.m b/test/ARCMT/atautorelease-3.m deleted file mode 100644 index 87b80af9350e..000000000000 --- a/test/ARCMT/atautorelease-3.m +++ /dev/null @@ -1,40 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t -// RUN: diff %t %s.result - -@interface NSAutoreleasePool -- drain; -+new; -+alloc; --init; --autorelease; -- release; -@end - -void NSLog(id, ...); - -void test1(int x) { - // All this stuff get removed since nothing is happening inside. - NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; - NSAutoreleasePool *chunkPool = [[NSAutoreleasePool alloc] init]; - while (x) { - chunkPool = [[NSAutoreleasePool alloc] init]; - [chunkPool release]; - } - - [chunkPool drain]; - [pool drain]; -} - -void test2(int x) { - NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; - NSAutoreleasePool *chunkPool = [[NSAutoreleasePool alloc] init]; - while (x) { - chunkPool = [[NSAutoreleasePool alloc] init]; - ++x; - [chunkPool release]; - } - - [chunkPool drain]; - [pool drain]; -} diff --git a/test/ARCMT/atautorelease-3.m.result b/test/ARCMT/atautorelease-3.m.result deleted file mode 100644 index 801376a7e82b..000000000000 --- a/test/ARCMT/atautorelease-3.m.result +++ /dev/null @@ -1,31 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t -// RUN: diff %t %s.result - -@interface NSAutoreleasePool -- drain; -+new; -+alloc; --init; --autorelease; -- release; -@end - -void NSLog(id, ...); - -void test1(int x) { - // All this stuff get removed since nothing is happening inside. -} - -void test2(int x) { - @autoreleasepool { - @autoreleasepool { - while (x) { - @autoreleasepool { - ++x; - } - } - - } - } -} diff --git a/test/ARCMT/atautorelease-check.m b/test/ARCMT/atautorelease-check.m deleted file mode 100644 index d74ef3b61d1f..000000000000 --- a/test/ARCMT/atautorelease-check.m +++ /dev/null @@ -1,144 +0,0 @@ -// RUN: %clang_cc1 -arcmt-check -verify -triple x86_64-apple-darwin10 %s - -#if __has_feature(objc_arr) -#define NS_AUTOMATED_REFCOUNT_UNAVAILABLE __attribute__((unavailable("not available in automatic reference counting mode"))) -#else -#define NS_AUTOMATED_REFCOUNT_UNAVAILABLE -#endif - -typedef struct _NSZone NSZone; -typedef int BOOL; -typedef unsigned NSUInteger; - -@protocol NSObject -- (BOOL)isEqual:(id)object; -- (id)retain NS_AUTOMATED_REFCOUNT_UNAVAILABLE; -- (NSUInteger)retainCount NS_AUTOMATED_REFCOUNT_UNAVAILABLE; -- (oneway void)release NS_AUTOMATED_REFCOUNT_UNAVAILABLE; -- (id)autorelease NS_AUTOMATED_REFCOUNT_UNAVAILABLE; - -- (NSZone *)zone NS_AUTOMATED_REFCOUNT_UNAVAILABLE; -@end - -@protocol NSCopying -- (id)copyWithZone:(NSZone *)zone; -@end - -@protocol NSMutableCopying -- (id)mutableCopyWithZone:(NSZone *)zone; -@end - -@interface NSObject <NSObject> {} -- (id)init; - -+ (id)new; -+ (id)allocWithZone:(NSZone *)zone NS_AUTOMATED_REFCOUNT_UNAVAILABLE; -+ (id)alloc; -- (void)dealloc; - -- (void)finalize; - -- (id)copy; -- (id)mutableCopy; - -+ (id)copyWithZone:(NSZone *)zone NS_AUTOMATED_REFCOUNT_UNAVAILABLE; -+ (id)mutableCopyWithZone:(NSZone *)zone NS_AUTOMATED_REFCOUNT_UNAVAILABLE; -@end - -extern void NSRecycleZone(NSZone *zone); - -NS_AUTOMATED_REFCOUNT_UNAVAILABLE -@interface NSAutoreleasePool : NSObject { // expected-note 13 {{marked unavailable here}} -@private - void *_token; - void *_reserved3; - void *_reserved2; - void *_reserved; -} - -+ (void)addObject:(id)anObject; - -- (void)addObject:(id)anObject; - -- (void)drain; - -@end - - -void NSLog(id, ...); - -int main (int argc, const char * argv[]) { - NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; - NSAutoreleasePool *chunkPool = [[NSAutoreleasePool alloc] init]; // expected-error 2 {{'NSAutoreleasePool' is unavailable}} - - while (argc) { - [chunkPool release]; - // the following pool was not released in this scope, don't touch it. - chunkPool = [[NSAutoreleasePool alloc] init]; // expected-error {{'NSAutoreleasePool' is unavailable}} - } - - [chunkPool drain]; - [pool drain]; - - return 0; -} - -void f(void) { - NSAutoreleasePool * pool; // expected-error {{'NSAutoreleasePool' is unavailable}} - - for (int i=0; i != 10; ++i) { - id x = pool; // We won't touch a NSAutoreleasePool if we can't safely - // remove all the references to it. - } - - pool = [[NSAutoreleasePool alloc] init]; // expected-error {{'NSAutoreleasePool' is unavailable}} - NSLog(@"%s", "YES"); - [pool release]; -} - -void f2(void) { - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; // expected-error 2 {{'NSAutoreleasePool' is unavailable}} \ - // expected-note {{scope begins here}} - - // 'x' is declared inside the "pool scope" but used outside it, if we create - // a @autorelease scope it will be undefined outside it so don't touch the pool. - int x = 0; // expected-note {{declared here}} - - [pool release]; // expected-note {{scope ends here}} - - ++x; // expected-error {{a name is referenced outside the NSAutoreleasePool scope that it was declared in}} -} - -void f3(void) { - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; // expected-error 2 {{'NSAutoreleasePool' is unavailable}} \ - // expected-note {{scope begins here}} - - struct S { int x; }; // expected-note {{declared here}} - - [pool release]; // expected-note {{scope ends here}} - - struct S *var; // expected-error {{a name is referenced outside the NSAutoreleasePool scope that it was declared in}} - var->x = 0; -} - -void f4(void) { - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; // expected-error 2 {{'NSAutoreleasePool' is unavailable}} \ - // expected-note {{scope begins here}} - - enum { Bar }; // expected-note {{declared here}} - - [pool release]; // expected-note {{scope ends here}} - - int x = Bar; // expected-error {{a name is referenced outside the NSAutoreleasePool scope that it was declared in}} -} - -void f5(void) { - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; // expected-error 2 {{'NSAutoreleasePool' is unavailable}} \ - // expected-note {{scope begins here}} - - typedef int Bar; // expected-note {{declared here}} - - [pool release]; // expected-note {{scope ends here}} - - Bar x; // expected-error {{a name is referenced outside the NSAutoreleasePool scope that it was declared in}} -} diff --git a/test/ARCMT/atautorelease.m b/test/ARCMT/atautorelease.m deleted file mode 100644 index a6aed146497b..000000000000 --- a/test/ARCMT/atautorelease.m +++ /dev/null @@ -1,61 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t -// RUN: diff %t %s.result - -#include "Common.h" - -void NSLog(id, ...); - -int main (int argc, const char * argv[]) { - - NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; - - if (argc) { - NSAutoreleasePool * pool = [NSAutoreleasePool new]; - NSLog(@"%s", "YES"); - [pool drain]; - } - [pool drain]; - - NSAutoreleasePool * pool1 = [[NSAutoreleasePool alloc] init]; - NSLog(@"%s", "YES"); - [pool1 release]; - - return 0; -} - -void f(void) { - NSAutoreleasePool *pool1; - - pool1 = [NSAutoreleasePool new]; - int x = 4; - - NSAutoreleasePool *pool2 = [[NSAutoreleasePool alloc] init]; - ++x; - [pool2 drain]; - - [pool1 release]; -} - -int UIApplicationMain(int argc, char *argv[]); - -int main2(int argc, char *argv[]) { - NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; - int result = UIApplicationMain(argc, argv); - [pool release]; - return result; -} - -@interface Foo : NSObject -@property (assign) id myProp; -@end - -@implementation Foo -@synthesize myProp; - --(void)test:(id)p { - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - [pool drain]; - self.myProp = p; -} -@end diff --git a/test/ARCMT/atautorelease.m.result b/test/ARCMT/atautorelease.m.result deleted file mode 100644 index e24339a3b9e3..000000000000 --- a/test/ARCMT/atautorelease.m.result +++ /dev/null @@ -1,60 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t -// RUN: diff %t %s.result - -#include "Common.h" - -void NSLog(id, ...); - -int main (int argc, const char * argv[]) { - - @autoreleasepool { - - if (argc) { - @autoreleasepool { - NSLog(@"%s", "YES"); - } - } - } - - @autoreleasepool { - NSLog(@"%s", "YES"); - } - - return 0; -} - -void f(void) { - - @autoreleasepool { - int x = 4; - - @autoreleasepool { - ++x; - } - - } -} - -int UIApplicationMain(int argc, char *argv[]); - -int main2(int argc, char *argv[]) { - @autoreleasepool { - int result = UIApplicationMain(argc, argv); - return result; - } -} - -@interface Foo : NSObject -@property (unsafe_unretained) id myProp; -@end - -@implementation Foo -@synthesize myProp; - --(void)test:(id)p { - @autoreleasepool { - } - self.myProp = p; -} -@end diff --git a/test/ARCMT/autoreleases.m b/test/ARCMT/autoreleases.m deleted file mode 100644 index 91413e51ca66..000000000000 --- a/test/ARCMT/autoreleases.m +++ /dev/null @@ -1,75 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t -// RUN: diff %t %s.result - -#include "Common.h" - -@interface A : NSObject { -@package - id object; -} -@end - -@interface B : NSObject { - id _prop; - xpc_object_t _xpc_prop; -} -- (BOOL)containsSelf:(A*)a; -@property (retain) id prop; -@property (retain) xpc_object_t xpc_prop; -@end - -@implementation A -@end - -@implementation B -- (BOOL)containsSelf:(A*)a { - return a->object == self; -} - --(id) prop { - return _prop; -} --(void) setProp:(id) newVal { - [_prop autorelease]; - _prop = [newVal retain]; -} --(void) setProp2:(CFTypeRef) newVal { - [_prop autorelease]; - _prop = (id)CFRetain(newVal); -} - --(id) xpc_prop { - return _xpc_prop; -} --(void) setXpc_prop:(xpc_object_t) newVal { - [_xpc_prop autorelease]; - _xpc_prop = xpc_retain(newVal); -} -@end - -void NSLog(id, ...); - -int main (int argc, const char * argv[]) { - NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; - A *a = [[A new] autorelease]; - B *b = [[B new] autorelease]; - NSLog(@"%s", [b containsSelf:a] ? "YES" : "NO"); - [pool drain]; - return 0; -} - -void test(A *prevVal, A *newVal) { - [prevVal autorelease]; - prevVal = [newVal retain]; -} - -id test2(A* val) { - [[val retain] autorelease]; - return val; -} - -id test3() { - id a = [[A alloc] init]; - [a autorelease]; -} diff --git a/test/ARCMT/autoreleases.m.result b/test/ARCMT/autoreleases.m.result deleted file mode 100644 index 32c7ad3c3971..000000000000 --- a/test/ARCMT/autoreleases.m.result +++ /dev/null @@ -1,69 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t -// RUN: diff %t %s.result - -#include "Common.h" - -@interface A : NSObject { -@package - id object; -} -@end - -@interface B : NSObject { - id _prop; - xpc_object_t _xpc_prop; -} -- (BOOL)containsSelf:(A*)a; -@property (strong) id prop; -@property (strong) xpc_object_t xpc_prop; -@end - -@implementation A -@end - -@implementation B -- (BOOL)containsSelf:(A*)a { - return a->object == self; -} - --(id) prop { - return _prop; -} --(void) setProp:(id) newVal { - _prop = newVal; -} --(void) setProp2:(CFTypeRef) newVal { - _prop = (id)CFBridgingRelease(CFRetain(newVal)); -} - --(id) xpc_prop { - return _xpc_prop; -} --(void) setXpc_prop:(xpc_object_t) newVal { - _xpc_prop = newVal; -} -@end - -void NSLog(id, ...); - -int main (int argc, const char * argv[]) { - @autoreleasepool { - A *a = [A new]; - B *b = [B new]; - NSLog(@"%s", [b containsSelf:a] ? "YES" : "NO"); - } - return 0; -} - -void test(A *prevVal, A *newVal) { - prevVal = newVal; -} - -id test2(A* val) { - return val; -} - -id test3() { - id a = [[A alloc] init]; -} diff --git a/test/ARCMT/block_copy_release.m b/test/ARCMT/block_copy_release.m deleted file mode 100644 index ae3b82660a8e..000000000000 --- a/test/ARCMT/block_copy_release.m +++ /dev/null @@ -1,17 +0,0 @@ -// RUN: %clang_cc1 -fblocks -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fblocks -fsyntax-only -x objective-c %s > %t -// RUN: diff %t %s.result - -#include "Common.h" - -typedef void (^blk)(int); - -void func(blk b) { - blk c = Block_copy(b); - Block_release(c); -} - -void func2(id b) { - id c = Block_copy(b); - Block_release(c); -} diff --git a/test/ARCMT/block_copy_release.m.result b/test/ARCMT/block_copy_release.m.result deleted file mode 100644 index b292b64f17d6..000000000000 --- a/test/ARCMT/block_copy_release.m.result +++ /dev/null @@ -1,15 +0,0 @@ -// RUN: %clang_cc1 -fblocks -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fblocks -fsyntax-only -x objective-c %s > %t -// RUN: diff %t %s.result - -#include "Common.h" - -typedef void (^blk)(int); - -void func(blk b) { - blk c = [b copy]; -} - -void func2(id b) { - id c = [b copy]; -} diff --git a/test/ARCMT/check-api.m b/test/ARCMT/check-api.m deleted file mode 100644 index 11f431377da6..000000000000 --- a/test/ARCMT/check-api.m +++ /dev/null @@ -1,43 +0,0 @@ -// RUN: %clang_cc1 -arcmt-check -verify -triple x86_64-apple-macosx10.7 %s - -#include "Common.h" - -@interface NSInvocation : NSObject -- (void)getReturnValue:(void *)retLoc; -- (void)setReturnValue:(void *)retLoc; - -- (void)getArgument:(void *)argumentLocation atIndex:(int)idx; -- (void)setArgument:(void *)argumentLocation atIndex:(int)idx; -@end - -@interface Test -@end - -@implementation Test { - id strong_id; - __weak id weak_id; - __unsafe_unretained id unsafe_id; - int arg; -} -- (void) test:(NSInvocation *)invok { - [invok getReturnValue:&strong_id]; // expected-error {{NSInvocation's getReturnValue is not safe to be used with an object with ownership other than __unsafe_unretained}} - [invok getReturnValue:&weak_id]; // expected-error {{NSInvocation's getReturnValue is not safe to be used with an object with ownership other than __unsafe_unretained}} - [invok getReturnValue:&unsafe_id]; - [invok getReturnValue:&arg]; - - [invok setReturnValue:&strong_id]; // expected-error {{NSInvocation's setReturnValue is not safe to be used with an object with ownership other than __unsafe_unretained}} - [invok setReturnValue:&weak_id]; // expected-error {{NSInvocation's setReturnValue is not safe to be used with an object with ownership other than __unsafe_unretained}} - [invok setReturnValue:&unsafe_id]; - [invok setReturnValue:&arg]; - - [invok getArgument:&strong_id atIndex:0]; // expected-error {{NSInvocation's getArgument is not safe to be used with an object with ownership other than __unsafe_unretained}} - [invok getArgument:&weak_id atIndex:0]; // expected-error {{NSInvocation's getArgument is not safe to be used with an object with ownership other than __unsafe_unretained}} - [invok getArgument:&unsafe_id atIndex:0]; - [invok getArgument:&arg atIndex:0]; - - [invok setArgument:&strong_id atIndex:0]; // expected-error {{NSInvocation's setArgument is not safe to be used with an object with ownership other than __unsafe_unretained}} - [invok setArgument:&weak_id atIndex:0]; // expected-error {{NSInvocation's setArgument is not safe to be used with an object with ownership other than __unsafe_unretained}} - [invok setArgument:&unsafe_id atIndex:0]; - [invok setArgument:&arg atIndex:0]; -} -@end diff --git a/test/ARCMT/check-with-pch.m b/test/ARCMT/check-with-pch.m deleted file mode 100644 index 5e843ff08df7..000000000000 --- a/test/ARCMT/check-with-pch.m +++ /dev/null @@ -1,16 +0,0 @@ -// RUN: %clang_cc1 -x objective-c -triple x86_64-apple-darwin10 %S/Common.h -emit-pch -o %t.pch -// RUN: %clang_cc1 -include-pch %t.pch -arcmt-check -verify -triple x86_64-apple-darwin10 -fblocks -Werror %s -// REQUIRES: x86-registered-target - -// rdar://9601437 -@interface I9601437 { - __unsafe_unretained id x; -} --(void)Meth; -@end - -@implementation I9601437 --(void)Meth { - self->x = [NSObject new]; // expected-error {{assigning retained object}} -} -@end diff --git a/test/ARCMT/check-with-serialized-diag.m b/test/ARCMT/check-with-serialized-diag.m deleted file mode 100644 index 77bad96dcc3a..000000000000 --- a/test/ARCMT/check-with-serialized-diag.m +++ /dev/null @@ -1,55 +0,0 @@ - -@protocol NSObject -- (id)retain; -- (unsigned)retainCount; -- (oneway void)release; -- (id)autorelease; -@end - -@interface NSObject <NSObject> {} -- (id)init; - -+ (id)new; -+ (id)alloc; -- (void)dealloc; - -- (void)finalize; - -- (id)copy; -- (id)mutableCopy; -@end - -@interface A : NSObject -@end - -struct UnsafeS { - A *__unsafe_unretained unsafeObj; -}; - -id global_foo; - -void test1(A *a, struct UnsafeS *unsafeS) { - [unsafeS->unsafeObj retain]; - id foo = [unsafeS->unsafeObj retain]; // no warning. - [global_foo retain]; - [a retainCount]; -} - -// RUN: not %clang_cc1 -arcmt-check -triple x86_64-apple-darwin10 %s -serialize-diagnostic-file %t.diag -// RUN: c-index-test -read-diagnostics %t.diag > %t 2>&1 -// RUN: FileCheck --input-file=%t %s - -// CHECK: {{.*}}check-with-serialized-diag.m:32:4: error: [rewriter] it is not safe to remove 'retain' message on an __unsafe_unretained type -// CHECK-NEXT: Number FIXITs = 0 -// CHECK-NEXT: {{.*}}check-with-serialized-diag.m:34:4: error: [rewriter] it is not safe to remove 'retain' message on a global variable -// CHECK-NEXT: Number FIXITs = 0 -// CHECK-NEXT: {{.*}}check-with-serialized-diag.m:32:23: error: ARC forbids explicit message send of 'retain' -// CHECK-NEXT: Range: {{.*}}check-with-serialized-diag.m:32:4 {{.*}}check-with-serialized-diag.m:32:22 -// CHECK-NEXT: Number FIXITs = 0 -// CHECK-NEXT: {{.*}}check-with-serialized-diag.m:34:15: error: ARC forbids explicit message send of 'retain' -// CHECK-NEXT: Range: {{.*}}check-with-serialized-diag.m:34:4 {{.*}}check-with-serialized-diag.m:34:14 -// CHECK-NEXT: Number FIXITs = 0 -// CHECK-NEXT: {{.*}}check-with-serialized-diag.m:35:6: error: ARC forbids explicit message send of 'retainCount' -// CHECK-NEXT: Range: {{.*}}check-with-serialized-diag.m:35:4 {{.*}}check-with-serialized-diag.m:35:5 -// CHECK-NEXT: Number FIXITs = 0 - diff --git a/test/ARCMT/checking-in-arc.m b/test/ARCMT/checking-in-arc.m deleted file mode 100644 index d41a162289b2..000000000000 --- a/test/ARCMT/checking-in-arc.m +++ /dev/null @@ -1,50 +0,0 @@ -// RUN: %clang_cc1 -arcmt-check -fobjc-arc -fobjc-runtime=macosx-10.8.0 -triple x86_64-apple-darwin12 -fblocks -Werror %s - -#if __has_feature(objc_arc) -#define NS_AUTOMATED_REFCOUNT_UNAVAILABLE __attribute__((unavailable("not available in automatic reference counting mode"))) -#else -#define NS_AUTOMATED_REFCOUNT_UNAVAILABLE -#endif - -typedef const void * CFTypeRef; -CFTypeRef CFBridgingRetain(id X); -id CFBridgingRelease(CFTypeRef); - -typedef int BOOL; -typedef unsigned NSUInteger; - -@protocol NSObject -- (id)retain NS_AUTOMATED_REFCOUNT_UNAVAILABLE; -- (NSUInteger)retainCount NS_AUTOMATED_REFCOUNT_UNAVAILABLE; -- (oneway void)release NS_AUTOMATED_REFCOUNT_UNAVAILABLE; -- (id)autorelease NS_AUTOMATED_REFCOUNT_UNAVAILABLE; -@end - -@interface NSObject <NSObject> {} -- (id)init; - -+ (id)new; -+ (id)alloc; -- (void)dealloc; - -- (void)finalize; - -- (id)copy; -- (id)mutableCopy; -@end - -typedef const struct __CFString * CFStringRef; -extern const CFStringRef kUTTypePlainText; -extern const CFStringRef kUTTypeRTF; -@class NSString; - -@interface Test : NSObject -@property (weak) NSString *weakProperty; -@end - -@implementation Test -@end - -#if ! __has_feature(objc_arc) -#error This file must be compiled with ARC (set -fobjc_arc flag on file) -#endif diff --git a/test/ARCMT/checking.m b/test/ARCMT/checking.m deleted file mode 100644 index 182260c18e59..000000000000 --- a/test/ARCMT/checking.m +++ /dev/null @@ -1,355 +0,0 @@ -// RUN: %clang_cc1 -arcmt-check -verify -triple x86_64-apple-darwin10 -fblocks -Werror %s - -#if __has_feature(objc_arc) -#define NS_AUTOMATED_REFCOUNT_UNAVAILABLE __attribute__((unavailable("not available in automatic reference counting mode"))) -#else -#define NS_AUTOMATED_REFCOUNT_UNAVAILABLE -#endif - -typedef const void * CFTypeRef; -CFTypeRef CFBridgingRetain(id X); -id CFBridgingRelease(CFTypeRef); - -typedef int BOOL; -typedef unsigned NSUInteger; - -@protocol NSObject -- (id)retain NS_AUTOMATED_REFCOUNT_UNAVAILABLE; -- (NSUInteger)retainCount NS_AUTOMATED_REFCOUNT_UNAVAILABLE; -- (oneway void)release NS_AUTOMATED_REFCOUNT_UNAVAILABLE; -- (id)autorelease NS_AUTOMATED_REFCOUNT_UNAVAILABLE; -@end - -@interface NSObject <NSObject> {} -- (id)init; - -+ (id)new; -+ (id)alloc; -- (void)dealloc; - -- (void)finalize; - -- (id)copy; -- (id)mutableCopy; -@end - -typedef const struct __CFString * CFStringRef; -extern const CFStringRef kUTTypePlainText; -extern const CFStringRef kUTTypeRTF; -@class NSString; -@class A; - -struct UnsafeS { - A *__unsafe_unretained unsafeObj; -}; - -@interface A : NSObject -- (id)retain __attribute__((unavailable)); // expected-note {{'retain' has been explicitly marked unavailable here}} -- (id)retainCount __attribute__((unavailable)); // expected-note {{'retainCount' has been explicitly marked unavailable here}} -- (id)autorelease __attribute__((unavailable)); // expected-note 2 {{'autorelease' has been explicitly marked unavailable here}} -- (id)init; -- (oneway void)release; -- (void)dealloc; --(void)test; --(id)delegate; -@end - -@implementation A --(void)test { - [super dealloc]; -} --(void)dealloc { - [super dealloc]; -} - -- (id)retain { return self; } // expected-error {{ARC forbids implementation}} -- (id)retainCount { return self; } // expected-error {{ARC forbids implementation}} -- (id)autorelease { return self; } // expected-error {{ARC forbids implementation}} -- (oneway void)release { } // expected-error {{ARC forbids implementation}} - --(id)delegate { return self; } -@end - -id global_foo; - -void test1(A *a, BOOL b, struct UnsafeS *unsafeS) { - [[a delegate] release]; // expected-error {{it is not safe to remove 'retain' message on the result of a 'delegate' message; the object that was passed to 'setDelegate:' may not be properly retained}} \ - // expected-error {{ARC forbids explicit message send}} - [a.delegate release]; // expected-error {{it is not safe to remove 'retain' message on the result of a 'delegate' message; the object that was passed to 'setDelegate:' may not be properly retained}} \ - // expected-error {{ARC forbids explicit message send}} - [unsafeS->unsafeObj retain]; // expected-error {{it is not safe to remove 'retain' message on an __unsafe_unretained type}} \ - // expected-error {{ARC forbids explicit message send}} \ - // expected-error {{'retain' is unavailable}} - id foo = [unsafeS->unsafeObj retain]; // no warning. - [global_foo retain]; // expected-error {{it is not safe to remove 'retain' message on a global variable}} \ - // expected-error {{ARC forbids explicit message send}} - [global_foo release]; // expected-error {{it is not safe to remove 'release' message on a global variable}} \ - // expected-error {{ARC forbids explicit message send}} - [a dealloc]; - [a retain]; - [a retainCount]; // expected-error {{ARC forbids explicit message send of 'retainCount'}} \ - // expected-error {{'retainCount' is unavailable}} - [a release]; - [a autorelease]; // expected-error {{it is not safe to remove an unused 'autorelease' message; its receiver may be destroyed immediately}} \ - // expected-error {{ARC forbids explicit message send}} \ - // expected-error {{'autorelease' is unavailable}} - [a autorelease]; // expected-error {{it is not safe to remove an unused 'autorelease' message; its receiver may be destroyed immediately}} \ - // expected-error {{ARC forbids explicit message send}} \ - // expected-error {{'autorelease' is unavailable}} - a = 0; - - CFStringRef cfstr; - NSString *str = (NSString *)cfstr; // expected-error {{cast of C pointer type 'CFStringRef' (aka 'const struct __CFString *') to Objective-C pointer type 'NSString *' requires a bridged cast}} \ - // expected-note {{use __bridge to convert directly (no change in ownership)}} \ - // expected-note {{use CFBridgingRelease call to transfer ownership of a +1 'CFStringRef' (aka 'const struct __CFString *') into ARC}} \ - str = (NSString *)kUTTypePlainText; - str = b ? kUTTypeRTF : kUTTypePlainText; - str = (NSString *)(b ? kUTTypeRTF : kUTTypePlainText); - str = (NSString *)a; // no change. - - SEL s = @selector(retain); // expected-error {{ARC forbids use of 'retain' in a @selector}} - s = @selector(release); // expected-error {{ARC forbids use of 'release' in a @selector}} - s = @selector(autorelease); // expected-error {{ARC forbids use of 'autorelease' in a @selector}} - s = @selector(dealloc); // expected-error {{ARC forbids use of 'dealloc' in a @selector}} - - static id __autoreleasing X1; // expected-error {{global variables cannot have __autoreleasing ownership}} -} - -struct S { - A* a; -}; - -@interface B --(id)alloc; -- (id)initWithInt: (int) i; -@end - -void rdar8861761() { - B *o1 = [[B alloc] initWithInt:0]; - B *o2 = [B alloc]; - [o2 initWithInt:0]; -} - -@interface Test13 -- (id) init0; -- (void) noninit; -@end -@implementation Test13 -- (id) init0 { - self = 0; -} -- (void) noninit { - self = 0; // expected-error {{cannot assign to 'self' outside of a method in the init family}} - - for (__strong id x in collection) { // expected-error {{use of undeclared identifier 'collection'}} - x = 0; - } -} -@end - -void * cvt(id arg) -{ - void* voidp_val; - (void)(int*)arg; // expected-error {{disallowed}} - (void)(id)arg; - (void)(__autoreleasing id*)arg; // expected-error {{disallowed}} - (void)(id*)arg; // expected-error {{disallowed}} - - (void)(__autoreleasing id**)voidp_val; - (void)(void*)voidp_val; - (void)(void**)arg; // expected-error {{disallowed}} - cvt((void*)arg); // expected-error 2 {{requires a bridged cast}} \ - // expected-note 2 {{use __bridge to}} expected-note {{use CFBridgingRelease call}} expected-note {{use CFBridgingRetain call}} - cvt(0); - (void)(__strong id**)(0); - return arg; // expected-error {{requires a bridged cast}} expected-note {{use __bridge}} expected-note {{use CFBridgingRetain call}} -} - - -void test12(id collection) { - for (id x in collection) { - x = 0; - } - - for (__strong id x in collection) { - x = 0; - } -} - -void test6(unsigned cond) { - switch (cond) { - case 0: - ; - id x; // expected-note {{jump bypasses initialization of __strong variable}} - - case 1: // expected-error {{cannot jump}} - x = 0; - break; - } -} - -@class Test8_incomplete; -@interface Test8_complete @end; -@interface Test8_super @end; -@interface Test8 : Test8_super -- (id) init00; -- (id) init01; // expected-note {{declaration in interface}} -- (id) init02; -- (id) init03; // covariance -- (id) init04; // covariance -- (id) init05; - -- (void) init10; // expected-note {{declaration in interface is not in the 'init' family because its result type is not an object pointer}} -- (void) init11; -- (void) init12; -- (void) init13; // expected-note {{declaration in interface is not in the 'init' family because its result type is not an object pointer}} -- (void) init14; // expected-note {{declaration in interface is not in the 'init' family because its result type is not an object pointer}} -- (void) init15; - -// These should be invalid to actually call. -- (Test8_incomplete*) init20; -- (Test8_incomplete*) init21; // expected-note {{declaration in interface}} -- (Test8_incomplete*) init22; -- (Test8_incomplete*) init23; -- (Test8_incomplete*) init24; -- (Test8_incomplete*) init25; - -- (Test8_super*) init30; // id exception to covariance -- (Test8_super*) init31; // expected-note {{declaration in interface}} -- (Test8_super*) init32; -- (Test8_super*) init33; -- (Test8_super*) init34; // covariance -- (Test8_super*) init35; - -- (Test8*) init40; // id exception to covariance -- (Test8*) init41; // expected-note {{declaration in interface}} -- (Test8*) init42; -- (Test8*) init43; // this should be a warning, but that's a general language thing, not an ARC thing -- (Test8*) init44; -- (Test8*) init45; - -- (Test8_complete*) init50; // expected-error {{init methods must return a type related to the receiver type}} -- (Test8_complete*) init51; // expected-error {{init methods must return a type related to the receiver type}} -- (Test8_complete*) init52; // expected-error {{init methods must return a type related to the receiver type}} -- (Test8_complete*) init53; // expected-error {{init methods must return a type related to the receiver type}} -- (Test8_complete*) init54; // expected-error {{init methods must return a type related to the receiver type}} -- (Test8_complete*) init55; // expected-error {{init methods must return a type related to the receiver type}} -@end -@implementation Test8 -- (id) init00 { return 0; } -- (id) init10 { return 0; } // expected-error {{method implementation does not match its declaration}} -- (id) init20 { return 0; } -- (id) init30 { return 0; } -- (id) init40 { return 0; } -- (id) init50 { return 0; } - -- (void) init01 {} // expected-error {{method was declared as an 'init' method, but its implementation doesn't match because its result type is not an object pointer}} -- (void) init11 {} -- (void) init21 {} // expected-error {{method was declared as an 'init' method, but its implementation doesn't match because its result type is not an object pointer}} -- (void) init31 {} // expected-error {{method was declared as an 'init' method, but its implementation doesn't match because its result type is not an object pointer}} -- (void) init41 {} // expected-error {{method was declared as an 'init' method, but its implementation doesn't match because its result type is not an object pointer}} -- (void) init51 {} - -- (Test8_incomplete*) init02 { return 0; } // expected-error {{init methods must return a type related to the receiver type}} -- (Test8_incomplete*) init12 { return 0; } // expected-error {{init methods must return a type related to the receiver type}} -- (Test8_incomplete*) init22 { return 0; } // expected-error {{init methods must return a type related to the receiver type}} -- (Test8_incomplete*) init32 { return 0; } // expected-error {{init methods must return a type related to the receiver type}} -- (Test8_incomplete*) init42 { return 0; } // expected-error {{init methods must return a type related to the receiver type}} -- (Test8_incomplete*) init52 { return 0; } // expected-error {{init methods must return a type related to the receiver type}} - -- (Test8_super*) init03 { return 0; } -- (Test8_super*) init13 { return 0; } // expected-error {{method implementation does not match its declaration}} -- (Test8_super*) init23 { return 0; } -- (Test8_super*) init33 { return 0; } -- (Test8_super*) init43 { return 0; } -- (Test8_super*) init53 { return 0; } - -- (Test8*) init04 { return 0; } -- (Test8*) init14 { return 0; } // expected-error {{method implementation does not match its declaration}} -- (Test8*) init24 { return 0; } -- (Test8*) init34 { return 0; } -- (Test8*) init44 { return 0; } -- (Test8*) init54 { return 0; } - -- (Test8_complete*) init05 { return 0; } // expected-error {{init methods must return a type related to the receiver type}} -- (Test8_complete*) init15 { return 0; } // expected-error {{init methods must return a type related to the receiver type}} -- (Test8_complete*) init25 { return 0; } // expected-error {{init methods must return a type related to the receiver type}} -- (Test8_complete*) init35 { return 0; } // expected-error {{init methods must return a type related to the receiver type}} -- (Test8_complete*) init45 { return 0; } // expected-error {{init methods must return a type related to the receiver type}} -- (Test8_complete*) init55 { return 0; } // expected-error {{init methods must return a type related to the receiver type}} -@end - -@class Test9_incomplete; -@interface Test9 -- (Test9_incomplete*) init1; // expected-error {{init methods must return a type related to the receiver type}} -- (Test9_incomplete*) init2; -@end -id test9(Test9 *v) { - return [v init1]; -} - -// rdar://9491791 -void rdar9491791(int p) { - switch (p) { - case 3:; - NSObject *o = [[NSObject alloc] init]; - [o release]; - break; - default: - break; - } -} - -#define RELEASE_MACRO(x) do { [x release]; } while(1) - -// rdar://9504750 -void rdar9504750(id p) { - RELEASE_MACRO(p); // expected-error {{ARC forbids explicit message send of 'release'}} -} - -// rdar://8939557 -@interface TestReadonlyProperty : NSObject -@property(assign,readonly) NSObject *value; -@end - -@implementation TestReadonlyProperty -@synthesize value; -- (void)viewDidLoad { - value = [NSObject new]; // expected-error {{assigning retained object}} -} -@end - -// rdar://9601437 -@interface I9601437 { - __unsafe_unretained id x; -} --(void)Meth; -@end - -@implementation I9601437 --(void)Meth { - self->x = [NSObject new]; // expected-error {{assigning retained object}} -} -@end - -@interface Test10 : NSObject { - CFStringRef cfstr; -} -@property (retain) id prop; --(void)foo; -@end - -void test(Test10 *x) { - x.prop = ^{ [x foo]; }; // expected-warning {{likely to lead to a retain cycle}} \ - // expected-note {{retained by the captured object}} -} - -@implementation Test10 --(void)foo { - ^{ - NSString *str = (NSString *)cfstr; // expected-error {{cast of C pointer type 'CFStringRef' (aka 'const struct __CFString *') to Objective-C pointer type 'NSString *' requires a bridged cast}} \ - // expected-note {{use __bridge to convert directly (no change in ownership)}} \ - // expected-note {{use CFBridgingRelease call to transfer ownership of a +1 'CFStringRef' (aka 'const struct __CFString *') into ARC}} - }; -} -@end diff --git a/test/ARCMT/cxx-checking.mm b/test/ARCMT/cxx-checking.mm deleted file mode 100644 index aa3bc466f672..000000000000 --- a/test/ARCMT/cxx-checking.mm +++ /dev/null @@ -1,100 +0,0 @@ -// RUN: %clang_cc1 -arcmt-check -verify -triple x86_64-apple-darwin10 -fsyntax-only -fblocks %s - -// Classes that have an Objective-C object pointer. -struct HasObjectMember0 { - id x; -}; - -struct HasObjectMember1 { - id x[3]; -}; - -struct HasObjectMember2 { - id x[3][2]; -}; - -// Don't complain if the type has non-external linkage -namespace { - struct HasObjectMember3 { - id x[3][2]; - }; -} - -// Don't complain if the Objective-C pointer type was explicitly given -// no lifetime. -struct HasObjectMember3 { - __unsafe_unretained id x[3][2]; -}; - -struct HasBlockPointerMember0 { - int (^bp)(int); -}; - -struct HasBlockPointerMember1 { - int (^bp[2][3])(int); -}; - -struct NonPOD { - NonPOD(const NonPOD&); -}; - -struct HasObjectMemberAndNonPOD0 { - id x; - NonPOD np; -}; - -struct HasObjectMemberAndNonPOD1 { - NonPOD np; - id x[3]; -}; - -struct HasObjectMemberAndNonPOD2 { - NonPOD np; - id x[3][2]; -}; - -struct HasObjectMemberAndNonPOD3 { - HasObjectMemberAndNonPOD3 &operator=(const HasObjectMemberAndNonPOD3&); - ~HasObjectMemberAndNonPOD3(); - NonPOD np; - id x[3][2]; -}; - -struct HasBlockPointerMemberAndNonPOD0 { - NonPOD np; - int (^bp)(int); -}; - -struct HasBlockPointerMemberAndNonPOD1 { - NonPOD np; - int (^bp[2][3])(int); -}; - -int check_non_pod_objc_pointer0[__is_pod(id)? 1 : -1]; -int check_non_pod_objc_pointer1[__is_pod(__strong id)? -1 : 1]; -int check_non_pod_objc_pointer2[__is_pod(__unsafe_unretained id)? 1 : -1]; -int check_non_pod_objc_pointer3[__is_pod(id[2][3])? 1 : -1]; -int check_non_pod_objc_pointer4[__is_pod(__unsafe_unretained id[2][3])? 1 : -1]; -int check_non_pod_block0[__is_pod(int (^)(int))? 1 : -1]; -int check_non_pod_block1[__is_pod(int (^ __unsafe_unretained)(int))? 1 : -1]; - -struct FlexibleArrayMember0 { - int length; - id array[]; // expected-error{{flexible array member 'array' of type 'id __strong[]' with non-trivial destruction}} -}; - -struct FlexibleArrayMember1 { - int length; - __unsafe_unretained id array[]; -}; - -// It's okay to pass a retainable type through an ellipsis. -void variadic(...); -void test_variadic() { - variadic(1, 17, @"Foo"); -} - -// It's okay to create a VLA of retainable types. -void vla(int n) { - id vla[n]; -} diff --git a/test/ARCMT/cxx-rewrite.mm b/test/ARCMT/cxx-rewrite.mm deleted file mode 100644 index 4a9c50c92426..000000000000 --- a/test/ARCMT/cxx-rewrite.mm +++ /dev/null @@ -1,33 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c++ %s.result -// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c++ %s > %t -// RUN: diff %t %s.result - -#include "Common.h" - -@interface NSString : NSObject -+(id)string; -@end - -struct foo { - NSString *s; - foo(NSString *s): s([s retain]){ - NSAutoreleasePool *pool = [NSAutoreleasePool new]; - [[[NSString string] retain] release]; - [pool drain]; - if (s) - [s release]; - } - ~foo(){ [s release]; } -private: - foo(foo const &); - foo &operator=(foo const &); -}; - -int main(){ - NSAutoreleasePool *pool = [NSAutoreleasePool new]; - - foo f([[NSString string] autorelease]); - - [pool drain]; - return 0; -} diff --git a/test/ARCMT/cxx-rewrite.mm.result b/test/ARCMT/cxx-rewrite.mm.result deleted file mode 100644 index a96d254bf463..000000000000 --- a/test/ARCMT/cxx-rewrite.mm.result +++ /dev/null @@ -1,31 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c++ %s.result -// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c++ %s > %t -// RUN: diff %t %s.result - -#include "Common.h" - -@interface NSString : NSObject -+(id)string; -@end - -struct foo { - NSString *s; - foo(NSString *s): s(s){ - @autoreleasepool { - [NSString string]; - } - } - ~foo(){ } -private: - foo(foo const &); - foo &operator=(foo const &); -}; - -int main(){ - @autoreleasepool { - - foo f([NSString string]); - - } - return 0; -} diff --git a/test/ARCMT/dealloc.m b/test/ARCMT/dealloc.m deleted file mode 100644 index d7a72af4f726..000000000000 --- a/test/ARCMT/dealloc.m +++ /dev/null @@ -1,24 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t -// RUN: diff %t %s.result - -@interface A -- (id)retain; -- (id)autorelease; -- (oneway void)release; -- (void)dealloc; -@end - -void test1(A *a) { - [a dealloc]; -} - -@interface Test2 : A -- (void) dealloc; -@end - -@implementation Test2 -- (void) dealloc { - [super dealloc]; -} -@end diff --git a/test/ARCMT/dealloc.m.result b/test/ARCMT/dealloc.m.result deleted file mode 100644 index fbd9e445d275..000000000000 --- a/test/ARCMT/dealloc.m.result +++ /dev/null @@ -1,20 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t -// RUN: diff %t %s.result - -@interface A -- (id)retain; -- (id)autorelease; -- (oneway void)release; -- (void)dealloc; -@end - -void test1(A *a) { -} - -@interface Test2 : A -- (void) dealloc; -@end - -@implementation Test2 -@end diff --git a/test/ARCMT/designated-init-in-header/designated-init-in-header.m b/test/ARCMT/designated-init-in-header/designated-init-in-header.m deleted file mode 100644 index 8286583b3c89..000000000000 --- a/test/ARCMT/designated-init-in-header/designated-init-in-header.m +++ /dev/null @@ -1,3 +0,0 @@ -// RUN: %clang_cc1 -objcmt-migrate-designated-init -objcmt-migrate-readwrite-property -objcmt-migrate-instancetype -x objective-c %S/file1.m.in -triple x86_64-apple-darwin11 -fobjc-arc -migrate -o %t1.remap -// RUN: %clang_cc1 -objcmt-migrate-designated-init -objcmt-migrate-readwrite-property -objcmt-migrate-instancetype -x objective-c %S/file2.m.in -triple x86_64-apple-darwin11 -fobjc-arc -migrate -o %t2.remap -// RUN: c-arcmt-test %t1.remap %t2.remap | arcmt-test -verify-transformed-files %S/header1.h.result %S/file2.m.in.result diff --git a/test/ARCMT/designated-init-in-header/file1.m.in b/test/ARCMT/designated-init-in-header/file1.m.in deleted file mode 100644 index 0201b32abd32..000000000000 --- a/test/ARCMT/designated-init-in-header/file1.m.in +++ /dev/null @@ -1,2 +0,0 @@ -#include "header1.h" - diff --git a/test/ARCMT/designated-init-in-header/file2.m.in b/test/ARCMT/designated-init-in-header/file2.m.in deleted file mode 100644 index 258159735a77..000000000000 --- a/test/ARCMT/designated-init-in-header/file2.m.in +++ /dev/null @@ -1,14 +0,0 @@ -#include "header1.h" - -@implementation S1 --(int)prop { return 0; } --(void)setProp:(int)p {} -+(id)s1 { return 0; } --(id)initWithFoo:(NSString*)foo -{ - self = [super init]; - if (self) { - } - return self; -} -@end diff --git a/test/ARCMT/designated-init-in-header/file2.m.in.result b/test/ARCMT/designated-init-in-header/file2.m.in.result deleted file mode 100644 index 7465ed576f5f..000000000000 --- a/test/ARCMT/designated-init-in-header/file2.m.in.result +++ /dev/null @@ -1,14 +0,0 @@ -#include "header1.h" - -@implementation S1 --(int)prop { return 0; } --(void)setProp:(int)p {} -+(instancetype)s1 { return 0; } --(instancetype)initWithFoo:(NSString*)foo -{ - self = [super init]; - if (self) { - } - return self; -} -@end diff --git a/test/ARCMT/designated-init-in-header/header1.h b/test/ARCMT/designated-init-in-header/header1.h deleted file mode 100644 index c5668cc46086..000000000000 --- a/test/ARCMT/designated-init-in-header/header1.h +++ /dev/null @@ -1,14 +0,0 @@ -#define NS_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer)) - -@class NSString; - -@interface B1 --(id)init; -@end - -@interface S1 : B1 --(int)prop; --(void)setProp:(int)p; -+(id)s1; --(id)initWithFoo:(NSString*)foo; -@end diff --git a/test/ARCMT/designated-init-in-header/header1.h.result b/test/ARCMT/designated-init-in-header/header1.h.result deleted file mode 100644 index 974175b1c3e6..000000000000 --- a/test/ARCMT/designated-init-in-header/header1.h.result +++ /dev/null @@ -1,13 +0,0 @@ -#define NS_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer)) - -@class NSString; - -@interface B1 --(instancetype)init; -@end - -@interface S1 : B1 -@property (nonatomic) int prop; -+(instancetype)s1; --(instancetype)initWithFoo:(NSString*)foo NS_DESIGNATED_INITIALIZER; -@end diff --git a/test/ARCMT/dispatch.m b/test/ARCMT/dispatch.m deleted file mode 100644 index 58c7769638cb..000000000000 --- a/test/ARCMT/dispatch.m +++ /dev/null @@ -1,18 +0,0 @@ -// RUN: %clang_cc1 -fblocks -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fblocks -fsyntax-only -x objective-c %s > %t -// RUN: diff %t %s.result - -#include "Common.h" - -dispatch_object_t getme(void); - -void func(dispatch_object_t o) { - dispatch_retain(o); - dispatch_release(o); - dispatch_retain(getme()); -} - -void func2(xpc_object_t o) { - xpc_retain(o); - xpc_release(o); -} diff --git a/test/ARCMT/dispatch.m.result b/test/ARCMT/dispatch.m.result deleted file mode 100644 index 55b65585e4f6..000000000000 --- a/test/ARCMT/dispatch.m.result +++ /dev/null @@ -1,14 +0,0 @@ -// RUN: %clang_cc1 -fblocks -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fblocks -fsyntax-only -x objective-c %s > %t -// RUN: diff %t %s.result - -#include "Common.h" - -dispatch_object_t getme(void); - -void func(dispatch_object_t o) { - getme(); -} - -void func2(xpc_object_t o) { -} diff --git a/test/ARCMT/driver-migrate.m b/test/ARCMT/driver-migrate.m deleted file mode 100644 index b1e419ae6fb3..000000000000 --- a/test/ARCMT/driver-migrate.m +++ /dev/null @@ -1,15 +0,0 @@ -// RUN: %clang -### -ccc-arcmt-migrate /foo/bar -fsyntax-only %s 2>&1 | FileCheck %s - -// CHECK: "-arcmt-migrate" "-mt-migrate-directory" "{{[^"]*}}/foo/bar" - -// RUN: touch %t.o -// RUN: %clang -ccc-arcmt-check -target i386-apple-darwin9 -### %t.o 2> %t.log -// RUN: FileCheck -check-prefix=LINK %s < %t.log -// RUN: %clang -ccc-arcmt-migrate /foo/bar -target i386-apple-darwin9 -### %t.o 2> %t.log -// RUN: FileCheck -check-prefix=LINK %s < %t.log - -// LINK-NOT: {{ld(.exe)?"}} -// LINK: {{touch(.exe)?"}} - -// RUN: %clang -### -ccc-arcmt-migrate /foo/bar -fsyntax-only -fno-objc-arc %s 2>&1 | FileCheck -check-prefix=CHECK-NOARC %s -// CHECK-NOARC-NOT: argument unused during compilation diff --git a/test/ARCMT/init.m b/test/ARCMT/init.m deleted file mode 100644 index b1f127e54fd1..000000000000 --- a/test/ARCMT/init.m +++ /dev/null @@ -1,39 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t -// RUN: diff %t %s.result - -#define nil (void *)0 - -@interface NSObject --init; -@end - -@interface A : NSObject --init; --init2; --foo; -+alloc; -@end - -@implementation A --(id) init { - [self init]; - id a; - [a init]; - a = [[A alloc] init]; - - return self; -} - --(id) init2 { - [super init]; - return self; -} - --(id) foo { - [self init]; - [super init]; - - return self; -} -@end diff --git a/test/ARCMT/init.m.result b/test/ARCMT/init.m.result deleted file mode 100644 index d550dedb1dc1..000000000000 --- a/test/ARCMT/init.m.result +++ /dev/null @@ -1,39 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t -// RUN: diff %t %s.result - -#define nil (void *)0 - -@interface NSObject --init; -@end - -@interface A : NSObject --init; --init2; --foo; -+alloc; -@end - -@implementation A --(id) init { - if (!(self = [self init])) return nil; - id a; - [a init]; - a = [[A alloc] init]; - - return self; -} - --(id) init2 { - if (!(self = [super init])) return nil; - return self; -} - --(id) foo { - [self init]; - [super init]; - - return self; -} -@end diff --git a/test/ARCMT/lit.local.cfg b/test/ARCMT/lit.local.cfg deleted file mode 100644 index e9b04164d69d..000000000000 --- a/test/ARCMT/lit.local.cfg +++ /dev/null @@ -1,2 +0,0 @@ -if not config.root.clang_arcmt: - config.unsupported = True diff --git a/test/ARCMT/migrate-emit-errors.m b/test/ARCMT/migrate-emit-errors.m deleted file mode 100644 index 95c0d2f8f073..000000000000 --- a/test/ARCMT/migrate-emit-errors.m +++ /dev/null @@ -1,12 +0,0 @@ -// RUN: %clang_cc1 -arcmt-migrate -mt-migrate-directory %t -arcmt-migrate-emit-errors %s 2>&1 | FileCheck %s -// RUN: rm -rf %t - -@protocol NSObject -- (oneway void)release; -@end - -void test(id p) { - [p release]; -} - -// CHECK: error: ARC forbids explicit message send of 'release'
\ No newline at end of file diff --git a/test/ARCMT/migrate-on-pch-and-module.m b/test/ARCMT/migrate-on-pch-and-module.m deleted file mode 100644 index 42e01ea91a9c..000000000000 --- a/test/ARCMT/migrate-on-pch-and-module.m +++ /dev/null @@ -1,12 +0,0 @@ -// RUN: rm -rf %t-mcp -// RUN: %clang_cc1 -objcmt-migrate-subscripting -emit-pch -o %t.pch %s -isysroot %S/Inputs/System -triple x86_64-apple-darwin10 -F %S/Inputs -fmodules -fimplicit-module-maps -fmodules-cache-path=%t-mcp -w -// RUN: %clang_cc1 -objcmt-migrate-subscripting -include-pch %t.pch %s -migrate -o %t.remap -isysroot %S/Inputs/System -triple x86_64-apple-darwin10 -F %S/Inputs -fmodules -fimplicit-module-maps -fmodules-cache-path=%t-mcp -// REQUIRES: x86-registered-target -#ifndef HEADER -#define HEADER - -@import Module; - -#else - -#endif diff --git a/test/ARCMT/migrate-plist-output.m b/test/ARCMT/migrate-plist-output.m deleted file mode 100644 index 9b47b91d5809..000000000000 --- a/test/ARCMT/migrate-plist-output.m +++ /dev/null @@ -1,51 +0,0 @@ -// RUN: %clang_cc1 -arcmt-migrate -mt-migrate-directory %t.dir -arcmt-migrate-report-output %t.plist %s -// RUN: FileCheck %s -input-file=%t.plist -// RUN: rm -rf %t.dir - -@protocol NSObject -- (oneway void)release; -@end - -void test(id p) { - [p release]; -} - -// CHECK: <?xml version="1.0" encoding="UTF-8"?> -// CHECK: <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> -// CHECK: <plist version="1.0"> -// CHECK: <dict> -// CHECK: <key>files</key> -// CHECK: <array> -// CHECK: </array> -// CHECK: <key>diagnostics</key> -// CHECK: <array> -// CHECK: <dict> -// CHECK: <key>description</key><string>ARC forbids explicit message send of 'release'</string> -// CHECK: <key>category</key><string>ARC Restrictions</string> -// CHECK: <key>type</key><string>error</string> -// CHECK: <key>location</key> -// CHECK: <dict> -// CHECK: <key>line</key><integer>10</integer> -// CHECK: <key>col</key><integer>6</integer> -// CHECK: <key>file</key><integer>0</integer> -// CHECK: </dict> -// CHECK: <key>ranges</key> -// CHECK: <array> -// CHECK: <array> -// CHECK: <dict> -// CHECK: <key>line</key><integer>10</integer> -// CHECK: <key>col</key><integer>4</integer> -// CHECK: <key>file</key><integer>0</integer> -// CHECK: </dict> -// CHECK: <dict> -// CHECK: <key>line</key><integer>10</integer> -// CHECK: <key>col</key><integer>4</integer> -// CHECK: <key>file</key><integer>0</integer> -// CHECK: </dict> -// CHECK: </array> -// CHECK: </array> -// CHECK: </dict> -// CHECK: </array> -// CHECK: </dict> -// CHECK: </plist> - diff --git a/test/ARCMT/migrate-space-in-path.m b/test/ARCMT/migrate-space-in-path.m deleted file mode 100644 index d060485ee20e..000000000000 --- a/test/ARCMT/migrate-space-in-path.m +++ /dev/null @@ -1,5 +0,0 @@ -// RUN: rm -rf %t.migrate -// RUN: %clang_cc1 -arcmt-migrate -mt-migrate-directory %t.migrate %S/Inputs/"with space"/test1.m.in -x objective-c -// RUN: %clang_cc1 -arcmt-migrate -mt-migrate-directory %t.migrate %S/Inputs/"with space"/test2.m.in -x objective-c -// RUN: c-arcmt-test -mt-migrate-directory %t.migrate | arcmt-test -verify-transformed-files %S/Inputs/"with space"/test1.m.in.result %S/Inputs/"with space"/test2.m.in.result %S/Inputs/"with space"/test.h.result -// RUN: rm -rf %t.migrate diff --git a/test/ARCMT/migrate-with-pch.m b/test/ARCMT/migrate-with-pch.m deleted file mode 100644 index 1aafbdaf9b1e..000000000000 --- a/test/ARCMT/migrate-with-pch.m +++ /dev/null @@ -1,6 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -x objective-c %S/Common.h -emit-pch -o %t.pch -// RUN: %clang_cc1 -arcmt-migrate -mt-migrate-directory %t %S/Inputs/test1.m.in -x objective-c -include-pch %t.pch -// RUN: %clang_cc1 -arcmt-migrate -mt-migrate-directory %t %S/Inputs/test2.m.in -x objective-c -include-pch %t.pch -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %S/Inputs/test1.m.in.result %S/Inputs/test2.m.in.result %S/Inputs/test.h.result -// RUN: rm -rf %t diff --git a/test/ARCMT/migrate.m b/test/ARCMT/migrate.m deleted file mode 100644 index d92cef7eb7cc..000000000000 --- a/test/ARCMT/migrate.m +++ /dev/null @@ -1,5 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -arcmt-migrate -mt-migrate-directory %t %S/Inputs/test1.m.in -x objective-c -// RUN: %clang_cc1 -arcmt-migrate -mt-migrate-directory %t %S/Inputs/test2.m.in -x objective-c -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %S/Inputs/test1.m.in.result %S/Inputs/test2.m.in.result %S/Inputs/test.h.result -// RUN: rm -rf %t diff --git a/test/ARCMT/no-canceling-bridge-to-bridge-cast.m b/test/ARCMT/no-canceling-bridge-to-bridge-cast.m deleted file mode 100644 index 2c47822001e5..000000000000 --- a/test/ARCMT/no-canceling-bridge-to-bridge-cast.m +++ /dev/null @@ -1,42 +0,0 @@ -// RUN: %clang_cc1 -arcmt-check -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -verify %s -// rdar://10387088 -typedef const void * CFTypeRef; -CFTypeRef CFBridgingRetain(id X); -id CFBridgingRelease(CFTypeRef); - -extern -CFTypeRef CFRetain(CFTypeRef cf); - -@interface INTF -{ - void *cf_format; - id objc_format; -} -@end - -@interface NSString -+ (id)stringWithFormat:(NSString *)format; -@end - -@implementation INTF -- (void) Meth { - NSString *result; - - result = (id) CFRetain([NSString stringWithFormat:@"PBXLoopMode"]); // expected-error {{cast of C pointer type 'CFTypeRef' (aka 'const void *') to Objective-C pointer type 'id' requires a bridged cast}} \ - // expected-note {{use __bridge to convert directly (no change in ownership)}} \ - // expected-note {{use CFBridgingRelease call to transfer ownership of a +1 'CFTypeRef' (aka 'const void *') into ARC}} - - result = (id) CFRetain((id)((objc_format))); // expected-error {{cast of C pointer type 'CFTypeRef' (aka 'const void *') to Objective-C pointer type 'id' requires a bridged cast}} \ - // expected-note {{use __bridge to convert directly (no change in ownership)}} \ - // expected-note {{use CFBridgingRelease call to transfer ownership of a +1 'CFTypeRef' (aka 'const void *') into ARC}} - - result = (id) CFRetain((id)((cf_format))); // expected-error {{cast of C pointer type 'CFTypeRef' (aka 'const void *') to Objective-C pointer type 'id' requires a bridged cast}} \ - // expected-note {{use __bridge to convert directly (no change in ownership)}} \ - // expected-note {{use CFBridgingRelease call to transfer ownership of a +1 'CFTypeRef' (aka 'const void *') into ARC}} - - result = (id) CFRetain((CFTypeRef)((objc_format))); - - result = (id) CFRetain(cf_format); // OK -} -@end - diff --git a/test/ARCMT/nonobjc-to-objc-cast-2.m b/test/ARCMT/nonobjc-to-objc-cast-2.m deleted file mode 100644 index 2b421b0757ad..000000000000 --- a/test/ARCMT/nonobjc-to-objc-cast-2.m +++ /dev/null @@ -1,64 +0,0 @@ -// RUN: %clang_cc1 -arcmt-check -verify -triple x86_64-apple-darwin10 %s - -#include "Common.h" - -typedef const struct __CFString * CFStringRef; -typedef const void * CFTypeRef; -CFTypeRef CFBridgingRetain(id X); -id CFBridgingRelease(CFTypeRef); - -struct StrS { - CFStringRef sref_member; -}; - -@interface NSString : NSObject { - CFStringRef sref; - struct StrS *strS; -} --(id)string; --(id)newString; -@end - -@implementation NSString --(id)string { - if (0) - return sref; - else - return strS->sref_member; -} --(id)newString { - return sref; // expected-error {{implicit conversion of C pointer type 'CFStringRef' (aka 'const struct __CFString *') to Objective-C pointer type 'id' requires a bridged cast}} \ - // expected-note{{use __bridge to convert directly (no change in ownership)}} \ - // expected-note{{use CFBridgingRelease call to transfer ownership of a +1 'CFStringRef' (aka 'const struct __CFString *') into ARC}} -} -@end - -void f(BOOL b) { - CFStringRef cfstr; - NSString *str = (NSString *)cfstr; // expected-error {{cast of C pointer type 'CFStringRef' (aka 'const struct __CFString *') to Objective-C pointer type 'NSString *' requires a bridged cast}} \ - // expected-note{{use __bridge to convert directly (no change in ownership)}} \ - // expected-note{{use CFBridgingRelease call to transfer ownership of a +1 'CFStringRef' (aka 'const struct __CFString *') into ARC}} - void *vp = str; // expected-error {{requires a bridged cast}} expected-note {{use CFBridgingRetain call}} expected-note {{use __bridge}} -} - -void f2(NSString *s) { - CFStringRef ref; - ref = [(CFStringRef)[s string] retain]; // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFStringRef' (aka 'const struct __CFString *') requires a bridged cast}} \ - // expected-error {{bad receiver type 'CFStringRef' (aka 'const struct __CFString *')}} \ - // expected-note{{use __bridge to convert directly (no change in ownership)}} \ - // expected-note{{use CFBridgingRetain call to make an ARC object available as a +1 'CFStringRef' (aka 'const struct __CFString *')}} -} - -CFStringRef f3() { - return (CFStringRef)[[[NSString alloc] init] autorelease]; // expected-error {{it is not safe to cast to 'CFStringRef' the result of 'autorelease' message; a __bridge cast may result in a pointer to a destroyed object and a __bridge_retained may leak the object}} \ - // expected-note {{remove the cast and change return type of function to 'NSString *' to have the object automatically autoreleased}} -} - -extern void NSLog(NSString *format, ...); - -// rdar://13192395 -void f4(NSString *s) { - NSLog(@"%@", (CFStringRef)s); // expected-error {{cast of Objective-C pointer type 'NSString *' to C pointer type 'CFStringRef' (aka 'const struct __CFString *') requires a bridged cast}} \ - // expected-note{{use __bridge to convert directly (no change in ownership)}} \ - // expected-note{{use CFBridgingRetain call to make an ARC object available as a +1 'CFStringRef' (aka 'const struct __CFString *')}} -} diff --git a/test/ARCMT/nonobjc-to-objc-cast.m b/test/ARCMT/nonobjc-to-objc-cast.m deleted file mode 100644 index 7913661787e5..000000000000 --- a/test/ARCMT/nonobjc-to-objc-cast.m +++ /dev/null @@ -1,83 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t -// RUN: diff %t %s.result - -#include "Common.h" - -typedef const struct __CFString * CFStringRef; -extern const CFStringRef kUTTypePlainText; -extern const CFStringRef kUTTypeRTF; -extern CFStringRef kNonConst; - -typedef const struct __CFAllocator * CFAllocatorRef; -typedef const struct __CFUUID * CFUUIDRef; - -extern const CFAllocatorRef kCFAllocatorDefault; - -extern CFStringRef CFUUIDCreateString(CFAllocatorRef alloc, CFUUIDRef uuid); - -struct StrS { - CFStringRef sref_member; -}; - -@interface NSString : NSObject { - CFStringRef sref; - struct StrS *strS; -} --(id)string; --(id)newString; -@end - -void f(BOOL b, id p) { - NSString *str = (NSString *)kUTTypePlainText; // no change - str = b ? kUTTypeRTF : kUTTypePlainText; // no change - str = (NSString *)(b ? kUTTypeRTF : kUTTypePlainText); // no change - str = (NSString *)p; // no change. - - str = (NSString *)kNonConst; - str = b ? kUTTypeRTF : kNonConst; - str = (NSString *)(b ? kUTTypeRTF : kNonConst); - - CFUUIDRef _uuid; - NSString *_uuidString = (NSString *)CFUUIDCreateString(kCFAllocatorDefault, _uuid); - _uuidString = [(NSString *)CFUUIDCreateString(kCFAllocatorDefault, _uuid) autorelease]; - _uuidString = CFRetain(_uuid); -} - -@implementation NSString (StrExt) -- (NSString *)stringEscapedAsURI { - CFStringRef str = (CFStringRef)self; - CFStringRef str2 = self; - return self; -} -@end - -@implementation NSString --(id)string { - if (0) - return sref; - else - return strS->sref_member; -} --(id)newString { return 0; } -@end - -extern void consumeParam(CFStringRef CF_CONSUMED p); - -void f2(NSString *s) { - CFStringRef ref = [s string]; - ref = (CFStringRef)[s string]; - ref = s.string; - ref = [NSString new]; - ref = [s newString]; - ref = (CFStringRef)[NSString new]; - ref = [[NSString alloc] init]; - ref = [[s string] retain]; - ref = CFRetain((CFStringRef)[s string]); - ref = CFRetain([s string]); - ref = CFRetain(s); - ref = [s retain]; - - consumeParam((CFStringRef)s); - consumeParam(s); -} diff --git a/test/ARCMT/nonobjc-to-objc-cast.m.result b/test/ARCMT/nonobjc-to-objc-cast.m.result deleted file mode 100644 index 8f3092f8786d..000000000000 --- a/test/ARCMT/nonobjc-to-objc-cast.m.result +++ /dev/null @@ -1,83 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t -// RUN: diff %t %s.result - -#include "Common.h" - -typedef const struct __CFString * CFStringRef; -extern const CFStringRef kUTTypePlainText; -extern const CFStringRef kUTTypeRTF; -extern CFStringRef kNonConst; - -typedef const struct __CFAllocator * CFAllocatorRef; -typedef const struct __CFUUID * CFUUIDRef; - -extern const CFAllocatorRef kCFAllocatorDefault; - -extern CFStringRef CFUUIDCreateString(CFAllocatorRef alloc, CFUUIDRef uuid); - -struct StrS { - CFStringRef sref_member; -}; - -@interface NSString : NSObject { - CFStringRef sref; - struct StrS *strS; -} --(id)string; --(id)newString; -@end - -void f(BOOL b, id p) { - NSString *str = (NSString *)kUTTypePlainText; // no change - str = b ? kUTTypeRTF : kUTTypePlainText; // no change - str = (NSString *)(b ? kUTTypeRTF : kUTTypePlainText); // no change - str = (NSString *)p; // no change. - - str = (__bridge NSString *)kNonConst; - str = (__bridge NSString *)(b ? kUTTypeRTF : kNonConst); - str = (__bridge NSString *)(b ? kUTTypeRTF : kNonConst); - - CFUUIDRef _uuid; - NSString *_uuidString = (NSString *)CFBridgingRelease(CFUUIDCreateString(kCFAllocatorDefault, _uuid)); - _uuidString = (NSString *)CFBridgingRelease(CFUUIDCreateString(kCFAllocatorDefault, _uuid)); - _uuidString = CFBridgingRelease(CFRetain(_uuid)); -} - -@implementation NSString (StrExt) -- (NSString *)stringEscapedAsURI { - CFStringRef str = (__bridge CFStringRef)self; - CFStringRef str2 = (__bridge CFStringRef)(self); - return self; -} -@end - -@implementation NSString --(id)string { - if (0) - return (__bridge id)(sref); - else - return (__bridge id)(strS->sref_member); -} --(id)newString { return 0; } -@end - -extern void consumeParam(CFStringRef CF_CONSUMED p); - -void f2(NSString *s) { - CFStringRef ref = (__bridge CFStringRef)([s string]); - ref = (__bridge CFStringRef)[s string]; - ref = (__bridge CFStringRef)(s.string); - ref = CFBridgingRetain([NSString new]); - ref = CFBridgingRetain([s newString]); - ref = (CFStringRef)CFBridgingRetain([NSString new]); - ref = CFBridgingRetain([[NSString alloc] init]); - ref = CFBridgingRetain([s string]); - ref = (CFStringRef)CFBridgingRetain([s string]); - ref = CFBridgingRetain([s string]); - ref = CFBridgingRetain(s); - ref = CFBridgingRetain(s); - - consumeParam((CFStringRef)CFBridgingRetain(s)); - consumeParam(CFBridgingRetain(s)); -} diff --git a/test/ARCMT/objcmt-arc-cf-annotations.m b/test/ARCMT/objcmt-arc-cf-annotations.m deleted file mode 100644 index c9a5b8215d10..000000000000 --- a/test/ARCMT/objcmt-arc-cf-annotations.m +++ /dev/null @@ -1,2063 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -fblocks -objcmt-migrate-annotation -objcmt-migrate-instancetype -objcmt-migrate-readwrite-property -mt-migrate-directory %t %s -x objective-c -triple x86_64-apple-darwin11 -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s.result - -#ifndef CF_IMPLICIT_BRIDGING_ENABLED -#if __has_feature(arc_cf_code_audited) -#define CF_IMPLICIT_BRIDGING_ENABLED _Pragma("clang arc_cf_code_audited begin") -#else -#define CF_IMPLICIT_BRIDGING_ENABLED -#endif -#endif - -#ifndef CF_IMPLICIT_BRIDGING_DISABLED -#if __has_feature(arc_cf_code_audited) -#define CF_IMPLICIT_BRIDGING_DISABLED _Pragma("clang arc_cf_code_audited end") -#else -#define CF_IMPLICIT_BRIDGING_DISABLED -#endif -#endif - -#if __has_feature(attribute_ns_returns_retained) -#define NS_RETURNS_RETAINED __attribute__((ns_returns_retained)) -#endif -#if __has_feature(attribute_cf_returns_retained) -#define CF_RETURNS_RETAINED __attribute__((cf_returns_retained)) -#endif -#if __has_feature(attribute_ns_returns_not_retained) -#define NS_RETURNS_NOT_RETAINED __attribute__((ns_returns_not_retained)) -#endif -#if __has_feature(attribute_cf_returns_not_retained) -#define CF_RETURNS_NOT_RETAINED __attribute__((cf_returns_not_retained)) -#endif -#if __has_feature(attribute_ns_consumes_self) -#define NS_CONSUMES_SELF __attribute__((ns_consumes_self)) -#endif -#if __has_feature(attribute_ns_consumed) -#define NS_CONSUMED __attribute__((ns_consumed)) -#endif -#if __has_feature(attribute_cf_consumed) -#define CF_CONSUMED __attribute__((cf_consumed)) -#endif -#if __has_attribute(ns_returns_autoreleased) -#define NS_RETURNS_AUTORELEASED __attribute__((ns_returns_autoreleased)) -#endif - -//===----------------------------------------------------------------------===// -// The following code is reduced using delta-debugging from Mac OS X headers: -// -// #include <Cocoa/Cocoa.h> -// #include <CoreFoundation/CoreFoundation.h> -// #include <DiskArbitration/DiskArbitration.h> -// #include <QuartzCore/QuartzCore.h> -// #include <Quartz/Quartz.h> -// #include <IOKit/IOKitLib.h> -// -// It includes the basic definitions for the test cases below. -//===----------------------------------------------------------------------===// - -typedef unsigned int __darwin_natural_t; -typedef unsigned long uintptr_t; -typedef unsigned int uint32_t; -typedef unsigned long long uint64_t; -typedef unsigned int UInt32; -typedef signed long CFIndex; -typedef CFIndex CFByteOrder; -typedef struct { - CFIndex location; - CFIndex length; -} CFRange; -static __inline__ __attribute__((always_inline)) CFRange CFRangeMake(CFIndex loc, CFIndex len) { - CFRange range; - range.location = loc; - range.length = len; - return range; -} -typedef const void * CFTypeRef; -typedef const struct __CFString * CFStringRef; -typedef const struct __CFAllocator * CFAllocatorRef; -extern const CFAllocatorRef kCFAllocatorDefault; -extern CFTypeRef CFRetain(CFTypeRef cf); -extern void CFRelease(CFTypeRef cf); -extern CFTypeRef CFMakeCollectable(CFTypeRef cf); -typedef struct { -} -CFArrayCallBacks; -extern const CFArrayCallBacks kCFTypeArrayCallBacks; -typedef const struct __CFArray * CFArrayRef; -typedef struct __CFArray * CFMutableArrayRef; -extern CFMutableArrayRef CFArrayCreateMutable(CFAllocatorRef allocator, CFIndex capacity, const CFArrayCallBacks *callBacks); -extern const void *CFArrayGetValueAtIndex(CFArrayRef theArray, CFIndex idx); -extern void CFArrayAppendValue(CFMutableArrayRef theArray, const void *value); -typedef struct { -} -CFDictionaryKeyCallBacks; -extern const CFDictionaryKeyCallBacks kCFTypeDictionaryKeyCallBacks; -typedef struct { -} -CFDictionaryValueCallBacks; -extern const CFDictionaryValueCallBacks kCFTypeDictionaryValueCallBacks; -typedef const struct __CFDictionary * CFDictionaryRef; -typedef struct __CFDictionary * CFMutableDictionaryRef; -extern CFMutableDictionaryRef CFDictionaryCreateMutable(CFAllocatorRef allocator, CFIndex capacity, const CFDictionaryKeyCallBacks *keyCallBacks, const CFDictionaryValueCallBacks *valueCallBacks); -typedef UInt32 CFStringEncoding; -enum { -kCFStringEncodingMacRoman = 0, kCFStringEncodingWindowsLatin1 = 0x0500, kCFStringEncodingISOLatin1 = 0x0201, kCFStringEncodingNextStepLatin = 0x0B01, kCFStringEncodingASCII = 0x0600, kCFStringEncodingUnicode = 0x0100, kCFStringEncodingUTF8 = 0x08000100, kCFStringEncodingNonLossyASCII = 0x0BFF , kCFStringEncodingUTF16 = 0x0100, kCFStringEncodingUTF16BE = 0x10000100, kCFStringEncodingUTF16LE = 0x14000100, kCFStringEncodingUTF32 = 0x0c000100, kCFStringEncodingUTF32BE = 0x18000100, kCFStringEncodingUTF32LE = 0x1c000100 }; -extern CFStringRef CFStringCreateWithCString(CFAllocatorRef alloc, const char *cStr, CFStringEncoding encoding); -typedef double CFTimeInterval; -typedef CFTimeInterval CFAbsoluteTime; -extern CFAbsoluteTime CFAbsoluteTimeGetCurrent(void); -typedef const struct __CFDate * CFDateRef; -extern CFDateRef CFDateCreate(CFAllocatorRef allocator, CFAbsoluteTime at); -extern CFAbsoluteTime CFDateGetAbsoluteTime(CFDateRef theDate); -typedef __darwin_natural_t natural_t; -typedef natural_t mach_port_name_t; -typedef mach_port_name_t mach_port_t; -typedef int kern_return_t; -typedef kern_return_t mach_error_t; -enum { -kCFNumberSInt8Type = 1, kCFNumberSInt16Type = 2, kCFNumberSInt32Type = 3, kCFNumberSInt64Type = 4, kCFNumberFloat32Type = 5, kCFNumberFloat64Type = 6, kCFNumberCharType = 7, kCFNumberShortType = 8, kCFNumberIntType = 9, kCFNumberLongType = 10, kCFNumberLongLongType = 11, kCFNumberFloatType = 12, kCFNumberDoubleType = 13, kCFNumberCFIndexType = 14, kCFNumberNSIntegerType = 15, kCFNumberCGFloatType = 16, kCFNumberMaxType = 16 }; -typedef CFIndex CFNumberType; -typedef const struct __CFNumber * CFNumberRef; -extern CFNumberRef CFNumberCreate(CFAllocatorRef allocator, CFNumberType theType, const void *valuePtr); -typedef const struct __CFAttributedString *CFAttributedStringRef; -typedef struct __CFAttributedString *CFMutableAttributedStringRef; -extern CFAttributedStringRef CFAttributedStringCreate(CFAllocatorRef alloc, CFStringRef str, CFDictionaryRef attributes) ; -extern CFMutableAttributedStringRef CFAttributedStringCreateMutableCopy(CFAllocatorRef alloc, CFIndex maxLength, CFAttributedStringRef aStr) ; -extern void CFAttributedStringSetAttribute(CFMutableAttributedStringRef aStr, CFRange range, CFStringRef attrName, CFTypeRef value) ; -typedef signed char BOOL; -typedef unsigned long NSUInteger; -@class NSString, Protocol; -extern void NSLog(NSString *format, ...) __attribute__((format(__NSString__, 1, 2))); -typedef struct _NSZone NSZone; -@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator; -@protocol NSObject -- (BOOL)isEqual:(id)object; -- (id)retain; -- (oneway void)release; -- (id)autorelease; -- (NSString *)description; -- (id)init; -@end -@protocol NSCopying -- (id)copyWithZone:(NSZone *)zone; -@end -@protocol NSMutableCopying - (id)mutableCopyWithZone:(NSZone *)zone; -@end -@protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder; -@end -@interface NSObject <NSObject> {} -+ (id)allocWithZone:(NSZone *)zone; -+ (id)alloc; -+ (id)new; -- (void)dealloc; -@end -@interface NSObject (NSCoderMethods) -- (id)awakeAfterUsingCoder:(NSCoder *)aDecoder; -@end -extern id NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone); -typedef struct { -} -NSFastEnumerationState; -@protocol NSFastEnumeration -- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len; -@end -@class NSString, NSDictionary; -@interface NSValue : NSObject <NSCopying, NSCoding> - (void)getValue:(void *)value; -@end -@interface NSNumber : NSValue -- (char)charValue; -- (id)initWithInt:(int)value; -+ (NSNumber *)numberWithInt:(int)value; -@end -@class NSString; -@interface NSArray : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration> -- (NSUInteger)count; -- (id)initWithObjects:(const id [])objects count:(NSUInteger)cnt; -+ (id)arrayWithObject:(id)anObject; -+ (id)arrayWithObjects:(const id [])objects count:(NSUInteger)cnt; -+ (id)arrayWithObjects:(id)firstObj, ... __attribute__((sentinel(0,1))); -- (id)initWithObjects:(id)firstObj, ... __attribute__((sentinel(0,1))); -- (id)initWithArray:(NSArray *)array; -@end @interface NSArray (NSArrayCreation) + (id)array; -@end @interface NSAutoreleasePool : NSObject { -} -- (void)drain; -@end extern NSString * const NSBundleDidLoadNotification; -typedef double NSTimeInterval; -@interface NSDate : NSObject <NSCopying, NSCoding> - (NSTimeInterval)timeIntervalSinceReferenceDate; -@end typedef unsigned short unichar; -@interface NSString : NSObject <NSCopying, NSMutableCopying, NSCoding> -- (NSUInteger)length; -- (NSString *)stringByAppendingString:(NSString *)aString; -- ( const char *)UTF8String; -- (id)initWithUTF8String:(const char *)nullTerminatedCString; -+ (id)stringWithUTF8String:(const char *)nullTerminatedCString; -@end @class NSString, NSURL, NSError; -@interface NSData : NSObject <NSCopying, NSMutableCopying, NSCoding> - (NSUInteger)length; -+ (id)dataWithBytesNoCopy:(void *)bytes length:(NSUInteger)length; -+ (id)dataWithBytesNoCopy:(void *)bytes length:(NSUInteger)length freeWhenDone:(BOOL)b; -@end @class NSLocale, NSDate, NSCalendar, NSTimeZone, NSError, NSArray, NSMutableDictionary; -@interface NSDictionary : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration> -- (NSUInteger)count; -+ (id)dictionaryWithObjects:(NSArray *)objects forKeys:(NSArray *)keys; -+ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id <NSCopying> [])keys count:(NSUInteger)cnt; -@end -@interface NSMutableDictionary : NSDictionary - (void)removeObjectForKey:(id)aKey; -- (void)setObject:(id)anObject forKey:(id)aKey; -@end @interface NSMutableDictionary (NSMutableDictionaryCreation) + (id)dictionaryWithCapacity:(NSUInteger)numItems; -@end typedef double CGFloat; -struct CGSize { -}; -typedef struct CGSize CGSize; -struct CGRect { -}; -typedef struct CGRect CGRect; -typedef mach_port_t io_object_t; -typedef char io_name_t[128]; -typedef io_object_t io_iterator_t; -typedef io_object_t io_service_t; -typedef struct IONotificationPort * IONotificationPortRef; -typedef void (*IOServiceMatchingCallback)( void * refcon, io_iterator_t iterator ); -io_service_t IOServiceGetMatchingService( mach_port_t masterPort, CFDictionaryRef matching ); -kern_return_t IOServiceGetMatchingServices( mach_port_t masterPort, CFDictionaryRef matching, io_iterator_t * existing ); -kern_return_t IOServiceAddNotification( mach_port_t masterPort, const io_name_t notificationType, CFDictionaryRef matching, mach_port_t wakePort, uintptr_t reference, io_iterator_t * notification ) __attribute__((deprecated)); // expected-note {{'IOServiceAddNotification' declared here}} -kern_return_t IOServiceAddMatchingNotification( IONotificationPortRef notifyPort, const io_name_t notificationType, CFDictionaryRef matching, IOServiceMatchingCallback callback, void * refCon, io_iterator_t * notification ); -CFMutableDictionaryRef IOServiceMatching( const char * name ); -CFMutableDictionaryRef IOServiceNameMatching( const char * name ); -CFMutableDictionaryRef IOBSDNameMatching( mach_port_t masterPort, uint32_t options, const char * bsdName ); -CFMutableDictionaryRef IOOpenFirmwarePathMatching( mach_port_t masterPort, uint32_t options, const char * path ); -CFMutableDictionaryRef IORegistryEntryIDMatching( uint64_t entryID ); -typedef struct __DASession * DASessionRef; -extern DASessionRef DASessionCreate( CFAllocatorRef allocator ); -typedef struct __DADisk * DADiskRef; -extern DADiskRef DADiskCreateFromBSDName( CFAllocatorRef allocator, DASessionRef session, const char * name ); -extern DADiskRef DADiskCreateFromIOMedia( CFAllocatorRef allocator, DASessionRef session, io_service_t media ); -extern CFDictionaryRef DADiskCopyDescription( DADiskRef disk ); -extern DADiskRef DADiskCopyWholeDisk( DADiskRef disk ); -@interface NSTask : NSObject - (id)init; -@end typedef struct CGColorSpace *CGColorSpaceRef; -typedef struct CGImage *CGImageRef; -typedef struct CGLayer *CGLayerRef; -@interface NSResponder : NSObject <NSCoding> { -} -@end @protocol NSAnimatablePropertyContainer - (id)animator; -@end extern NSString *NSAnimationTriggerOrderIn ; -@interface NSView : NSResponder <NSAnimatablePropertyContainer> { -} -@end @protocol NSValidatedUserInterfaceItem - (SEL)action; -@end @protocol NSUserInterfaceValidations - (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)anItem; -@end @class NSDate, NSDictionary, NSError, NSException, NSNotification; -@class NSTextField, NSPanel, NSArray, NSWindow, NSImage, NSButton, NSError; -@interface NSApplication : NSResponder <NSUserInterfaceValidations> { -} -- (void)beginSheet:(NSWindow *)sheet modalForWindow:(NSWindow *)docWindow modalDelegate:(id)modalDelegate didEndSelector:(SEL)didEndSelector contextInfo:(void *)contextInfo; -@end enum { -NSTerminateCancel = 0, NSTerminateNow = 1, NSTerminateLater = 2 }; -typedef NSUInteger NSApplicationTerminateReply; -@protocol NSApplicationDelegate <NSObject> @optional - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender; -@end @class NSAttributedString, NSEvent, NSFont, NSFormatter, NSImage, NSMenu, NSText, NSView, NSTextView; -@interface NSCell : NSObject <NSCopying, NSCoding> { -} -@end -typedef struct { -} -CVTimeStamp; -@interface CIImage : NSObject <NSCoding, NSCopying> { -} -typedef int CIFormat; -@end enum { -kDAReturnSuccess = 0, kDAReturnError = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x01, kDAReturnBusy = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x02, kDAReturnBadArgument = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x03, kDAReturnExclusiveAccess = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x04, kDAReturnNoResources = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x05, kDAReturnNotFound = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x06, kDAReturnNotMounted = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x07, kDAReturnNotPermitted = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x08, kDAReturnNotPrivileged = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x09, kDAReturnNotReady = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x0A, kDAReturnNotWritable = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x0B, kDAReturnUnsupported = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x0C }; -typedef mach_error_t DAReturn; -typedef const struct __DADissenter * DADissenterRef; -extern DADissenterRef DADissenterCreate( CFAllocatorRef allocator, DAReturn status, CFStringRef string ); -@interface CIContext: NSObject { -} -- (CGImageRef)createCGImage:(CIImage *)im fromRect:(CGRect)r; -- (CGImageRef)createCGImage:(CIImage *)im fromRect:(CGRect)r format:(CIFormat)f colorSpace:(CGColorSpaceRef)cs; -- (CGLayerRef)createCGLayerWithSize:(CGSize)size info:(CFDictionaryRef)d; -@end extern NSString* const QCRendererEventKey; -@protocol QCCompositionRenderer - (NSDictionary*) attributes; -@end @interface QCRenderer : NSObject <QCCompositionRenderer> { -} -- (id) createSnapshotImageOfType:(NSString*)type; -@end extern NSString* const QCViewDidStartRenderingNotification; -@interface QCView : NSView <QCCompositionRenderer> { -} -- (id) createSnapshotImageOfType:(NSString*)type; -@end enum { -ICEXIFOrientation1 = 1, ICEXIFOrientation2 = 2, ICEXIFOrientation3 = 3, ICEXIFOrientation4 = 4, ICEXIFOrientation5 = 5, ICEXIFOrientation6 = 6, ICEXIFOrientation7 = 7, ICEXIFOrientation8 = 8, }; -@class ICDevice; -@protocol ICDeviceDelegate <NSObject> @required - (void)didRemoveDevice:(ICDevice*)device; -@end extern NSString *const ICScannerStatusWarmingUp; -@class ICScannerDevice; -@protocol ICScannerDeviceDelegate <ICDeviceDelegate> @optional - (void)scannerDeviceDidBecomeAvailable:(ICScannerDevice*)scanner; -@end - -typedef long unsigned int __darwin_size_t; -typedef __darwin_size_t size_t; -typedef unsigned long CFTypeID; -struct CGPoint { - CGFloat x; - CGFloat y; -}; -typedef struct CGPoint CGPoint; -typedef struct CGGradient *CGGradientRef; -typedef uint32_t CGGradientDrawingOptions; -extern CFTypeID CGGradientGetTypeID(void); -extern CGGradientRef CGGradientCreateWithColorComponents(CGColorSpaceRef - space, const CGFloat components[], const CGFloat locations[], size_t count); -extern CGGradientRef CGGradientCreateWithColors(CGColorSpaceRef space, - CFArrayRef colors, const CGFloat locations[]); -extern CGGradientRef CGGradientRetain(CGGradientRef gradient); -extern void CGGradientRelease(CGGradientRef gradient); -typedef struct CGContext *CGContextRef; -extern void CGContextDrawLinearGradient(CGContextRef context, - CGGradientRef gradient, CGPoint startPoint, CGPoint endPoint, - CGGradientDrawingOptions options); -extern CGColorSpaceRef CGColorSpaceCreateDeviceRGB(void); - -@interface NSMutableArray : NSObject -- (void)addObject:(id)object; -+ (id)array; -@end - -// This is how NSMakeCollectable is declared in the OS X 10.8 headers. -id NSMakeCollectable(CFTypeRef __attribute__((cf_consumed))) __attribute__((ns_returns_retained)); - -typedef const struct __CFUUID * CFUUIDRef; - -extern -void *CFPlugInInstanceCreate(CFAllocatorRef allocator, CFUUIDRef factoryUUID, CFUUIDRef typeUUID); - -//===----------------------------------------------------------------------===// -// Test cases. -//===----------------------------------------------------------------------===// - -CFAbsoluteTime f1() { - CFAbsoluteTime t = CFAbsoluteTimeGetCurrent(); - CFDateRef date = CFDateCreate(0, t); - CFRetain(date); - CFRelease(date); - CFDateGetAbsoluteTime(date); // no-warning - CFRelease(date); - t = CFDateGetAbsoluteTime(date); // expected-warning{{Reference-counted object is used after it is released}} - return t; -} - -CFAbsoluteTime f2() { - CFAbsoluteTime t = CFAbsoluteTimeGetCurrent(); - CFDateRef date = CFDateCreate(0, t); - [((NSDate*) date) retain]; - CFRelease(date); - CFDateGetAbsoluteTime(date); // no-warning - [((NSDate*) date) release]; - t = CFDateGetAbsoluteTime(date); // expected-warning{{Reference-counted object is used after it is released}} - return t; -} - - -NSDate* global_x; - -// Test to see if we suppress an error when we store the pointer -// to a global. - -CFAbsoluteTime f3() { - CFAbsoluteTime t = CFAbsoluteTimeGetCurrent(); - CFDateRef date = CFDateCreate(0, t); - [((NSDate*) date) retain]; - CFRelease(date); - CFDateGetAbsoluteTime(date); // no-warning - global_x = (NSDate*) date; - [((NSDate*) date) release]; - t = CFDateGetAbsoluteTime(date); // no-warning - return t; -} - -//--------------------------------------------------------------------------- -// Test case 'f4' differs for region store and basic store. See -// retain-release-region-store.m and retain-release-basic-store.m. -//--------------------------------------------------------------------------- - -// Test a leak. - -CFAbsoluteTime f5(int x) { - CFAbsoluteTime t = CFAbsoluteTimeGetCurrent(); - CFDateRef date = CFDateCreate(0, t); // expected-warning{{leak}} - - if (x) - CFRelease(date); - - return t; -} - -// Test a leak involving the return. - -CFDateRef f6(int x) { - CFDateRef date = CFDateCreate(0, CFAbsoluteTimeGetCurrent()); // expected-warning{{leak}} - CFRetain(date); - return date; -} - -// Test a leak involving an overwrite. - -CFDateRef f7() { - CFDateRef date = CFDateCreate(0, CFAbsoluteTimeGetCurrent()); //expected-warning{{leak}} - CFRetain(date); - date = CFDateCreate(0, CFAbsoluteTimeGetCurrent()); // expected-warning {{leak}} - return date; -} - -// Generalization of Create rule. MyDateCreate returns a CFXXXTypeRef, and -// has the word create. -CFDateRef MyDateCreate(); - -CFDateRef f8() { - CFDateRef date = MyDateCreate(); // expected-warning{{leak}} - CFRetain(date); - return date; -} - -__attribute__((cf_returns_retained)) CFDateRef f9() { - CFDateRef date = CFDateCreate(0, CFAbsoluteTimeGetCurrent()); // no-warning - int *p = 0; - // When allocations fail, CFDateCreate can return null. - if (!date) *p = 1; // expected-warning{{null}} - return date; -} - -// Handle DiskArbitration API: -// -// http://developer.apple.com/DOCUMENTATION/DARWIN/Reference/DiscArbitrationFramework/ -// -void f10(io_service_t media, DADiskRef d, CFStringRef s) { - DADiskRef disk = DADiskCreateFromBSDName(kCFAllocatorDefault, 0, "hello"); // expected-warning{{leak}} - if (disk) NSLog(@"ok"); - - disk = DADiskCreateFromIOMedia(kCFAllocatorDefault, 0, media); // expected-warning{{leak}} - if (disk) NSLog(@"ok"); - - CFDictionaryRef dict = DADiskCopyDescription(d); // expected-warning{{leak}} - if (dict) NSLog(@"ok"); - - disk = DADiskCopyWholeDisk(d); // expected-warning{{leak}} - if (disk) NSLog(@"ok"); - - DADissenterRef dissenter = DADissenterCreate(kCFAllocatorDefault, // expected-warning{{leak}} - kDAReturnSuccess, s); - if (dissenter) NSLog(@"ok"); - - DASessionRef session = DASessionCreate(kCFAllocatorDefault); // expected-warning{{leak}} - if (session) NSLog(@"ok"); -} - -// Test retain/release checker with CFString and CFMutableArray. -void f11() { - // Create the array. - CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); - - // Create a string. - CFStringRef s1 = CFStringCreateWithCString(0, "hello world", - kCFStringEncodingUTF8); - - // Add the string to the array. - CFArrayAppendValue(A, s1); - - // Decrement the reference count. - CFRelease(s1); // no-warning - - // Get the string. We don't own it. - s1 = (CFStringRef) CFArrayGetValueAtIndex(A, 0); - - // Release the array. - CFRelease(A); // no-warning - - // Release the string. This is a bug. - CFRelease(s1); // expected-warning{{Incorrect decrement of the reference count}} -} - -// PR 3337: Handle functions declared using typedefs. -typedef CFTypeRef CREATEFUN(); -CFTypeRef MyCreateFun(); - -void f12() { - CFTypeRef o = MyCreateFun(); // expected-warning {{leak}} -} - -void f13_autorelease() { - CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning - [(id) A autorelease]; // no-warning -} - -void f13_autorelease_b() { - CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); - [(id) A autorelease]; - [(id) A autorelease]; -} // expected-warning{{Object autoreleased too many times}} - -CFMutableArrayRef f13_autorelease_c() { - CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); - [(id) A autorelease]; - [(id) A autorelease]; - return A; // expected-warning{{Object autoreleased too many times}} -} - -CFMutableArrayRef f13_autorelease_d() { - CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); - [(id) A autorelease]; - [(id) A autorelease]; - CFMutableArrayRef B = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // expected-warning{{Object autoreleased too many times}} - CFRelease(B); // no-warning - while (1) {} -} - - -// This case exercises the logic where the leak site is the same as the allocation site. -void f14_leakimmediately() { - CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // expected-warning{{leak}} -} - -// Test that we track an allocated object beyond the point where the *name* -// of the variable storing the reference is no longer live. -void f15() { - // Create the array. - CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); - CFMutableArrayRef *B = &A; - // At this point, the name 'A' is no longer live. - CFRelease(*B); // no-warning -} - -// Test when we pass NULL to CFRetain/CFRelease/CFMakeCollectable/CFAutorelease. -void f16(int x, CFTypeRef p) { - if (p) - return; - - switch (x) { - case 0: - CFRelease(p); - break; - case 1: - CFRetain(p); - break; - case 2: - CFMakeCollectable(p); - break; - case 3: - CFAutorelease(p); - break; - default: - break; - } -} - -// Test that an object is non-null after CFRetain/CFRelease/CFMakeCollectable/CFAutorelease. -void f17(int x, CFTypeRef p) { - switch (x) { - case 0: - CFRelease(p); - if (!p) - CFRelease(0); // no-warning - break; - case 1: - CFRetain(p); - if (!p) - CFRetain(0); // no-warning - break; - case 2: - CFMakeCollectable(p); - if (!p) - CFMakeCollectable(0); // no-warning - break; - case 3: - CFAutorelease(p); - if (!p) - CFAutorelease(0); // no-warning - break; - default: - break; - } -} - -// Test basic tracking of ivars associated with 'self'. For the retain/release -// checker we currently do not want to flag leaks associated with stores -// of tracked objects to ivars. -@interface SelfIvarTest : NSObject { - id myObj; -} -- (void)test_self_tracking; -@end - -@implementation SelfIvarTest -- (void)test_self_tracking { - myObj = (id) CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning -} -@end - -// Test return of non-owned objects in contexts where an owned object -// is expected. -@interface TestReturnNotOwnedWhenExpectedOwned -- (NSString*)newString; -@end - -@implementation TestReturnNotOwnedWhenExpectedOwned -- (NSString*)newString { - NSString *s = [NSString stringWithUTF8String:"hello"]; - return s; // expected-warning{{Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected}} -} -@end - -// <rdar://problem/6659160> -int isFoo(char c); - -static void rdar_6659160(char *inkind, char *inname) -{ - // We currently expect that [NSObject alloc] cannot fail. This - // will be a toggled flag in the future. It can indeed return null, but - // Cocoa programmers generally aren't expected to reason about out-of-memory - // conditions. - NSString *kind = [[NSString alloc] initWithUTF8String:inkind]; // expected-warning{{leak}} - - // We do allow stringWithUTF8String to fail. This isn't really correct, as - // far as returning 0. In most error conditions it will throw an exception. - // If allocation fails it could return 0, but again this - // isn't expected. - NSString *name = [NSString stringWithUTF8String:inname]; - if(!name) - return; - - const char *kindC = 0; - const char *nameC = 0; - - // In both cases, we cannot reach a point down below where we - // dereference kindC or nameC with either being null. This is because - // we assume that [NSObject alloc] doesn't fail and that we have the guard - // up above. - - if(kind) - kindC = [kind UTF8String]; - if(name) - nameC = [name UTF8String]; - if(!isFoo(kindC[0])) // expected-warning{{null}} - return; - if(!isFoo(nameC[0])) // no-warning - return; - - [kind release]; - [name release]; // expected-warning{{Incorrect decrement of the reference count}} -} - -// PR 3677 - 'allocWithZone' should be treated as following the Cocoa naming -// conventions with respect to 'return'ing ownership. -@interface PR3677: NSObject @end -@implementation PR3677 -+ (id)allocWithZone:(NSZone *)inZone { - return [super allocWithZone:inZone]; // no-warning -} -@end - -// PR 3820 - Reason about calls to -dealloc -void pr3820_DeallocInsteadOfRelease(void) -{ - id foo = [[NSString alloc] init]; // no-warning - [foo dealloc]; - // foo is not leaked, since it has been deallocated. -} - -void pr3820_ReleaseAfterDealloc(void) -{ - id foo = [[NSString alloc] init]; - [foo dealloc]; - [foo release]; // expected-warning{{used after it is release}} - // NSInternalInconsistencyException: message sent to deallocated object -} - -void pr3820_DeallocAfterRelease(void) -{ - NSLog(@"\n\n[%s]", __FUNCTION__); - id foo = [[NSString alloc] init]; - [foo release]; - [foo dealloc]; // expected-warning{{used after it is released}} - // message sent to released object -} - -// From <rdar://problem/6704930>. The problem here is that 'length' binds to -// '($0 - 1)' after '--length', but SimpleConstraintManager doesn't know how to -// reason about '($0 - 1) > constant'. As a temporary hack, we drop the value -// of '($0 - 1)' and conjure a new symbol. -void rdar6704930(unsigned char *s, unsigned int length) { - NSString* name = 0; - if (s != 0) { - if (length > 0) { - while (length > 0) { - if (*s == ':') { - ++s; - --length; - name = [[NSString alloc] init]; // no-warning - break; - } - ++s; - --length; - } - if ((length == 0) && (name != 0)) { - [name release]; - name = 0; - } - if (length == 0) { // no ':' found -> use it all as name - name = [[NSString alloc] init]; // no-warning - } - } - } - - if (name != 0) { - [name release]; - } -} - -//===----------------------------------------------------------------------===// -// <rdar://problem/6833332> -// One build of the analyzer accidentally stopped tracking the allocated -// object after the 'retain'. -//===----------------------------------------------------------------------===// - -@interface rdar_6833332 : NSObject <NSApplicationDelegate> { - NSWindow *window; -} -@property (nonatomic, retain) NSWindow *window; -@end - -@implementation rdar_6833332 -@synthesize window; -- (void)applicationDidFinishLaunching:(NSNotification *)aNotification { - NSMutableDictionary *dict = [[NSMutableDictionary dictionaryWithCapacity:4] retain]; // expected-warning{{leak}} - - [dict setObject:@"foo" forKey:@"bar"]; - - NSLog(@"%@", dict); -} -- (void)dealloc { - [window release]; - [super dealloc]; -} - -- (void)radar10102244 { - NSMutableDictionary *dict = [[NSMutableDictionary dictionaryWithCapacity:4] retain]; // expected-warning{{leak}} - if (window) - NSLog(@"%@", window); -} -@end - -//===----------------------------------------------------------------------===// -// <rdar://problem/6257780> clang checker fails to catch use-after-release -//===----------------------------------------------------------------------===// - -int rdar_6257780_Case1() { - NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; - NSArray *array = [NSArray array]; - [array release]; // expected-warning{{Incorrect decrement of the reference count of an object that is not owned at this point by the caller}} - [pool drain]; - return 0; -} - -//===----------------------------------------------------------------------===// -// <rdar://problem/10640253> Analyzer is confused about NSAutoreleasePool -allocWithZone:. -//===----------------------------------------------------------------------===// - -void rdar_10640253_autorelease_allocWithZone() { - NSAutoreleasePool *pool = [[NSAutoreleasePool allocWithZone:(NSZone*)0] init]; - (void) pool; -} - -//===----------------------------------------------------------------------===// -// <rdar://problem/6866843> Checker should understand new/setObject:/release constructs -//===----------------------------------------------------------------------===// - -void rdar_6866843() { - NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; - NSMutableDictionary* dictionary = [[NSMutableDictionary alloc] init]; - NSArray* array = [[NSArray alloc] init]; - [dictionary setObject:array forKey:@"key"]; - [array release]; - // Using 'array' here should be fine - NSLog(@"array = %@\n", array); // no-warning - // Now the array is released - [dictionary release]; - [pool drain]; -} - - -//===----------------------------------------------------------------------===// -// <rdar://problem/6877235> Classes typedef-ed to CF objects should get the same treatment as CF objects -//===----------------------------------------------------------------------===// - -typedef CFTypeRef OtherRef; - -@interface RDar6877235 : NSObject {} -- (CFTypeRef)_copyCFTypeRef; -- (OtherRef)_copyOtherRef; -@end - -@implementation RDar6877235 -- (CFTypeRef)_copyCFTypeRef { - return [[NSString alloc] init]; // no-warning -} -- (OtherRef)_copyOtherRef { - return [[NSString alloc] init]; // no-warning -} -@end - -//===----------------------------------------------------------------------===// -// <rdar://problem/6320065> false positive - init method returns an object -// owned by caller -//===----------------------------------------------------------------------===// - -@interface RDar6320065 : NSObject { - NSString *_foo; -} -- (id)initReturningNewClass; -- (id)_initReturningNewClassBad; -- (id)initReturningNewClassBad2; -@end - -@interface RDar6320065Subclass : RDar6320065 -@end - -@implementation RDar6320065 -- (id)initReturningNewClass { - [self release]; - self = [[RDar6320065Subclass alloc] init]; // no-warning - return self; -} -- (id)_initReturningNewClassBad { - [self release]; - [[RDar6320065Subclass alloc] init]; // expected-warning {{leak}} - return self; -} -- (id)initReturningNewClassBad2 { - [self release]; - self = [[RDar6320065Subclass alloc] init]; - return [self autorelease]; // expected-warning{{Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected}} -} - -@end - -@implementation RDar6320065Subclass -@end - -int RDar6320065_test() { - RDar6320065 *test = [[RDar6320065 alloc] init]; // no-warning - [test release]; - return 0; -} - -//===----------------------------------------------------------------------===// -// <rdar://problem/7129086> -awakeAfterUsingCoder: returns an owned object -// and claims the receiver -//===----------------------------------------------------------------------===// - -@interface RDar7129086 : NSObject {} @end -@implementation RDar7129086 -- (id)awakeAfterUsingCoder:(NSCoder *)aDecoder { - [self release]; // no-warning - return [NSString alloc]; // no-warning -} -@end - -//===----------------------------------------------------------------------===// -// <rdar://problem/6859457> [NSData dataWithBytesNoCopy] does not return a -// retained object -//===----------------------------------------------------------------------===// - -@interface RDar6859457 : NSObject {} -- (NSString*) NoCopyString; -- (NSString*) noCopyString; -@end - -@implementation RDar6859457 -- (NSString*) NoCopyString { return [[NSString alloc] init]; } // expected-warning{{leak}} -- (NSString*) noCopyString { return [[NSString alloc] init]; } // expected-warning{{leak}} -@end - -void test_RDar6859457(RDar6859457 *x, void *bytes, NSUInteger dataLength) { - [x NoCopyString]; // expected-warning{{leak}} - [x noCopyString]; // expected-warning{{leak}} - [NSData dataWithBytesNoCopy:bytes length:dataLength]; // no-warning - [NSData dataWithBytesNoCopy:bytes length:dataLength freeWhenDone:1]; // no-warning -} - -//===----------------------------------------------------------------------===// -// PR 4230 - an autorelease pool is not necessarily leaked during a premature -// return -//===----------------------------------------------------------------------===// - -static void PR4230(void) -{ - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; // no-warning - NSString *object = [[[NSString alloc] init] autorelease]; // no-warning - return; -} - -static void PR4230_new(void) -{ - NSAutoreleasePool *pool = [NSAutoreleasePool new]; // no-warning - NSString *object = [[[NSString alloc] init] autorelease]; // no-warning - return; -} - -//===----------------------------------------------------------------------===// -// Method name that has a null IdentifierInfo* for its first selector slot. -// This test just makes sure that we handle it. -//===----------------------------------------------------------------------===// - -@interface TestNullIdentifier -@end - -@implementation TestNullIdentifier -+ (id):(int)x, ... { - return [[NSString alloc] init]; // expected-warning{{leak}} -} -@end - -//===----------------------------------------------------------------------===// -// <rdar://problem/6893565> don't flag leaks for return types that cannot be -// determined to be CF types -//===----------------------------------------------------------------------===// - -// We don't know if 'struct s6893565' represents a Core Foundation type, so -// we shouldn't emit an error here. -typedef struct s6893565* TD6893565; - -@interface RDar6893565 {} --(TD6893565)newThing; -@end - -@implementation RDar6893565 --(TD6893565)newThing { - return (TD6893565) [[NSString alloc] init]; // no-warning -} -@end - -//===----------------------------------------------------------------------===// -// <rdar://problem/6902710> clang: false positives w/QC and CoreImage methods -//===----------------------------------------------------------------------===// - -void rdar6902710(QCView *view, QCRenderer *renderer, CIContext *context, - NSString *str, CIImage *img, CGRect rect, - CIFormat form, CGColorSpaceRef cs) { - [view createSnapshotImageOfType:str]; // expected-warning{{leak}} - [renderer createSnapshotImageOfType:str]; // expected-warning{{leak}} - [context createCGImage:img fromRect:rect]; // expected-warning{{leak}} - [context createCGImage:img fromRect:rect format:form colorSpace:cs]; // expected-warning{{leak}} -} - -//===----------------------------------------------------------------------===// -// <rdar://problem/6945561> -[CIContext createCGLayerWithSize:info:] -// misinterpreted by clang scan-build -//===----------------------------------------------------------------------===// - -void rdar6945561(CIContext *context, CGSize size, CFDictionaryRef d) { - [context createCGLayerWithSize:size info:d]; // expected-warning{{leak}} -} - -//===----------------------------------------------------------------------===// -// <rdar://problem/6961230> add knowledge of IOKit functions to retain/release -// checker -//===----------------------------------------------------------------------===// - -void IOBSDNameMatching_wrapper(mach_port_t masterPort, uint32_t options, const char * bsdName) { - IOBSDNameMatching(masterPort, options, bsdName); // expected-warning{{leak}} -} - -void IOServiceMatching_wrapper(const char * name) { - IOServiceMatching(name); // expected-warning{{leak}} -} - -void IOServiceNameMatching_wrapper(const char * name) { - IOServiceNameMatching(name); // expected-warning{{leak}} -} - -CF_RETURNS_RETAINED CFDictionaryRef CreateDict(); - -void IOServiceAddNotification_wrapper(mach_port_t masterPort, const io_name_t notificationType, - mach_port_t wakePort, uintptr_t reference, io_iterator_t * notification ) { - - CFDictionaryRef matching = CreateDict(); - CFRelease(matching); - IOServiceAddNotification(masterPort, notificationType, matching, // expected-warning{{used after it is released}} expected-warning{{deprecated}} - wakePort, reference, notification); -} - -void IORegistryEntryIDMatching_wrapper(uint64_t entryID ) { - IORegistryEntryIDMatching(entryID); // expected-warning{{leak}} -} - -void IOOpenFirmwarePathMatching_wrapper(mach_port_t masterPort, uint32_t options, - const char * path) { - IOOpenFirmwarePathMatching(masterPort, options, path); // expected-warning{{leak}} -} - -void IOServiceGetMatchingService_wrapper(mach_port_t masterPort) { - CFDictionaryRef matching = CreateDict(); - IOServiceGetMatchingService(masterPort, matching); - CFRelease(matching); // expected-warning{{used after it is released}} -} - -void IOServiceGetMatchingServices_wrapper(mach_port_t masterPort, io_iterator_t *existing) { - CFDictionaryRef matching = CreateDict(); - IOServiceGetMatchingServices(masterPort, matching, existing); - CFRelease(matching); // expected-warning{{used after it is released}} -} - -void IOServiceAddMatchingNotification_wrapper(IONotificationPortRef notifyPort, const io_name_t notificationType, - IOServiceMatchingCallback callback, void * refCon, io_iterator_t * notification) { - - CFDictionaryRef matching = CreateDict(); - IOServiceAddMatchingNotification(notifyPort, notificationType, matching, callback, refCon, notification); - CFRelease(matching); // expected-warning{{used after it is released}} -} - -//===----------------------------------------------------------------------===// -// Test of handling objects whose references "escape" to containers. -//===----------------------------------------------------------------------===// - -void CFDictionaryAddValue(CFMutableDictionaryRef, void *, void *); - -// <rdar://problem/6539791> -void rdar_6539791(CFMutableDictionaryRef y, void* key, void* val_key) { - CFMutableDictionaryRef x = CFDictionaryCreateMutable(kCFAllocatorDefault, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); - CFDictionaryAddValue(y, key, x); - CFRelease(x); // the dictionary keeps a reference, so the object isn't deallocated yet - signed z = 1; - CFNumberRef value = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &z); - if (value) { - CFDictionaryAddValue(x, val_key, (void*)value); // no-warning - CFRelease(value); - CFDictionaryAddValue(y, val_key, (void*)value); // no-warning - } -} - -// <rdar://problem/6560661> -// Same issue, except with "AppendValue" functions. -void rdar_6560661(CFMutableArrayRef x) { - signed z = 1; - CFNumberRef value = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &z); - // CFArrayAppendValue keeps a reference to value. - CFArrayAppendValue(x, value); - CFRelease(value); - CFRetain(value); - CFRelease(value); // no-warning -} - -// <rdar://problem/7152619> -// Same issue, excwept with "CFAttributeStringSetAttribute". -void rdar_7152619(CFStringRef str) { - CFAttributedStringRef string = CFAttributedStringCreate(kCFAllocatorDefault, str, 0); - CFMutableAttributedStringRef attrString = CFAttributedStringCreateMutableCopy(kCFAllocatorDefault, 100, string); - CFRelease(string); - NSNumber *number = [[NSNumber alloc] initWithInt:5]; // expected-warning{{leak}} - CFAttributedStringSetAttribute(attrString, CFRangeMake(0, 1), str, number); - [number release]; - [number retain]; - CFRelease(attrString); -} - -//===----------------------------------------------------------------------===// -// Test of handling CGGradientXXX functions. -//===----------------------------------------------------------------------===// - -void rdar_7184450(CGContextRef myContext, CGFloat x, CGPoint myStartPoint, - CGPoint myEndPoint) { - size_t num_locations = 6; - CGFloat locations[6] = { 0.0, 0.265, 0.28, 0.31, 0.36, 1.0 }; - CGFloat components[28] = { 239.0/256.0, 167.0/256.0, 170.0/256.0, - x, // Start color - 207.0/255.0, 39.0/255.0, 39.0/255.0, x, - 147.0/255.0, 21.0/255.0, 22.0/255.0, x, - 175.0/255.0, 175.0/255.0, 175.0/255.0, x, - 255.0/255.0,255.0/255.0, 255.0/255.0, x, - 255.0/255.0,255.0/255.0, 255.0/255.0, x - }; // End color - - CGGradientRef myGradient = - CGGradientCreateWithColorComponents(CGColorSpaceCreateDeviceRGB(), // expected-warning{{leak}} - components, locations, num_locations); - - CGContextDrawLinearGradient(myContext, myGradient, myStartPoint, myEndPoint, - 0); - CGGradientRelease(myGradient); -} - -void rdar_7184450_pos(CGContextRef myContext, CGFloat x, CGPoint myStartPoint, - CGPoint myEndPoint) { - size_t num_locations = 6; - CGFloat locations[6] = { 0.0, 0.265, 0.28, 0.31, 0.36, 1.0 }; - CGFloat components[28] = { 239.0/256.0, 167.0/256.0, 170.0/256.0, - x, // Start color - 207.0/255.0, 39.0/255.0, 39.0/255.0, x, - 147.0/255.0, 21.0/255.0, 22.0/255.0, x, - 175.0/255.0, 175.0/255.0, 175.0/255.0, x, - 255.0/255.0,255.0/255.0, 255.0/255.0, x, - 255.0/255.0,255.0/255.0, 255.0/255.0, x - }; // End color - - CGGradientRef myGradient = - CGGradientCreateWithColorComponents(CGColorSpaceCreateDeviceRGB(), components, locations, num_locations); // expected-warning 2 {{leak}} - - CGContextDrawLinearGradient(myContext, myGradient, myStartPoint, myEndPoint, - 0); -} - -//===----------------------------------------------------------------------===// -// <rdar://problem/7299394> clang false positive: retained instance passed to -// thread in pthread_create marked as leak -// -// Until we have full IPA, the analyzer should stop tracking the reference -// count of objects passed to pthread_create. -// -//===----------------------------------------------------------------------===// - -struct _opaque_pthread_t {}; -struct _opaque_pthread_attr_t {}; -typedef struct _opaque_pthread_t *__darwin_pthread_t; -typedef struct _opaque_pthread_attr_t __darwin_pthread_attr_t; -typedef __darwin_pthread_t pthread_t; -typedef __darwin_pthread_attr_t pthread_attr_t; -typedef unsigned long __darwin_pthread_key_t; -typedef __darwin_pthread_key_t pthread_key_t; - -int pthread_create(pthread_t *, const pthread_attr_t *, - void *(*)(void *), void *); - -int pthread_setspecific(pthread_key_t key, const void *value); - -void *rdar_7299394_start_routine(void *p) { - [((id) p) release]; - return 0; -} -void rdar_7299394(pthread_attr_t *attr, pthread_t *thread, void *args) { - NSNumber *number = [[NSNumber alloc] initWithInt:5]; // no-warning - pthread_create(thread, attr, rdar_7299394_start_routine, number); -} -void rdar_7299394_positive(pthread_attr_t *attr, pthread_t *thread) { - NSNumber *number = [[NSNumber alloc] initWithInt:5]; // expected-warning{{leak}} -} - -//===----------------------------------------------------------------------===// -// <rdar://problem/11282706> false positive with not understanding thread -// local storage -//===----------------------------------------------------------------------===// - -void rdar11282706(pthread_key_t key) { - NSNumber *number = [[NSNumber alloc] initWithInt:5]; // no-warning - pthread_setspecific(key, (void*) number); -} - -//===----------------------------------------------------------------------===// -// <rdar://problem/7283567> False leak associated with call to -// CVPixelBufferCreateWithBytes () -// -// According to the Core Video Reference (ADC), CVPixelBufferCreateWithBytes and -// CVPixelBufferCreateWithPlanarBytes can release (via a callback) the -// pixel buffer object. These test cases show how the analyzer stops tracking -// the reference count for the objects passed for this argument. This -// could be made smarter. -//===----------------------------------------------------------------------===// - -typedef int int32_t; -typedef UInt32 FourCharCode; -typedef FourCharCode OSType; -typedef uint64_t CVOptionFlags; -typedef int32_t CVReturn; -typedef struct __CVBuffer *CVBufferRef; -typedef CVBufferRef CVImageBufferRef; -typedef CVImageBufferRef CVPixelBufferRef; -typedef void (*CVPixelBufferReleaseBytesCallback)( void *releaseRefCon, const void *baseAddress ); - -extern CVReturn CVPixelBufferCreateWithBytes(CFAllocatorRef allocator, - size_t width, - size_t height, - OSType pixelFormatType, - void *baseAddress, - size_t bytesPerRow, - CVPixelBufferReleaseBytesCallback releaseCallback, - void *releaseRefCon, - CFDictionaryRef pixelBufferAttributes, - CVPixelBufferRef *pixelBufferOut) ; - -typedef void (*CVPixelBufferReleasePlanarBytesCallback)( void *releaseRefCon, const void *dataPtr, size_t dataSize, size_t numberOfPlanes, const void *planeAddresses[] ); - -extern CVReturn CVPixelBufferCreateWithPlanarBytes(CFAllocatorRef allocator, - size_t width, - size_t height, - OSType pixelFormatType, - void *dataPtr, - size_t dataSize, - size_t numberOfPlanes, - void *planeBaseAddress[], - size_t planeWidth[], - size_t planeHeight[], - size_t planeBytesPerRow[], - CVPixelBufferReleasePlanarBytesCallback releaseCallback, - void *releaseRefCon, - CFDictionaryRef pixelBufferAttributes, - CVPixelBufferRef *pixelBufferOut) ; - -extern CVReturn CVPixelBufferCreateWithBytes(CFAllocatorRef allocator, - size_t width, - size_t height, - OSType pixelFormatType, - void *baseAddress, - size_t bytesPerRow, - CVPixelBufferReleaseBytesCallback releaseCallback, - void *releaseRefCon, - CFDictionaryRef pixelBufferAttributes, - CVPixelBufferRef *pixelBufferOut) ; - -CVReturn rdar_7283567(CFAllocatorRef allocator, size_t width, size_t height, - OSType pixelFormatType, void *baseAddress, - size_t bytesPerRow, - CVPixelBufferReleaseBytesCallback releaseCallback, - CFDictionaryRef pixelBufferAttributes, - CVPixelBufferRef *pixelBufferOut) { - - // For the allocated object, it doesn't really matter what type it is - // for the purpose of this test. All we want to show is that - // this is freed later by the callback. - NSNumber *number = [[NSNumber alloc] initWithInt:5]; // no-warning - - return CVPixelBufferCreateWithBytes(allocator, width, height, pixelFormatType, - baseAddress, bytesPerRow, releaseCallback, - number, // potentially released by callback - pixelBufferAttributes, pixelBufferOut) ; -} - -CVReturn rdar_7283567_2(CFAllocatorRef allocator, size_t width, size_t height, - OSType pixelFormatType, void *dataPtr, size_t dataSize, - size_t numberOfPlanes, void *planeBaseAddress[], - size_t planeWidth[], size_t planeHeight[], size_t planeBytesPerRow[], - CVPixelBufferReleasePlanarBytesCallback releaseCallback, - CFDictionaryRef pixelBufferAttributes, - CVPixelBufferRef *pixelBufferOut) { - - // For the allocated object, it doesn't really matter what type it is - // for the purpose of this test. All we want to show is that - // this is freed later by the callback. - NSNumber *number = [[NSNumber alloc] initWithInt:5]; // no-warning - - return CVPixelBufferCreateWithPlanarBytes(allocator, - width, height, pixelFormatType, dataPtr, dataSize, - numberOfPlanes, planeBaseAddress, planeWidth, - planeHeight, planeBytesPerRow, releaseCallback, - number, // potentially released by callback - pixelBufferAttributes, pixelBufferOut) ; -} - -//===----------------------------------------------------------------------===// -// <rdar://problem/7358899> False leak associated with -// CGBitmapContextCreateWithData -//===----------------------------------------------------------------------===// -typedef uint32_t CGBitmapInfo; -typedef void (*CGBitmapContextReleaseDataCallback)(void *releaseInfo, void *data); - -CGContextRef CGBitmapContextCreateWithData(void *data, - size_t width, size_t height, size_t bitsPerComponent, - size_t bytesPerRow, CGColorSpaceRef space, CGBitmapInfo bitmapInfo, - CGBitmapContextReleaseDataCallback releaseCallback, void *releaseInfo); - -void rdar_7358899(void *data, - size_t width, size_t height, size_t bitsPerComponent, - size_t bytesPerRow, CGColorSpaceRef space, CGBitmapInfo bitmapInfo, - CGBitmapContextReleaseDataCallback releaseCallback) { - - // For the allocated object, it doesn't really matter what type it is - // for the purpose of this test. All we want to show is that - // this is freed later by the callback. - NSNumber *number = [[NSNumber alloc] initWithInt:5]; // no-warning - - CGBitmapContextCreateWithData(data, width, height, bitsPerComponent, // expected-warning{{leak}} - bytesPerRow, space, bitmapInfo, releaseCallback, number); -} - -//===----------------------------------------------------------------------===// -// <rdar://problem/7265711> allow 'new', 'copy', 'alloc', 'init' prefix to -// start before '_' when determining Cocoa fundamental rule -// -// Previously the retain/release checker just skipped prefixes before the -// first '_' entirely. Now the checker honors the prefix if it results in a -// recognizable naming convention (e.g., 'new', 'init'). -//===----------------------------------------------------------------------===// - -@interface RDar7265711 {} -- (id) new_stuff; -@end - -void rdar7265711_a(RDar7265711 *x) { - id y = [x new_stuff]; // expected-warning{{leak}} -} - -void rdar7265711_b(RDar7265711 *x) { - id y = [x new_stuff]; // no-warning - [y release]; -} - -//===----------------------------------------------------------------------===// -// <rdar://problem/7306898> clang thinks [NSCursor dragCopyCursor] returns a -// retained reference -//===----------------------------------------------------------------------===// - -@interface NSCursor : NSObject -+ (NSCursor *)dragCopyCursor; -@end - -void rdar7306898(void) { - // 'dragCopyCursor' does not follow Cocoa's fundamental rule. It is a noun, not an sentence - // implying a 'copy' of something. - NSCursor *c = [NSCursor dragCopyCursor]; // no-warning - NSNumber *number = [[NSNumber alloc] initWithInt:5]; // expected-warning{{leak}} -} - -//===----------------------------------------------------------------------===// -// <rdar://problem/7252064> sending 'release', 'retain', etc. to a Class -// directly is not likely what the user intended -//===----------------------------------------------------------------------===// - -@interface RDar7252064 : NSObject @end -void rdar7252064(void) { - [RDar7252064 release]; // expected-warning{{The 'release' message should be sent to instances of class 'RDar7252064' and not the class directly}} - [RDar7252064 retain]; // expected-warning{{The 'retain' message should be sent to instances of class 'RDar7252064' and not the class directly}} - [RDar7252064 autorelease]; // expected-warning{{The 'autorelease' message should be sent to instances of class 'RDar7252064' and not the class directly}} - [NSAutoreleasePool drain]; // expected-warning{{method '+drain' not found}} expected-warning{{The 'drain' message should be sent to instances of class 'NSAutoreleasePool' and not the class directly}} -} - -//===----------------------------------------------------------------------===// -// Tests of ownership attributes. -//===----------------------------------------------------------------------===// - -typedef NSString* MyStringTy; - -@protocol FooP; - -@interface TestOwnershipAttr : NSObject -- (NSString*) returnsAnOwnedString NS_RETURNS_RETAINED; // no-warning -- (NSString*) returnsAnOwnedCFString CF_RETURNS_RETAINED; // no-warning -- (MyStringTy) returnsAnOwnedTypedString NS_RETURNS_RETAINED; // no-warning -- (NSString*) newString NS_RETURNS_NOT_RETAINED; // no-warning -- (NSString*) newString_auto NS_RETURNS_AUTORELEASED; // no-warning -- (NSString*) newStringNoAttr; -- (int) returnsAnOwnedInt NS_RETURNS_RETAINED; // expected-warning{{'ns_returns_retained' attribute only applies to methods that return an Objective-C object}} -- (id) pseudoInit NS_CONSUMES_SELF NS_RETURNS_RETAINED; -+ (void) consume:(id) NS_CONSUMED x; -+ (void) consume2:(id) CF_CONSUMED x; -@end - -static int ownership_attribute_doesnt_go_here NS_RETURNS_RETAINED; // expected-warning{{'ns_returns_retained' attribute only applies to functions and methods}} - -void test_attr_1(TestOwnershipAttr *X) { - NSString *str = [X returnsAnOwnedString]; // expected-warning{{leak}} -} - -void test_attr_1b(TestOwnershipAttr *X) { - NSString *str = [X returnsAnOwnedCFString]; // expected-warning{{leak}} -} - -void test_attr1c(TestOwnershipAttr *X) { - NSString *str = [X newString]; // no-warning - NSString *str2 = [X newStringNoAttr]; // expected-warning{{leak}} - NSString *str3 = [X newString_auto]; // no-warning - NSString *str4 = [[X newString_auto] retain]; // expected-warning {{leak}} -} - -void testattr2_a() { - TestOwnershipAttr *x = [TestOwnershipAttr alloc]; // expected-warning{{leak}} -} - -void testattr2_b() { - TestOwnershipAttr *x = [[TestOwnershipAttr alloc] pseudoInit]; // expected-warning{{leak}} -} - -void testattr2_b_11358224_self_assign_looses_the_leak() { - TestOwnershipAttr *x = [[TestOwnershipAttr alloc] pseudoInit];// expected-warning{{leak}} - x = x; -} - -void testattr2_c() { - TestOwnershipAttr *x = [[TestOwnershipAttr alloc] pseudoInit]; // no-warning - [x release]; -} - -void testattr3() { - TestOwnershipAttr *x = [TestOwnershipAttr alloc]; // no-warning - [TestOwnershipAttr consume:x]; - TestOwnershipAttr *y = [TestOwnershipAttr alloc]; // no-warning - [TestOwnershipAttr consume2:y]; -} - -void consume_ns(id NS_CONSUMED x); -void consume_cf(id CF_CONSUMED x); - -void testattr4() { - TestOwnershipAttr *x = [TestOwnershipAttr alloc]; // no-warning - consume_ns(x); - TestOwnershipAttr *y = [TestOwnershipAttr alloc]; // no-warning - consume_cf(y); -} - -@interface TestOwnershipAttr2 : NSObject -- (NSString*) newString NS_RETURNS_NOT_RETAINED; // no-warning -@end - -@implementation TestOwnershipAttr2 -- (NSString*) newString { - return [NSString alloc]; // expected-warning {{Potential leak of an object}} -} -@end - -@interface MyClassTestCFAttr : NSObject {} -- (NSDate*) returnsCFRetained CF_RETURNS_RETAINED; -- (CFDateRef) returnsCFRetainedAsCF CF_RETURNS_RETAINED; -- (CFDateRef) newCFRetainedAsCF CF_RETURNS_NOT_RETAINED; -- (CFDateRef) newCFRetainedAsCFNoAttr; -- (NSDate*) alsoReturnsRetained; -- (CFDateRef) alsoReturnsRetainedAsCF; -- (NSDate*) returnsNSRetained NS_RETURNS_RETAINED; -@end - -CF_RETURNS_RETAINED -CFDateRef returnsRetainedCFDate() { - return CFDateCreate(0, CFAbsoluteTimeGetCurrent()); -} - -@implementation MyClassTestCFAttr -- (NSDate*) returnsCFRetained { - return (NSDate*) returnsRetainedCFDate(); // No leak. -} - -- (CFDateRef) returnsCFRetainedAsCF { - return returnsRetainedCFDate(); // No leak. -} - -- (CFDateRef) newCFRetainedAsCF { - return (CFDateRef)[(id)[self returnsCFRetainedAsCF] autorelease]; -} - -- (CFDateRef) newCFRetainedAsCFNoAttr { - return (CFDateRef)[(id)[self returnsCFRetainedAsCF] autorelease]; // expected-warning{{Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected}} -} - -- (NSDate*) alsoReturnsRetained { - return (NSDate*) returnsRetainedCFDate(); // expected-warning{{leak}} -} - -- (CFDateRef) alsoReturnsRetainedAsCF { - return returnsRetainedCFDate(); // expected-warning{{leak}} -} - - -- (NSDate*) returnsNSRetained { - return (NSDate*) returnsRetainedCFDate(); // no-warning -} -@end - -//===----------------------------------------------------------------------===// -// Test that leaks post-dominated by "panic" functions are not reported. -// -// <rdar://problem/5905851> do not report a leak when post-dominated by a call -// to a noreturn or panic function -//===----------------------------------------------------------------------===// - -void panic() __attribute__((noreturn)); -void panic_not_in_hardcoded_list() __attribute__((noreturn)); - -void test_panic_negative() { - signed z = 1; - CFNumberRef value = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &z); // expected-warning{{leak}} -} - -void test_panic_positive() { - signed z = 1; - CFNumberRef value = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &z); // no-warning - panic(); -} - -void test_panic_neg_2(int x) { - signed z = 1; - CFNumberRef value = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &z); // expected-warning{{leak}} - if (x) - panic(); -} - -void test_panic_pos_2(int x) { - signed z = 1; - CFNumberRef value = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &z); // no-warning - if (x) - panic(); - if (!x) { - // This showed up in <rdar://problem/7796563>, where we silently missed checking - // the function type for noreturn. "panic()" is a hard-coded known panic function - // that isn't always noreturn. - panic_not_in_hardcoded_list(); - } -} - -//===----------------------------------------------------------------------===// -// Test uses of blocks (closures) -//===----------------------------------------------------------------------===// - -void test_blocks_1_pos(void) { - NSNumber *number = [[NSNumber alloc] initWithInt:5]; // expected-warning{{leak}} - ^{}(); -} - -void test_blocks_1_indirect_release(void) { - NSNumber *number = [[NSNumber alloc] initWithInt:5]; // no-warning - ^{ [number release]; }(); -} - -void test_blocks_1_indirect_retain(void) { - // Eventually this should be reported as a leak. - NSNumber *number = [[NSNumber alloc] initWithInt:5]; // no-warning - ^{ [number retain]; }(); -} - -void test_blocks_1_indirect_release_via_call(void) { - NSNumber *number = [[NSNumber alloc] initWithInt:5]; // no-warning - ^(NSObject *o){ [o release]; }(number); -} - -void test_blocks_1_indirect_retain_via_call(void) { - NSNumber *number = [[NSNumber alloc] initWithInt:5]; // expected-warning {{leak}} - ^(NSObject *o){ [o retain]; }(number); -} - -//===--------------------------------------------------------------------===// -// Test sending message to super that returns an object alias. Previously -// this caused a crash in the analyzer. -//===--------------------------------------------------------------------===// - -@interface Rdar8015556 : NSObject {} @end -@implementation Rdar8015556 -- (id)retain { - return [super retain]; -} -@end - -// <rdar://problem/8272168> - Correcly handle Class<...> in Cocoa Conventions -// detector. - -@protocol Prot_R8272168 @end -Class <Prot_R8272168> GetAClassThatImplementsProt_R8272168(); -void r8272168() { - GetAClassThatImplementsProt_R8272168(); -} - -// Test case for <rdar://problem/8356342>, which in the past triggered -// a false positive. -@interface RDar8356342 -- (NSDate*) rdar8356342:(NSDate *)inValue; -@end - -@implementation RDar8356342 -- (NSDate*) rdar8356342:(NSDate*)inValue { - NSDate *outValue = inValue; - if (outValue == 0) - outValue = [[NSDate alloc] init]; // no-warning - - if (outValue != inValue) - [outValue autorelease]; - - return outValue; -} -@end - -// <rdar://problem/8724287> - This test case previously crashed because -// of a bug in BugReporter. -extern const void *CFDictionaryGetValue(CFDictionaryRef theDict, const void *key); -typedef struct __CFError * CFErrorRef; -extern const CFStringRef kCFErrorUnderlyingErrorKey; -extern CFDictionaryRef CFErrorCopyUserInfo(CFErrorRef err); -static void rdar_8724287(CFErrorRef error) -{ - CFErrorRef error_to_dump; - - error_to_dump = error; - while (error_to_dump != ((void*)0)) { - CFDictionaryRef info; - - info = CFErrorCopyUserInfo(error_to_dump); // expected-warning{{Potential leak of an object}} - - if (info != ((void*)0)) { - } - - error_to_dump = (CFErrorRef) CFDictionaryGetValue(info, kCFErrorUnderlyingErrorKey); - } -} - -// <rdar://problem/9234108> - Make sure the model applies cf_consumed -// correctly in argument positions besides the first. -extern void *CFStringCreate(void); -extern void rdar_9234108_helper(void *key, void * CF_CONSUMED value); -void rdar_9234108() { - rdar_9234108_helper(0, CFStringCreate()); -} - -// <rdar://problem/9726279> - Make sure that objc_method_family works -// to override naming conventions. -struct TwoDoubles { - double one; - double two; -}; -typedef struct TwoDoubles TwoDoubles; - -@interface NSValue (Mine) -- (id)_prefix_initWithTwoDoubles:(TwoDoubles)twoDoubles __attribute__((objc_method_family(init))); -@end - -@implementation NSValue (Mine) -- (id)_prefix_initWithTwoDoubles:(TwoDoubles)twoDoubles -{ - return [self init]; -} -@end - -void rdar9726279() { - TwoDoubles twoDoubles = { 0.0, 0.0 }; - NSValue *value = [[NSValue alloc] _prefix_initWithTwoDoubles:twoDoubles]; - [value release]; -} - -// <rdar://problem/9732321> -// Test camelcase support for CF conventions. While Core Foundation APIs -// don't use camel casing, other code is allowed to use it. -CFArrayRef camelcase_create_1() { - return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning -} - -CFArrayRef camelcase_createno() { - return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // expected-warning {{leak}} -} - -CFArrayRef camelcase_copy() { - return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning -} - -CFArrayRef camelcase_copying() { - return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // expected-warning {{leak}} -} - -CFArrayRef copyCamelCase() { - return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning -} - -CFArrayRef __copyCamelCase() { - return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning -} - -CFArrayRef __createCamelCase() { - return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning -} - -CFArrayRef camel_create() { - return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning -} - - -CFArrayRef camel_creat() { - return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // expected-warning {{leak}} -} - -CFArrayRef camel_copy() { - return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning -} - -CFArrayRef camel_copyMachine() { - return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning -} - -CFArrayRef camel_copymachine() { - return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // expected-warning {{leak}} -} - -// rdar://problem/8024350 -@protocol F18P -- (id) clone; -@end -@interface F18 : NSObject<F18P> @end -@interface F18(Cat) -- (id) clone NS_RETURNS_RETAINED; -@end - -@implementation F18 -- (id) clone { - return [F18 alloc]; -} -@end - -// Radar 6582778. -void rdar6582778(void) { - CFAbsoluteTime t = CFAbsoluteTimeGetCurrent(); - CFTypeRef vals[] = { CFDateCreate(0, t) }; // expected-warning {{leak}} -} - -CFTypeRef global; - -void rdar6582778_2(void) { - CFAbsoluteTime t = CFAbsoluteTimeGetCurrent(); - global = CFDateCreate(0, t); // no-warning -} - -// <rdar://problem/10232019> - Test that objects passed to containers -// are marked "escaped". - -void rdar10232019() { - NSMutableArray *array = [NSMutableArray array]; - - NSString *string = [[NSString alloc] initWithUTF8String:"foo"]; - [array addObject:string]; - [string release]; - - NSString *otherString = [string stringByAppendingString:@"bar"]; // no-warning - NSLog(@"%@", otherString); -} - -void rdar10232019_positive() { - NSMutableArray *array = [NSMutableArray array]; - - NSString *string = [[NSString alloc] initWithUTF8String:"foo"]; - [string release]; - - NSString *otherString = [string stringByAppendingString:@"bar"]; // expected-warning {{Reference-counted object is used after it is release}} - NSLog(@"%@", otherString); -} - -// RetainCountChecker support for XPC. -// <rdar://problem/9658496> -typedef void * xpc_object_t; -xpc_object_t _CFXPCCreateXPCObjectFromCFObject(CFTypeRef cf); -void xpc_release(xpc_object_t object); - -void rdar9658496() { - CFStringRef cf; - xpc_object_t xpc; - cf = CFStringCreateWithCString( ((CFAllocatorRef)0), "test", kCFStringEncodingUTF8 ); // no-warning - xpc = _CFXPCCreateXPCObjectFromCFObject( cf ); - CFRelease(cf); - xpc_release(xpc); -} - -// Support annotations with method families. -@interface RDar10824732 : NSObject -- (id)initWithObj:(id CF_CONSUMED)obj; -@end - -@implementation RDar10824732 -- (id)initWithObj:(id)obj { - [obj release]; - return [super init]; -} -@end - -void rdar_10824732() { - @autoreleasepool { - NSString *obj = @"test"; - RDar10824732 *foo = [[RDar10824732 alloc] initWithObj:obj]; // no-warning - [foo release]; - } -} - -// Stop tracking objects passed to functions, which take callbacks as parameters. -// radar://10973977 -typedef int (*CloseCallback) (void *); -void ReaderForIO(CloseCallback ioclose, void *ioctx); -int IOClose(void *context); - -@protocol SInS <NSObject> -@end - -@interface radar10973977 : NSObject -- (id<SInS>)inputS; -- (void)reader; -@end - -@implementation radar10973977 -- (void)reader -{ - id<SInS> inputS = [[self inputS] retain]; - ReaderForIO(IOClose, inputS); -} -- (id<SInS>)inputS -{ - return 0; -} -@end - -// Object escapes through a selector callback: radar://11398514 -extern id NSApp; -@interface MySheetController -- (id<SInS>)inputS; -- (void)showDoSomethingSheetAction:(id)action; -- (void)sheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo; -@end - -@implementation MySheetController -- (id<SInS>)inputS { - return 0; -} -- (void)showDoSomethingSheetAction:(id)action { - id<SInS> inputS = [[self inputS] retain]; - [NSApp beginSheet:0 - modalForWindow:0 - modalDelegate:0 - didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:) - contextInfo:(void *)inputS]; // no - warning -} -- (void)sheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo { - - id contextObject = (id)contextInfo; - [contextObject release]; -} - -- (id)copyAutoreleaseRadar13081402 { - id x = [[[NSString alloc] initWithUTF8String:"foo"] autorelease]; - [x retain]; - return x; // no warning -} - -@end -//===----------------------------------------------------------------------===// -// Test returning allocated memory in a struct. -// -// We currently don't have a general way to track pointers that "escape". -// Here we test that RetainCountChecker doesn't get excited about returning -// allocated CF objects in struct fields. -//===----------------------------------------------------------------------===// -void *malloc(size_t); -struct rdar11104566 { CFStringRef myStr; }; -struct rdar11104566 test_rdar11104566() { - CFStringRef cf = CFStringCreateWithCString( ((CFAllocatorRef)0), "test", kCFStringEncodingUTF8 ); // no-warning - struct rdar11104566 V; - V.myStr = cf; - return V; // no-warning -} - -struct rdar11104566 *test_2_rdar11104566() { - CFStringRef cf = CFStringCreateWithCString( ((CFAllocatorRef)0), "test", kCFStringEncodingUTF8 ); // no-warning - struct rdar11104566 *V = (struct rdar11104566 *) malloc(sizeof(*V)); - V->myStr = cf; - return V; // no-warning -} - -//===----------------------------------------------------------------------===// -// ObjC literals support. -//===----------------------------------------------------------------------===// - -void test_objc_arrays() { - { // CASE ONE -- OBJECT IN ARRAY CREATED DIRECTLY - NSObject *o = [[NSObject alloc] init]; - NSArray *a = [[NSArray alloc] initWithObjects:o, (void*)0]; // expected-warning {{leak}} - [o release]; - [a description]; - [o description]; - } - - { // CASE TWO -- OBJECT IN ARRAY CREATED BY DUPING AUTORELEASED ARRAY - NSObject *o = [[NSObject alloc] init]; - NSArray *a1 = [NSArray arrayWithObjects:o, (void*)0]; - NSArray *a2 = [[NSArray alloc] initWithArray:a1]; // expected-warning {{leak}} - [o release]; - [a2 description]; - [o description]; - } - - { // CASE THREE -- OBJECT IN RETAINED @[] - NSObject *o = [[NSObject alloc] init]; - NSArray *a3 = [@[o] retain]; // expected-warning {{leak}} - [o release]; - [a3 description]; - [o description]; - } - - { // CASE FOUR -- OBJECT IN ARRAY CREATED BY DUPING @[] - NSObject *o = [[NSObject alloc] init]; - NSArray *a = [[NSArray alloc] initWithArray:@[o]]; // expected-warning {{leak}} - [o release]; - - [a description]; - [o description]; - } - - { // CASE FIVE -- OBJECT IN RETAINED @{} - NSValue *o = [[NSValue alloc] init]; - NSDictionary *a = [@{o : o} retain]; // expected-warning {{leak}} - [o release]; - - [a description]; - [o description]; - } -} - -void test_objc_integer_literals() { - id value = [@1 retain]; // expected-warning {{leak}} - [value description]; -} - -void test_objc_boxed_expressions(int x, const char *y) { - id value = [@(x) retain]; // expected-warning {{leak}} - [value description]; - - value = [@(y) retain]; // expected-warning {{leak}} - [value description]; -} - -// Test NSLog doesn't escape tracked objects. -void rdar11400885(int y) -{ - @autoreleasepool { - NSString *printString; - if(y > 2) - printString = [[NSString alloc] init]; - else - printString = [[NSString alloc] init]; - NSLog(@"Once %@", printString); - [printString release]; - NSLog(@"Again: %@", printString); // expected-warning {{Reference-counted object is used after it is released}} - } -} - -id makeCollectableNonLeak() { - extern CFTypeRef CFCreateSomething(); - - CFTypeRef object = CFCreateSomething(); // +1 - CFRetain(object); // +2 - id objCObject = NSMakeCollectable(object); // +2 - [objCObject release]; // +1 - return [objCObject autorelease]; // +0 -} - - -void consumeAndStopTracking(id NS_CONSUMED obj, void (^callback)(void)); -void CFConsumeAndStopTracking(CFTypeRef CF_CONSUMED obj, void (^callback)(void)); - -void testConsumeAndStopTracking() { - id retained = [@[] retain]; // +1 - consumeAndStopTracking(retained, ^{}); // no-warning - - id doubleRetained = [[@[] retain] retain]; // +2 - consumeAndStopTracking(doubleRetained, ^{ - [doubleRetained release]; - }); // no-warning - - id unretained = @[]; // +0 - consumeAndStopTracking(unretained, ^{}); // expected-warning {{Incorrect decrement of the reference count of an object that is not owned at this point by the caller}} -} - -void testCFConsumeAndStopTracking() { - id retained = [@[] retain]; // +1 - CFConsumeAndStopTracking((CFTypeRef)retained, ^{}); // no-warning - - id doubleRetained = [[@[] retain] retain]; // +2 - CFConsumeAndStopTracking((CFTypeRef)doubleRetained, ^{ - [doubleRetained release]; - }); // no-warning - - id unretained = @[]; // +0 - CFConsumeAndStopTracking((CFTypeRef)unretained, ^{}); // expected-warning {{Incorrect decrement of the reference count of an object that is not owned at this point by the caller}} -} -//===----------------------------------------------------------------------===// -// Test 'pragma clang arc_cf_code_audited' support. -//===----------------------------------------------------------------------===// - -typedef void *MyCFType; -#pragma clang arc_cf_code_audited begin -MyCFType CreateMyCFType(); -#pragma clang arc_cf_code_audited end - -void test_custom_cf() { - MyCFType x = CreateMyCFType(); // expected-warning {{leak of an object stored into 'x'}} -} - -//===----------------------------------------------------------------------===// -// Test calling CFPlugInInstanceCreate, which appears in CF but doesn't -// return a CF object. -//===----------------------------------------------------------------------===// - -void test_CFPlugInInstanceCreate(CFUUIDRef factoryUUID, CFUUIDRef typeUUID) { - CFPlugInInstanceCreate(kCFAllocatorDefault, factoryUUID, typeUUID); // no-warning -} - -//===----------------------------------------------------------------------===// -// PR14927: -drain only has retain-count semantics on NSAutoreleasePool. -//===----------------------------------------------------------------------===// - -@interface PR14927 : NSObject -- (void)drain; -@end - -void test_drain() { - PR14927 *obj = [[PR14927 alloc] init]; - [obj drain]; - [obj release]; // no-warning -} - -//===----------------------------------------------------------------------===// -// Allow cf_returns_retained and cf_returns_not_retained to mark a return -// value as tracked, even if the object isn't a known CF type. -//===----------------------------------------------------------------------===// - -MyCFType getCustom() __attribute__((cf_returns_not_retained)); -MyCFType makeCustom() __attribute__((cf_returns_retained)); - -void testCustomReturnsRetained() { - MyCFType obj = makeCustom(); // expected-warning {{leak of an object stored into 'obj'}} -} - -void testCustomReturnsNotRetained() { - CFRelease(getCustom()); // expected-warning {{Incorrect decrement of the reference count of an object that is not owned at this point by the caller}} -} - -//===----------------------------------------------------------------------===// -// Don't print variables which are out of the current scope. -//===----------------------------------------------------------------------===// -@interface MyObj12706177 : NSObject --(id)initX; -+(void)test12706177; -@end -static int Cond; -@implementation MyObj12706177 --(id)initX { - if (Cond) - return 0; - self = [super init]; - return self; -} -+(void)test12706177 { - id x = [[MyObj12706177 alloc] initX]; //expected-warning {{Potential leak of an object}} - [x release]; -} -@end - -//===----------------------------------------------------------------------===// -// <rdar://problem/13783514> xpc_connection_set_finalizer_f -//===----------------------------------------------------------------------===// - -typedef xpc_object_t xpc_connection_t; -typedef void (*xpc_finalizer_t)(void *value); -void xpc_connection_set_context(xpc_connection_t connection, void *ctx); -void xpc_connection_set_finalizer_f(xpc_connection_t connection, - xpc_finalizer_t finalizer); -void releaseAfterXPC(void *context) { - [(NSArray *)context release]; -} - -void rdar13783514(xpc_connection_t connection) { - xpc_connection_set_context(connection, [[NSMutableArray alloc] init]); - xpc_connection_set_finalizer_f(connection, releaseAfterXPC); -} // no-warning - -CFAttributedStringRef CFAttributedCreate(void *CFObj CF_CONSUMED) CF_RETURNS_RETAINED; - -@interface Action -- (SEL)action; -- (void)setAction:(SEL)aSelector; -- (id) target; -- (void)setTarget:(id)aTarget; -@end diff --git a/test/ARCMT/objcmt-arc-cf-annotations.m.result b/test/ARCMT/objcmt-arc-cf-annotations.m.result deleted file mode 100644 index ac4794820eeb..000000000000 --- a/test/ARCMT/objcmt-arc-cf-annotations.m.result +++ /dev/null @@ -1,2109 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -fblocks -objcmt-migrate-annotation -objcmt-migrate-instancetype -objcmt-migrate-readwrite-property -mt-migrate-directory %t %s -x objective-c -triple x86_64-apple-darwin11 -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s.result - -#ifndef CF_IMPLICIT_BRIDGING_ENABLED -#if __has_feature(arc_cf_code_audited) -#define CF_IMPLICIT_BRIDGING_ENABLED _Pragma("clang arc_cf_code_audited begin") -#else -#define CF_IMPLICIT_BRIDGING_ENABLED -#endif -#endif - -#ifndef CF_IMPLICIT_BRIDGING_DISABLED -#if __has_feature(arc_cf_code_audited) -#define CF_IMPLICIT_BRIDGING_DISABLED _Pragma("clang arc_cf_code_audited end") -#else -#define CF_IMPLICIT_BRIDGING_DISABLED -#endif -#endif - -#if __has_feature(attribute_ns_returns_retained) -#define NS_RETURNS_RETAINED __attribute__((ns_returns_retained)) -#endif -#if __has_feature(attribute_cf_returns_retained) -#define CF_RETURNS_RETAINED __attribute__((cf_returns_retained)) -#endif -#if __has_feature(attribute_ns_returns_not_retained) -#define NS_RETURNS_NOT_RETAINED __attribute__((ns_returns_not_retained)) -#endif -#if __has_feature(attribute_cf_returns_not_retained) -#define CF_RETURNS_NOT_RETAINED __attribute__((cf_returns_not_retained)) -#endif -#if __has_feature(attribute_ns_consumes_self) -#define NS_CONSUMES_SELF __attribute__((ns_consumes_self)) -#endif -#if __has_feature(attribute_ns_consumed) -#define NS_CONSUMED __attribute__((ns_consumed)) -#endif -#if __has_feature(attribute_cf_consumed) -#define CF_CONSUMED __attribute__((cf_consumed)) -#endif -#if __has_attribute(ns_returns_autoreleased) -#define NS_RETURNS_AUTORELEASED __attribute__((ns_returns_autoreleased)) -#endif - -//===----------------------------------------------------------------------===// -// The following code is reduced using delta-debugging from Mac OS X headers: -// -// #include <Cocoa/Cocoa.h> -// #include <CoreFoundation/CoreFoundation.h> -// #include <DiskArbitration/DiskArbitration.h> -// #include <QuartzCore/QuartzCore.h> -// #include <Quartz/Quartz.h> -// #include <IOKit/IOKitLib.h> -// -// It includes the basic definitions for the test cases below. -//===----------------------------------------------------------------------===// - -typedef unsigned int __darwin_natural_t; -typedef unsigned long uintptr_t; -typedef unsigned int uint32_t; -typedef unsigned long long uint64_t; -typedef unsigned int UInt32; -typedef signed long CFIndex; -typedef CFIndex CFByteOrder; -typedef struct { - CFIndex location; - CFIndex length; -} CFRange; -static __inline__ __attribute__((always_inline)) CFRange CFRangeMake(CFIndex loc, CFIndex len) { - CFRange range; - range.location = loc; - range.length = len; - return range; -} -typedef const void * CFTypeRef; -typedef const struct __CFString * CFStringRef; -typedef const struct __CFAllocator * CFAllocatorRef; -extern const CFAllocatorRef kCFAllocatorDefault; -extern CFTypeRef CFRetain(CFTypeRef cf); - -CF_IMPLICIT_BRIDGING_ENABLED - -extern void CFRelease(CFTypeRef cf); - -CF_IMPLICIT_BRIDGING_DISABLED - -extern CFTypeRef CFMakeCollectable(CFTypeRef cf); -typedef struct { -} -CFArrayCallBacks; -extern const CFArrayCallBacks kCFTypeArrayCallBacks; -typedef const struct __CFArray * CFArrayRef; -typedef struct __CFArray * CFMutableArrayRef; -extern CFMutableArrayRef CFArrayCreateMutable(CFAllocatorRef allocator, CFIndex capacity, const CFArrayCallBacks *callBacks) CF_RETURNS_RETAINED; -extern const void *CFArrayGetValueAtIndex(CFArrayRef theArray, CFIndex idx) CF_RETURNS_NOT_RETAINED; -extern void CFArrayAppendValue(CFMutableArrayRef theArray, const void *value); -typedef struct { -} -CFDictionaryKeyCallBacks; -extern const CFDictionaryKeyCallBacks kCFTypeDictionaryKeyCallBacks; -typedef struct { -} -CFDictionaryValueCallBacks; -extern const CFDictionaryValueCallBacks kCFTypeDictionaryValueCallBacks; -typedef const struct __CFDictionary * CFDictionaryRef; -typedef struct __CFDictionary * CFMutableDictionaryRef; -extern CFMutableDictionaryRef CFDictionaryCreateMutable(CFAllocatorRef allocator, CFIndex capacity, const CFDictionaryKeyCallBacks *keyCallBacks, const CFDictionaryValueCallBacks *valueCallBacks) CF_RETURNS_RETAINED; -typedef UInt32 CFStringEncoding; -enum { -kCFStringEncodingMacRoman = 0, kCFStringEncodingWindowsLatin1 = 0x0500, kCFStringEncodingISOLatin1 = 0x0201, kCFStringEncodingNextStepLatin = 0x0B01, kCFStringEncodingASCII = 0x0600, kCFStringEncodingUnicode = 0x0100, kCFStringEncodingUTF8 = 0x08000100, kCFStringEncodingNonLossyASCII = 0x0BFF , kCFStringEncodingUTF16 = 0x0100, kCFStringEncodingUTF16BE = 0x10000100, kCFStringEncodingUTF16LE = 0x14000100, kCFStringEncodingUTF32 = 0x0c000100, kCFStringEncodingUTF32BE = 0x18000100, kCFStringEncodingUTF32LE = 0x1c000100 }; -extern CFStringRef CFStringCreateWithCString(CFAllocatorRef alloc, const char *cStr, CFStringEncoding encoding) CF_RETURNS_RETAINED; -typedef double CFTimeInterval; -typedef CFTimeInterval CFAbsoluteTime; -extern CFAbsoluteTime CFAbsoluteTimeGetCurrent(void); -typedef const struct __CFDate * CFDateRef; -extern CFDateRef CFDateCreate(CFAllocatorRef allocator, CFAbsoluteTime at) CF_RETURNS_RETAINED; -extern CFAbsoluteTime CFDateGetAbsoluteTime(CFDateRef theDate); -typedef __darwin_natural_t natural_t; -typedef natural_t mach_port_name_t; -typedef mach_port_name_t mach_port_t; -typedef int kern_return_t; -typedef kern_return_t mach_error_t; -enum { -kCFNumberSInt8Type = 1, kCFNumberSInt16Type = 2, kCFNumberSInt32Type = 3, kCFNumberSInt64Type = 4, kCFNumberFloat32Type = 5, kCFNumberFloat64Type = 6, kCFNumberCharType = 7, kCFNumberShortType = 8, kCFNumberIntType = 9, kCFNumberLongType = 10, kCFNumberLongLongType = 11, kCFNumberFloatType = 12, kCFNumberDoubleType = 13, kCFNumberCFIndexType = 14, kCFNumberNSIntegerType = 15, kCFNumberCGFloatType = 16, kCFNumberMaxType = 16 }; -typedef CFIndex CFNumberType; -typedef const struct __CFNumber * CFNumberRef; -extern CFNumberRef CFNumberCreate(CFAllocatorRef allocator, CFNumberType theType, const void *valuePtr) CF_RETURNS_RETAINED; -typedef const struct __CFAttributedString *CFAttributedStringRef; -typedef struct __CFAttributedString *CFMutableAttributedStringRef; -extern CFAttributedStringRef CFAttributedStringCreate(CFAllocatorRef alloc, CFStringRef str, CFDictionaryRef attributes) CF_RETURNS_RETAINED ; -extern CFMutableAttributedStringRef CFAttributedStringCreateMutableCopy(CFAllocatorRef alloc, CFIndex maxLength, CFAttributedStringRef aStr) CF_RETURNS_RETAINED ; -extern void CFAttributedStringSetAttribute(CFMutableAttributedStringRef aStr, CFRange range, CFStringRef attrName, CFTypeRef value) ; -typedef signed char BOOL; -typedef unsigned long NSUInteger; -@class NSString, Protocol; -extern void NSLog(NSString *format, ...) __attribute__((format(__NSString__, 1, 2))); -typedef struct _NSZone NSZone; -@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator; -@protocol NSObject -- (BOOL)isEqual:(id)object; -- (id)retain; -- (oneway void)release; -- (id)autorelease; -- (NSString *)description; -- (instancetype)init; -@end -@protocol NSCopying -- (id)copyWithZone:(NSZone *)zone; -@end -@protocol NSMutableCopying - (id)mutableCopyWithZone:(NSZone *)zone; -@end -@protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder; -@end -@interface NSObject <NSObject> {} -+ (id)allocWithZone:(NSZone *)zone; -+ (id)alloc; -+ (id)new; -- (void)dealloc; -@end -@interface NSObject (NSCoderMethods) -- (id)awakeAfterUsingCoder:(NSCoder *)aDecoder; -@end -extern id NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone); -typedef struct { -} -NSFastEnumerationState; -@protocol NSFastEnumeration -- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len; -@end -@class NSString, NSDictionary; -@interface NSValue : NSObject <NSCopying, NSCoding> - (void)getValue:(void *)value; -@end -@interface NSNumber : NSValue -- (char)charValue; -- (instancetype)initWithInt:(int)value; -+ (NSNumber *)numberWithInt:(int)value; -@end -@class NSString; -@interface NSArray : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration> -- (NSUInteger)count; -- (instancetype)initWithObjects:(const id [])objects count:(NSUInteger)cnt; -+ (instancetype)arrayWithObject:(id)anObject; -+ (instancetype)arrayWithObjects:(const id [])objects count:(NSUInteger)cnt; -+ (instancetype)arrayWithObjects:(id)firstObj, ... __attribute__((sentinel(0,1))); -- (instancetype)initWithObjects:(id)firstObj, ... __attribute__((sentinel(0,1))); -- (instancetype)initWithArray:(NSArray *)array; -@end @interface NSArray (NSArrayCreation) + (instancetype)array; -@end @interface NSAutoreleasePool : NSObject { -} -- (void)drain; -@end extern NSString * const NSBundleDidLoadNotification; -typedef double NSTimeInterval; -@interface NSDate : NSObject <NSCopying, NSCoding> - (NSTimeInterval)timeIntervalSinceReferenceDate; -@end typedef unsigned short unichar; -@interface NSString : NSObject <NSCopying, NSMutableCopying, NSCoding> -- (NSUInteger)length; -- (NSString *)stringByAppendingString:(NSString *)aString; -- ( const char *)UTF8String; -- (instancetype)initWithUTF8String:(const char *)nullTerminatedCString; -+ (instancetype)stringWithUTF8String:(const char *)nullTerminatedCString; -@end @class NSString, NSURL, NSError; -@interface NSData : NSObject <NSCopying, NSMutableCopying, NSCoding> - (NSUInteger)length; -+ (instancetype)dataWithBytesNoCopy:(void *)bytes length:(NSUInteger)length; -+ (instancetype)dataWithBytesNoCopy:(void *)bytes length:(NSUInteger)length freeWhenDone:(BOOL)b; -@end @class NSLocale, NSDate, NSCalendar, NSTimeZone, NSError, NSArray, NSMutableDictionary; -@interface NSDictionary : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration> -- (NSUInteger)count; -+ (instancetype)dictionaryWithObjects:(NSArray *)objects forKeys:(NSArray *)keys; -+ (instancetype)dictionaryWithObjects:(const id [])objects forKeys:(const id <NSCopying> [])keys count:(NSUInteger)cnt; -@end -@interface NSMutableDictionary : NSDictionary - (void)removeObjectForKey:(id)aKey; -- (void)setObject:(id)anObject forKey:(id)aKey; -@end @interface NSMutableDictionary (NSMutableDictionaryCreation) + (instancetype)dictionaryWithCapacity:(NSUInteger)numItems; -@end typedef double CGFloat; -struct CGSize { -}; -typedef struct CGSize CGSize; -struct CGRect { -}; -typedef struct CGRect CGRect; -typedef mach_port_t io_object_t; -typedef char io_name_t[128]; -typedef io_object_t io_iterator_t; -typedef io_object_t io_service_t; -typedef struct IONotificationPort * IONotificationPortRef; -typedef void (*IOServiceMatchingCallback)( void * refcon, io_iterator_t iterator ); - -CF_IMPLICIT_BRIDGING_ENABLED - -io_service_t IOServiceGetMatchingService( mach_port_t masterPort, CFDictionaryRef matching ); -kern_return_t IOServiceGetMatchingServices( mach_port_t masterPort, CFDictionaryRef matching, io_iterator_t * existing ); - -CF_IMPLICIT_BRIDGING_DISABLED - -kern_return_t IOServiceAddNotification( mach_port_t masterPort, const io_name_t notificationType, CFDictionaryRef matching, mach_port_t wakePort, uintptr_t reference, io_iterator_t * notification ) __attribute__((deprecated)); // expected-note {{'IOServiceAddNotification' declared here}} -kern_return_t IOServiceAddMatchingNotification( IONotificationPortRef notifyPort, const io_name_t notificationType, CFDictionaryRef CF_CONSUMED matching, IOServiceMatchingCallback callback, void * refCon, io_iterator_t * notification ); - -CF_IMPLICIT_BRIDGING_ENABLED - -CFMutableDictionaryRef IOServiceMatching( const char * name ); -CFMutableDictionaryRef IOServiceNameMatching( const char * name ); -CFMutableDictionaryRef IOBSDNameMatching( mach_port_t masterPort, uint32_t options, const char * bsdName ); -CFMutableDictionaryRef IOOpenFirmwarePathMatching( mach_port_t masterPort, uint32_t options, const char * path ); -CFMutableDictionaryRef IORegistryEntryIDMatching( uint64_t entryID ); - -CF_IMPLICIT_BRIDGING_DISABLED - -typedef struct __DASession * DASessionRef; -extern DASessionRef DASessionCreate( CFAllocatorRef allocator ) CF_RETURNS_RETAINED; -typedef struct __DADisk * DADiskRef; -extern DADiskRef DADiskCreateFromBSDName( CFAllocatorRef allocator, DASessionRef session, const char * name ) CF_RETURNS_RETAINED; -extern DADiskRef DADiskCreateFromIOMedia( CFAllocatorRef allocator, DASessionRef session, io_service_t media ) CF_RETURNS_RETAINED; -extern CFDictionaryRef DADiskCopyDescription( DADiskRef disk ) CF_RETURNS_RETAINED; -extern DADiskRef DADiskCopyWholeDisk( DADiskRef disk ) CF_RETURNS_RETAINED; -@interface NSTask : NSObject - (instancetype)init; -@end typedef struct CGColorSpace *CGColorSpaceRef; -typedef struct CGImage *CGImageRef; -typedef struct CGLayer *CGLayerRef; -@interface NSResponder : NSObject <NSCoding> { -} -@end @protocol NSAnimatablePropertyContainer - (id)animator; -@end extern NSString *NSAnimationTriggerOrderIn ; -@interface NSView : NSResponder <NSAnimatablePropertyContainer> { -} -@end @protocol NSValidatedUserInterfaceItem - (SEL)action; -@end @protocol NSUserInterfaceValidations - (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)anItem; -@end @class NSDate, NSDictionary, NSError, NSException, NSNotification; -@class NSTextField, NSPanel, NSArray, NSWindow, NSImage, NSButton, NSError; -@interface NSApplication : NSResponder <NSUserInterfaceValidations> { -} -- (void)beginSheet:(NSWindow *)sheet modalForWindow:(NSWindow *)docWindow modalDelegate:(id)modalDelegate didEndSelector:(SEL)didEndSelector contextInfo:(void *)contextInfo; -@end enum { -NSTerminateCancel = 0, NSTerminateNow = 1, NSTerminateLater = 2 }; -typedef NSUInteger NSApplicationTerminateReply; -@protocol NSApplicationDelegate <NSObject> @optional - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender; -@end @class NSAttributedString, NSEvent, NSFont, NSFormatter, NSImage, NSMenu, NSText, NSView, NSTextView; -@interface NSCell : NSObject <NSCopying, NSCoding> { -} -@end -typedef struct { -} -CVTimeStamp; -@interface CIImage : NSObject <NSCoding, NSCopying> { -} -typedef int CIFormat; -@end enum { -kDAReturnSuccess = 0, kDAReturnError = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x01, kDAReturnBusy = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x02, kDAReturnBadArgument = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x03, kDAReturnExclusiveAccess = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x04, kDAReturnNoResources = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x05, kDAReturnNotFound = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x06, kDAReturnNotMounted = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x07, kDAReturnNotPermitted = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x08, kDAReturnNotPrivileged = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x09, kDAReturnNotReady = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x0A, kDAReturnNotWritable = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x0B, kDAReturnUnsupported = (((0x3eU)&0x3f)<<26) | (((0x368)&0xfff)<<14) | 0x0C }; -typedef mach_error_t DAReturn; -typedef const struct __DADissenter * DADissenterRef; -extern DADissenterRef DADissenterCreate( CFAllocatorRef allocator, DAReturn status, CFStringRef string ) CF_RETURNS_RETAINED; -@interface CIContext: NSObject { -} -- (CGImageRef)createCGImage:(CIImage *)im fromRect:(CGRect)r CF_RETURNS_RETAINED; -- (CGImageRef)createCGImage:(CIImage *)im fromRect:(CGRect)r format:(CIFormat)f colorSpace:(CGColorSpaceRef)cs CF_RETURNS_RETAINED; -- (CGLayerRef)createCGLayerWithSize:(CGSize)size info:(CFDictionaryRef)d CF_RETURNS_RETAINED; -@end extern NSString* const QCRendererEventKey; -@protocol QCCompositionRenderer - (NSDictionary*) attributes; -@end @interface QCRenderer : NSObject <QCCompositionRenderer> { -} -- (id) createSnapshotImageOfType:(NSString*)type NS_RETURNS_RETAINED; -@end extern NSString* const QCViewDidStartRenderingNotification; -@interface QCView : NSView <QCCompositionRenderer> { -} -- (id) createSnapshotImageOfType:(NSString*)type NS_RETURNS_RETAINED; -@end enum { -ICEXIFOrientation1 = 1, ICEXIFOrientation2 = 2, ICEXIFOrientation3 = 3, ICEXIFOrientation4 = 4, ICEXIFOrientation5 = 5, ICEXIFOrientation6 = 6, ICEXIFOrientation7 = 7, ICEXIFOrientation8 = 8, }; -@class ICDevice; -@protocol ICDeviceDelegate <NSObject> @required - (void)didRemoveDevice:(ICDevice*)device; -@end extern NSString *const ICScannerStatusWarmingUp; -@class ICScannerDevice; -@protocol ICScannerDeviceDelegate <ICDeviceDelegate> @optional - (void)scannerDeviceDidBecomeAvailable:(ICScannerDevice*)scanner; -@end - -typedef long unsigned int __darwin_size_t; -typedef __darwin_size_t size_t; -typedef unsigned long CFTypeID; -struct CGPoint { - CGFloat x; - CGFloat y; -}; -typedef struct CGPoint CGPoint; -typedef struct CGGradient *CGGradientRef; -typedef uint32_t CGGradientDrawingOptions; -extern CFTypeID CGGradientGetTypeID(void); -extern CGGradientRef CGGradientCreateWithColorComponents(CGColorSpaceRef - space, const CGFloat components[], const CGFloat locations[], size_t count) CF_RETURNS_RETAINED; -extern CGGradientRef CGGradientCreateWithColors(CGColorSpaceRef space, - CFArrayRef colors, const CGFloat locations[]) CF_RETURNS_RETAINED; -extern CGGradientRef CGGradientRetain(CGGradientRef gradient); - -CF_IMPLICIT_BRIDGING_ENABLED - -extern void CGGradientRelease(CGGradientRef gradient); - -CF_IMPLICIT_BRIDGING_DISABLED - -typedef struct CGContext *CGContextRef; -extern void CGContextDrawLinearGradient(CGContextRef context, - CGGradientRef gradient, CGPoint startPoint, CGPoint endPoint, - CGGradientDrawingOptions options); - -CF_IMPLICIT_BRIDGING_ENABLED - -extern CGColorSpaceRef CGColorSpaceCreateDeviceRGB(void); - -CF_IMPLICIT_BRIDGING_DISABLED - - -@interface NSMutableArray : NSObject -- (void)addObject:(id)object; -+ (instancetype)array; -@end - -// This is how NSMakeCollectable is declared in the OS X 10.8 headers. -id NSMakeCollectable(CFTypeRef __attribute__((cf_consumed))) __attribute__((ns_returns_retained)); - -typedef const struct __CFUUID * CFUUIDRef; - -extern -void *CFPlugInInstanceCreate(CFAllocatorRef allocator, CFUUIDRef factoryUUID, CFUUIDRef typeUUID); - -//===----------------------------------------------------------------------===// -// Test cases. -//===----------------------------------------------------------------------===// - -CFAbsoluteTime f1() { - CFAbsoluteTime t = CFAbsoluteTimeGetCurrent(); - CFDateRef date = CFDateCreate(0, t); - CFRetain(date); - CFRelease(date); - CFDateGetAbsoluteTime(date); // no-warning - CFRelease(date); - t = CFDateGetAbsoluteTime(date); // expected-warning{{Reference-counted object is used after it is released}} - return t; -} - -CFAbsoluteTime f2() { - CFAbsoluteTime t = CFAbsoluteTimeGetCurrent(); - CFDateRef date = CFDateCreate(0, t); - [((NSDate*) date) retain]; - CFRelease(date); - CFDateGetAbsoluteTime(date); // no-warning - [((NSDate*) date) release]; - t = CFDateGetAbsoluteTime(date); // expected-warning{{Reference-counted object is used after it is released}} - return t; -} - - -NSDate* global_x; - -// Test to see if we suppress an error when we store the pointer -// to a global. - -CFAbsoluteTime f3() { - CFAbsoluteTime t = CFAbsoluteTimeGetCurrent(); - CFDateRef date = CFDateCreate(0, t); - [((NSDate*) date) retain]; - CFRelease(date); - CFDateGetAbsoluteTime(date); // no-warning - global_x = (NSDate*) date; - [((NSDate*) date) release]; - t = CFDateGetAbsoluteTime(date); // no-warning - return t; -} - -//--------------------------------------------------------------------------- -// Test case 'f4' differs for region store and basic store. See -// retain-release-region-store.m and retain-release-basic-store.m. -//--------------------------------------------------------------------------- - -// Test a leak. - -CFAbsoluteTime f5(int x) { - CFAbsoluteTime t = CFAbsoluteTimeGetCurrent(); - CFDateRef date = CFDateCreate(0, t); // expected-warning{{leak}} - - if (x) - CFRelease(date); - - return t; -} - -// Test a leak involving the return. - -CFDateRef f6(int x) { - CFDateRef date = CFDateCreate(0, CFAbsoluteTimeGetCurrent()); // expected-warning{{leak}} - CFRetain(date); - return date; -} - -// Test a leak involving an overwrite. - -CFDateRef f7() { - CFDateRef date = CFDateCreate(0, CFAbsoluteTimeGetCurrent()); //expected-warning{{leak}} - CFRetain(date); - date = CFDateCreate(0, CFAbsoluteTimeGetCurrent()); // expected-warning {{leak}} - return date; -} - -// Generalization of Create rule. MyDateCreate returns a CFXXXTypeRef, and -// has the word create. - -CF_IMPLICIT_BRIDGING_ENABLED - -CFDateRef MyDateCreate(); - -CF_IMPLICIT_BRIDGING_DISABLED - - -CFDateRef f8() { - CFDateRef date = MyDateCreate(); // expected-warning{{leak}} - CFRetain(date); - return date; -} - -__attribute__((cf_returns_retained)) CFDateRef f9() { - CFDateRef date = CFDateCreate(0, CFAbsoluteTimeGetCurrent()); // no-warning - int *p = 0; - // When allocations fail, CFDateCreate can return null. - if (!date) *p = 1; // expected-warning{{null}} - return date; -} - -// Handle DiskArbitration API: -// -// http://developer.apple.com/DOCUMENTATION/DARWIN/Reference/DiscArbitrationFramework/ -// -void f10(io_service_t media, DADiskRef d, CFStringRef s) { - DADiskRef disk = DADiskCreateFromBSDName(kCFAllocatorDefault, 0, "hello"); // expected-warning{{leak}} - if (disk) NSLog(@"ok"); - - disk = DADiskCreateFromIOMedia(kCFAllocatorDefault, 0, media); // expected-warning{{leak}} - if (disk) NSLog(@"ok"); - - CFDictionaryRef dict = DADiskCopyDescription(d); // expected-warning{{leak}} - if (dict) NSLog(@"ok"); - - disk = DADiskCopyWholeDisk(d); // expected-warning{{leak}} - if (disk) NSLog(@"ok"); - - DADissenterRef dissenter = DADissenterCreate(kCFAllocatorDefault, // expected-warning{{leak}} - kDAReturnSuccess, s); - if (dissenter) NSLog(@"ok"); - - DASessionRef session = DASessionCreate(kCFAllocatorDefault); // expected-warning{{leak}} - if (session) NSLog(@"ok"); -} - -// Test retain/release checker with CFString and CFMutableArray. -void f11() { - // Create the array. - CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); - - // Create a string. - CFStringRef s1 = CFStringCreateWithCString(0, "hello world", - kCFStringEncodingUTF8); - - // Add the string to the array. - CFArrayAppendValue(A, s1); - - // Decrement the reference count. - CFRelease(s1); // no-warning - - // Get the string. We don't own it. - s1 = (CFStringRef) CFArrayGetValueAtIndex(A, 0); - - // Release the array. - CFRelease(A); // no-warning - - // Release the string. This is a bug. - CFRelease(s1); // expected-warning{{Incorrect decrement of the reference count}} -} - -// PR 3337: Handle functions declared using typedefs. -typedef CFTypeRef CREATEFUN(); - -CF_IMPLICIT_BRIDGING_ENABLED - -CFTypeRef MyCreateFun(); - -CF_IMPLICIT_BRIDGING_DISABLED - - -void f12() { - CFTypeRef o = MyCreateFun(); // expected-warning {{leak}} -} - -void f13_autorelease() { - CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning - [(id) A autorelease]; // no-warning -} - -void f13_autorelease_b() { - CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); - [(id) A autorelease]; - [(id) A autorelease]; -} // expected-warning{{Object autoreleased too many times}} - -CFMutableArrayRef f13_autorelease_c() { - CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); - [(id) A autorelease]; - [(id) A autorelease]; - return A; // expected-warning{{Object autoreleased too many times}} -} - -CFMutableArrayRef f13_autorelease_d() { - CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); - [(id) A autorelease]; - [(id) A autorelease]; - CFMutableArrayRef B = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // expected-warning{{Object autoreleased too many times}} - CFRelease(B); // no-warning - while (1) {} -} - - -// This case exercises the logic where the leak site is the same as the allocation site. -void f14_leakimmediately() { - CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // expected-warning{{leak}} -} - -// Test that we track an allocated object beyond the point where the *name* -// of the variable storing the reference is no longer live. -void f15() { - // Create the array. - CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); - CFMutableArrayRef *B = &A; - // At this point, the name 'A' is no longer live. - CFRelease(*B); // no-warning -} - -// Test when we pass NULL to CFRetain/CFRelease/CFMakeCollectable/CFAutorelease. -void f16(int x, CFTypeRef p) { - if (p) - return; - - switch (x) { - case 0: - CFRelease(p); - break; - case 1: - CFRetain(p); - break; - case 2: - CFMakeCollectable(p); - break; - case 3: - CFAutorelease(p); - break; - default: - break; - } -} - -// Test that an object is non-null after CFRetain/CFRelease/CFMakeCollectable/CFAutorelease. -void f17(int x, CFTypeRef p) { - switch (x) { - case 0: - CFRelease(p); - if (!p) - CFRelease(0); // no-warning - break; - case 1: - CFRetain(p); - if (!p) - CFRetain(0); // no-warning - break; - case 2: - CFMakeCollectable(p); - if (!p) - CFMakeCollectable(0); // no-warning - break; - case 3: - CFAutorelease(p); - if (!p) - CFAutorelease(0); // no-warning - break; - default: - break; - } -} - -// Test basic tracking of ivars associated with 'self'. For the retain/release -// checker we currently do not want to flag leaks associated with stores -// of tracked objects to ivars. -@interface SelfIvarTest : NSObject { - id myObj; -} -- (void)test_self_tracking; -@end - -@implementation SelfIvarTest -- (void)test_self_tracking { - myObj = (id) CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning -} -@end - -// Test return of non-owned objects in contexts where an owned object -// is expected. -@interface TestReturnNotOwnedWhenExpectedOwned -- (NSString*)newString; -@end - -@implementation TestReturnNotOwnedWhenExpectedOwned -- (NSString*)newString { - NSString *s = [NSString stringWithUTF8String:"hello"]; - return s; // expected-warning{{Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected}} -} -@end - -// <rdar://problem/6659160> -int isFoo(char c); - -static void rdar_6659160(char *inkind, char *inname) -{ - // We currently expect that [NSObject alloc] cannot fail. This - // will be a toggled flag in the future. It can indeed return null, but - // Cocoa programmers generally aren't expected to reason about out-of-memory - // conditions. - NSString *kind = [[NSString alloc] initWithUTF8String:inkind]; // expected-warning{{leak}} - - // We do allow stringWithUTF8String to fail. This isn't really correct, as - // far as returning 0. In most error conditions it will throw an exception. - // If allocation fails it could return 0, but again this - // isn't expected. - NSString *name = [NSString stringWithUTF8String:inname]; - if(!name) - return; - - const char *kindC = 0; - const char *nameC = 0; - - // In both cases, we cannot reach a point down below where we - // dereference kindC or nameC with either being null. This is because - // we assume that [NSObject alloc] doesn't fail and that we have the guard - // up above. - - if(kind) - kindC = [kind UTF8String]; - if(name) - nameC = [name UTF8String]; - if(!isFoo(kindC[0])) // expected-warning{{null}} - return; - if(!isFoo(nameC[0])) // no-warning - return; - - [kind release]; - [name release]; // expected-warning{{Incorrect decrement of the reference count}} -} - -// PR 3677 - 'allocWithZone' should be treated as following the Cocoa naming -// conventions with respect to 'return'ing ownership. -@interface PR3677: NSObject @end -@implementation PR3677 -+ (id)allocWithZone:(NSZone *)inZone { - return [super allocWithZone:inZone]; // no-warning -} -@end - -// PR 3820 - Reason about calls to -dealloc -void pr3820_DeallocInsteadOfRelease(void) -{ - id foo = [[NSString alloc] init]; // no-warning - [foo dealloc]; - // foo is not leaked, since it has been deallocated. -} - -void pr3820_ReleaseAfterDealloc(void) -{ - id foo = [[NSString alloc] init]; - [foo dealloc]; - [foo release]; // expected-warning{{used after it is release}} - // NSInternalInconsistencyException: message sent to deallocated object -} - -void pr3820_DeallocAfterRelease(void) -{ - NSLog(@"\n\n[%s]", __FUNCTION__); - id foo = [[NSString alloc] init]; - [foo release]; - [foo dealloc]; // expected-warning{{used after it is released}} - // message sent to released object -} - -// From <rdar://problem/6704930>. The problem here is that 'length' binds to -// '($0 - 1)' after '--length', but SimpleConstraintManager doesn't know how to -// reason about '($0 - 1) > constant'. As a temporary hack, we drop the value -// of '($0 - 1)' and conjure a new symbol. -void rdar6704930(unsigned char *s, unsigned int length) { - NSString* name = 0; - if (s != 0) { - if (length > 0) { - while (length > 0) { - if (*s == ':') { - ++s; - --length; - name = [[NSString alloc] init]; // no-warning - break; - } - ++s; - --length; - } - if ((length == 0) && (name != 0)) { - [name release]; - name = 0; - } - if (length == 0) { // no ':' found -> use it all as name - name = [[NSString alloc] init]; // no-warning - } - } - } - - if (name != 0) { - [name release]; - } -} - -//===----------------------------------------------------------------------===// -// <rdar://problem/6833332> -// One build of the analyzer accidentally stopped tracking the allocated -// object after the 'retain'. -//===----------------------------------------------------------------------===// - -@interface rdar_6833332 : NSObject <NSApplicationDelegate> { - NSWindow *window; -} -@property (nonatomic, retain) NSWindow *window; -@end - -@implementation rdar_6833332 -@synthesize window; -- (void)applicationDidFinishLaunching:(NSNotification *)aNotification { - NSMutableDictionary *dict = [[NSMutableDictionary dictionaryWithCapacity:4] retain]; // expected-warning{{leak}} - - [dict setObject:@"foo" forKey:@"bar"]; - - NSLog(@"%@", dict); -} -- (void)dealloc { - [window release]; - [super dealloc]; -} - -- (void)radar10102244 { - NSMutableDictionary *dict = [[NSMutableDictionary dictionaryWithCapacity:4] retain]; // expected-warning{{leak}} - if (window) - NSLog(@"%@", window); -} -@end - -//===----------------------------------------------------------------------===// -// <rdar://problem/6257780> clang checker fails to catch use-after-release -//===----------------------------------------------------------------------===// - -int rdar_6257780_Case1() { - NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; - NSArray *array = [NSArray array]; - [array release]; // expected-warning{{Incorrect decrement of the reference count of an object that is not owned at this point by the caller}} - [pool drain]; - return 0; -} - -//===----------------------------------------------------------------------===// -// <rdar://problem/10640253> Analyzer is confused about NSAutoreleasePool -allocWithZone:. -//===----------------------------------------------------------------------===// - -void rdar_10640253_autorelease_allocWithZone() { - NSAutoreleasePool *pool = [[NSAutoreleasePool allocWithZone:(NSZone*)0] init]; - (void) pool; -} - -//===----------------------------------------------------------------------===// -// <rdar://problem/6866843> Checker should understand new/setObject:/release constructs -//===----------------------------------------------------------------------===// - -void rdar_6866843() { - NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; - NSMutableDictionary* dictionary = [[NSMutableDictionary alloc] init]; - NSArray* array = [[NSArray alloc] init]; - [dictionary setObject:array forKey:@"key"]; - [array release]; - // Using 'array' here should be fine - NSLog(@"array = %@\n", array); // no-warning - // Now the array is released - [dictionary release]; - [pool drain]; -} - - -//===----------------------------------------------------------------------===// -// <rdar://problem/6877235> Classes typedef-ed to CF objects should get the same treatment as CF objects -//===----------------------------------------------------------------------===// - -typedef CFTypeRef OtherRef; - -@interface RDar6877235 : NSObject {} -- (CFTypeRef)_copyCFTypeRef CF_RETURNS_RETAINED; -- (OtherRef)_copyOtherRef CF_RETURNS_RETAINED; -@end - -@implementation RDar6877235 -- (CFTypeRef)_copyCFTypeRef { - return [[NSString alloc] init]; // no-warning -} -- (OtherRef)_copyOtherRef { - return [[NSString alloc] init]; // no-warning -} -@end - -//===----------------------------------------------------------------------===// -// <rdar://problem/6320065> false positive - init method returns an object -// owned by caller -//===----------------------------------------------------------------------===// - -@interface RDar6320065 : NSObject { - NSString *_foo; -} -- (instancetype)initReturningNewClass; -- (id)_initReturningNewClassBad; -- (instancetype)initReturningNewClassBad2; -@end - -@interface RDar6320065Subclass : RDar6320065 -@end - -@implementation RDar6320065 -- (instancetype)initReturningNewClass { - [self release]; - self = [[RDar6320065Subclass alloc] init]; // no-warning - return self; -} -- (id)_initReturningNewClassBad { - [self release]; - [[RDar6320065Subclass alloc] init]; // expected-warning {{leak}} - return self; -} -- (instancetype)initReturningNewClassBad2 { - [self release]; - self = [[RDar6320065Subclass alloc] init]; - return [self autorelease]; // expected-warning{{Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected}} -} - -@end - -@implementation RDar6320065Subclass -@end - -int RDar6320065_test() { - RDar6320065 *test = [[RDar6320065 alloc] init]; // no-warning - [test release]; - return 0; -} - -//===----------------------------------------------------------------------===// -// <rdar://problem/7129086> -awakeAfterUsingCoder: returns an owned object -// and claims the receiver -//===----------------------------------------------------------------------===// - -@interface RDar7129086 : NSObject {} @end -@implementation RDar7129086 -- (id)awakeAfterUsingCoder:(NSCoder *)aDecoder { - [self release]; // no-warning - return [NSString alloc]; // no-warning -} -@end - -//===----------------------------------------------------------------------===// -// <rdar://problem/6859457> [NSData dataWithBytesNoCopy] does not return a -// retained object -//===----------------------------------------------------------------------===// - -@interface RDar6859457 : NSObject {} -- (NSString*) NoCopyString; -- (NSString*) noCopyString; -@end - -@implementation RDar6859457 -- (NSString*) NoCopyString { return [[NSString alloc] init]; } // expected-warning{{leak}} -- (NSString*) noCopyString { return [[NSString alloc] init]; } // expected-warning{{leak}} -@end - -void test_RDar6859457(RDar6859457 *x, void *bytes, NSUInteger dataLength) { - [x NoCopyString]; // expected-warning{{leak}} - [x noCopyString]; // expected-warning{{leak}} - [NSData dataWithBytesNoCopy:bytes length:dataLength]; // no-warning - [NSData dataWithBytesNoCopy:bytes length:dataLength freeWhenDone:1]; // no-warning -} - -//===----------------------------------------------------------------------===// -// PR 4230 - an autorelease pool is not necessarily leaked during a premature -// return -//===----------------------------------------------------------------------===// - -static void PR4230(void) -{ - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; // no-warning - NSString *object = [[[NSString alloc] init] autorelease]; // no-warning - return; -} - -static void PR4230_new(void) -{ - NSAutoreleasePool *pool = [NSAutoreleasePool new]; // no-warning - NSString *object = [[[NSString alloc] init] autorelease]; // no-warning - return; -} - -//===----------------------------------------------------------------------===// -// Method name that has a null IdentifierInfo* for its first selector slot. -// This test just makes sure that we handle it. -//===----------------------------------------------------------------------===// - -@interface TestNullIdentifier -@end - -@implementation TestNullIdentifier -+ (id):(int)x, ... { - return [[NSString alloc] init]; // expected-warning{{leak}} -} -@end - -//===----------------------------------------------------------------------===// -// <rdar://problem/6893565> don't flag leaks for return types that cannot be -// determined to be CF types -//===----------------------------------------------------------------------===// - -// We don't know if 'struct s6893565' represents a Core Foundation type, so -// we shouldn't emit an error here. -typedef struct s6893565* TD6893565; - -@interface RDar6893565 {} --(TD6893565)newThing; -@end - -@implementation RDar6893565 --(TD6893565)newThing { - return (TD6893565) [[NSString alloc] init]; // no-warning -} -@end - -//===----------------------------------------------------------------------===// -// <rdar://problem/6902710> clang: false positives w/QC and CoreImage methods -//===----------------------------------------------------------------------===// - -void rdar6902710(QCView *view, QCRenderer *renderer, CIContext *context, - NSString *str, CIImage *img, CGRect rect, - CIFormat form, CGColorSpaceRef cs) { - [view createSnapshotImageOfType:str]; // expected-warning{{leak}} - [renderer createSnapshotImageOfType:str]; // expected-warning{{leak}} - [context createCGImage:img fromRect:rect]; // expected-warning{{leak}} - [context createCGImage:img fromRect:rect format:form colorSpace:cs]; // expected-warning{{leak}} -} - -//===----------------------------------------------------------------------===// -// <rdar://problem/6945561> -[CIContext createCGLayerWithSize:info:] -// misinterpreted by clang scan-build -//===----------------------------------------------------------------------===// - -void rdar6945561(CIContext *context, CGSize size, CFDictionaryRef d) { - [context createCGLayerWithSize:size info:d]; // expected-warning{{leak}} -} - -//===----------------------------------------------------------------------===// -// <rdar://problem/6961230> add knowledge of IOKit functions to retain/release -// checker -//===----------------------------------------------------------------------===// - -void IOBSDNameMatching_wrapper(mach_port_t masterPort, uint32_t options, const char * bsdName) { - IOBSDNameMatching(masterPort, options, bsdName); // expected-warning{{leak}} -} - -void IOServiceMatching_wrapper(const char * name) { - IOServiceMatching(name); // expected-warning{{leak}} -} - -void IOServiceNameMatching_wrapper(const char * name) { - IOServiceNameMatching(name); // expected-warning{{leak}} -} - -CF_RETURNS_RETAINED CFDictionaryRef CreateDict(); - -void IOServiceAddNotification_wrapper(mach_port_t masterPort, const io_name_t notificationType, - mach_port_t wakePort, uintptr_t reference, io_iterator_t * notification ) { - - CFDictionaryRef matching = CreateDict(); - CFRelease(matching); - IOServiceAddNotification(masterPort, notificationType, matching, // expected-warning{{used after it is released}} expected-warning{{deprecated}} - wakePort, reference, notification); -} - -void IORegistryEntryIDMatching_wrapper(uint64_t entryID ) { - IORegistryEntryIDMatching(entryID); // expected-warning{{leak}} -} - -void IOOpenFirmwarePathMatching_wrapper(mach_port_t masterPort, uint32_t options, - const char * path) { - IOOpenFirmwarePathMatching(masterPort, options, path); // expected-warning{{leak}} -} - -void IOServiceGetMatchingService_wrapper(mach_port_t masterPort) { - CFDictionaryRef matching = CreateDict(); - IOServiceGetMatchingService(masterPort, matching); - CFRelease(matching); // expected-warning{{used after it is released}} -} - -void IOServiceGetMatchingServices_wrapper(mach_port_t masterPort, io_iterator_t *existing) { - CFDictionaryRef matching = CreateDict(); - IOServiceGetMatchingServices(masterPort, matching, existing); - CFRelease(matching); // expected-warning{{used after it is released}} -} - -void IOServiceAddMatchingNotification_wrapper(IONotificationPortRef notifyPort, const io_name_t notificationType, - IOServiceMatchingCallback callback, void * refCon, io_iterator_t * notification) { - - CFDictionaryRef matching = CreateDict(); - IOServiceAddMatchingNotification(notifyPort, notificationType, matching, callback, refCon, notification); - CFRelease(matching); // expected-warning{{used after it is released}} -} - -//===----------------------------------------------------------------------===// -// Test of handling objects whose references "escape" to containers. -//===----------------------------------------------------------------------===// - -void CFDictionaryAddValue(CFMutableDictionaryRef, void *, void *); - -// <rdar://problem/6539791> -void rdar_6539791(CFMutableDictionaryRef y, void* key, void* val_key) { - CFMutableDictionaryRef x = CFDictionaryCreateMutable(kCFAllocatorDefault, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); - CFDictionaryAddValue(y, key, x); - CFRelease(x); // the dictionary keeps a reference, so the object isn't deallocated yet - signed z = 1; - CFNumberRef value = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &z); - if (value) { - CFDictionaryAddValue(x, val_key, (void*)value); // no-warning - CFRelease(value); - CFDictionaryAddValue(y, val_key, (void*)value); // no-warning - } -} - -// <rdar://problem/6560661> -// Same issue, except with "AppendValue" functions. -void rdar_6560661(CFMutableArrayRef x) { - signed z = 1; - CFNumberRef value = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &z); - // CFArrayAppendValue keeps a reference to value. - CFArrayAppendValue(x, value); - CFRelease(value); - CFRetain(value); - CFRelease(value); // no-warning -} - -// <rdar://problem/7152619> -// Same issue, excwept with "CFAttributeStringSetAttribute". -void rdar_7152619(CFStringRef str) { - CFAttributedStringRef string = CFAttributedStringCreate(kCFAllocatorDefault, str, 0); - CFMutableAttributedStringRef attrString = CFAttributedStringCreateMutableCopy(kCFAllocatorDefault, 100, string); - CFRelease(string); - NSNumber *number = [[NSNumber alloc] initWithInt:5]; // expected-warning{{leak}} - CFAttributedStringSetAttribute(attrString, CFRangeMake(0, 1), str, number); - [number release]; - [number retain]; - CFRelease(attrString); -} - -//===----------------------------------------------------------------------===// -// Test of handling CGGradientXXX functions. -//===----------------------------------------------------------------------===// - -void rdar_7184450(CGContextRef myContext, CGFloat x, CGPoint myStartPoint, - CGPoint myEndPoint) { - size_t num_locations = 6; - CGFloat locations[6] = { 0.0, 0.265, 0.28, 0.31, 0.36, 1.0 }; - CGFloat components[28] = { 239.0/256.0, 167.0/256.0, 170.0/256.0, - x, // Start color - 207.0/255.0, 39.0/255.0, 39.0/255.0, x, - 147.0/255.0, 21.0/255.0, 22.0/255.0, x, - 175.0/255.0, 175.0/255.0, 175.0/255.0, x, - 255.0/255.0,255.0/255.0, 255.0/255.0, x, - 255.0/255.0,255.0/255.0, 255.0/255.0, x - }; // End color - - CGGradientRef myGradient = - CGGradientCreateWithColorComponents(CGColorSpaceCreateDeviceRGB(), // expected-warning{{leak}} - components, locations, num_locations); - - CGContextDrawLinearGradient(myContext, myGradient, myStartPoint, myEndPoint, - 0); - CGGradientRelease(myGradient); -} - -void rdar_7184450_pos(CGContextRef myContext, CGFloat x, CGPoint myStartPoint, - CGPoint myEndPoint) { - size_t num_locations = 6; - CGFloat locations[6] = { 0.0, 0.265, 0.28, 0.31, 0.36, 1.0 }; - CGFloat components[28] = { 239.0/256.0, 167.0/256.0, 170.0/256.0, - x, // Start color - 207.0/255.0, 39.0/255.0, 39.0/255.0, x, - 147.0/255.0, 21.0/255.0, 22.0/255.0, x, - 175.0/255.0, 175.0/255.0, 175.0/255.0, x, - 255.0/255.0,255.0/255.0, 255.0/255.0, x, - 255.0/255.0,255.0/255.0, 255.0/255.0, x - }; // End color - - CGGradientRef myGradient = - CGGradientCreateWithColorComponents(CGColorSpaceCreateDeviceRGB(), components, locations, num_locations); // expected-warning 2 {{leak}} - - CGContextDrawLinearGradient(myContext, myGradient, myStartPoint, myEndPoint, - 0); -} - -//===----------------------------------------------------------------------===// -// <rdar://problem/7299394> clang false positive: retained instance passed to -// thread in pthread_create marked as leak -// -// Until we have full IPA, the analyzer should stop tracking the reference -// count of objects passed to pthread_create. -// -//===----------------------------------------------------------------------===// - -struct _opaque_pthread_t {}; -struct _opaque_pthread_attr_t {}; -typedef struct _opaque_pthread_t *__darwin_pthread_t; -typedef struct _opaque_pthread_attr_t __darwin_pthread_attr_t; -typedef __darwin_pthread_t pthread_t; -typedef __darwin_pthread_attr_t pthread_attr_t; -typedef unsigned long __darwin_pthread_key_t; -typedef __darwin_pthread_key_t pthread_key_t; - -int pthread_create(pthread_t *, const pthread_attr_t *, - void *(*)(void *), void *); - -int pthread_setspecific(pthread_key_t key, const void *value); - -void *rdar_7299394_start_routine(void *p) { - [((id) p) release]; - return 0; -} -void rdar_7299394(pthread_attr_t *attr, pthread_t *thread, void *args) { - NSNumber *number = [[NSNumber alloc] initWithInt:5]; // no-warning - pthread_create(thread, attr, rdar_7299394_start_routine, number); -} -void rdar_7299394_positive(pthread_attr_t *attr, pthread_t *thread) { - NSNumber *number = [[NSNumber alloc] initWithInt:5]; // expected-warning{{leak}} -} - -//===----------------------------------------------------------------------===// -// <rdar://problem/11282706> false positive with not understanding thread -// local storage -//===----------------------------------------------------------------------===// - -void rdar11282706(pthread_key_t key) { - NSNumber *number = [[NSNumber alloc] initWithInt:5]; // no-warning - pthread_setspecific(key, (void*) number); -} - -//===----------------------------------------------------------------------===// -// <rdar://problem/7283567> False leak associated with call to -// CVPixelBufferCreateWithBytes () -// -// According to the Core Video Reference (ADC), CVPixelBufferCreateWithBytes and -// CVPixelBufferCreateWithPlanarBytes can release (via a callback) the -// pixel buffer object. These test cases show how the analyzer stops tracking -// the reference count for the objects passed for this argument. This -// could be made smarter. -//===----------------------------------------------------------------------===// - -typedef int int32_t; -typedef UInt32 FourCharCode; -typedef FourCharCode OSType; -typedef uint64_t CVOptionFlags; -typedef int32_t CVReturn; -typedef struct __CVBuffer *CVBufferRef; -typedef CVBufferRef CVImageBufferRef; -typedef CVImageBufferRef CVPixelBufferRef; -typedef void (*CVPixelBufferReleaseBytesCallback)( void *releaseRefCon, const void *baseAddress ); - -extern CVReturn CVPixelBufferCreateWithBytes(CFAllocatorRef allocator, - size_t width, - size_t height, - OSType pixelFormatType, - void *baseAddress, - size_t bytesPerRow, - CVPixelBufferReleaseBytesCallback releaseCallback, - void *releaseRefCon, - CFDictionaryRef pixelBufferAttributes, - CVPixelBufferRef *pixelBufferOut) ; - -typedef void (*CVPixelBufferReleasePlanarBytesCallback)( void *releaseRefCon, const void *dataPtr, size_t dataSize, size_t numberOfPlanes, const void *planeAddresses[] ); - -extern CVReturn CVPixelBufferCreateWithPlanarBytes(CFAllocatorRef allocator, - size_t width, - size_t height, - OSType pixelFormatType, - void *dataPtr, - size_t dataSize, - size_t numberOfPlanes, - void *planeBaseAddress[], - size_t planeWidth[], - size_t planeHeight[], - size_t planeBytesPerRow[], - CVPixelBufferReleasePlanarBytesCallback releaseCallback, - void *releaseRefCon, - CFDictionaryRef pixelBufferAttributes, - CVPixelBufferRef *pixelBufferOut) ; - -extern CVReturn CVPixelBufferCreateWithBytes(CFAllocatorRef allocator, - size_t width, - size_t height, - OSType pixelFormatType, - void *baseAddress, - size_t bytesPerRow, - CVPixelBufferReleaseBytesCallback releaseCallback, - void *releaseRefCon, - CFDictionaryRef pixelBufferAttributes, - CVPixelBufferRef *pixelBufferOut) ; - -CVReturn rdar_7283567(CFAllocatorRef allocator, size_t width, size_t height, - OSType pixelFormatType, void *baseAddress, - size_t bytesPerRow, - CVPixelBufferReleaseBytesCallback releaseCallback, - CFDictionaryRef pixelBufferAttributes, - CVPixelBufferRef *pixelBufferOut) { - - // For the allocated object, it doesn't really matter what type it is - // for the purpose of this test. All we want to show is that - // this is freed later by the callback. - NSNumber *number = [[NSNumber alloc] initWithInt:5]; // no-warning - - return CVPixelBufferCreateWithBytes(allocator, width, height, pixelFormatType, - baseAddress, bytesPerRow, releaseCallback, - number, // potentially released by callback - pixelBufferAttributes, pixelBufferOut) ; -} - -CVReturn rdar_7283567_2(CFAllocatorRef allocator, size_t width, size_t height, - OSType pixelFormatType, void *dataPtr, size_t dataSize, - size_t numberOfPlanes, void *planeBaseAddress[], - size_t planeWidth[], size_t planeHeight[], size_t planeBytesPerRow[], - CVPixelBufferReleasePlanarBytesCallback releaseCallback, - CFDictionaryRef pixelBufferAttributes, - CVPixelBufferRef *pixelBufferOut) { - - // For the allocated object, it doesn't really matter what type it is - // for the purpose of this test. All we want to show is that - // this is freed later by the callback. - NSNumber *number = [[NSNumber alloc] initWithInt:5]; // no-warning - - return CVPixelBufferCreateWithPlanarBytes(allocator, - width, height, pixelFormatType, dataPtr, dataSize, - numberOfPlanes, planeBaseAddress, planeWidth, - planeHeight, planeBytesPerRow, releaseCallback, - number, // potentially released by callback - pixelBufferAttributes, pixelBufferOut) ; -} - -//===----------------------------------------------------------------------===// -// <rdar://problem/7358899> False leak associated with -// CGBitmapContextCreateWithData -//===----------------------------------------------------------------------===// -typedef uint32_t CGBitmapInfo; -typedef void (*CGBitmapContextReleaseDataCallback)(void *releaseInfo, void *data); - -CGContextRef CGBitmapContextCreateWithData(void *data, - size_t width, size_t height, size_t bitsPerComponent, - size_t bytesPerRow, CGColorSpaceRef space, CGBitmapInfo bitmapInfo, - CGBitmapContextReleaseDataCallback releaseCallback, void *releaseInfo) CF_RETURNS_RETAINED; - -void rdar_7358899(void *data, - size_t width, size_t height, size_t bitsPerComponent, - size_t bytesPerRow, CGColorSpaceRef space, CGBitmapInfo bitmapInfo, - CGBitmapContextReleaseDataCallback releaseCallback) { - - // For the allocated object, it doesn't really matter what type it is - // for the purpose of this test. All we want to show is that - // this is freed later by the callback. - NSNumber *number = [[NSNumber alloc] initWithInt:5]; // no-warning - - CGBitmapContextCreateWithData(data, width, height, bitsPerComponent, // expected-warning{{leak}} - bytesPerRow, space, bitmapInfo, releaseCallback, number); -} - -//===----------------------------------------------------------------------===// -// <rdar://problem/7265711> allow 'new', 'copy', 'alloc', 'init' prefix to -// start before '_' when determining Cocoa fundamental rule -// -// Previously the retain/release checker just skipped prefixes before the -// first '_' entirely. Now the checker honors the prefix if it results in a -// recognizable naming convention (e.g., 'new', 'init'). -//===----------------------------------------------------------------------===// - -@interface RDar7265711 {} -- (id) new_stuff; -@end - -void rdar7265711_a(RDar7265711 *x) { - id y = [x new_stuff]; // expected-warning{{leak}} -} - -void rdar7265711_b(RDar7265711 *x) { - id y = [x new_stuff]; // no-warning - [y release]; -} - -//===----------------------------------------------------------------------===// -// <rdar://problem/7306898> clang thinks [NSCursor dragCopyCursor] returns a -// retained reference -//===----------------------------------------------------------------------===// - -@interface NSCursor : NSObject -+ (NSCursor *)dragCopyCursor; -@end - -void rdar7306898(void) { - // 'dragCopyCursor' does not follow Cocoa's fundamental rule. It is a noun, not an sentence - // implying a 'copy' of something. - NSCursor *c = [NSCursor dragCopyCursor]; // no-warning - NSNumber *number = [[NSNumber alloc] initWithInt:5]; // expected-warning{{leak}} -} - -//===----------------------------------------------------------------------===// -// <rdar://problem/7252064> sending 'release', 'retain', etc. to a Class -// directly is not likely what the user intended -//===----------------------------------------------------------------------===// - -@interface RDar7252064 : NSObject @end -void rdar7252064(void) { - [RDar7252064 release]; // expected-warning{{The 'release' message should be sent to instances of class 'RDar7252064' and not the class directly}} - [RDar7252064 retain]; // expected-warning{{The 'retain' message should be sent to instances of class 'RDar7252064' and not the class directly}} - [RDar7252064 autorelease]; // expected-warning{{The 'autorelease' message should be sent to instances of class 'RDar7252064' and not the class directly}} - [NSAutoreleasePool drain]; // expected-warning{{method '+drain' not found}} expected-warning{{The 'drain' message should be sent to instances of class 'NSAutoreleasePool' and not the class directly}} -} - -//===----------------------------------------------------------------------===// -// Tests of ownership attributes. -//===----------------------------------------------------------------------===// - -typedef NSString* MyStringTy; - -@protocol FooP; - -@interface TestOwnershipAttr : NSObject -- (NSString*) returnsAnOwnedString NS_RETURNS_RETAINED; // no-warning -- (NSString*) returnsAnOwnedCFString CF_RETURNS_RETAINED; // no-warning -- (MyStringTy) returnsAnOwnedTypedString NS_RETURNS_RETAINED; // no-warning -- (NSString*) newString NS_RETURNS_NOT_RETAINED; // no-warning -- (NSString*) newString_auto NS_RETURNS_AUTORELEASED; // no-warning -- (NSString*) newStringNoAttr; -- (int) returnsAnOwnedInt NS_RETURNS_RETAINED; // expected-warning{{'ns_returns_retained' attribute only applies to methods that return an Objective-C object}} -- (id) pseudoInit NS_CONSUMES_SELF NS_RETURNS_RETAINED; -+ (void) consume:(id) NS_CONSUMED x; -+ (void) consume2:(id) CF_CONSUMED x; -@end - -static int ownership_attribute_doesnt_go_here NS_RETURNS_RETAINED; // expected-warning{{'ns_returns_retained' attribute only applies to functions and methods}} - -void test_attr_1(TestOwnershipAttr *X) { - NSString *str = [X returnsAnOwnedString]; // expected-warning{{leak}} -} - -void test_attr_1b(TestOwnershipAttr *X) { - NSString *str = [X returnsAnOwnedCFString]; // expected-warning{{leak}} -} - -void test_attr1c(TestOwnershipAttr *X) { - NSString *str = [X newString]; // no-warning - NSString *str2 = [X newStringNoAttr]; // expected-warning{{leak}} - NSString *str3 = [X newString_auto]; // no-warning - NSString *str4 = [[X newString_auto] retain]; // expected-warning {{leak}} -} - -void testattr2_a() { - TestOwnershipAttr *x = [TestOwnershipAttr alloc]; // expected-warning{{leak}} -} - -void testattr2_b() { - TestOwnershipAttr *x = [[TestOwnershipAttr alloc] pseudoInit]; // expected-warning{{leak}} -} - -void testattr2_b_11358224_self_assign_looses_the_leak() { - TestOwnershipAttr *x = [[TestOwnershipAttr alloc] pseudoInit];// expected-warning{{leak}} - x = x; -} - -void testattr2_c() { - TestOwnershipAttr *x = [[TestOwnershipAttr alloc] pseudoInit]; // no-warning - [x release]; -} - -void testattr3() { - TestOwnershipAttr *x = [TestOwnershipAttr alloc]; // no-warning - [TestOwnershipAttr consume:x]; - TestOwnershipAttr *y = [TestOwnershipAttr alloc]; // no-warning - [TestOwnershipAttr consume2:y]; -} - -void consume_ns(id NS_CONSUMED x); -void consume_cf(id CF_CONSUMED x); - -void testattr4() { - TestOwnershipAttr *x = [TestOwnershipAttr alloc]; // no-warning - consume_ns(x); - TestOwnershipAttr *y = [TestOwnershipAttr alloc]; // no-warning - consume_cf(y); -} - -@interface TestOwnershipAttr2 : NSObject -- (NSString*) newString NS_RETURNS_NOT_RETAINED; // no-warning -@end - -@implementation TestOwnershipAttr2 -- (NSString*) newString { - return [NSString alloc]; // expected-warning {{Potential leak of an object}} -} -@end - -@interface MyClassTestCFAttr : NSObject {} -- (NSDate*) returnsCFRetained CF_RETURNS_RETAINED; -- (CFDateRef) returnsCFRetainedAsCF CF_RETURNS_RETAINED; -- (CFDateRef) newCFRetainedAsCF CF_RETURNS_NOT_RETAINED; -- (CFDateRef) newCFRetainedAsCFNoAttr CF_RETURNS_RETAINED; -- (NSDate*) alsoReturnsRetained; -- (CFDateRef) alsoReturnsRetainedAsCF CF_RETURNS_NOT_RETAINED; -- (NSDate*) returnsNSRetained NS_RETURNS_RETAINED; -@end - -CF_RETURNS_RETAINED -CFDateRef returnsRetainedCFDate() { - return CFDateCreate(0, CFAbsoluteTimeGetCurrent()); -} - -@implementation MyClassTestCFAttr -- (NSDate*) returnsCFRetained { - return (NSDate*) returnsRetainedCFDate(); // No leak. -} - -- (CFDateRef) returnsCFRetainedAsCF { - return returnsRetainedCFDate(); // No leak. -} - -- (CFDateRef) newCFRetainedAsCF { - return (CFDateRef)[(id)[self returnsCFRetainedAsCF] autorelease]; -} - -- (CFDateRef) newCFRetainedAsCFNoAttr { - return (CFDateRef)[(id)[self returnsCFRetainedAsCF] autorelease]; // expected-warning{{Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected}} -} - -- (NSDate*) alsoReturnsRetained { - return (NSDate*) returnsRetainedCFDate(); // expected-warning{{leak}} -} - -- (CFDateRef) alsoReturnsRetainedAsCF { - return returnsRetainedCFDate(); // expected-warning{{leak}} -} - - -- (NSDate*) returnsNSRetained { - return (NSDate*) returnsRetainedCFDate(); // no-warning -} -@end - -//===----------------------------------------------------------------------===// -// Test that leaks post-dominated by "panic" functions are not reported. -// -// <rdar://problem/5905851> do not report a leak when post-dominated by a call -// to a noreturn or panic function -//===----------------------------------------------------------------------===// - -void panic() __attribute__((noreturn)); -void panic_not_in_hardcoded_list() __attribute__((noreturn)); - -void test_panic_negative() { - signed z = 1; - CFNumberRef value = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &z); // expected-warning{{leak}} -} - -void test_panic_positive() { - signed z = 1; - CFNumberRef value = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &z); // no-warning - panic(); -} - -void test_panic_neg_2(int x) { - signed z = 1; - CFNumberRef value = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &z); // expected-warning{{leak}} - if (x) - panic(); -} - -void test_panic_pos_2(int x) { - signed z = 1; - CFNumberRef value = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &z); // no-warning - if (x) - panic(); - if (!x) { - // This showed up in <rdar://problem/7796563>, where we silently missed checking - // the function type for noreturn. "panic()" is a hard-coded known panic function - // that isn't always noreturn. - panic_not_in_hardcoded_list(); - } -} - -//===----------------------------------------------------------------------===// -// Test uses of blocks (closures) -//===----------------------------------------------------------------------===// - -void test_blocks_1_pos(void) { - NSNumber *number = [[NSNumber alloc] initWithInt:5]; // expected-warning{{leak}} - ^{}(); -} - -void test_blocks_1_indirect_release(void) { - NSNumber *number = [[NSNumber alloc] initWithInt:5]; // no-warning - ^{ [number release]; }(); -} - -void test_blocks_1_indirect_retain(void) { - // Eventually this should be reported as a leak. - NSNumber *number = [[NSNumber alloc] initWithInt:5]; // no-warning - ^{ [number retain]; }(); -} - -void test_blocks_1_indirect_release_via_call(void) { - NSNumber *number = [[NSNumber alloc] initWithInt:5]; // no-warning - ^(NSObject *o){ [o release]; }(number); -} - -void test_blocks_1_indirect_retain_via_call(void) { - NSNumber *number = [[NSNumber alloc] initWithInt:5]; // expected-warning {{leak}} - ^(NSObject *o){ [o retain]; }(number); -} - -//===--------------------------------------------------------------------===// -// Test sending message to super that returns an object alias. Previously -// this caused a crash in the analyzer. -//===--------------------------------------------------------------------===// - -@interface Rdar8015556 : NSObject {} @end -@implementation Rdar8015556 -- (id)retain { - return [super retain]; -} -@end - -// <rdar://problem/8272168> - Correcly handle Class<...> in Cocoa Conventions -// detector. - -@protocol Prot_R8272168 @end -Class <Prot_R8272168> GetAClassThatImplementsProt_R8272168(); -void r8272168() { - GetAClassThatImplementsProt_R8272168(); -} - -// Test case for <rdar://problem/8356342>, which in the past triggered -// a false positive. -@interface RDar8356342 -- (NSDate*) rdar8356342:(NSDate *)inValue; -@end - -@implementation RDar8356342 -- (NSDate*) rdar8356342:(NSDate*)inValue { - NSDate *outValue = inValue; - if (outValue == 0) - outValue = [[NSDate alloc] init]; // no-warning - - if (outValue != inValue) - [outValue autorelease]; - - return outValue; -} -@end - -// <rdar://problem/8724287> - This test case previously crashed because -// of a bug in BugReporter. -extern const void *CFDictionaryGetValue(CFDictionaryRef theDict, const void *key) CF_RETURNS_NOT_RETAINED; -typedef struct __CFError * CFErrorRef; -extern const CFStringRef kCFErrorUnderlyingErrorKey; -extern CFDictionaryRef CFErrorCopyUserInfo(CFErrorRef err) CF_RETURNS_RETAINED; -static void rdar_8724287(CFErrorRef error) -{ - CFErrorRef error_to_dump; - - error_to_dump = error; - while (error_to_dump != ((void*)0)) { - CFDictionaryRef info; - - info = CFErrorCopyUserInfo(error_to_dump); // expected-warning{{Potential leak of an object}} - - if (info != ((void*)0)) { - } - - error_to_dump = (CFErrorRef) CFDictionaryGetValue(info, kCFErrorUnderlyingErrorKey); - } -} - -// <rdar://problem/9234108> - Make sure the model applies cf_consumed -// correctly in argument positions besides the first. - -CF_IMPLICIT_BRIDGING_ENABLED - -extern void *CFStringCreate(void); - -CF_IMPLICIT_BRIDGING_DISABLED - -extern void rdar_9234108_helper(void *key, void * CF_CONSUMED value); -void rdar_9234108() { - rdar_9234108_helper(0, CFStringCreate()); -} - -// <rdar://problem/9726279> - Make sure that objc_method_family works -// to override naming conventions. -struct TwoDoubles { - double one; - double two; -}; -typedef struct TwoDoubles TwoDoubles; - -@interface NSValue (Mine) -- (id)_prefix_initWithTwoDoubles:(TwoDoubles)twoDoubles __attribute__((objc_method_family(init))); -@end - -@implementation NSValue (Mine) -- (id)_prefix_initWithTwoDoubles:(TwoDoubles)twoDoubles -{ - return [self init]; -} -@end - -void rdar9726279() { - TwoDoubles twoDoubles = { 0.0, 0.0 }; - NSValue *value = [[NSValue alloc] _prefix_initWithTwoDoubles:twoDoubles]; - [value release]; -} - -// <rdar://problem/9732321> -// Test camelcase support for CF conventions. While Core Foundation APIs -// don't use camel casing, other code is allowed to use it. -CFArrayRef camelcase_create_1() { - return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning -} - -CFArrayRef camelcase_createno() { - return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // expected-warning {{leak}} -} - -CFArrayRef camelcase_copy() { - return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning -} - -CFArrayRef camelcase_copying() { - return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // expected-warning {{leak}} -} - -CFArrayRef copyCamelCase() { - return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning -} - -CFArrayRef __copyCamelCase() { - return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning -} - -CFArrayRef __createCamelCase() { - return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning -} - -CFArrayRef camel_create() { - return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning -} - - -CFArrayRef camel_creat() { - return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // expected-warning {{leak}} -} - -CFArrayRef camel_copy() { - return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning -} - -CFArrayRef camel_copyMachine() { - return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning -} - -CFArrayRef camel_copymachine() { - return CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // expected-warning {{leak}} -} - -// rdar://problem/8024350 -@protocol F18P -- (id) clone; -@end -@interface F18 : NSObject<F18P> @end -@interface F18(Cat) -- (id) clone NS_RETURNS_RETAINED; -@end - -@implementation F18 -- (id) clone { - return [F18 alloc]; -} -@end - -// Radar 6582778. -void rdar6582778(void) { - CFAbsoluteTime t = CFAbsoluteTimeGetCurrent(); - CFTypeRef vals[] = { CFDateCreate(0, t) }; // expected-warning {{leak}} -} - -CFTypeRef global; - -void rdar6582778_2(void) { - CFAbsoluteTime t = CFAbsoluteTimeGetCurrent(); - global = CFDateCreate(0, t); // no-warning -} - -// <rdar://problem/10232019> - Test that objects passed to containers -// are marked "escaped". - -void rdar10232019() { - NSMutableArray *array = [NSMutableArray array]; - - NSString *string = [[NSString alloc] initWithUTF8String:"foo"]; - [array addObject:string]; - [string release]; - - NSString *otherString = [string stringByAppendingString:@"bar"]; // no-warning - NSLog(@"%@", otherString); -} - -void rdar10232019_positive() { - NSMutableArray *array = [NSMutableArray array]; - - NSString *string = [[NSString alloc] initWithUTF8String:"foo"]; - [string release]; - - NSString *otherString = [string stringByAppendingString:@"bar"]; // expected-warning {{Reference-counted object is used after it is release}} - NSLog(@"%@", otherString); -} - -// RetainCountChecker support for XPC. -// <rdar://problem/9658496> -typedef void * xpc_object_t; -xpc_object_t _CFXPCCreateXPCObjectFromCFObject(CFTypeRef cf); -void xpc_release(xpc_object_t object); - -void rdar9658496() { - CFStringRef cf; - xpc_object_t xpc; - cf = CFStringCreateWithCString( ((CFAllocatorRef)0), "test", kCFStringEncodingUTF8 ); // no-warning - xpc = _CFXPCCreateXPCObjectFromCFObject( cf ); - CFRelease(cf); - xpc_release(xpc); -} - -// Support annotations with method families. -@interface RDar10824732 : NSObject -- (instancetype)initWithObj:(id CF_CONSUMED)obj; -@end - -@implementation RDar10824732 -- (instancetype)initWithObj:(id)obj { - [obj release]; - return [super init]; -} -@end - -void rdar_10824732() { - @autoreleasepool { - NSString *obj = @"test"; - RDar10824732 *foo = [[RDar10824732 alloc] initWithObj:obj]; // no-warning - [foo release]; - } -} - -// Stop tracking objects passed to functions, which take callbacks as parameters. -// radar://10973977 -typedef int (*CloseCallback) (void *); -void ReaderForIO(CloseCallback ioclose, void *ioctx); -int IOClose(void *context); - -@protocol SInS <NSObject> -@end - -@interface radar10973977 : NSObject -- (id<SInS>)inputS; -- (void)reader; -@end - -@implementation radar10973977 -- (void)reader -{ - id<SInS> inputS = [[self inputS] retain]; - ReaderForIO(IOClose, inputS); -} -- (id<SInS>)inputS -{ - return 0; -} -@end - -// Object escapes through a selector callback: radar://11398514 -extern id NSApp; -@interface MySheetController -- (id<SInS>)inputS; -- (void)showDoSomethingSheetAction:(id)action; -- (void)sheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo; -@end - -@implementation MySheetController -- (id<SInS>)inputS { - return 0; -} -- (void)showDoSomethingSheetAction:(id)action { - id<SInS> inputS = [[self inputS] retain]; - [NSApp beginSheet:0 - modalForWindow:0 - modalDelegate:0 - didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:) - contextInfo:(void *)inputS]; // no - warning -} -- (void)sheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo { - - id contextObject = (id)contextInfo; - [contextObject release]; -} - -- (id)copyAutoreleaseRadar13081402 { - id x = [[[NSString alloc] initWithUTF8String:"foo"] autorelease]; - [x retain]; - return x; // no warning -} - -@end -//===----------------------------------------------------------------------===// -// Test returning allocated memory in a struct. -// -// We currently don't have a general way to track pointers that "escape". -// Here we test that RetainCountChecker doesn't get excited about returning -// allocated CF objects in struct fields. -//===----------------------------------------------------------------------===// -void *malloc(size_t); -struct rdar11104566 { CFStringRef myStr; }; -struct rdar11104566 test_rdar11104566() { - CFStringRef cf = CFStringCreateWithCString( ((CFAllocatorRef)0), "test", kCFStringEncodingUTF8 ); // no-warning - struct rdar11104566 V; - V.myStr = cf; - return V; // no-warning -} - -struct rdar11104566 *test_2_rdar11104566() { - CFStringRef cf = CFStringCreateWithCString( ((CFAllocatorRef)0), "test", kCFStringEncodingUTF8 ); // no-warning - struct rdar11104566 *V = (struct rdar11104566 *) malloc(sizeof(*V)); - V->myStr = cf; - return V; // no-warning -} - -//===----------------------------------------------------------------------===// -// ObjC literals support. -//===----------------------------------------------------------------------===// - -void test_objc_arrays() { - { // CASE ONE -- OBJECT IN ARRAY CREATED DIRECTLY - NSObject *o = [[NSObject alloc] init]; - NSArray *a = [[NSArray alloc] initWithObjects:o, (void*)0]; // expected-warning {{leak}} - [o release]; - [a description]; - [o description]; - } - - { // CASE TWO -- OBJECT IN ARRAY CREATED BY DUPING AUTORELEASED ARRAY - NSObject *o = [[NSObject alloc] init]; - NSArray *a1 = [NSArray arrayWithObjects:o, (void*)0]; - NSArray *a2 = [[NSArray alloc] initWithArray:a1]; // expected-warning {{leak}} - [o release]; - [a2 description]; - [o description]; - } - - { // CASE THREE -- OBJECT IN RETAINED @[] - NSObject *o = [[NSObject alloc] init]; - NSArray *a3 = [@[o] retain]; // expected-warning {{leak}} - [o release]; - [a3 description]; - [o description]; - } - - { // CASE FOUR -- OBJECT IN ARRAY CREATED BY DUPING @[] - NSObject *o = [[NSObject alloc] init]; - NSArray *a = [[NSArray alloc] initWithArray:@[o]]; // expected-warning {{leak}} - [o release]; - - [a description]; - [o description]; - } - - { // CASE FIVE -- OBJECT IN RETAINED @{} - NSValue *o = [[NSValue alloc] init]; - NSDictionary *a = [@{o : o} retain]; // expected-warning {{leak}} - [o release]; - - [a description]; - [o description]; - } -} - -void test_objc_integer_literals() { - id value = [@1 retain]; // expected-warning {{leak}} - [value description]; -} - -void test_objc_boxed_expressions(int x, const char *y) { - id value = [@(x) retain]; // expected-warning {{leak}} - [value description]; - - value = [@(y) retain]; // expected-warning {{leak}} - [value description]; -} - -// Test NSLog doesn't escape tracked objects. -void rdar11400885(int y) -{ - @autoreleasepool { - NSString *printString; - if(y > 2) - printString = [[NSString alloc] init]; - else - printString = [[NSString alloc] init]; - NSLog(@"Once %@", printString); - [printString release]; - NSLog(@"Again: %@", printString); // expected-warning {{Reference-counted object is used after it is released}} - } -} - -id makeCollectableNonLeak() { - extern CFTypeRef CFCreateSomething(); - - CFTypeRef object = CFCreateSomething(); // +1 - CFRetain(object); // +2 - id objCObject = NSMakeCollectable(object); // +2 - [objCObject release]; // +1 - return [objCObject autorelease]; // +0 -} - - -void consumeAndStopTracking(id NS_CONSUMED obj, void (^callback)(void)); -void CFConsumeAndStopTracking(CFTypeRef CF_CONSUMED obj, void (^callback)(void)); - -void testConsumeAndStopTracking() { - id retained = [@[] retain]; // +1 - consumeAndStopTracking(retained, ^{}); // no-warning - - id doubleRetained = [[@[] retain] retain]; // +2 - consumeAndStopTracking(doubleRetained, ^{ - [doubleRetained release]; - }); // no-warning - - id unretained = @[]; // +0 - consumeAndStopTracking(unretained, ^{}); // expected-warning {{Incorrect decrement of the reference count of an object that is not owned at this point by the caller}} -} - -void testCFConsumeAndStopTracking() { - id retained = [@[] retain]; // +1 - CFConsumeAndStopTracking((CFTypeRef)retained, ^{}); // no-warning - - id doubleRetained = [[@[] retain] retain]; // +2 - CFConsumeAndStopTracking((CFTypeRef)doubleRetained, ^{ - [doubleRetained release]; - }); // no-warning - - id unretained = @[]; // +0 - CFConsumeAndStopTracking((CFTypeRef)unretained, ^{}); // expected-warning {{Incorrect decrement of the reference count of an object that is not owned at this point by the caller}} -} -//===----------------------------------------------------------------------===// -// Test 'pragma clang arc_cf_code_audited' support. -//===----------------------------------------------------------------------===// - -typedef void *MyCFType; -#pragma clang arc_cf_code_audited begin -MyCFType CreateMyCFType(); -#pragma clang arc_cf_code_audited end - -void test_custom_cf() { - MyCFType x = CreateMyCFType(); // expected-warning {{leak of an object stored into 'x'}} -} - -//===----------------------------------------------------------------------===// -// Test calling CFPlugInInstanceCreate, which appears in CF but doesn't -// return a CF object. -//===----------------------------------------------------------------------===// - -void test_CFPlugInInstanceCreate(CFUUIDRef factoryUUID, CFUUIDRef typeUUID) { - CFPlugInInstanceCreate(kCFAllocatorDefault, factoryUUID, typeUUID); // no-warning -} - -//===----------------------------------------------------------------------===// -// PR14927: -drain only has retain-count semantics on NSAutoreleasePool. -//===----------------------------------------------------------------------===// - -@interface PR14927 : NSObject -- (void)drain; -@end - -void test_drain() { - PR14927 *obj = [[PR14927 alloc] init]; - [obj drain]; - [obj release]; // no-warning -} - -//===----------------------------------------------------------------------===// -// Allow cf_returns_retained and cf_returns_not_retained to mark a return -// value as tracked, even if the object isn't a known CF type. -//===----------------------------------------------------------------------===// - -MyCFType getCustom() __attribute__((cf_returns_not_retained)); -MyCFType makeCustom() __attribute__((cf_returns_retained)); - -void testCustomReturnsRetained() { - MyCFType obj = makeCustom(); // expected-warning {{leak of an object stored into 'obj'}} -} - -void testCustomReturnsNotRetained() { - CFRelease(getCustom()); // expected-warning {{Incorrect decrement of the reference count of an object that is not owned at this point by the caller}} -} - -//===----------------------------------------------------------------------===// -// Don't print variables which are out of the current scope. -//===----------------------------------------------------------------------===// -@interface MyObj12706177 : NSObject --(instancetype)initX; -+(void)test12706177; -@end -static int Cond; -@implementation MyObj12706177 --(instancetype)initX { - if (Cond) - return 0; - self = [super init]; - return self; -} -+(void)test12706177 { - id x = [[MyObj12706177 alloc] initX]; //expected-warning {{Potential leak of an object}} - [x release]; -} -@end - -//===----------------------------------------------------------------------===// -// <rdar://problem/13783514> xpc_connection_set_finalizer_f -//===----------------------------------------------------------------------===// - -typedef xpc_object_t xpc_connection_t; -typedef void (*xpc_finalizer_t)(void *value); -void xpc_connection_set_context(xpc_connection_t connection, void *ctx); -void xpc_connection_set_finalizer_f(xpc_connection_t connection, - xpc_finalizer_t finalizer); -void releaseAfterXPC(void *context) { - [(NSArray *)context release]; -} - -void rdar13783514(xpc_connection_t connection) { - xpc_connection_set_context(connection, [[NSMutableArray alloc] init]); - xpc_connection_set_finalizer_f(connection, releaseAfterXPC); -} // no-warning - -CFAttributedStringRef CFAttributedCreate(void *CFObj CF_CONSUMED) CF_RETURNS_RETAINED; - -@interface Action -@property (nonatomic) SEL action; -@property (nonatomic, assign) id target; -@end diff --git a/test/ARCMT/objcmt-atomic-property.m b/test/ARCMT/objcmt-atomic-property.m deleted file mode 100644 index 78ab3ec71596..000000000000 --- a/test/ARCMT/objcmt-atomic-property.m +++ /dev/null @@ -1,229 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -fblocks -objcmt-migrate-readwrite-property -objcmt-migrate-readonly-property -objcmt-atomic-property -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11 -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result - -#define WEBKIT_OBJC_METHOD_ANNOTATION(ANNOTATION) ANNOTATION -#define WEAK_IMPORT_ATTRIBUTE __attribute__((objc_arc_weak_reference_unavailable)) -#define AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER -#define DEPRECATED __attribute__((deprecated)) - -typedef char BOOL; -@class NSString; -@protocol NSCopying @end - -@interface NSObject <NSCopying> -@end - -@interface NSDictionary : NSObject -@end - -@interface I : NSObject { - int ivarVal; -} -- (void) setWeakProp : (NSString *__weak)Val; -- (NSString *__weak) WeakProp; - -- (NSString *) StrongProp; -- (void) setStrongProp : (NSString *)Val; - -- (NSString *) UnavailProp __attribute__((unavailable)); -- (void) setUnavailProp : (NSString *)Val; - -- (NSString *) UnavailProp1 __attribute__((unavailable)); -- (void) setUnavailProp1 : (NSString *)Val __attribute__((unavailable)); - -- (NSString *) UnavailProp2; -- (void) setUnavailProp2 : (NSString *)Val __attribute__((unavailable)); - -- (NSDictionary*) undoAction; -- (void) setUndoAction: (NSDictionary*)Arg; -@end - -@implementation I -@end - -@class NSArray; - -@interface MyClass2 { -@private - NSArray *_names1; - NSArray *_names2; - NSArray *_names3; - NSArray *_names4; -} -- (void)setNames1:(NSArray *)names; -- (void)setNames4:(__strong NSArray *)names; -- (void)setNames3:(__strong NSArray *)names; -- (void)setNames2:(NSArray *)names; -- (NSArray *) names2; -- (NSArray *)names3; -- (__strong NSArray *)names4; -- (NSArray *) names1; -@end - -// Properties that contain the name "delegate" or "dataSource", -// or have exact name "target" have unsafe_unretained attribute. -@interface NSInvocation -- (id)target; -- (void)setTarget:(id)target; - -- (id) dataSource; - -- (id)xxxdelegateYYY; -- (void)setXxxdelegateYYY:(id)delegate; - -- (void)setDataSource:(id)source; - -- (id)MYtarget; -- (void)setMYtarget: (id)target; - -- (id)targetX; -- (void)setTargetX: (id)t; - -- (int)value; -- (void)setValue: (int)val; - --(BOOL) isContinuous; --(void) setContinuous:(BOOL)value; - -- (id) isAnObject; -- (void)setAnObject : (id) object; - -- (BOOL) isinValid; -- (void) setInValid : (BOOL) arg; - -- (void) Nothing; -- (int) Length; -- (id) object; -+ (double) D; -- (void *)JSObject WEBKIT_OBJC_METHOD_ANNOTATION(AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER); -- (BOOL)isIgnoringInteractionEvents; - -- (NSString *)getStringValue; -- (BOOL)getCounterValue; -- (void)setStringValue:(NSString *)stringValue AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; -- (NSDictionary *)getns_dixtionary; - -- (BOOL)is3bar; // watch out -- (NSString *)get3foo; // watch out - -- (BOOL) getM; -- (BOOL) getMA; -- (BOOL) getALL; -- (BOOL) getMANY; -- (BOOL) getSome; -@end - - -@interface NSInvocation(CAT) -- (id)target; -- (void)setTarget:(id)target; - -- (id) dataSource; - -- (id)xxxdelegateYYY; -- (void)setXxxdelegateYYY:(id)delegate; - -- (void)setDataSource:(id)source; - -- (id)MYtarget; -- (void)setMYtarget: (id)target; - -- (id)targetX; -- (void)setTargetX: (id)t; - -- (int)value; -- (void)setValue: (int)val; - --(BOOL) isContinuous; --(void) setContinuous:(BOOL)value; - -- (id) isAnObject; -- (void)setAnObject : (id) object; - -- (BOOL) isinValid; -- (void) setInValid : (BOOL) arg; - -- (void) Nothing; -- (int) Length; -- (id) object; -+ (double) D; - -- (BOOL)is3bar; // watch out -- (NSString *)get3foo; // watch out - -- (BOOL) getM; -- (BOOL) getMA; -- (BOOL) getALL; -- (BOOL) getMANY; -- (BOOL) getSome; -@end - -DEPRECATED -@interface I_DEP -- (BOOL) isinValid; -- (void) setInValid : (BOOL) arg; -@end - -@interface AnotherOne -- (BOOL) isinValid DEPRECATED; -- (void) setInValid : (BOOL) arg; -- (id)MYtarget; -- (void)setMYtarget: (id)target DEPRECATED; -- (BOOL) getM DEPRECATED; - -- (id)xxxdelegateYYY DEPRECATED; -- (void)setXxxdelegateYYY:(id)delegate DEPRECATED; -@end - -// rdar://14987909 -#define NS_AVAILABLE __attribute__((availability(macosx,introduced=10.0))) -#define NORETURN __attribute__((noreturn)) -#define ALIGNED __attribute__((aligned(16))) - -@interface NSURL -// Do not infer a property. -- (NSURL *)appStoreReceiptURL NS_AVAILABLE; -- (void) setAppStoreReceiptURL : (NSURL *)object; - -- (NSURL *)appStoreReceiptURLX NS_AVAILABLE; -- (void) setAppStoreReceiptURLX : (NSURL *)object NS_AVAILABLE; - -// Do not infer a property. -- (NSURL *)appStoreReceiptURLY ; -- (void) setAppStoreReceiptURLY : (NSURL *)object NS_AVAILABLE; - -- (id)OkToInfer NS_AVAILABLE; - -// Do not infer a property. -- (NSURL *)appStoreReceiptURLZ ; -- (void) setAppStoreReceiptURLZ : (NSURL *)object NS_AVAILABLE; - -// Do not infer a property. -- (id) t1 NORETURN NS_AVAILABLE; -- (void) setT1 : (id) arg NS_AVAILABLE; - -- (id)method1 ALIGNED NS_AVAILABLE; -- (void) setMethod1 : (id) object NS_AVAILABLE ALIGNED; - -- (NSURL *)init; // No Change -+ (id)alloc; // No Change - -- (BOOL)is1stClass; // Not a valid property -- (BOOL)isClass; // This is a valid property 'class' is not a keyword in ObjC -- (BOOL)isDouble; // Not a valid property - -@end - -// rdar://15082818 -@class NSMutableDictionary; - -@interface NSArray -- (id (^)(id, NSArray *, NSMutableDictionary *)) expressionBlock; -- (id (^)(id, NSArray *, NSMutableDictionary *)) MyBlock; -- (void) setMyBlock : (id (^)(id, NSArray *, NSMutableDictionary *)) bl; -- (id (*)(id, NSArray *, NSMutableDictionary *)) expressionFuncptr; -- (id (*)(id, NSArray *, NSMutableDictionary *)) MyFuncptr; -- (void) setMyFuncptr : (id (*)(id, NSArray *, NSMutableDictionary *)) bl; -@end diff --git a/test/ARCMT/objcmt-atomic-property.m.result b/test/ARCMT/objcmt-atomic-property.m.result deleted file mode 100644 index 3378ff1e487f..000000000000 --- a/test/ARCMT/objcmt-atomic-property.m.result +++ /dev/null @@ -1,202 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -fblocks -objcmt-migrate-readwrite-property -objcmt-migrate-readonly-property -objcmt-atomic-property -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11 -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result - -#define WEBKIT_OBJC_METHOD_ANNOTATION(ANNOTATION) ANNOTATION -#define WEAK_IMPORT_ATTRIBUTE __attribute__((objc_arc_weak_reference_unavailable)) -#define AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER -#define DEPRECATED __attribute__((deprecated)) - -typedef char BOOL; -@class NSString; -@protocol NSCopying @end - -@interface NSObject <NSCopying> -@end - -@interface NSDictionary : NSObject -@end - -@interface I : NSObject { - int ivarVal; -} -@property (weak) NSString *WeakProp; - -@property (strong) NSString *StrongProp; - -@property (strong) NSString *UnavailProp __attribute__((unavailable)); -- (void) setUnavailProp : (NSString *)Val; - -@property (strong) NSString *UnavailProp1 __attribute__((unavailable)); - -@property (strong) NSString *UnavailProp2; -- (void) setUnavailProp2 : (NSString *)Val __attribute__((unavailable)); - -@property (copy) NSDictionary *undoAction; -@end - -@implementation I -@end - -@class NSArray; - -@interface MyClass2 { -@private - NSArray *_names1; - NSArray *_names2; - NSArray *_names3; - NSArray *_names4; -} -@property (strong) NSArray *names2; -@property (strong) NSArray *names3; -@property (strong) NSArray *names4; -@property (strong) NSArray *names1; -@end - -// Properties that contain the name "delegate" or "dataSource", -// or have exact name "target" have unsafe_unretained attribute. -@interface NSInvocation -@property (assign) id target; - -@property (assign) id dataSource; - -@property (assign) id xxxdelegateYYY; - - -@property (strong) id MYtarget; - -@property (strong) id targetX; - -@property int value; - -@property (getter=isContinuous) BOOL continuous; - -- (id) isAnObject; -- (void)setAnObject : (id) object; - -@property (getter=isinValid, readonly) BOOL inValid; -- (void) setInValid : (BOOL) arg; - -- (void) Nothing; -@property (readonly) int Length; -@property (readonly, strong) id object; -+ (double) D; -@property (readonly) void *JSObject WEBKIT_OBJC_METHOD_ANNOTATION(AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER); -@property (getter=isIgnoringInteractionEvents, readonly) BOOL ignoringInteractionEvents; - -@property (getter=getStringValue, strong) NSString *stringValue; -@property (getter=getCounterValue, readonly) BOOL counterValue; -@property (getter=getns_dixtionary, readonly, copy) NSDictionary *ns_dixtionary; - -- (BOOL)is3bar; // watch out -- (NSString *)get3foo; // watch out - -@property (getter=getM, readonly) BOOL m; -@property (getter=getMA, readonly) BOOL MA; -@property (getter=getALL, readonly) BOOL ALL; -@property (getter=getMANY, readonly) BOOL MANY; -@property (getter=getSome, readonly) BOOL some; -@end - - -@interface NSInvocation(CAT) -@property (assign) id target; - -@property (assign) id dataSource; - -@property (assign) id xxxdelegateYYY; - - -@property (strong) id MYtarget; - -@property (strong) id targetX; - -@property int value; - -@property (getter=isContinuous) BOOL continuous; - -- (id) isAnObject; -- (void)setAnObject : (id) object; - -@property (getter=isinValid, readonly) BOOL inValid; -- (void) setInValid : (BOOL) arg; - -- (void) Nothing; -@property (readonly) int Length; -@property (readonly, strong) id object; -+ (double) D; - -- (BOOL)is3bar; // watch out -- (NSString *)get3foo; // watch out - -@property (getter=getM, readonly) BOOL m; -@property (getter=getMA, readonly) BOOL MA; -@property (getter=getALL, readonly) BOOL ALL; -@property (getter=getMANY, readonly) BOOL MANY; -@property (getter=getSome, readonly) BOOL some; -@end - -DEPRECATED -@interface I_DEP -- (BOOL) isinValid; -- (void) setInValid : (BOOL) arg; -@end - -@interface AnotherOne -- (BOOL) isinValid DEPRECATED; -- (void) setInValid : (BOOL) arg; -- (id)MYtarget; -- (void)setMYtarget: (id)target DEPRECATED; -- (BOOL) getM DEPRECATED; - -- (id)xxxdelegateYYY DEPRECATED; -- (void)setXxxdelegateYYY:(id)delegate DEPRECATED; -@end - -// rdar://14987909 -#define NS_AVAILABLE __attribute__((availability(macosx,introduced=10.0))) -#define NORETURN __attribute__((noreturn)) -#define ALIGNED __attribute__((aligned(16))) - -@interface NSURL -// Do not infer a property. -@property (strong) NSURL *appStoreReceiptURL NS_AVAILABLE; -- (void) setAppStoreReceiptURL : (NSURL *)object; - -@property (strong) NSURL *appStoreReceiptURLX NS_AVAILABLE; - -// Do not infer a property. -@property (strong) NSURL *appStoreReceiptURLY ; -- (void) setAppStoreReceiptURLY : (NSURL *)object NS_AVAILABLE; - -@property (readonly, strong) id OkToInfer NS_AVAILABLE; - -// Do not infer a property. -@property (strong) NSURL *appStoreReceiptURLZ ; -- (void) setAppStoreReceiptURLZ : (NSURL *)object NS_AVAILABLE; - -// Do not infer a property. -- (id) t1 NORETURN NS_AVAILABLE; -- (void) setT1 : (id) arg NS_AVAILABLE; - -@property (strong) id method1 ALIGNED NS_AVAILABLE; - -- (NSURL *)init; // No Change -+ (id)alloc; // No Change - -- (BOOL)is1stClass; // Not a valid property -@property (getter=isClass, readonly) BOOL class; // This is a valid property 'class' is not a keyword in ObjC -- (BOOL)isDouble; // Not a valid property - -@end - -// rdar://15082818 -@class NSMutableDictionary; - -@interface NSArray -@property (readonly, copy) id (^expressionBlock)(id, NSArray *, NSMutableDictionary *); -@property (copy) id (^MyBlock)(id, NSArray *, NSMutableDictionary *); -@property (readonly) id (*expressionFuncptr)(id, NSArray *, NSMutableDictionary *); -@property id (*MyFuncptr)(id, NSArray *, NSMutableDictionary *); -@end diff --git a/test/ARCMT/objcmt-boxing.m b/test/ARCMT/objcmt-boxing.m deleted file mode 100644 index c4b6f42b1bd5..000000000000 --- a/test/ARCMT/objcmt-boxing.m +++ /dev/null @@ -1,107 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -fobjc-arc -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c++ -verify -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c++ %s.result - -#define YES __objc_yes -#define NO __objc_no - -typedef long NSInteger; -typedef unsigned long NSUInteger; -typedef signed char BOOL; -#define nil ((void*) 0) - -#define INT_MIN (-__INT_MAX__ -1) - -@interface NSObject -+ (id)alloc; -@end - -@interface NSNumber : NSObject -@end - -@interface NSNumber (NSNumberCreation) -- (id)initWithChar:(char)value; -- (id)initWithUnsignedChar:(unsigned char)value; -- (id)initWithShort:(short)value; -- (id)initWithUnsignedShort:(unsigned short)value; -- (id)initWithInt:(int)value; -- (id)initWithUnsignedInt:(unsigned int)value; -- (id)initWithLong:(long)value; -- (id)initWithUnsignedLong:(unsigned long)value; -- (id)initWithLongLong:(long long)value; -- (id)initWithUnsignedLongLong:(unsigned long long)value; -- (id)initWithFloat:(float)value; -- (id)initWithDouble:(double)value; -- (id)initWithBool:(BOOL)value; -- (id)initWithInteger:(NSInteger)value; -- (id)initWithUnsignedInteger:(NSUInteger)value; - -+ (NSNumber *)numberWithChar:(char)value; -+ (NSNumber *)numberWithUnsignedChar:(unsigned char)value; -+ (NSNumber *)numberWithShort:(short)value; -+ (NSNumber *)numberWithUnsignedShort:(unsigned short)value; -+ (NSNumber *)numberWithInt:(int)value; -+ (NSNumber *)numberWithUnsignedInt:(unsigned int)value; -+ (NSNumber *)numberWithLong:(long)value; -+ (NSNumber *)numberWithUnsignedLong:(unsigned long)value; -+ (NSNumber *)numberWithLongLong:(long long)value; -+ (NSNumber *)numberWithUnsignedLongLong:(unsigned long long)value; -+ (NSNumber *)numberWithFloat:(float)value; -+ (NSNumber *)numberWithDouble:(double)value; -+ (NSNumber *)numberWithBool:(BOOL)value; -+ (NSNumber *)numberWithInteger:(NSInteger)value; -+ (NSNumber *)numberWithUnsignedInteger:(NSUInteger)value; -@end - -enum { - NSASCIIStringEncoding = 1, - NSUTF8StringEncoding = 4, - NSUnicodeStringEncoding = 10 -}; -typedef NSUInteger NSStringEncoding; - -@interface NSString : NSObject -@end - -@interface NSString (NSStringExtensionMethods) -+ (id)stringWithUTF8String:(const char *)nullTerminatedCString; -+ (id)stringWithCString:(const char *)cString encoding:(NSStringEncoding)enc; -+ (id)stringWithCString:(const char *)bytes; -- (instancetype)initWithUTF8String:(const char *)nullTerminatedCString; -@end - -enum MyEnm { - ME_foo -}; - -void foo() { - [NSNumber numberWithInt:INT_MIN]; - bool cppb; - [NSNumber numberWithBool:cppb]; - MyEnm myenum; - [NSNumber numberWithInteger:myenum]; - [NSNumber numberWithInteger:ME_foo]; - [NSNumber numberWithDouble:cppb]; // expected-warning {{converting to boxing syntax requires casting 'bool' to 'double'}} -} - -void boxString() { - NSString *s = [NSString stringWithUTF8String:"box"]; - const char *cstr1; - char *cstr2; - s = [NSString stringWithUTF8String:cstr1]; - s = [NSString stringWithUTF8String:cstr2]; - s = [NSString stringWithCString:cstr1 encoding:NSASCIIStringEncoding]; - s = [NSString stringWithCString:cstr1 encoding:NSUTF8StringEncoding]; - s = [NSString stringWithCString:cstr1 encoding: NSUnicodeStringEncoding]; - NSStringEncoding encode; - s = [NSString stringWithCString:cstr1 encoding:encode]; - s = [NSString stringWithCString:cstr1]; - - static const char strarr[] = "coolbox"; - s = [NSString stringWithUTF8String:strarr]; - // rdar://18080352 - const char *utf8Bytes = "blah"; - NSString *string1 = [NSString stringWithUTF8String:utf8Bytes]; - NSString *string2 = [[NSString alloc] initWithUTF8String:utf8Bytes]; -} diff --git a/test/ARCMT/objcmt-boxing.m.result b/test/ARCMT/objcmt-boxing.m.result deleted file mode 100644 index 59fdb88d51a3..000000000000 --- a/test/ARCMT/objcmt-boxing.m.result +++ /dev/null @@ -1,107 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -fobjc-arc -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c++ -verify -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c++ %s.result - -#define YES __objc_yes -#define NO __objc_no - -typedef long NSInteger; -typedef unsigned long NSUInteger; -typedef signed char BOOL; -#define nil ((void*) 0) - -#define INT_MIN (-__INT_MAX__ -1) - -@interface NSObject -+ (id)alloc; -@end - -@interface NSNumber : NSObject -@end - -@interface NSNumber (NSNumberCreation) -- (id)initWithChar:(char)value; -- (id)initWithUnsignedChar:(unsigned char)value; -- (id)initWithShort:(short)value; -- (id)initWithUnsignedShort:(unsigned short)value; -- (id)initWithInt:(int)value; -- (id)initWithUnsignedInt:(unsigned int)value; -- (id)initWithLong:(long)value; -- (id)initWithUnsignedLong:(unsigned long)value; -- (id)initWithLongLong:(long long)value; -- (id)initWithUnsignedLongLong:(unsigned long long)value; -- (id)initWithFloat:(float)value; -- (id)initWithDouble:(double)value; -- (id)initWithBool:(BOOL)value; -- (id)initWithInteger:(NSInteger)value; -- (id)initWithUnsignedInteger:(NSUInteger)value; - -+ (NSNumber *)numberWithChar:(char)value; -+ (NSNumber *)numberWithUnsignedChar:(unsigned char)value; -+ (NSNumber *)numberWithShort:(short)value; -+ (NSNumber *)numberWithUnsignedShort:(unsigned short)value; -+ (NSNumber *)numberWithInt:(int)value; -+ (NSNumber *)numberWithUnsignedInt:(unsigned int)value; -+ (NSNumber *)numberWithLong:(long)value; -+ (NSNumber *)numberWithUnsignedLong:(unsigned long)value; -+ (NSNumber *)numberWithLongLong:(long long)value; -+ (NSNumber *)numberWithUnsignedLongLong:(unsigned long long)value; -+ (NSNumber *)numberWithFloat:(float)value; -+ (NSNumber *)numberWithDouble:(double)value; -+ (NSNumber *)numberWithBool:(BOOL)value; -+ (NSNumber *)numberWithInteger:(NSInteger)value; -+ (NSNumber *)numberWithUnsignedInteger:(NSUInteger)value; -@end - -enum { - NSASCIIStringEncoding = 1, - NSUTF8StringEncoding = 4, - NSUnicodeStringEncoding = 10 -}; -typedef NSUInteger NSStringEncoding; - -@interface NSString : NSObject -@end - -@interface NSString (NSStringExtensionMethods) -+ (id)stringWithUTF8String:(const char *)nullTerminatedCString; -+ (id)stringWithCString:(const char *)cString encoding:(NSStringEncoding)enc; -+ (id)stringWithCString:(const char *)bytes; -- (instancetype)initWithUTF8String:(const char *)nullTerminatedCString; -@end - -enum MyEnm { - ME_foo -}; - -void foo() { - @INT_MIN; - bool cppb; - @(cppb); - MyEnm myenum; - @(myenum); - @(ME_foo); - [NSNumber numberWithDouble:cppb]; // expected-warning {{converting to boxing syntax requires casting 'bool' to 'double'}} -} - -void boxString() { - NSString *s = @"box"; - const char *cstr1; - char *cstr2; - s = @(cstr1); - s = @(cstr2); - s = @(cstr1); - s = @(cstr1); - s = [NSString stringWithCString:cstr1 encoding: NSUnicodeStringEncoding]; - NSStringEncoding encode; - s = [NSString stringWithCString:cstr1 encoding:encode]; - s = @(cstr1); - - static const char strarr[] = "coolbox"; - s = @(strarr); - // rdar://18080352 - const char *utf8Bytes = "blah"; - NSString *string1 = @(utf8Bytes); - NSString *string2 = @(utf8Bytes); -} diff --git a/test/ARCMT/objcmt-designated-initializer.m b/test/ARCMT/objcmt-designated-initializer.m deleted file mode 100644 index 279d4f35d8eb..000000000000 --- a/test/ARCMT/objcmt-designated-initializer.m +++ /dev/null @@ -1,44 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -objcmt-migrate-designated-init %s -triple x86_64-apple-darwin11 -fobjc-arc -migrate -o %t.remap -// RUN: c-arcmt-test %t.remap | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -x objective-c -fobjc-arc %s.result - -#define NS_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer)) - -@class NSString; - -@interface B1 --(id)init; -@end - -@interface S1 : B1 --(id)initWithFoo:(NSString*)foo; -@end - -@implementation S1 --(id)initWithFoo:(NSString*)foo -{ - self = [super init]; - if (self) { - } - return self; -} -@end - -@interface B2 --(id)init NS_DESIGNATED_INITIALIZER; -@end - -@interface S2 : B2 --(id)init; -@end - -@implementation S2 --(id)init -{ - self = [super init]; - if (self) { - } - return self; -} -@end diff --git a/test/ARCMT/objcmt-designated-initializer.m.result b/test/ARCMT/objcmt-designated-initializer.m.result deleted file mode 100644 index 4c59b0cc5826..000000000000 --- a/test/ARCMT/objcmt-designated-initializer.m.result +++ /dev/null @@ -1,44 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -objcmt-migrate-designated-init %s -triple x86_64-apple-darwin11 -fobjc-arc -migrate -o %t.remap -// RUN: c-arcmt-test %t.remap | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -x objective-c -fobjc-arc %s.result - -#define NS_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer)) - -@class NSString; - -@interface B1 --(id)init; -@end - -@interface S1 : B1 --(id)initWithFoo:(NSString*)foo NS_DESIGNATED_INITIALIZER; -@end - -@implementation S1 --(id)initWithFoo:(NSString*)foo -{ - self = [super init]; - if (self) { - } - return self; -} -@end - -@interface B2 --(id)init NS_DESIGNATED_INITIALIZER; -@end - -@interface S2 : B2 --(id)init; -@end - -@implementation S2 --(id)init -{ - self = [super init]; - if (self) { - } - return self; -} -@end diff --git a/test/ARCMT/objcmt-instancetype-2.m b/test/ARCMT/objcmt-instancetype-2.m deleted file mode 100644 index fb59265c4be3..000000000000 --- a/test/ARCMT/objcmt-instancetype-2.m +++ /dev/null @@ -1,103 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -objcmt-migrate-instancetype -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11 -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result - -typedef unsigned int NSUInteger; -typedef int NSInteger; -typedef char BOOL; -@class NSData, NSError, NSProtocolChecker, NSObject; -@class NSPortNameServer, NSTimeZone; - -@interface NSMutableString -@end - -@interface NSString @end - -@class NSString, NSURL; -@interface NSString (NSStringDeprecated) -+ (id)stringWithContentsOfFile:(NSString *)path __attribute__((availability(macosx,introduced=10.0 ,message="" ))); -+ (id)stringWithContentsOfURL:(NSURL *)url __attribute__((availability(macosx,introduced=10.0 ,message="" ))); -+ (id)stringWithCString:(const char *)bytes length:(NSUInteger)length __attribute__((availability(macosx,introduced=10.0 ,message="" ))); -+ (id)stringWithCString:(const char *)bytes __attribute__((availability(macosx,introduced=10.0 ,message="" ))); -@end - - -typedef enum NSURLBookmarkResolutionOptions { - Bookmark -} NSURLBookmarkResolutionOptions; - -@interface NSURL -+ (id)URLWithString:(NSString *)URLString; -+ (id)URLWithString:(NSString *)URLString relativeToURL:(NSURL *)baseURL; -+ (id)URLByResolvingBookmarkData:(NSData *)bookmarkData options:(NSURLBookmarkResolutionOptions)options relativeToURL:(NSURL *)relativeURL bookmarkDataIsStale:(BOOL *)isStale error:(NSError **)error __attribute__((availability(macosx,introduced=10.6))); -@end - -@class NSDictionary; -@interface NSError -+ (id)errorWithDomain:(NSString *)domain code:(NSInteger)code userInfo:(NSDictionary *)dict; -@end - - -@interface NSMutableString (NSMutableStringExtensionMethods) -+ (id)stringWithCapacity:(NSUInteger)capacity; -@end - -@interface NSMutableData -+ (id)dataWithCapacity:(NSUInteger)aNumItems; -+ (id)dataWithLength:(NSUInteger)length; -@end - -@interface NSMutableDictionary @end - -@interface NSMutableDictionary (NSSharedKeySetDictionary) -+ (id )dictionaryWithSharedKeySet:(id)keyset __attribute__((availability(macosx,introduced=10.8))); -@end - -@interface NSProtocolChecker -+ (id)protocolCheckerWithTarget:(NSObject *)anObject protocol:(Protocol *)aProtocol; -@end - -@interface NSConnection -+ (id)connectionWithRegisteredName:(NSString *)name host:(NSString *)hostName; -+ (id)connectionWithRegisteredName:(NSString *)name host:(NSString *)hostName usingNameServer:(NSPortNameServer *)server; -@end - -@interface NSDate -+ (id)dateWithString:(NSString *)aString __attribute__((availability(macosx,introduced=10.4))); -@end - -@interface NSCalendarDate : NSDate -+ (id)calendarDate __attribute__((availability(macosx,introduced=10.4))); -+ (id)dateWithString:(NSString *)description calendarFormat:(NSString *)format locale:(id)locale __attribute__((availability(macosx,introduced=10.4))); -+ (id)dateWithString:(NSString *)description calendarFormat:(NSString *)format __attribute__((availability(macosx,introduced=10.4))); -+ (id)dateWithYear:(NSInteger)year month:(NSUInteger)month day:(NSUInteger)day hour:(NSUInteger)hour minute:(NSUInteger)minute second:(NSUInteger)second timeZone:(NSTimeZone *)aTimeZone __attribute__((availability(macosx,introduced=10.4))); -@end - -@interface NSUserDefaults -+ (id) standardUserDefaults; -@end - -@interface NSNotificationCenter -+ (id) defaultCenter; -+ sharedCenter; -@end - -@interface UIApplication -+ (id)sharedApplication; -+ defaultApplication; -@end - -//===----------------------------------------------------------------------===// -// Method name that has a null IdentifierInfo* for its first selector slot. -// This test just makes sure that we handle it. -//===----------------------------------------------------------------------===// -@interface TestNullIdentifier -@end - -@implementation TestNullIdentifier -+ (id):(int)x, ... { - return 0; -} -@end - diff --git a/test/ARCMT/objcmt-instancetype-2.m.result b/test/ARCMT/objcmt-instancetype-2.m.result deleted file mode 100644 index 7a32894f5706..000000000000 --- a/test/ARCMT/objcmt-instancetype-2.m.result +++ /dev/null @@ -1,103 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -objcmt-migrate-instancetype -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11 -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result - -typedef unsigned int NSUInteger; -typedef int NSInteger; -typedef char BOOL; -@class NSData, NSError, NSProtocolChecker, NSObject; -@class NSPortNameServer, NSTimeZone; - -@interface NSMutableString -@end - -@interface NSString @end - -@class NSString, NSURL; -@interface NSString (NSStringDeprecated) -+ (id)stringWithContentsOfFile:(NSString *)path __attribute__((availability(macosx,introduced=10.0 ,message="" ))); -+ (id)stringWithContentsOfURL:(NSURL *)url __attribute__((availability(macosx,introduced=10.0 ,message="" ))); -+ (id)stringWithCString:(const char *)bytes length:(NSUInteger)length __attribute__((availability(macosx,introduced=10.0 ,message="" ))); -+ (id)stringWithCString:(const char *)bytes __attribute__((availability(macosx,introduced=10.0 ,message="" ))); -@end - - -typedef enum NSURLBookmarkResolutionOptions { - Bookmark -} NSURLBookmarkResolutionOptions; - -@interface NSURL -+ (instancetype)URLWithString:(NSString *)URLString; -+ (instancetype)URLWithString:(NSString *)URLString relativeToURL:(NSURL *)baseURL; -+ (instancetype)URLByResolvingBookmarkData:(NSData *)bookmarkData options:(NSURLBookmarkResolutionOptions)options relativeToURL:(NSURL *)relativeURL bookmarkDataIsStale:(BOOL *)isStale error:(NSError **)error __attribute__((availability(macosx,introduced=10.6))); -@end - -@class NSDictionary; -@interface NSError -+ (instancetype)errorWithDomain:(NSString *)domain code:(NSInteger)code userInfo:(NSDictionary *)dict; -@end - - -@interface NSMutableString (NSMutableStringExtensionMethods) -+ (instancetype)stringWithCapacity:(NSUInteger)capacity; -@end - -@interface NSMutableData -+ (instancetype)dataWithCapacity:(NSUInteger)aNumItems; -+ (instancetype)dataWithLength:(NSUInteger)length; -@end - -@interface NSMutableDictionary @end - -@interface NSMutableDictionary (NSSharedKeySetDictionary) -+ (instancetype )dictionaryWithSharedKeySet:(id)keyset __attribute__((availability(macosx,introduced=10.8))); -@end - -@interface NSProtocolChecker -+ (instancetype)protocolCheckerWithTarget:(NSObject *)anObject protocol:(Protocol *)aProtocol; -@end - -@interface NSConnection -+ (instancetype)connectionWithRegisteredName:(NSString *)name host:(NSString *)hostName; -+ (instancetype)connectionWithRegisteredName:(NSString *)name host:(NSString *)hostName usingNameServer:(NSPortNameServer *)server; -@end - -@interface NSDate -+ (instancetype)dateWithString:(NSString *)aString __attribute__((availability(macosx,introduced=10.4))); -@end - -@interface NSCalendarDate : NSDate -+ (instancetype)calendarDate __attribute__((availability(macosx,introduced=10.4))); -+ (instancetype)dateWithString:(NSString *)description calendarFormat:(NSString *)format locale:(id)locale __attribute__((availability(macosx,introduced=10.4))); -+ (instancetype)dateWithString:(NSString *)description calendarFormat:(NSString *)format __attribute__((availability(macosx,introduced=10.4))); -+ (instancetype)dateWithYear:(NSInteger)year month:(NSUInteger)month day:(NSUInteger)day hour:(NSUInteger)hour minute:(NSUInteger)minute second:(NSUInteger)second timeZone:(NSTimeZone *)aTimeZone __attribute__((availability(macosx,introduced=10.4))); -@end - -@interface NSUserDefaults -+ (instancetype) standardUserDefaults; -@end - -@interface NSNotificationCenter -+ (NSNotificationCenter*) defaultCenter; -+ (NSNotificationCenter*) sharedCenter; -@end - -@interface UIApplication -+ (UIApplication*)sharedApplication; -+ (UIApplication*) defaultApplication; -@end - -//===----------------------------------------------------------------------===// -// Method name that has a null IdentifierInfo* for its first selector slot. -// This test just makes sure that we handle it. -//===----------------------------------------------------------------------===// -@interface TestNullIdentifier -@end - -@implementation TestNullIdentifier -+ (id):(int)x, ... { - return 0; -} -@end - diff --git a/test/ARCMT/objcmt-instancetype-unnecessary-diff.m b/test/ARCMT/objcmt-instancetype-unnecessary-diff.m deleted file mode 100644 index e250bb0956c0..000000000000 --- a/test/ARCMT/objcmt-instancetype-unnecessary-diff.m +++ /dev/null @@ -1,10 +0,0 @@ -// RUN: %clang_cc1 -objcmt-migrate-instancetype %s -triple x86_64-apple-darwin11 -fobjc-arc -migrate -o %t.remap -// RUN: FileCheck %s -input-file=%t.remap - -// Make sure we don't create an edit unnecessarily. -// CHECK-NOT: instancetype - -@class NSString; -@interface NSDictionary -+(instancetype) dictionaryWithURLEncodedString:(NSString *)urlEncodedString; -@end diff --git a/test/ARCMT/objcmt-instancetype.m b/test/ARCMT/objcmt-instancetype.m deleted file mode 100644 index 47dbd7aeed5a..000000000000 --- a/test/ARCMT/objcmt-instancetype.m +++ /dev/null @@ -1,111 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -objcmt-migrate-instancetype -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11 -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result - -typedef signed char BOOL; -#define nil ((void*) 0) - -@interface NSObject -+ (id)alloc; -@end - -@interface NSString : NSObject -+ (id)stringWithString:(NSString *)string; -- (id)initWithString:(NSString *)aString; -@end - -@implementation NSString : NSObject -+ (id)stringWithString:(NSString *)string { return 0; }; -- (instancetype)initWithString:(NSString *)aString { return 0; }; -@end - -@interface NSArray : NSObject -- (id)objectAtIndex:(unsigned long)index; -- (id)objectAtIndexedSubscript:(int)index; -@end - -@interface NSArray (NSArrayCreation) -+ (id)array; -+ (id)arrayWithObject:(id)anObject; -+ (id)arrayWithObjects:(const id [])objects count:(unsigned long)cnt; -+ (id)arrayWithObjects:(id)firstObj, ...; -+ arrayWithArray:(NSArray *)array; - -- (id)initWithObjects:(const id [])objects count:(unsigned long)cnt; -- (id)initWithObjects:(id)firstObj, ...; -- (id)initWithArray:(NSArray *)array; - -- (id)objectAtIndex:(unsigned long)index; -@end - -@implementation NSArray (NSArrayCreation) -+ (id)array { return 0; } -+ (id)arrayWithObject:(id)anObject { - return anObject; -} -+ (id)arrayWithObjects:(const id [])objects count:(unsigned long)cnt { return 0; } -+ (id)arrayWithObjects:(id)firstObj, ... { - return 0; } -+ arrayWithArray:(NSArray *)array { - return 0; -} - -- (id)initWithObjects:(const id [])objects count:(unsigned long)cnt { return 0; } -- (id)initWithObjects:(id)firstObj, ... { return 0; } -- (id)initWithArray:(NSArray *)array { return 0; } - -- (id)objectAtIndex:(unsigned long)index { return 0; } -@end - -@interface NSMutableArray : NSArray -- (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject; -- (void)setObject:(id)object atIndexedSubscript:(int)index; -@end - -@interface NSDictionary : NSObject -- (id)objectForKeyedSubscript:(id)key; -@end - -@interface NSDictionary (NSDictionaryCreation) -+ (id)dictionary; -+ (id)dictionaryWithObject:(id)object forKey:(id)key; -+ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt; -+ dictionaryWithObjectsAndKeys:(id)firstObject, ...; -+ (id)dictionaryWithDictionary:(NSDictionary *)dict; -+ (id)dictionaryWithObjects:(NSArray *)objects forKeys:(NSArray *)keys; - -- (id)initWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt; -- (id)initWithObjectsAndKeys:(id)firstObject, ...; -- (id)initWithDictionary:(NSDictionary *)otherDictionary; -- (id)initWithObjects:(NSArray *)objects forKeys:(NSArray *)keys; - -- (id)objectForKey:(id)aKey; -@end - -@interface NSMutableDictionary : NSDictionary -- (void)setObject:(id)anObject forKey:(id)aKey; -- (void)setObject:(id)object forKeyedSubscript:(id)key; -@end - -@interface NSNumber : NSObject -@end - -@interface NSNumber (NSNumberCreation) -+ (NSNumber *)numberWithInt:(int)value; -@end - -@implementation NSNumber (NSNumberCreation) -+ (NSNumber *)numberWithInt:(int)value { return 0; } -@end - -#define M(x) (x) -#define PAIR(x) @#x, [NSNumber numberWithInt:(x)] -#define TWO(x) ((x), (x)) - -void foo() { - NSString *str = M([NSString stringWithString:@"foo"]); // expected-warning {{redundant}} - str = [[NSString alloc] initWithString:@"foo"]; // expected-warning {{redundant}} - NSArray *arr = [NSArray arrayWithArray:@[str]]; // expected-warning {{redundant}} - NSDictionary *dict = [NSDictionary dictionaryWithDictionary:@{str: arr}]; // expected-warning {{redundant}} -} diff --git a/test/ARCMT/objcmt-instancetype.m.result b/test/ARCMT/objcmt-instancetype.m.result deleted file mode 100644 index ce51678708dd..000000000000 --- a/test/ARCMT/objcmt-instancetype.m.result +++ /dev/null @@ -1,111 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -objcmt-migrate-instancetype -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11 -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result - -typedef signed char BOOL; -#define nil ((void*) 0) - -@interface NSObject -+ (id)alloc; -@end - -@interface NSString : NSObject -+ (instancetype)stringWithString:(NSString *)string; -- (instancetype)initWithString:(NSString *)aString; -@end - -@implementation NSString : NSObject -+ (instancetype)stringWithString:(NSString *)string { return 0; }; -- (instancetype)initWithString:(NSString *)aString { return 0; }; -@end - -@interface NSArray : NSObject -- (id)objectAtIndex:(unsigned long)index; -- (id)objectAtIndexedSubscript:(int)index; -@end - -@interface NSArray (NSArrayCreation) -+ (instancetype)array; -+ (instancetype)arrayWithObject:(id)anObject; -+ (instancetype)arrayWithObjects:(const id [])objects count:(unsigned long)cnt; -+ (instancetype)arrayWithObjects:(id)firstObj, ...; -+ (instancetype) arrayWithArray:(NSArray *)array; - -- (instancetype)initWithObjects:(const id [])objects count:(unsigned long)cnt; -- (instancetype)initWithObjects:(id)firstObj, ...; -- (instancetype)initWithArray:(NSArray *)array; - -- (id)objectAtIndex:(unsigned long)index; -@end - -@implementation NSArray (NSArrayCreation) -+ (instancetype)array { return 0; } -+ (instancetype)arrayWithObject:(id)anObject { - return anObject; -} -+ (instancetype)arrayWithObjects:(const id [])objects count:(unsigned long)cnt { return 0; } -+ (instancetype)arrayWithObjects:(id)firstObj, ... { - return 0; } -+ (instancetype) arrayWithArray:(NSArray *)array { - return 0; -} - -- (instancetype)initWithObjects:(const id [])objects count:(unsigned long)cnt { return 0; } -- (instancetype)initWithObjects:(id)firstObj, ... { return 0; } -- (instancetype)initWithArray:(NSArray *)array { return 0; } - -- (id)objectAtIndex:(unsigned long)index { return 0; } -@end - -@interface NSMutableArray : NSArray -- (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject; -- (void)setObject:(id)object atIndexedSubscript:(int)index; -@end - -@interface NSDictionary : NSObject -- (id)objectForKeyedSubscript:(id)key; -@end - -@interface NSDictionary (NSDictionaryCreation) -+ (instancetype)dictionary; -+ (instancetype)dictionaryWithObject:(id)object forKey:(id)key; -+ (instancetype)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt; -+ (instancetype) dictionaryWithObjectsAndKeys:(id)firstObject, ...; -+ (instancetype)dictionaryWithDictionary:(NSDictionary *)dict; -+ (instancetype)dictionaryWithObjects:(NSArray *)objects forKeys:(NSArray *)keys; - -- (instancetype)initWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt; -- (instancetype)initWithObjectsAndKeys:(id)firstObject, ...; -- (instancetype)initWithDictionary:(NSDictionary *)otherDictionary; -- (instancetype)initWithObjects:(NSArray *)objects forKeys:(NSArray *)keys; - -- (id)objectForKey:(id)aKey; -@end - -@interface NSMutableDictionary : NSDictionary -- (void)setObject:(id)anObject forKey:(id)aKey; -- (void)setObject:(id)object forKeyedSubscript:(id)key; -@end - -@interface NSNumber : NSObject -@end - -@interface NSNumber (NSNumberCreation) -+ (NSNumber *)numberWithInt:(int)value; -@end - -@implementation NSNumber (NSNumberCreation) -+ (NSNumber *)numberWithInt:(int)value { return 0; } -@end - -#define M(x) (x) -#define PAIR(x) @#x, [NSNumber numberWithInt:(x)] -#define TWO(x) ((x), (x)) - -void foo() { - NSString *str = M([NSString stringWithString:@"foo"]); // expected-warning {{redundant}} - str = [[NSString alloc] initWithString:@"foo"]; // expected-warning {{redundant}} - NSArray *arr = [NSArray arrayWithArray:@[str]]; // expected-warning {{redundant}} - NSDictionary *dict = [NSDictionary dictionaryWithDictionary:@{str: arr}]; // expected-warning {{redundant}} -} diff --git a/test/ARCMT/objcmt-invalid-code.mm b/test/ARCMT/objcmt-invalid-code.mm deleted file mode 100644 index f780d3de57ed..000000000000 --- a/test/ARCMT/objcmt-invalid-code.mm +++ /dev/null @@ -1,19 +0,0 @@ -// REQUIRES: x86-registered-target -// RUN: rm -rf %t -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only %s -verify -// RUN: not %clang_cc1 -triple x86_64-apple-darwin10 -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result - -// Make sure there is no crash. - -@interface NSObject @end -@interface NSNumber : NSObject -@end - -@interface NSNumber (NSNumberCreation) -+ (NSNumber *)numberWithInt:(int)value; -@end - -void foo(int x = undeclared) { // expected-error {{undeclared}} - NSNumber *n = [NSNumber numberWithInt:1]; -} diff --git a/test/ARCMT/objcmt-invalid-code.mm.result b/test/ARCMT/objcmt-invalid-code.mm.result deleted file mode 100644 index 52b2db00f610..000000000000 --- a/test/ARCMT/objcmt-invalid-code.mm.result +++ /dev/null @@ -1,19 +0,0 @@ -// REQUIRES: x86-registered-target -// RUN: rm -rf %t -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only %s -verify -// RUN: not %clang_cc1 -triple x86_64-apple-darwin10 -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result - -// Make sure there is no crash. - -@interface NSObject @end -@interface NSNumber : NSObject -@end - -@interface NSNumber (NSNumberCreation) -+ (NSNumber *)numberWithInt:(int)value; -@end - -void foo(int x = undeclared) { // expected-error {{undeclared}} - NSNumber *n = @1; -} diff --git a/test/ARCMT/objcmt-migrate-all.m b/test/ARCMT/objcmt-migrate-all.m deleted file mode 100644 index 7ae898cf9cba..000000000000 --- a/test/ARCMT/objcmt-migrate-all.m +++ /dev/null @@ -1,135 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -objcmt-migrate-all -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11 -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result -// rdar://15396636 - -#ifndef NS_RETURNS_INNER_POINTER // defined in iOS 6 for sure -#define NS_RETURNS_INNER_POINTER __attribute__((objc_returns_inner_pointer)) -#endif - -#define CF_IMPLICIT_BRIDGING_ENABLED _Pragma("clang arc_cf_code_audited begin") - -#define CF_IMPLICIT_BRIDGING_DISABLED _Pragma("clang arc_cf_code_audited end") - -#if __has_feature(attribute_ns_returns_retained) -#define NS_RETURNS_RETAINED __attribute__((ns_returns_retained)) -#endif -#if __has_feature(attribute_cf_returns_retained) -#define CF_RETURNS_RETAINED __attribute__((cf_returns_retained)) -#endif -#if __has_feature(attribute_ns_returns_not_retained) -#define NS_RETURNS_NOT_RETAINED __attribute__((ns_returns_not_retained)) -#endif -#if __has_feature(attribute_cf_returns_not_retained) -#define CF_RETURNS_NOT_RETAINED __attribute__((cf_returns_not_retained)) -#endif -#if __has_feature(attribute_ns_consumes_self) -#define NS_CONSUMES_SELF __attribute__((ns_consumes_self)) -#endif -#if __has_feature(attribute_ns_consumed) -#define NS_CONSUMED __attribute__((ns_consumed)) -#endif -#if __has_feature(attribute_cf_consumed) -#define CF_CONSUMED __attribute__((cf_consumed)) -#endif -#if __has_attribute(ns_returns_autoreleased) -#define NS_RETURNS_AUTORELEASED __attribute__((ns_returns_autoreleased)) -#endif - -#define NS_AVAILABLE __attribute__((availability(macosx,introduced=10.0))) - -CF_IMPLICIT_BRIDGING_ENABLED - -typedef unsigned long CFTypeID; -typedef unsigned long CFOptionFlags; -typedef unsigned long CFHashCode; - -typedef signed long CFIndex; /*AnyObj*/ -typedef const struct __CFArray * CFArrayRef; -typedef struct { - CFIndex location; - CFIndex length; -} CFRange; - -typedef void (*CFArrayApplierFunction)(const void *value, void *context); - -typedef enum CFComparisonResult : CFIndex CFComparisonResult; enum CFComparisonResult : CFIndex { - kCFCompareLessThan = -1L, - kCFCompareEqualTo = 0, - kCFCompareGreaterThan = 1 -}; - - -typedef CFComparisonResult (*CFComparatorFunction)(const void *val1, const void *val2, void *context); - -typedef struct __CFArray * CFMutableArrayRef; - -typedef const struct __CFAttributedString *CFAttributedStringRef; -typedef struct __CFAttributedString *CFMutableAttributedStringRef; - -typedef const struct __CFAllocator * CFAllocatorRef; - -typedef const struct __CFString * CFStringRef; -typedef struct __CFString * CFMutableStringRef; - -typedef const struct __CFDictionary * CFDictionaryRef; -typedef struct __CFDictionary * CFMutableDictionaryRef; - -typedef struct CGImage *CGImageRef; - -typedef struct OpaqueJSValue* JSObjectRef; - -typedef JSObjectRef TTJSObjectRef; -typedef unsigned int NSUInteger; - -CF_IMPLICIT_BRIDGING_DISABLED - -@interface I -- (void*) ReturnsInnerPointer; -- (int*) AlreadyReturnsInnerPointer NS_RETURNS_INNER_POINTER; -@end - -@interface UIImage -- (CGImageRef)CGImage; -@end - -@interface NSData -- (void *)bytes; -- (void **) ptr_bytes __attribute__((availability(macosx,unavailable))); -@end - -@interface NSMutableData -- (void *)mutableBytes __attribute__((deprecated)) __attribute__((unavailable)); -@end - -@interface JS -- (JSObjectRef)JSObject; -- (TTJSObjectRef)JSObject1; -- (JSObjectRef*)JSObject2; -@end - -// rdar://15044991 -typedef void *SecTrustRef; - -@interface NSURLProtectionSpace -@property (readonly) SecTrustRef serverTrust NS_AVAILABLE; -- (void *) FOO NS_AVAILABLE; -@property (readonly) void * mitTrust NS_AVAILABLE; - -@property (readonly) void * mittiTrust; - -@property (readonly) SecTrustRef XserverTrust; - -- (SecTrustRef) FOO1 NS_AVAILABLE; - -+ (const NSURLProtectionSpace *)ProtectionSpace; - -// pointer personality functions -@property NSUInteger (*hashFunction)(const void *item, NSUInteger (*size)(const void *item)); -@end - -@interface MustNotMigrateToInnerPointer -- (void*) nono; -- (void) setNono : (void*) val; -@end diff --git a/test/ARCMT/objcmt-migrate-all.m.result b/test/ARCMT/objcmt-migrate-all.m.result deleted file mode 100644 index d2ee4090b28c..000000000000 --- a/test/ARCMT/objcmt-migrate-all.m.result +++ /dev/null @@ -1,134 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -objcmt-migrate-all -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11 -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result -// rdar://15396636 - -#ifndef NS_RETURNS_INNER_POINTER // defined in iOS 6 for sure -#define NS_RETURNS_INNER_POINTER __attribute__((objc_returns_inner_pointer)) -#endif - -#define CF_IMPLICIT_BRIDGING_ENABLED _Pragma("clang arc_cf_code_audited begin") - -#define CF_IMPLICIT_BRIDGING_DISABLED _Pragma("clang arc_cf_code_audited end") - -#if __has_feature(attribute_ns_returns_retained) -#define NS_RETURNS_RETAINED __attribute__((ns_returns_retained)) -#endif -#if __has_feature(attribute_cf_returns_retained) -#define CF_RETURNS_RETAINED __attribute__((cf_returns_retained)) -#endif -#if __has_feature(attribute_ns_returns_not_retained) -#define NS_RETURNS_NOT_RETAINED __attribute__((ns_returns_not_retained)) -#endif -#if __has_feature(attribute_cf_returns_not_retained) -#define CF_RETURNS_NOT_RETAINED __attribute__((cf_returns_not_retained)) -#endif -#if __has_feature(attribute_ns_consumes_self) -#define NS_CONSUMES_SELF __attribute__((ns_consumes_self)) -#endif -#if __has_feature(attribute_ns_consumed) -#define NS_CONSUMED __attribute__((ns_consumed)) -#endif -#if __has_feature(attribute_cf_consumed) -#define CF_CONSUMED __attribute__((cf_consumed)) -#endif -#if __has_attribute(ns_returns_autoreleased) -#define NS_RETURNS_AUTORELEASED __attribute__((ns_returns_autoreleased)) -#endif - -#define NS_AVAILABLE __attribute__((availability(macosx,introduced=10.0))) - -CF_IMPLICIT_BRIDGING_ENABLED - -typedef unsigned long CFTypeID; -typedef unsigned long CFOptionFlags; -typedef unsigned long CFHashCode; - -typedef signed long CFIndex; /*AnyObj*/ -typedef const struct __CFArray * CFArrayRef; -typedef struct { - CFIndex location; - CFIndex length; -} CFRange; - -typedef void (*CFArrayApplierFunction)(const void *value, void *context); - -typedef enum CFComparisonResult : CFIndex CFComparisonResult; enum CFComparisonResult : CFIndex { - kCFCompareLessThan = -1L, - kCFCompareEqualTo = 0, - kCFCompareGreaterThan = 1 -}; - - -typedef CFComparisonResult (*CFComparatorFunction)(const void *val1, const void *val2, void *context); - -typedef struct __CFArray * CFMutableArrayRef; - -typedef const struct __CFAttributedString *CFAttributedStringRef; -typedef struct __CFAttributedString *CFMutableAttributedStringRef; - -typedef const struct __CFAllocator * CFAllocatorRef; - -typedef const struct __CFString * CFStringRef; -typedef struct __CFString * CFMutableStringRef; - -typedef const struct __CFDictionary * CFDictionaryRef; -typedef struct __CFDictionary * CFMutableDictionaryRef; - -typedef struct CGImage *CGImageRef; - -typedef struct OpaqueJSValue* JSObjectRef; - -typedef JSObjectRef TTJSObjectRef; -typedef unsigned int NSUInteger; - -CF_IMPLICIT_BRIDGING_DISABLED - -@interface I -@property (nonatomic, readonly) void *ReturnsInnerPointer; -@property (nonatomic, readonly) int *AlreadyReturnsInnerPointer NS_RETURNS_INNER_POINTER; -@end - -@interface UIImage -@property (nonatomic, readonly) CGImageRef CGImage CF_RETURNS_NOT_RETAINED; -@end - -@interface NSData -@property (nonatomic, readonly) void *bytes; -@property (nonatomic, readonly) void **ptr_bytes __attribute__((availability(macosx,unavailable))); -@end - -@interface NSMutableData -@property (nonatomic, readonly) void *mutableBytes __attribute__((deprecated)) __attribute__((unavailable)); -@end - -@interface JS -@property (nonatomic, readonly) JSObjectRef JSObject; -@property (nonatomic, readonly) TTJSObjectRef JSObject1; -@property (nonatomic, readonly) JSObjectRef *JSObject2; -@end - -// rdar://15044991 -typedef void *SecTrustRef; - -@interface NSURLProtectionSpace -@property (readonly) SecTrustRef serverTrust NS_AVAILABLE; -@property (nonatomic, readonly) void *FOO NS_AVAILABLE; -@property (readonly) void * mitTrust NS_AVAILABLE; - -@property (readonly) void * mittiTrust; - -@property (readonly) SecTrustRef XserverTrust; - -@property (nonatomic, readonly) SecTrustRef FOO1 NS_AVAILABLE; - -+ (const NSURLProtectionSpace *)ProtectionSpace; - -// pointer personality functions -@property NSUInteger (*hashFunction)(const void *item, NSUInteger (*size)(const void *item)); -@end - -@interface MustNotMigrateToInnerPointer -@property (nonatomic) void *nono; -@end diff --git a/test/ARCMT/objcmt-ns-enum-crash.m b/test/ARCMT/objcmt-ns-enum-crash.m deleted file mode 100644 index 7c9c708efaef..000000000000 --- a/test/ARCMT/objcmt-ns-enum-crash.m +++ /dev/null @@ -1,14 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -objcmt-migrate-ns-macros -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11 -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result - -#define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type -#define NS_OPTIONS(_type, _name) enum _name : _type _name; enum _name : _type -typedef long NSInteger; - -typedef enum : NSInteger {five} ApplicableEnum; - -typedef unsigned long mytd; - -#define MY_ENUM(name, type, ...) typedef enum : type { __VA_ARGS__ } name##_t -MY_ENUM(MyEnum, unsigned int, One); diff --git a/test/ARCMT/objcmt-ns-enum-crash.m.result b/test/ARCMT/objcmt-ns-enum-crash.m.result deleted file mode 100644 index 0a76e66ea211..000000000000 --- a/test/ARCMT/objcmt-ns-enum-crash.m.result +++ /dev/null @@ -1,14 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -objcmt-migrate-ns-macros -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11 -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result - -#define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type -#define NS_OPTIONS(_type, _name) enum _name : _type _name; enum _name : _type -typedef long NSInteger; - -typedef NS_ENUM(NSInteger, ApplicableEnum) {five}; - -typedef unsigned long mytd; - -#define MY_ENUM(name, type, ...) typedef enum : type { __VA_ARGS__ } name##_t -MY_ENUM(MyEnum, unsigned int, One); diff --git a/test/ARCMT/objcmt-ns-macros.m b/test/ARCMT/objcmt-ns-macros.m deleted file mode 100644 index 5bc390be58e1..000000000000 --- a/test/ARCMT/objcmt-ns-macros.m +++ /dev/null @@ -1,388 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -objcmt-migrate-ns-macros -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11 -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result - -typedef signed char int8_t; -typedef short int16_t; -typedef int int32_t; -typedef long NSInteger; -typedef long long int64_t; - -typedef unsigned char uint8_t; -typedef unsigned short uint16_t; -typedef unsigned int uint32_t; -typedef unsigned long NSUInteger; -typedef unsigned long long uint64_t; - -#define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type -#define NS_OPTIONS(_type, _name) enum _name : _type _name; enum _name : _type -#define DEPRECATED __attribute__((deprecated)) - -enum { - blah, - blarg -}; -typedef NSInteger wibble; - -enum { - UIViewAutoresizingNone = 0, - UIViewAutoresizingFlexibleLeftMargin, - UIViewAutoresizingFlexibleWidth, - UIViewAutoresizingFlexibleRightMargin, - UIViewAutoresizingFlexibleTopMargin, - UIViewAutoresizingFlexibleHeight, - UIViewAutoresizingFlexibleBottomMargin -}; -typedef NSUInteger UITableViewCellStyle; - -typedef enum { - UIViewAnimationTransitionNone, - UIViewAnimationTransitionFlipFromLeft, - UIViewAnimationTransitionFlipFromRight, - UIViewAnimationTransitionCurlUp, - UIViewAnimationTransitionCurlDown, -} UIViewAnimationTransition; - -typedef enum { - UIViewOne = 0, - UIViewTwo = 1 << 0, - UIViewThree = 1 << 1, - UIViewFour = 1 << 2, - UIViewFive = 1 << 3, - UIViewSix = 1 << 4, - UIViewSeven = 1 << 5 -} UITableView; - -enum { - UIOne = 0, - UITwo = 0x1, - UIthree = 0x8, - UIFour = 0x100 -}; -typedef NSInteger UI; - -typedef enum { - UIP2One = 0, - UIP2Two = 0x1, - UIP2three = 0x8, - UIP2Four = 0x100 -} UIPOWER2; - -enum { - UNOne, - UNTwo -}; - -// Should use NS_ENUM even though it is all power of 2. -enum { - UIKOne = 1, - UIKTwo = 2, -}; -typedef NSInteger UIK; - -typedef enum { - NSTickMarkBelow = 0, - NSTickMarkAbove = 1, - NSTickMarkLeft = NSTickMarkAbove, - NSTickMarkRight = NSTickMarkBelow -} NSTickMarkPosition; - -enum { - UIViewNone = 0x0, - UIViewMargin = 0x1, - UIViewWidth = 0x2, - UIViewRightMargin = 0x3, - UIViewBottomMargin = 0xbadbeef -}; -typedef NSInteger UITableStyle; - -enum { - UIView0 = 0, - UIView1 = 0XBADBEEF -}; -typedef NSInteger UIStyle; - -enum { - NSTIFFFileType, - NSBMPFileType, - NSGIFFileType, - NSJPEGFileType, - NSPNGFileType, - NSJPEG2000FileType -}; -typedef NSUInteger NSBitmapImageFileType; - -enum { - NSWarningAlertStyle = 0, - NSInformationalAlertStyle = 1, - NSCriticalAlertStyle = 2 -}; -typedef NSUInteger NSAlertStyle; - -enum { - D_NSTIFFFileType, - D_NSBMPFileType, - D_NSGIFFileType, - D_NSJPEGFileType, - D_NSPNGFileType, - D_NSJPEG2000FileType -}; -typedef NSUInteger D_NSBitmapImageFileType DEPRECATED; - -typedef enum { - D_NSTickMarkBelow = 0, - D_NSTickMarkAbove = 1 -} D_NSTickMarkPosition DEPRECATED; - - -#define NS_ENUM_AVAILABLE(X,Y) - -enum { - NSFStrongMemory NS_ENUM_AVAILABLE(10_5, 6_0) = (0UL << 0), - NSFOpaqueMemory NS_ENUM_AVAILABLE(10_5, 6_0) = (2UL << 0), - NSFMallocMemory NS_ENUM_AVAILABLE(10_5, 6_0) = (3UL << 0), - NSFMachVirtualMemory NS_ENUM_AVAILABLE(10_5, 6_0) = (4UL << 0), - NSFWeakMemory NS_ENUM_AVAILABLE(10_8, 6_0) = (5UL << 0), - - NSFObjectPersonality NS_ENUM_AVAILABLE(10_5, 6_0) = (0UL << 8), - NSFOpaquePersonality NS_ENUM_AVAILABLE(10_5, 6_0) = (1UL << 8), - NSFObjectPointerPersonality NS_ENUM_AVAILABLE(10_5, 6_0) = (2UL << 8), - NSFCStringPersonality NS_ENUM_AVAILABLE(10_5, 6_0) = (3UL << 8), - NSFStructPersonality NS_ENUM_AVAILABLE(10_5, 6_0) = (4UL << 8), - NSFIntegerPersonality NS_ENUM_AVAILABLE(10_5, 6_0) = (5UL << 8), - NSFCopyIn NS_ENUM_AVAILABLE(10_5, 6_0) = (1UL << 16), -}; - -typedef NSUInteger NSFOptions; - -typedef enum { - UIP0One = 0, - UIP0Two = 1, - UIP0Three = 2, - UIP0Four = 10, - UIP0Last = 0x100 -} UIP; - -typedef enum { - UIPZero = 0x0, - UIPOne = 0x1, - UIPTwo = 0x2, - UIP10 = 0x10, - UIPHundred = 0x100 -} UIP_3; - -typedef enum { - UIP4Zero = 0x0, - UIP4One = 0x1, - UIP4Two = 0x2, - UIP410 = 0x10, - UIP4Hundred = 100 -} UIP4_3; - -typedef enum { - UIP5Zero = 0x0, - UIP5Two = 0x2, - UIP510 = 0x3, - UIP5Hundred = 0x4 -} UIP5_3; - -typedef enum { - UIP6Zero = 0x0, - UIP6One = 0x1, - UIP6Two = 0x2, - UIP610 = 10, - UIP6Hundred = 0x100 -} UIP6_3; - -typedef enum { - UIP7Zero = 0x0, - UIP7One = 1, - UIP7Two = 0x2, - UIP710 = 10, - UIP7Hundred = 100 -} UIP7_3; - - -typedef enum { - Random = 0, - Random1 = 2, - Random2 = 4, - Random3 = 0x12345, - Random4 = 0x3444444, - Random5 = 0xbadbeef, - Random6 -} UIP8_3; - -// rdar://15200602 -#define NS_AVAILABLE_MAC(X) __attribute__((availability(macosx,introduced=X))) -#define NS_ENUM_AVAILABLE_MAC(X) __attribute__((availability(macosx,introduced=X))) - -enum { - NSModalResponseStop = (-1000), // Also used as the default response for sheets - NSModalResponseAbort = (-1001), - NSModalResponseContinue = (-1002), -} NS_ENUM_AVAILABLE_MAC(10.9); -typedef NSInteger NSModalResponse NS_AVAILABLE_MAC(10.9); - -// rdar://15201056 -typedef NSUInteger FarFarAwayOptions; - -// rdar://15200915 -typedef NSUInteger FarAwayOptions; -enum { - NSWorkspaceLaunchAndPrint = 0x00000002, - NSWorkspaceLaunchWithErrorPresentation = 0x00000040, - NSWorkspaceLaunchInhibitingBackgroundOnly = 0x00000080, - NSWorkspaceLaunchWithoutAddingToRecents = 0x00000100, - NSWorkspaceLaunchWithoutActivation = 0x00000200, - NSWorkspaceLaunchAsync = 0x00010000, - NSWorkspaceLaunchAllowingClassicStartup = 0x00020000, - NSWorkspaceLaunchPreferringClassic = 0x00040000, - NSWorkspaceLaunchNewInstance = 0x00080000, - NSWorkspaceLaunchAndHide = 0x00100000, - NSWorkspaceLaunchAndHideOthers = 0x00200000, - NSWorkspaceLaunchDefault = NSWorkspaceLaunchAsync | - NSWorkspaceLaunchAllowingClassicStartup -}; -typedef NSUInteger NSWorkspaceLaunchOptions; - -enum { - NSExcludeQuickDrawElementsIconCreationOption = 1 << 1, - NSExclude10_4ElementsIconCreationOption = 1 << 2 -}; -typedef NSUInteger NSExcludeOptions; - -enum { - NSExcludeQuickDrawElementsCreationOption = 1 << 1, - NSExclude10_4ElementsCreationOption = 1 << 2 -}; -typedef NSUInteger NSExcludeCreationOption; - -enum { - FarAway1 = 1 << 1, - FarAway2 = 1 << 2 -}; - -enum { - NSExcludeQuickDrawElementsIconOption = 1 << 1, - NSExclude10_4ElementsIconOption = 1 << 2 -}; -typedef NSUInteger NSExcludeIconOptions; - -@interface INTF { - NSExcludeIconOptions I1; - NSExcludeIconOptions I2; -} -@end - -enum { - FarFarAway1 = 1 << 1, - FarFarAway2 = 1 << 2 -}; - -// rdar://15200915 -typedef NS_OPTIONS(NSUInteger, NSWindowOcclusionState) { - NSWindowOcclusionStateVisible = 1UL << 1, -}; - -typedef NSUInteger NSWindowNumberListOptions; - -enum { - NSDirectSelection = 0, - NSSelectingNext, - NSSelectingPrevious -}; -typedef NSUInteger NSSelectionDirection; - -// standard window buttons -enum { - NSWindowCloseButton, - NSWindowMiniaturizeButton, - NSWindowZoomButton, - NSWindowToolbarButton, - NSWindowDocumentIconButton -}; - -// rdar://18262255 -typedef enum : NSUInteger { - ThingOne, - ThingTwo, - ThingThree, -} Thing; - -// rdar://18498539 -typedef enum { - one = 1 -} NumericEnum; - -typedef enum { - Two = 2 -}NumericEnum2; - -typedef enum { - Three = 3 -} -NumericEnum3; - -typedef enum { - Four = 4 -} - - NumericEnum4; - -// rdar://18532199 -enum -{ - UI8one = 1 -}; -typedef int8_t MyEnumeratedType; - - -enum { - UI16One = 0, - UI16Two = 0x1, - UI16three = 0x8, - UI16Four = 0x100 -}; -typedef int16_t UI16; - -enum { - UI32ViewAutoresizingNone = 0, - UI32ViewAutoresizingFlexibleLeftMargin, - UI32ViewAutoresizingFlexibleWidth, - UI32ViewAutoresizingFlexibleRightMargin, - UI32ViewAutoresizingFlexibleTopMargin, - UI32ViewAutoresizingFlexibleHeight, - UI32ViewAutoresizingFlexibleBottomMargin -}; -typedef uint32_t UI32TableViewCellStyle; - -enum -{ - UIU8one = 1 -}; -typedef uint8_t UI8Type; - -// rdar://19352510 -typedef enum : NSInteger {zero} MyEnum; - -typedef enum : NSUInteger {two} MyEnumNSUInteger; - -typedef enum : int {three, four} MyEnumint; - -typedef enum : unsigned long {five} MyEnumlonglong; - -typedef enum : unsigned long long { - ll1, - ll2= 0xff, - ll3, - ll4 -} MyEnumunsignedlonglong; - -// rdar://19994496 -typedef enum : int8_t {int8_one} MyOneEnum; - -typedef enum : int16_t { - int16_t_one, - int16_t_two } Myint16_tEnum; diff --git a/test/ARCMT/objcmt-ns-macros.m.result b/test/ARCMT/objcmt-ns-macros.m.result deleted file mode 100644 index 010782776736..000000000000 --- a/test/ARCMT/objcmt-ns-macros.m.result +++ /dev/null @@ -1,364 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -objcmt-migrate-ns-macros -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11 -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result - -typedef signed char int8_t; -typedef short int16_t; -typedef int int32_t; -typedef long NSInteger; -typedef long long int64_t; - -typedef unsigned char uint8_t; -typedef unsigned short uint16_t; -typedef unsigned int uint32_t; -typedef unsigned long NSUInteger; -typedef unsigned long long uint64_t; - -#define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type -#define NS_OPTIONS(_type, _name) enum _name : _type _name; enum _name : _type -#define DEPRECATED __attribute__((deprecated)) - -typedef NS_ENUM(NSInteger, wibble) { - blah, - blarg -}; - -typedef NS_ENUM(NSUInteger, UITableViewCellStyle) { - UIViewAutoresizingNone = 0, - UIViewAutoresizingFlexibleLeftMargin, - UIViewAutoresizingFlexibleWidth, - UIViewAutoresizingFlexibleRightMargin, - UIViewAutoresizingFlexibleTopMargin, - UIViewAutoresizingFlexibleHeight, - UIViewAutoresizingFlexibleBottomMargin -}; - -typedef NS_ENUM(unsigned int, UIViewAnimationTransition) { - UIViewAnimationTransitionNone, - UIViewAnimationTransitionFlipFromLeft, - UIViewAnimationTransitionFlipFromRight, - UIViewAnimationTransitionCurlUp, - UIViewAnimationTransitionCurlDown, -}; - -typedef NS_OPTIONS(unsigned int, UITableView) { - UIViewOne = 0, - UIViewTwo = 1 << 0, - UIViewThree = 1 << 1, - UIViewFour = 1 << 2, - UIViewFive = 1 << 3, - UIViewSix = 1 << 4, - UIViewSeven = 1 << 5 -}; - -typedef NS_OPTIONS(NSUInteger, UI) { - UIOne = 0, - UITwo = 0x1, - UIthree = 0x8, - UIFour = 0x100 -}; - -typedef NS_OPTIONS(unsigned int, UIPOWER2) { - UIP2One = 0, - UIP2Two = 0x1, - UIP2three = 0x8, - UIP2Four = 0x100 -}; - -enum { - UNOne, - UNTwo -}; - -// Should use NS_ENUM even though it is all power of 2. -typedef NS_ENUM(NSInteger, UIK) { - UIKOne = 1, - UIKTwo = 2, -}; - -typedef NS_ENUM(unsigned int, NSTickMarkPosition) { - NSTickMarkBelow = 0, - NSTickMarkAbove = 1, - NSTickMarkLeft = NSTickMarkAbove, - NSTickMarkRight = NSTickMarkBelow -}; - -typedef NS_OPTIONS(NSUInteger, UITableStyle) { - UIViewNone = 0x0, - UIViewMargin = 0x1, - UIViewWidth = 0x2, - UIViewRightMargin = 0x3, - UIViewBottomMargin = 0xbadbeef -}; - -typedef NS_OPTIONS(NSUInteger, UIStyle) { - UIView0 = 0, - UIView1 = 0XBADBEEF -}; - -typedef NS_ENUM(NSUInteger, NSBitmapImageFileType) { - NSTIFFFileType, - NSBMPFileType, - NSGIFFileType, - NSJPEGFileType, - NSPNGFileType, - NSJPEG2000FileType -}; - -typedef NS_ENUM(NSUInteger, NSAlertStyle) { - NSWarningAlertStyle = 0, - NSInformationalAlertStyle = 1, - NSCriticalAlertStyle = 2 -}; - -enum { - D_NSTIFFFileType, - D_NSBMPFileType, - D_NSGIFFileType, - D_NSJPEGFileType, - D_NSPNGFileType, - D_NSJPEG2000FileType -}; -typedef NSUInteger D_NSBitmapImageFileType DEPRECATED; - -typedef enum { - D_NSTickMarkBelow = 0, - D_NSTickMarkAbove = 1 -} D_NSTickMarkPosition DEPRECATED; - - -#define NS_ENUM_AVAILABLE(X,Y) - - -typedef NS_OPTIONS(NSUInteger, NSFOptions) { - NSFStrongMemory NS_ENUM_AVAILABLE(10_5, 6_0) = (0UL << 0), - NSFOpaqueMemory NS_ENUM_AVAILABLE(10_5, 6_0) = (2UL << 0), - NSFMallocMemory NS_ENUM_AVAILABLE(10_5, 6_0) = (3UL << 0), - NSFMachVirtualMemory NS_ENUM_AVAILABLE(10_5, 6_0) = (4UL << 0), - NSFWeakMemory NS_ENUM_AVAILABLE(10_8, 6_0) = (5UL << 0), - - NSFObjectPersonality NS_ENUM_AVAILABLE(10_5, 6_0) = (0UL << 8), - NSFOpaquePersonality NS_ENUM_AVAILABLE(10_5, 6_0) = (1UL << 8), - NSFObjectPointerPersonality NS_ENUM_AVAILABLE(10_5, 6_0) = (2UL << 8), - NSFCStringPersonality NS_ENUM_AVAILABLE(10_5, 6_0) = (3UL << 8), - NSFStructPersonality NS_ENUM_AVAILABLE(10_5, 6_0) = (4UL << 8), - NSFIntegerPersonality NS_ENUM_AVAILABLE(10_5, 6_0) = (5UL << 8), - NSFCopyIn NS_ENUM_AVAILABLE(10_5, 6_0) = (1UL << 16), -}; - -typedef NS_ENUM(unsigned int, UIP) { - UIP0One = 0, - UIP0Two = 1, - UIP0Three = 2, - UIP0Four = 10, - UIP0Last = 0x100 -}; - -typedef NS_OPTIONS(unsigned int, UIP_3) { - UIPZero = 0x0, - UIPOne = 0x1, - UIPTwo = 0x2, - UIP10 = 0x10, - UIPHundred = 0x100 -}; - -typedef NS_ENUM(unsigned int, UIP4_3) { - UIP4Zero = 0x0, - UIP4One = 0x1, - UIP4Two = 0x2, - UIP410 = 0x10, - UIP4Hundred = 100 -}; - -typedef NS_OPTIONS(unsigned int, UIP5_3) { - UIP5Zero = 0x0, - UIP5Two = 0x2, - UIP510 = 0x3, - UIP5Hundred = 0x4 -}; - -typedef NS_ENUM(unsigned int, UIP6_3) { - UIP6Zero = 0x0, - UIP6One = 0x1, - UIP6Two = 0x2, - UIP610 = 10, - UIP6Hundred = 0x100 -}; - -typedef NS_ENUM(unsigned int, UIP7_3) { - UIP7Zero = 0x0, - UIP7One = 1, - UIP7Two = 0x2, - UIP710 = 10, - UIP7Hundred = 100 -}; - - -typedef NS_ENUM(unsigned int, UIP8_3) { - Random = 0, - Random1 = 2, - Random2 = 4, - Random3 = 0x12345, - Random4 = 0x3444444, - Random5 = 0xbadbeef, - Random6 -}; - -// rdar://15200602 -#define NS_AVAILABLE_MAC(X) __attribute__((availability(macosx,introduced=X))) -#define NS_ENUM_AVAILABLE_MAC(X) __attribute__((availability(macosx,introduced=X))) - -typedef NS_ENUM(NSInteger, NSModalResponse) { - NSModalResponseStop = (-1000), // Also used as the default response for sheets - NSModalResponseAbort = (-1001), - NSModalResponseContinue = (-1002), -} NS_ENUM_AVAILABLE_MAC(10.9); - -// rdar://15201056 -typedef NSUInteger FarFarAwayOptions; - -// rdar://15200915 -typedef NS_OPTIONS(NSUInteger, FarAwayOptions) { - FarAway1 = 1 << 1, - FarAway2 = 1 << 2 -}; -typedef NS_OPTIONS(NSUInteger, NSWorkspaceLaunchOptions) { - NSWorkspaceLaunchAndPrint = 0x00000002, - NSWorkspaceLaunchWithErrorPresentation = 0x00000040, - NSWorkspaceLaunchInhibitingBackgroundOnly = 0x00000080, - NSWorkspaceLaunchWithoutAddingToRecents = 0x00000100, - NSWorkspaceLaunchWithoutActivation = 0x00000200, - NSWorkspaceLaunchAsync = 0x00010000, - NSWorkspaceLaunchAllowingClassicStartup = 0x00020000, - NSWorkspaceLaunchPreferringClassic = 0x00040000, - NSWorkspaceLaunchNewInstance = 0x00080000, - NSWorkspaceLaunchAndHide = 0x00100000, - NSWorkspaceLaunchAndHideOthers = 0x00200000, - NSWorkspaceLaunchDefault = NSWorkspaceLaunchAsync | - NSWorkspaceLaunchAllowingClassicStartup -}; - -typedef NS_OPTIONS(NSUInteger, NSExcludeOptions) { - NSExcludeQuickDrawElementsIconCreationOption = 1 << 1, - NSExclude10_4ElementsIconCreationOption = 1 << 2 -}; - -typedef NS_OPTIONS(NSUInteger, NSExcludeCreationOption) { - NSExcludeQuickDrawElementsCreationOption = 1 << 1, - NSExclude10_4ElementsCreationOption = 1 << 2 -}; - - -typedef NS_OPTIONS(NSUInteger, NSExcludeIconOptions) { - NSExcludeQuickDrawElementsIconOption = 1 << 1, - NSExclude10_4ElementsIconOption = 1 << 2 -}; - -@interface INTF { - NSExcludeIconOptions I1; - NSExcludeIconOptions I2; -} -@end - -enum { - FarFarAway1 = 1 << 1, - FarFarAway2 = 1 << 2 -}; - -// rdar://15200915 -typedef NS_OPTIONS(NSUInteger, NSWindowOcclusionState) { - NSWindowOcclusionStateVisible = 1UL << 1, -}; - -typedef NS_ENUM(NSUInteger, NSWindowNumberListOptions) { - NSWindowCloseButton, - NSWindowMiniaturizeButton, - NSWindowZoomButton, - NSWindowToolbarButton, - NSWindowDocumentIconButton -}; - -typedef NS_ENUM(NSUInteger, NSSelectionDirection) { - NSDirectSelection = 0, - NSSelectingNext, - NSSelectingPrevious -}; - -// standard window buttons - -// rdar://18262255 -typedef NS_ENUM(NSUInteger, Thing) { - ThingOne, - ThingTwo, - ThingThree, -}; - -// rdar://18498539 -typedef NS_ENUM(unsigned int, NumericEnum) { - one = 1 -}; - -typedef NS_ENUM(unsigned int, NumericEnum2) { - Two = 2 -}; - -typedef NS_ENUM(unsigned int, NumericEnum3) { - Three = 3 -}; - -typedef NS_OPTIONS(unsigned int, NumericEnum4) { - Four = 4 -}; - -// rdar://18532199 -typedef NS_ENUM(int8_t, MyEnumeratedType) -{ - UI8one = 1 -}; - - -typedef NS_OPTIONS(uint16_t, UI16) { - UI16One = 0, - UI16Two = 0x1, - UI16three = 0x8, - UI16Four = 0x100 -}; - -typedef NS_ENUM(uint32_t, UI32TableViewCellStyle) { - UI32ViewAutoresizingNone = 0, - UI32ViewAutoresizingFlexibleLeftMargin, - UI32ViewAutoresizingFlexibleWidth, - UI32ViewAutoresizingFlexibleRightMargin, - UI32ViewAutoresizingFlexibleTopMargin, - UI32ViewAutoresizingFlexibleHeight, - UI32ViewAutoresizingFlexibleBottomMargin -}; - -typedef NS_ENUM(uint8_t, UI8Type) -{ - UIU8one = 1 -}; - -// rdar://19352510 -typedef NS_ENUM(NSInteger, MyEnum) {zero}; - -typedef NS_ENUM(NSUInteger, MyEnumNSUInteger) {two}; - -typedef NS_ENUM(int, MyEnumint) {three, four}; - -typedef NS_ENUM(unsigned long, MyEnumlonglong) {five}; - -typedef NS_ENUM(unsigned long long, MyEnumunsignedlonglong) { - ll1, - ll2= 0xff, - ll3, - ll4 -}; - -// rdar://19994496 -typedef NS_ENUM(int8_t, MyOneEnum) {int8_one}; - -typedef NS_ENUM(int16_t, Myint16_tEnum) { - int16_t_one, - int16_t_two }; diff --git a/test/ARCMT/objcmt-ns-nonatomic-iosonly.m b/test/ARCMT/objcmt-ns-nonatomic-iosonly.m deleted file mode 100644 index 57b20415f969..000000000000 --- a/test/ARCMT/objcmt-ns-nonatomic-iosonly.m +++ /dev/null @@ -1,236 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -fblocks -objcmt-migrate-readwrite-property -objcmt-ns-nonatomic-iosonly -objcmt-migrate-readonly-property -objcmt-atomic-property -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11 -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result - -#define WEBKIT_OBJC_METHOD_ANNOTATION(ANNOTATION) ANNOTATION -#define WEAK_IMPORT_ATTRIBUTE __attribute__((objc_arc_weak_reference_unavailable)) -#define AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER -#define DEPRECATED __attribute__((deprecated)) - -// rdar://15442742 -#if TARGET_OS_IPHONE - #define NS_NONATOMIC_IOSONLY nonatomic -#else - #define NS_NONATOMIC_IOSONLY atomic -#endif - -typedef char BOOL; -@class NSString; -@protocol NSCopying @end - -@interface NSObject <NSCopying> -@end - -@interface NSDictionary : NSObject -@end - -@interface I : NSObject { - int ivarVal; -} -- (void) setWeakProp : (NSString *__weak)Val; -- (NSString *__weak) WeakProp; - -- (NSString *) StrongProp; -- (void) setStrongProp : (NSString *)Val; - -- (NSString *) UnavailProp __attribute__((unavailable)); -- (void) setUnavailProp : (NSString *)Val; - -- (NSString *) UnavailProp1 __attribute__((unavailable)); -- (void) setUnavailProp1 : (NSString *)Val __attribute__((unavailable)); - -- (NSString *) UnavailProp2; -- (void) setUnavailProp2 : (NSString *)Val __attribute__((unavailable)); - -- (NSDictionary*) undoAction; -- (void) setUndoAction: (NSDictionary*)Arg; -@end - -@implementation I -@end - -@class NSArray; - -@interface MyClass2 { -@private - NSArray *_names1; - NSArray *_names2; - NSArray *_names3; - NSArray *_names4; -} -- (void)setNames1:(NSArray *)names; -- (void)setNames4:(__strong NSArray *)names; -- (void)setNames3:(__strong NSArray *)names; -- (void)setNames2:(NSArray *)names; -- (NSArray *) names2; -- (NSArray *)names3; -- (__strong NSArray *)names4; -- (NSArray *) names1; -@end - -// Properties that contain the name "delegate" or "dataSource", -// or have exact name "target" have unsafe_unretained attribute. -@interface NSInvocation -- (id)target; -- (void)setTarget:(id)target; - -- (id) dataSource; - -- (id)xxxdelegateYYY; -- (void)setXxxdelegateYYY:(id)delegate; - -- (void)setDataSource:(id)source; - -- (id)MYtarget; -- (void)setMYtarget: (id)target; - -- (id)targetX; -- (void)setTargetX: (id)t; - -- (int)value; -- (void)setValue: (int)val; - --(BOOL) isContinuous; --(void) setContinuous:(BOOL)value; - -- (id) isAnObject; -- (void)setAnObject : (id) object; - -- (BOOL) isinValid; -- (void) setInValid : (BOOL) arg; - -- (void) Nothing; -- (int) Length; -- (id) object; -+ (double) D; -- (void *)JSObject WEBKIT_OBJC_METHOD_ANNOTATION(AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER); -- (BOOL)isIgnoringInteractionEvents; - -- (NSString *)getStringValue; -- (BOOL)getCounterValue; -- (void)setStringValue:(NSString *)stringValue AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; -- (NSDictionary *)getns_dixtionary; - -- (BOOL)is3bar; // watch out -- (NSString *)get3foo; // watch out - -- (BOOL) getM; -- (BOOL) getMA; -- (BOOL) getALL; -- (BOOL) getMANY; -- (BOOL) getSome; -@end - - -@interface NSInvocation(CAT) -- (id)target; -- (void)setTarget:(id)target; - -- (id) dataSource; - -- (id)xxxdelegateYYY; -- (void)setXxxdelegateYYY:(id)delegate; - -- (void)setDataSource:(id)source; - -- (id)MYtarget; -- (void)setMYtarget: (id)target; - -- (id)targetX; -- (void)setTargetX: (id)t; - -- (int)value; -- (void)setValue: (int)val; - --(BOOL) isContinuous; --(void) setContinuous:(BOOL)value; - -- (id) isAnObject; -- (void)setAnObject : (id) object; - -- (BOOL) isinValid; -- (void) setInValid : (BOOL) arg; - -- (void) Nothing; -- (int) Length; -- (id) object; -+ (double) D; - -- (BOOL)is3bar; // watch out -- (NSString *)get3foo; // watch out - -- (BOOL) getM; -- (BOOL) getMA; -- (BOOL) getALL; -- (BOOL) getMANY; -- (BOOL) getSome; -@end - -DEPRECATED -@interface I_DEP -- (BOOL) isinValid; -- (void) setInValid : (BOOL) arg; -@end - -@interface AnotherOne -- (BOOL) isinValid DEPRECATED; -- (void) setInValid : (BOOL) arg; -- (id)MYtarget; -- (void)setMYtarget: (id)target DEPRECATED; -- (BOOL) getM DEPRECATED; - -- (id)xxxdelegateYYY DEPRECATED; -- (void)setXxxdelegateYYY:(id)delegate DEPRECATED; -@end - -// rdar://14987909 -#define NS_AVAILABLE __attribute__((availability(macosx,introduced=10.0))) -#define NORETURN __attribute__((noreturn)) -#define ALIGNED __attribute__((aligned(16))) - -@interface NSURL -// Do not infer a property. -- (NSURL *)appStoreReceiptURL NS_AVAILABLE; -- (void) setAppStoreReceiptURL : (NSURL *)object; - -- (NSURL *)appStoreReceiptURLX NS_AVAILABLE; -- (void) setAppStoreReceiptURLX : (NSURL *)object NS_AVAILABLE; - -// Do not infer a property. -- (NSURL *)appStoreReceiptURLY ; -- (void) setAppStoreReceiptURLY : (NSURL *)object NS_AVAILABLE; - -- (id)OkToInfer NS_AVAILABLE; - -// Do not infer a property. -- (NSURL *)appStoreReceiptURLZ ; -- (void) setAppStoreReceiptURLZ : (NSURL *)object NS_AVAILABLE; - -// Do not infer a property. -- (id) t1 NORETURN NS_AVAILABLE; -- (void) setT1 : (id) arg NS_AVAILABLE; - -- (id)method1 ALIGNED NS_AVAILABLE; -- (void) setMethod1 : (id) object NS_AVAILABLE ALIGNED; - -- (NSURL *)init; // No Change -+ (id)alloc; // No Change - -- (BOOL)is1stClass; // Not a valid property -- (BOOL)isClass; // This is a valid property 'class' is not a keyword in ObjC -- (BOOL)isDouble; // Not a valid property - -@end - -// rdar://15082818 -@class NSMutableDictionary; - -@interface NSArray -- (id (^)(id, NSArray *, NSMutableDictionary *)) expressionBlock; -- (id (^)(id, NSArray *, NSMutableDictionary *)) MyBlock; -- (void) setMyBlock : (id (^)(id, NSArray *, NSMutableDictionary *)) bl; -- (id (*)(id, NSArray *, NSMutableDictionary *)) expressionFuncptr; -- (id (*)(id, NSArray *, NSMutableDictionary *)) MyFuncptr; -- (void) setMyFuncptr : (id (*)(id, NSArray *, NSMutableDictionary *)) bl; -@end diff --git a/test/ARCMT/objcmt-ns-nonatomic-iosonly.m.result b/test/ARCMT/objcmt-ns-nonatomic-iosonly.m.result deleted file mode 100644 index 8e9e3a0c21ca..000000000000 --- a/test/ARCMT/objcmt-ns-nonatomic-iosonly.m.result +++ /dev/null @@ -1,209 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -fblocks -objcmt-migrate-readwrite-property -objcmt-ns-nonatomic-iosonly -objcmt-migrate-readonly-property -objcmt-atomic-property -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11 -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result - -#define WEBKIT_OBJC_METHOD_ANNOTATION(ANNOTATION) ANNOTATION -#define WEAK_IMPORT_ATTRIBUTE __attribute__((objc_arc_weak_reference_unavailable)) -#define AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER -#define DEPRECATED __attribute__((deprecated)) - -// rdar://15442742 -#if TARGET_OS_IPHONE - #define NS_NONATOMIC_IOSONLY nonatomic -#else - #define NS_NONATOMIC_IOSONLY atomic -#endif - -typedef char BOOL; -@class NSString; -@protocol NSCopying @end - -@interface NSObject <NSCopying> -@end - -@interface NSDictionary : NSObject -@end - -@interface I : NSObject { - int ivarVal; -} -@property (NS_NONATOMIC_IOSONLY, weak) NSString *WeakProp; - -@property (NS_NONATOMIC_IOSONLY, strong) NSString *StrongProp; - -@property (NS_NONATOMIC_IOSONLY, strong) NSString *UnavailProp __attribute__((unavailable)); -- (void) setUnavailProp : (NSString *)Val; - -@property (NS_NONATOMIC_IOSONLY, strong) NSString *UnavailProp1 __attribute__((unavailable)); - -@property (NS_NONATOMIC_IOSONLY, strong) NSString *UnavailProp2; -- (void) setUnavailProp2 : (NSString *)Val __attribute__((unavailable)); - -@property (NS_NONATOMIC_IOSONLY, copy) NSDictionary *undoAction; -@end - -@implementation I -@end - -@class NSArray; - -@interface MyClass2 { -@private - NSArray *_names1; - NSArray *_names2; - NSArray *_names3; - NSArray *_names4; -} -@property (NS_NONATOMIC_IOSONLY, strong) NSArray *names2; -@property (NS_NONATOMIC_IOSONLY, strong) NSArray *names3; -@property (NS_NONATOMIC_IOSONLY, strong) NSArray *names4; -@property (NS_NONATOMIC_IOSONLY, strong) NSArray *names1; -@end - -// Properties that contain the name "delegate" or "dataSource", -// or have exact name "target" have unsafe_unretained attribute. -@interface NSInvocation -@property (NS_NONATOMIC_IOSONLY, assign) id target; - -@property (NS_NONATOMIC_IOSONLY, assign) id dataSource; - -@property (NS_NONATOMIC_IOSONLY, assign) id xxxdelegateYYY; - - -@property (NS_NONATOMIC_IOSONLY, strong) id MYtarget; - -@property (NS_NONATOMIC_IOSONLY, strong) id targetX; - -@property (NS_NONATOMIC_IOSONLY) int value; - -@property (NS_NONATOMIC_IOSONLY, getter=isContinuous) BOOL continuous; - -- (id) isAnObject; -- (void)setAnObject : (id) object; - -@property (NS_NONATOMIC_IOSONLY, getter=isinValid, readonly) BOOL inValid; -- (void) setInValid : (BOOL) arg; - -- (void) Nothing; -@property (NS_NONATOMIC_IOSONLY, readonly) int Length; -@property (NS_NONATOMIC_IOSONLY, readonly, strong) id object; -+ (double) D; -@property (NS_NONATOMIC_IOSONLY, readonly) void *JSObject WEBKIT_OBJC_METHOD_ANNOTATION(AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER); -@property (NS_NONATOMIC_IOSONLY, getter=isIgnoringInteractionEvents, readonly) BOOL ignoringInteractionEvents; - -@property (NS_NONATOMIC_IOSONLY, getter=getStringValue, strong) NSString *stringValue; -@property (NS_NONATOMIC_IOSONLY, getter=getCounterValue, readonly) BOOL counterValue; -@property (NS_NONATOMIC_IOSONLY, getter=getns_dixtionary, readonly, copy) NSDictionary *ns_dixtionary; - -- (BOOL)is3bar; // watch out -- (NSString *)get3foo; // watch out - -@property (NS_NONATOMIC_IOSONLY, getter=getM, readonly) BOOL m; -@property (NS_NONATOMIC_IOSONLY, getter=getMA, readonly) BOOL MA; -@property (NS_NONATOMIC_IOSONLY, getter=getALL, readonly) BOOL ALL; -@property (NS_NONATOMIC_IOSONLY, getter=getMANY, readonly) BOOL MANY; -@property (NS_NONATOMIC_IOSONLY, getter=getSome, readonly) BOOL some; -@end - - -@interface NSInvocation(CAT) -@property (NS_NONATOMIC_IOSONLY, assign) id target; - -@property (NS_NONATOMIC_IOSONLY, assign) id dataSource; - -@property (NS_NONATOMIC_IOSONLY, assign) id xxxdelegateYYY; - - -@property (NS_NONATOMIC_IOSONLY, strong) id MYtarget; - -@property (NS_NONATOMIC_IOSONLY, strong) id targetX; - -@property (NS_NONATOMIC_IOSONLY) int value; - -@property (NS_NONATOMIC_IOSONLY, getter=isContinuous) BOOL continuous; - -- (id) isAnObject; -- (void)setAnObject : (id) object; - -@property (NS_NONATOMIC_IOSONLY, getter=isinValid, readonly) BOOL inValid; -- (void) setInValid : (BOOL) arg; - -- (void) Nothing; -@property (NS_NONATOMIC_IOSONLY, readonly) int Length; -@property (NS_NONATOMIC_IOSONLY, readonly, strong) id object; -+ (double) D; - -- (BOOL)is3bar; // watch out -- (NSString *)get3foo; // watch out - -@property (NS_NONATOMIC_IOSONLY, getter=getM, readonly) BOOL m; -@property (NS_NONATOMIC_IOSONLY, getter=getMA, readonly) BOOL MA; -@property (NS_NONATOMIC_IOSONLY, getter=getALL, readonly) BOOL ALL; -@property (NS_NONATOMIC_IOSONLY, getter=getMANY, readonly) BOOL MANY; -@property (NS_NONATOMIC_IOSONLY, getter=getSome, readonly) BOOL some; -@end - -DEPRECATED -@interface I_DEP -- (BOOL) isinValid; -- (void) setInValid : (BOOL) arg; -@end - -@interface AnotherOne -- (BOOL) isinValid DEPRECATED; -- (void) setInValid : (BOOL) arg; -- (id)MYtarget; -- (void)setMYtarget: (id)target DEPRECATED; -- (BOOL) getM DEPRECATED; - -- (id)xxxdelegateYYY DEPRECATED; -- (void)setXxxdelegateYYY:(id)delegate DEPRECATED; -@end - -// rdar://14987909 -#define NS_AVAILABLE __attribute__((availability(macosx,introduced=10.0))) -#define NORETURN __attribute__((noreturn)) -#define ALIGNED __attribute__((aligned(16))) - -@interface NSURL -// Do not infer a property. -@property (NS_NONATOMIC_IOSONLY, strong) NSURL *appStoreReceiptURL NS_AVAILABLE; -- (void) setAppStoreReceiptURL : (NSURL *)object; - -@property (NS_NONATOMIC_IOSONLY, strong) NSURL *appStoreReceiptURLX NS_AVAILABLE; - -// Do not infer a property. -@property (NS_NONATOMIC_IOSONLY, strong) NSURL *appStoreReceiptURLY ; -- (void) setAppStoreReceiptURLY : (NSURL *)object NS_AVAILABLE; - -@property (NS_NONATOMIC_IOSONLY, readonly, strong) id OkToInfer NS_AVAILABLE; - -// Do not infer a property. -@property (NS_NONATOMIC_IOSONLY, strong) NSURL *appStoreReceiptURLZ ; -- (void) setAppStoreReceiptURLZ : (NSURL *)object NS_AVAILABLE; - -// Do not infer a property. -- (id) t1 NORETURN NS_AVAILABLE; -- (void) setT1 : (id) arg NS_AVAILABLE; - -@property (NS_NONATOMIC_IOSONLY, strong) id method1 ALIGNED NS_AVAILABLE; - -- (NSURL *)init; // No Change -+ (id)alloc; // No Change - -- (BOOL)is1stClass; // Not a valid property -@property (NS_NONATOMIC_IOSONLY, getter=isClass, readonly) BOOL class; // This is a valid property 'class' is not a keyword in ObjC -- (BOOL)isDouble; // Not a valid property - -@end - -// rdar://15082818 -@class NSMutableDictionary; - -@interface NSArray -@property (NS_NONATOMIC_IOSONLY, readonly, copy) id (^expressionBlock)(id, NSArray *, NSMutableDictionary *); -@property (NS_NONATOMIC_IOSONLY, copy) id (^MyBlock)(id, NSArray *, NSMutableDictionary *); -@property (NS_NONATOMIC_IOSONLY, readonly) id (*expressionFuncptr)(id, NSArray *, NSMutableDictionary *); -@property (NS_NONATOMIC_IOSONLY) id (*MyFuncptr)(id, NSArray *, NSMutableDictionary *); -@end diff --git a/test/ARCMT/objcmt-ns-returns-inner-pointer.m b/test/ARCMT/objcmt-ns-returns-inner-pointer.m deleted file mode 100644 index bff7d80b9414..000000000000 --- a/test/ARCMT/objcmt-ns-returns-inner-pointer.m +++ /dev/null @@ -1,129 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -objcmt-returns-innerpointer-property -objcmt-migrate-annotation -objcmt-migrate-readwrite-property -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11 -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result - -#ifndef NS_RETURNS_INNER_POINTER // defined in iOS 6 for sure -#define NS_RETURNS_INNER_POINTER __attribute__((objc_returns_inner_pointer)) -#endif - -#define CF_IMPLICIT_BRIDGING_ENABLED _Pragma("clang arc_cf_code_audited begin") - -#define CF_IMPLICIT_BRIDGING_DISABLED _Pragma("clang arc_cf_code_audited end") - -#if __has_feature(attribute_ns_returns_retained) -#define NS_RETURNS_RETAINED __attribute__((ns_returns_retained)) -#endif -#if __has_feature(attribute_cf_returns_retained) -#define CF_RETURNS_RETAINED __attribute__((cf_returns_retained)) -#endif -#if __has_feature(attribute_ns_returns_not_retained) -#define NS_RETURNS_NOT_RETAINED __attribute__((ns_returns_not_retained)) -#endif -#if __has_feature(attribute_cf_returns_not_retained) -#define CF_RETURNS_NOT_RETAINED __attribute__((cf_returns_not_retained)) -#endif -#if __has_feature(attribute_ns_consumes_self) -#define NS_CONSUMES_SELF __attribute__((ns_consumes_self)) -#endif -#if __has_feature(attribute_ns_consumed) -#define NS_CONSUMED __attribute__((ns_consumed)) -#endif -#if __has_feature(attribute_cf_consumed) -#define CF_CONSUMED __attribute__((cf_consumed)) -#endif -#if __has_attribute(ns_returns_autoreleased) -#define NS_RETURNS_AUTORELEASED __attribute__((ns_returns_autoreleased)) -#endif - -#define NS_AVAILABLE __attribute__((availability(macosx,introduced=10.0))) - -CF_IMPLICIT_BRIDGING_ENABLED - -typedef unsigned long CFTypeID; -typedef unsigned long CFOptionFlags; -typedef unsigned long CFHashCode; - -typedef signed long CFIndex; /*AnyObj*/ -typedef const struct __CFArray * CFArrayRef; -typedef struct { - CFIndex location; - CFIndex length; -} CFRange; - -typedef void (*CFArrayApplierFunction)(const void *value, void *context); - -typedef enum CFComparisonResult : CFIndex CFComparisonResult; enum CFComparisonResult : CFIndex { - kCFCompareLessThan = -1L, - kCFCompareEqualTo = 0, - kCFCompareGreaterThan = 1 -}; - - -typedef CFComparisonResult (*CFComparatorFunction)(const void *val1, const void *val2, void *context); - -typedef struct __CFArray * CFMutableArrayRef; - -typedef const struct __CFAttributedString *CFAttributedStringRef; -typedef struct __CFAttributedString *CFMutableAttributedStringRef; - -typedef const struct __CFAllocator * CFAllocatorRef; - -typedef const struct __CFString * CFStringRef; -typedef struct __CFString * CFMutableStringRef; - -typedef const struct __CFDictionary * CFDictionaryRef; -typedef struct __CFDictionary * CFMutableDictionaryRef; - -typedef struct CGImage *CGImageRef; - -typedef struct OpaqueJSValue* JSObjectRef; - -typedef JSObjectRef TTJSObjectRef; -typedef unsigned int NSUInteger; - -CF_IMPLICIT_BRIDGING_DISABLED - -@interface I -- (void*) ReturnsInnerPointer; -- (int*) AlreadyReturnsInnerPointer NS_RETURNS_INNER_POINTER; -@end - -@interface UIImage -- (CGImageRef)CGImage; -@end - -@interface NSData -- (void *)bytes; -- (void **) ptr_bytes __attribute__((availability(macosx,unavailable))); -@end - -@interface NSMutableData -- (void *)mutableBytes __attribute__((deprecated)) __attribute__((unavailable)); -@end - -@interface JS -- (JSObjectRef)JSObject; -- (TTJSObjectRef)JSObject1; -- (JSObjectRef*)JSObject2; -@end - -// rdar://15044991 -typedef void *SecTrustRef; - -@interface NSURLProtectionSpace -@property (readonly) SecTrustRef serverTrust NS_AVAILABLE; -- (void *) FOO NS_AVAILABLE; -@property (readonly) void * mitTrust NS_AVAILABLE; - -@property (readonly) void * mittiTrust; - -@property (readonly) SecTrustRef XserverTrust; - -- (SecTrustRef) FOO1 NS_AVAILABLE; - -+ (const NSURLProtectionSpace *)ProtectionSpace; - -// pointer personality functions -@property NSUInteger (*hashFunction)(const void *item, NSUInteger (*size)(const void *item)); -@end diff --git a/test/ARCMT/objcmt-ns-returns-inner-pointer.m.result b/test/ARCMT/objcmt-ns-returns-inner-pointer.m.result deleted file mode 100644 index 8048e06748aa..000000000000 --- a/test/ARCMT/objcmt-ns-returns-inner-pointer.m.result +++ /dev/null @@ -1,129 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -objcmt-returns-innerpointer-property -objcmt-migrate-annotation -objcmt-migrate-readwrite-property -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11 -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result - -#ifndef NS_RETURNS_INNER_POINTER // defined in iOS 6 for sure -#define NS_RETURNS_INNER_POINTER __attribute__((objc_returns_inner_pointer)) -#endif - -#define CF_IMPLICIT_BRIDGING_ENABLED _Pragma("clang arc_cf_code_audited begin") - -#define CF_IMPLICIT_BRIDGING_DISABLED _Pragma("clang arc_cf_code_audited end") - -#if __has_feature(attribute_ns_returns_retained) -#define NS_RETURNS_RETAINED __attribute__((ns_returns_retained)) -#endif -#if __has_feature(attribute_cf_returns_retained) -#define CF_RETURNS_RETAINED __attribute__((cf_returns_retained)) -#endif -#if __has_feature(attribute_ns_returns_not_retained) -#define NS_RETURNS_NOT_RETAINED __attribute__((ns_returns_not_retained)) -#endif -#if __has_feature(attribute_cf_returns_not_retained) -#define CF_RETURNS_NOT_RETAINED __attribute__((cf_returns_not_retained)) -#endif -#if __has_feature(attribute_ns_consumes_self) -#define NS_CONSUMES_SELF __attribute__((ns_consumes_self)) -#endif -#if __has_feature(attribute_ns_consumed) -#define NS_CONSUMED __attribute__((ns_consumed)) -#endif -#if __has_feature(attribute_cf_consumed) -#define CF_CONSUMED __attribute__((cf_consumed)) -#endif -#if __has_attribute(ns_returns_autoreleased) -#define NS_RETURNS_AUTORELEASED __attribute__((ns_returns_autoreleased)) -#endif - -#define NS_AVAILABLE __attribute__((availability(macosx,introduced=10.0))) - -CF_IMPLICIT_BRIDGING_ENABLED - -typedef unsigned long CFTypeID; -typedef unsigned long CFOptionFlags; -typedef unsigned long CFHashCode; - -typedef signed long CFIndex; /*AnyObj*/ -typedef const struct __CFArray * CFArrayRef; -typedef struct { - CFIndex location; - CFIndex length; -} CFRange; - -typedef void (*CFArrayApplierFunction)(const void *value, void *context); - -typedef enum CFComparisonResult : CFIndex CFComparisonResult; enum CFComparisonResult : CFIndex { - kCFCompareLessThan = -1L, - kCFCompareEqualTo = 0, - kCFCompareGreaterThan = 1 -}; - - -typedef CFComparisonResult (*CFComparatorFunction)(const void *val1, const void *val2, void *context); - -typedef struct __CFArray * CFMutableArrayRef; - -typedef const struct __CFAttributedString *CFAttributedStringRef; -typedef struct __CFAttributedString *CFMutableAttributedStringRef; - -typedef const struct __CFAllocator * CFAllocatorRef; - -typedef const struct __CFString * CFStringRef; -typedef struct __CFString * CFMutableStringRef; - -typedef const struct __CFDictionary * CFDictionaryRef; -typedef struct __CFDictionary * CFMutableDictionaryRef; - -typedef struct CGImage *CGImageRef; - -typedef struct OpaqueJSValue* JSObjectRef; - -typedef JSObjectRef TTJSObjectRef; -typedef unsigned int NSUInteger; - -CF_IMPLICIT_BRIDGING_DISABLED - -@interface I -- (void*) ReturnsInnerPointer NS_RETURNS_INNER_POINTER; -- (int*) AlreadyReturnsInnerPointer NS_RETURNS_INNER_POINTER; -@end - -@interface UIImage -- (CGImageRef)CGImage CF_RETURNS_NOT_RETAINED; -@end - -@interface NSData -- (void *)bytes NS_RETURNS_INNER_POINTER; -- (void **) ptr_bytes __attribute__((availability(macosx,unavailable))) NS_RETURNS_INNER_POINTER; -@end - -@interface NSMutableData -- (void *)mutableBytes __attribute__((deprecated)) __attribute__((unavailable)) NS_RETURNS_INNER_POINTER; -@end - -@interface JS -- (JSObjectRef)JSObject; -- (TTJSObjectRef)JSObject1; -- (JSObjectRef*)JSObject2 NS_RETURNS_INNER_POINTER; -@end - -// rdar://15044991 -typedef void *SecTrustRef; - -@interface NSURLProtectionSpace -@property (readonly) SecTrustRef NS_RETURNS_INNER_POINTER serverTrust NS_AVAILABLE; -- (void *) FOO NS_AVAILABLE NS_RETURNS_INNER_POINTER; -@property (readonly) void * NS_RETURNS_INNER_POINTER mitTrust NS_AVAILABLE; - -@property (readonly) void * NS_RETURNS_INNER_POINTER mittiTrust; - -@property (readonly) SecTrustRef NS_RETURNS_INNER_POINTER XserverTrust; - -- (SecTrustRef) FOO1 NS_AVAILABLE NS_RETURNS_INNER_POINTER; - -+ (const NSURLProtectionSpace *)ProtectionSpace; - -// pointer personality functions -@property NSUInteger (*hashFunction)(const void *item, NSUInteger (*size)(const void *item)); -@end diff --git a/test/ARCMT/objcmt-numeric-literals.m b/test/ARCMT/objcmt-numeric-literals.m deleted file mode 100644 index 7f33dc27997e..000000000000 --- a/test/ARCMT/objcmt-numeric-literals.m +++ /dev/null @@ -1,502 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c++ -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c++ %s.result - -#define YES __objc_yes -#define NO __objc_no - -typedef long NSInteger; -typedef unsigned long NSUInteger; -typedef signed char BOOL; -#define nil ((void*) 0) - -@interface NSObject -+ (id)alloc; -@end - -@interface NSNumber : NSObject -@end - -@interface NSNumber (NSNumberCreation) -- (id)initWithChar:(char)value; -- (id)initWithUnsignedChar:(unsigned char)value; -- (id)initWithShort:(short)value; -- (id)initWithUnsignedShort:(unsigned short)value; -- (id)initWithInt:(int)value; -- (id)initWithUnsignedInt:(unsigned int)value; -- (id)initWithLong:(long)value; -- (id)initWithUnsignedLong:(unsigned long)value; -- (id)initWithLongLong:(long long)value; -- (id)initWithUnsignedLongLong:(unsigned long long)value; -- (id)initWithFloat:(float)value; -- (id)initWithDouble:(double)value; -- (id)initWithBool:(BOOL)value; -- (id)initWithInteger:(NSInteger)value; -- (id)initWithUnsignedInteger:(NSUInteger)value; - -+ (NSNumber *)numberWithChar:(char)value; -+ (NSNumber *)numberWithUnsignedChar:(unsigned char)value; -+ (NSNumber *)numberWithShort:(short)value; -+ (NSNumber *)numberWithUnsignedShort:(unsigned short)value; -+ (NSNumber *)numberWithInt:(int)value; -+ (NSNumber *)numberWithUnsignedInt:(unsigned int)value; -+ (NSNumber *)numberWithLong:(long)value; -+ (NSNumber *)numberWithUnsignedLong:(unsigned long)value; -+ (NSNumber *)numberWithLongLong:(long long)value; -+ (NSNumber *)numberWithUnsignedLongLong:(unsigned long long)value; -+ (NSNumber *)numberWithFloat:(float)value; -+ (NSNumber *)numberWithDouble:(double)value; -+ (NSNumber *)numberWithBool:(BOOL)value; -+ (NSNumber *)numberWithInteger:(NSInteger)value; -+ (NSNumber *)numberWithUnsignedInteger:(NSUInteger)value; -@end - -#define VAL_INT 2 -#define VAL_UINT 2U -#define VAL_CHAR 'a' - -void foo() { - [NSNumber numberWithChar:'a']; - [NSNumber numberWithChar:L'a']; - [NSNumber numberWithChar:2]; - [NSNumber numberWithChar:2U]; - [NSNumber numberWithChar:2u]; - [NSNumber numberWithChar:2L]; - [NSNumber numberWithChar:2l]; - [NSNumber numberWithChar:2LL]; - [NSNumber numberWithChar:2ll]; - [NSNumber numberWithChar:2ul]; - [NSNumber numberWithChar:2lu]; - [NSNumber numberWithChar:2ull]; - [NSNumber numberWithChar:2llu]; - [NSNumber numberWithChar:2.0]; - [NSNumber numberWithChar:2.0f]; - [NSNumber numberWithChar:2.0F]; - [NSNumber numberWithChar:2.0l]; - [NSNumber numberWithChar:2.0L]; - [NSNumber numberWithChar:0x2f]; - [NSNumber numberWithChar:04]; - [NSNumber numberWithChar:0]; - [NSNumber numberWithChar:0.0]; - [NSNumber numberWithChar:YES]; - [NSNumber numberWithChar:NO]; - [NSNumber numberWithChar:true]; - [NSNumber numberWithChar:false]; - [NSNumber numberWithChar:VAL_INT]; - [NSNumber numberWithChar:VAL_UINT]; - [NSNumber numberWithChar:VAL_CHAR]; - - [NSNumber numberWithUnsignedChar:'a']; - [NSNumber numberWithUnsignedChar:L'a']; - [NSNumber numberWithUnsignedChar:2]; - [NSNumber numberWithUnsignedChar:2U]; - [NSNumber numberWithUnsignedChar:2u]; - [NSNumber numberWithUnsignedChar:2L]; - [NSNumber numberWithUnsignedChar:2l]; - [NSNumber numberWithUnsignedChar:2LL]; - [NSNumber numberWithUnsignedChar:2ll]; - [NSNumber numberWithUnsignedChar:2ul]; - [NSNumber numberWithUnsignedChar:2lu]; - [NSNumber numberWithUnsignedChar:2ull]; - [NSNumber numberWithUnsignedChar:2llu]; - [NSNumber numberWithUnsignedChar:2.0]; - [NSNumber numberWithUnsignedChar:2.0f]; - [NSNumber numberWithUnsignedChar:2.0F]; - [NSNumber numberWithUnsignedChar:2.0l]; - [NSNumber numberWithUnsignedChar:2.0L]; - [NSNumber numberWithUnsignedChar:0x2f]; - [NSNumber numberWithUnsignedChar:04]; - [NSNumber numberWithUnsignedChar:0]; - [NSNumber numberWithUnsignedChar:0.0]; - [NSNumber numberWithUnsignedChar:YES]; - [NSNumber numberWithUnsignedChar:NO]; - [NSNumber numberWithUnsignedChar:true]; - [NSNumber numberWithUnsignedChar:false]; - [NSNumber numberWithUnsignedChar:VAL_INT]; - [NSNumber numberWithUnsignedChar:VAL_UINT]; - [NSNumber numberWithUnsignedChar:VAL_CHAR]; - - [NSNumber numberWithShort:'a']; - [NSNumber numberWithShort:L'a']; - [NSNumber numberWithShort:2]; - [NSNumber numberWithShort:2U]; - [NSNumber numberWithShort:2u]; - [NSNumber numberWithShort:2L]; - [NSNumber numberWithShort:2l]; - [NSNumber numberWithShort:2LL]; - [NSNumber numberWithShort:2ll]; - [NSNumber numberWithShort:2ul]; - [NSNumber numberWithShort:2lu]; - [NSNumber numberWithShort:2ull]; - [NSNumber numberWithShort:2llu]; - [NSNumber numberWithShort:2.0]; - [NSNumber numberWithShort:2.0f]; - [NSNumber numberWithShort:2.0F]; - [NSNumber numberWithShort:2.0l]; - [NSNumber numberWithShort:2.0L]; - [NSNumber numberWithShort:0x2f]; - [NSNumber numberWithShort:04]; - [NSNumber numberWithShort:0]; - [NSNumber numberWithShort:0.0]; - [NSNumber numberWithShort:YES]; - [NSNumber numberWithShort:NO]; - [NSNumber numberWithShort:true]; - [NSNumber numberWithShort:false]; - [NSNumber numberWithShort:VAL_INT]; - [NSNumber numberWithShort:VAL_UINT]; - - [NSNumber numberWithUnsignedShort:'a']; - [NSNumber numberWithUnsignedShort:L'a']; - [NSNumber numberWithUnsignedShort:2]; - [NSNumber numberWithUnsignedShort:2U]; - [NSNumber numberWithUnsignedShort:2u]; - [NSNumber numberWithUnsignedShort:2L]; - [NSNumber numberWithUnsignedShort:2l]; - [NSNumber numberWithUnsignedShort:2LL]; - [NSNumber numberWithUnsignedShort:2ll]; - [NSNumber numberWithUnsignedShort:2ul]; - [NSNumber numberWithUnsignedShort:2lu]; - [NSNumber numberWithUnsignedShort:2ull]; - [NSNumber numberWithUnsignedShort:2llu]; - [NSNumber numberWithUnsignedShort:2.0]; - [NSNumber numberWithUnsignedShort:2.0f]; - [NSNumber numberWithUnsignedShort:2.0F]; - [NSNumber numberWithUnsignedShort:2.0l]; - [NSNumber numberWithUnsignedShort:2.0L]; - [NSNumber numberWithUnsignedShort:0x2f]; - [NSNumber numberWithUnsignedShort:04]; - [NSNumber numberWithUnsignedShort:0]; - [NSNumber numberWithUnsignedShort:0.0]; - [NSNumber numberWithUnsignedShort:YES]; - [NSNumber numberWithUnsignedShort:NO]; - [NSNumber numberWithUnsignedShort:true]; - [NSNumber numberWithUnsignedShort:false]; - [NSNumber numberWithUnsignedShort:VAL_INT]; - [NSNumber numberWithUnsignedShort:VAL_UINT]; - - [NSNumber numberWithInt:'a']; - [NSNumber numberWithInt:L'a']; - [NSNumber numberWithInt:2]; - [NSNumber numberWithInt:2U]; - [NSNumber numberWithInt:2u]; - [NSNumber numberWithInt:2L]; - [NSNumber numberWithInt:2l]; - [NSNumber numberWithInt:2LL]; - [NSNumber numberWithInt:2ll]; - [NSNumber numberWithInt:2ul]; - [NSNumber numberWithInt:2lu]; - [NSNumber numberWithInt:2ull]; - [NSNumber numberWithInt:2llu]; - [NSNumber numberWithInt:2.0]; - [NSNumber numberWithInt:2.0f]; - [NSNumber numberWithInt:2.0F]; - [NSNumber numberWithInt:2.0l]; - [NSNumber numberWithInt:2.0L]; - [NSNumber numberWithInt:0x2f]; - [NSNumber numberWithInt:04]; - [NSNumber numberWithInt:0]; - [NSNumber numberWithInt:0.0]; - [NSNumber numberWithInt:YES]; - [NSNumber numberWithInt:NO]; - [NSNumber numberWithInt:true]; - [NSNumber numberWithInt:false]; - [NSNumber numberWithInt:VAL_INT]; - [NSNumber numberWithInt:VAL_UINT]; - - (void)[[NSNumber alloc] initWithInt:2]; - (void)[[NSNumber alloc] initWithInt:2U]; - - [NSNumber numberWithInt:+2]; - [NSNumber numberWithInt:-2]; - - [NSNumber numberWithUnsignedInt:'a']; - [NSNumber numberWithUnsignedInt:L'a']; - [NSNumber numberWithUnsignedInt:2]; - [NSNumber numberWithUnsignedInt:2U]; - [NSNumber numberWithUnsignedInt:2u]; - [NSNumber numberWithUnsignedInt:2L]; - [NSNumber numberWithUnsignedInt:2l]; - [NSNumber numberWithUnsignedInt:2LL]; - [NSNumber numberWithUnsignedInt:2ll]; - [NSNumber numberWithUnsignedInt:2ul]; - [NSNumber numberWithUnsignedInt:2lu]; - [NSNumber numberWithUnsignedInt:2ull]; - [NSNumber numberWithUnsignedInt:2llu]; - [NSNumber numberWithUnsignedInt:2.0]; - [NSNumber numberWithUnsignedInt:2.0f]; - [NSNumber numberWithUnsignedInt:2.0F]; - [NSNumber numberWithUnsignedInt:2.0l]; - [NSNumber numberWithUnsignedInt:2.0L]; - [NSNumber numberWithUnsignedInt:0x2f]; - [NSNumber numberWithUnsignedInt:04]; - [NSNumber numberWithUnsignedInt:0]; - [NSNumber numberWithUnsignedInt:0.0]; - [NSNumber numberWithUnsignedInt:YES]; - [NSNumber numberWithUnsignedInt:NO]; - [NSNumber numberWithUnsignedInt:true]; - [NSNumber numberWithUnsignedInt:false]; - [NSNumber numberWithUnsignedInt:VAL_INT]; - [NSNumber numberWithUnsignedInt:VAL_UINT]; - - [NSNumber numberWithLong:'a']; - [NSNumber numberWithLong:L'a']; - [NSNumber numberWithLong:2]; - [NSNumber numberWithLong:2U]; - [NSNumber numberWithLong:2u]; - [NSNumber numberWithLong:2L]; - [NSNumber numberWithLong:2l]; - [NSNumber numberWithLong:2LL]; - [NSNumber numberWithLong:2ll]; - [NSNumber numberWithLong:2ul]; - [NSNumber numberWithLong:2lu]; - [NSNumber numberWithLong:2ull]; - [NSNumber numberWithLong:2llu]; - [NSNumber numberWithLong:2.0]; - [NSNumber numberWithLong:2.0f]; - [NSNumber numberWithLong:2.0F]; - [NSNumber numberWithLong:2.0l]; - [NSNumber numberWithLong:2.0L]; - [NSNumber numberWithLong:0x2f]; - [NSNumber numberWithLong:04]; - [NSNumber numberWithLong:0]; - [NSNumber numberWithLong:0.0]; - [NSNumber numberWithLong:YES]; - [NSNumber numberWithLong:NO]; - [NSNumber numberWithLong:true]; - [NSNumber numberWithLong:false]; - [NSNumber numberWithLong:VAL_INT]; - [NSNumber numberWithLong:VAL_UINT]; - - [NSNumber numberWithUnsignedLong:'a']; - [NSNumber numberWithUnsignedLong:L'a']; - [NSNumber numberWithUnsignedLong:2]; - [NSNumber numberWithUnsignedLong:2U]; - [NSNumber numberWithUnsignedLong:2u]; - [NSNumber numberWithUnsignedLong:2L]; - [NSNumber numberWithUnsignedLong:2l]; - [NSNumber numberWithUnsignedLong:2LL]; - [NSNumber numberWithUnsignedLong:2ll]; - [NSNumber numberWithUnsignedLong:2ul]; - [NSNumber numberWithUnsignedLong:2lu]; - [NSNumber numberWithUnsignedLong:2ull]; - [NSNumber numberWithUnsignedLong:2llu]; - [NSNumber numberWithUnsignedLong:2.0]; - [NSNumber numberWithUnsignedLong:2.0f]; - [NSNumber numberWithUnsignedLong:2.0F]; - [NSNumber numberWithUnsignedLong:2.0l]; - [NSNumber numberWithUnsignedLong:2.0L]; - [NSNumber numberWithUnsignedLong:0x2f]; - [NSNumber numberWithUnsignedLong:04]; - [NSNumber numberWithUnsignedLong:0]; - [NSNumber numberWithUnsignedLong:0.0]; - [NSNumber numberWithUnsignedLong:YES]; - [NSNumber numberWithUnsignedLong:NO]; - [NSNumber numberWithUnsignedLong:true]; - [NSNumber numberWithUnsignedLong:false]; - [NSNumber numberWithUnsignedLong:VAL_INT]; - [NSNumber numberWithUnsignedLong:VAL_UINT]; - - [NSNumber numberWithLongLong:'a']; - [NSNumber numberWithLongLong:L'a']; - [NSNumber numberWithLongLong:2]; - [NSNumber numberWithLongLong:2U]; - [NSNumber numberWithLongLong:2u]; - [NSNumber numberWithLongLong:2L]; - [NSNumber numberWithLongLong:2l]; - [NSNumber numberWithLongLong:2LL]; - [NSNumber numberWithLongLong:2ll]; - [NSNumber numberWithLongLong:2ul]; - [NSNumber numberWithLongLong:2lu]; - [NSNumber numberWithLongLong:2ull]; - [NSNumber numberWithLongLong:2llu]; - [NSNumber numberWithLongLong:2.0]; - [NSNumber numberWithLongLong:2.0f]; - [NSNumber numberWithLongLong:2.0F]; - [NSNumber numberWithLongLong:2.0l]; - [NSNumber numberWithLongLong:2.0L]; - [NSNumber numberWithLongLong:0x2f]; - [NSNumber numberWithLongLong:04]; - [NSNumber numberWithLongLong:0]; - [NSNumber numberWithLongLong:0.0]; - [NSNumber numberWithLongLong:YES]; - [NSNumber numberWithLongLong:NO]; - [NSNumber numberWithLongLong:true]; - [NSNumber numberWithLongLong:false]; - [NSNumber numberWithLongLong:VAL_INT]; - [NSNumber numberWithLongLong:VAL_UINT]; - - [NSNumber numberWithUnsignedLongLong:'a']; - [NSNumber numberWithUnsignedLongLong:L'a']; - [NSNumber numberWithUnsignedLongLong:2]; - [NSNumber numberWithUnsignedLongLong:2U]; - [NSNumber numberWithUnsignedLongLong:2u]; - [NSNumber numberWithUnsignedLongLong:2L]; - [NSNumber numberWithUnsignedLongLong:2l]; - [NSNumber numberWithUnsignedLongLong:2LL]; - [NSNumber numberWithUnsignedLongLong:2ll]; - [NSNumber numberWithUnsignedLongLong:2ul]; - [NSNumber numberWithUnsignedLongLong:2lu]; - [NSNumber numberWithUnsignedLongLong:2ull]; - [NSNumber numberWithUnsignedLongLong:2llu]; - [NSNumber numberWithUnsignedLongLong:2.0]; - [NSNumber numberWithUnsignedLongLong:2.0f]; - [NSNumber numberWithUnsignedLongLong:2.0F]; - [NSNumber numberWithUnsignedLongLong:2.0l]; - [NSNumber numberWithUnsignedLongLong:2.0L]; - [NSNumber numberWithUnsignedLongLong:0x2f]; - [NSNumber numberWithUnsignedLongLong:04]; - [NSNumber numberWithUnsignedLongLong:0]; - [NSNumber numberWithUnsignedLongLong:0.0]; - [NSNumber numberWithUnsignedLongLong:YES]; - [NSNumber numberWithUnsignedLongLong:NO]; - [NSNumber numberWithUnsignedLongLong:true]; - [NSNumber numberWithUnsignedLongLong:false]; - [NSNumber numberWithUnsignedLongLong:VAL_INT]; - [NSNumber numberWithUnsignedLongLong:VAL_UINT]; - - [NSNumber numberWithFloat:'a']; - [NSNumber numberWithFloat:L'a']; - [NSNumber numberWithFloat:2]; - [NSNumber numberWithFloat:2U]; - [NSNumber numberWithFloat:2u]; - [NSNumber numberWithFloat:2L]; - [NSNumber numberWithFloat:2l]; - [NSNumber numberWithFloat:2LL]; - [NSNumber numberWithFloat:2ll]; - [NSNumber numberWithFloat:2ul]; - [NSNumber numberWithFloat:2lu]; - [NSNumber numberWithFloat:2ull]; - [NSNumber numberWithFloat:2llu]; - [NSNumber numberWithFloat:2.0]; - [NSNumber numberWithFloat:2.0f]; - [NSNumber numberWithFloat:2.0F]; - [NSNumber numberWithFloat:2.0l]; - [NSNumber numberWithFloat:2.0L]; - [NSNumber numberWithFloat:0x2f]; - [NSNumber numberWithFloat:04]; - [NSNumber numberWithFloat:0]; - [NSNumber numberWithFloat:0.0]; - [NSNumber numberWithFloat:YES]; - [NSNumber numberWithFloat:NO]; - [NSNumber numberWithFloat:true]; - [NSNumber numberWithFloat:false]; - [NSNumber numberWithFloat:VAL_INT]; - [NSNumber numberWithFloat:VAL_UINT]; - - [NSNumber numberWithDouble:'a']; - [NSNumber numberWithDouble:L'a']; - [NSNumber numberWithDouble:2]; - [NSNumber numberWithDouble:2U]; - [NSNumber numberWithDouble:2u]; - [NSNumber numberWithDouble:2L]; - [NSNumber numberWithDouble:2l]; - [NSNumber numberWithDouble:2LL]; - [NSNumber numberWithDouble:2ll]; - [NSNumber numberWithDouble:2ul]; - [NSNumber numberWithDouble:2lu]; - [NSNumber numberWithDouble:2ull]; - [NSNumber numberWithDouble:2llu]; - [NSNumber numberWithDouble:2.0]; - [NSNumber numberWithDouble:2.0f]; - [NSNumber numberWithDouble:2.0F]; - [NSNumber numberWithDouble:2.0l]; - [NSNumber numberWithDouble:2.0L]; - [NSNumber numberWithDouble:0x2f]; - [NSNumber numberWithDouble:04]; - [NSNumber numberWithDouble:0]; - [NSNumber numberWithDouble:0.0]; - [NSNumber numberWithDouble:YES]; - [NSNumber numberWithDouble:NO]; - [NSNumber numberWithDouble:true]; - [NSNumber numberWithDouble:false]; - [NSNumber numberWithDouble:VAL_INT]; - [NSNumber numberWithDouble:VAL_UINT]; - - [NSNumber numberWithBool:'a']; - [NSNumber numberWithBool:L'a']; - [NSNumber numberWithBool:2]; - [NSNumber numberWithBool:2U]; - [NSNumber numberWithBool:2u]; - [NSNumber numberWithBool:2L]; - [NSNumber numberWithBool:2l]; - [NSNumber numberWithBool:2LL]; - [NSNumber numberWithBool:2ll]; - [NSNumber numberWithBool:2ul]; - [NSNumber numberWithBool:2lu]; - [NSNumber numberWithBool:2ull]; - [NSNumber numberWithBool:2llu]; - [NSNumber numberWithBool:2.0]; - [NSNumber numberWithBool:2.0f]; - [NSNumber numberWithBool:2.0F]; - [NSNumber numberWithBool:2.0l]; - [NSNumber numberWithBool:2.0L]; - [NSNumber numberWithBool:0x2f]; - [NSNumber numberWithBool:04]; - [NSNumber numberWithBool:0]; - [NSNumber numberWithBool:0.0]; - [NSNumber numberWithBool:YES]; - [NSNumber numberWithBool:NO]; - [NSNumber numberWithBool:true]; - [NSNumber numberWithBool:false]; - [NSNumber numberWithBool:VAL_INT]; - [NSNumber numberWithBool:VAL_UINT]; - - [NSNumber numberWithInteger:'a']; - [NSNumber numberWithInteger:L'a']; - [NSNumber numberWithInteger:2]; - [NSNumber numberWithInteger:2U]; - [NSNumber numberWithInteger:2u]; - [NSNumber numberWithInteger:2L]; - [NSNumber numberWithInteger:2l]; - [NSNumber numberWithInteger:2LL]; - [NSNumber numberWithInteger:2ll]; - [NSNumber numberWithInteger:2ul]; - [NSNumber numberWithInteger:2lu]; - [NSNumber numberWithInteger:2ull]; - [NSNumber numberWithInteger:2llu]; - [NSNumber numberWithInteger:2.0]; - [NSNumber numberWithInteger:2.0f]; - [NSNumber numberWithInteger:2.0F]; - [NSNumber numberWithInteger:2.0l]; - [NSNumber numberWithInteger:2.0L]; - [NSNumber numberWithInteger:0x2f]; - [NSNumber numberWithInteger:04]; - [NSNumber numberWithInteger:0]; - [NSNumber numberWithInteger:0.0]; - [NSNumber numberWithInteger:YES]; - [NSNumber numberWithInteger:NO]; - [NSNumber numberWithInteger:true]; - [NSNumber numberWithInteger:false]; - [NSNumber numberWithInteger:VAL_INT]; - [NSNumber numberWithInteger:VAL_UINT]; - - [NSNumber numberWithUnsignedInteger:'a']; - [NSNumber numberWithUnsignedInteger:L'a']; - [NSNumber numberWithUnsignedInteger:2]; - [NSNumber numberWithUnsignedInteger:2U]; - [NSNumber numberWithUnsignedInteger:2u]; - [NSNumber numberWithUnsignedInteger:2L]; - [NSNumber numberWithUnsignedInteger:2l]; - [NSNumber numberWithUnsignedInteger:2LL]; - [NSNumber numberWithUnsignedInteger:2ll]; - [NSNumber numberWithUnsignedInteger:2ul]; - [NSNumber numberWithUnsignedInteger:2lu]; - [NSNumber numberWithUnsignedInteger:2ull]; - [NSNumber numberWithUnsignedInteger:2llu]; - [NSNumber numberWithUnsignedInteger:2.0]; - [NSNumber numberWithUnsignedInteger:2.0f]; - [NSNumber numberWithUnsignedInteger:2.0F]; - [NSNumber numberWithUnsignedInteger:2.0l]; - [NSNumber numberWithUnsignedInteger:2.0L]; - [NSNumber numberWithUnsignedInteger:0x2f]; - [NSNumber numberWithUnsignedInteger:04]; - [NSNumber numberWithUnsignedInteger:0]; - [NSNumber numberWithUnsignedInteger:0.0]; - [NSNumber numberWithUnsignedInteger:YES]; - [NSNumber numberWithUnsignedInteger:NO]; - [NSNumber numberWithUnsignedInteger:true]; - [NSNumber numberWithUnsignedInteger:false]; - [NSNumber numberWithUnsignedInteger:VAL_INT]; - [NSNumber numberWithUnsignedInteger:VAL_UINT]; -} diff --git a/test/ARCMT/objcmt-numeric-literals.m.result b/test/ARCMT/objcmt-numeric-literals.m.result deleted file mode 100644 index bb7b515566d0..000000000000 --- a/test/ARCMT/objcmt-numeric-literals.m.result +++ /dev/null @@ -1,502 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c++ -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c++ %s.result - -#define YES __objc_yes -#define NO __objc_no - -typedef long NSInteger; -typedef unsigned long NSUInteger; -typedef signed char BOOL; -#define nil ((void*) 0) - -@interface NSObject -+ (id)alloc; -@end - -@interface NSNumber : NSObject -@end - -@interface NSNumber (NSNumberCreation) -- (id)initWithChar:(char)value; -- (id)initWithUnsignedChar:(unsigned char)value; -- (id)initWithShort:(short)value; -- (id)initWithUnsignedShort:(unsigned short)value; -- (id)initWithInt:(int)value; -- (id)initWithUnsignedInt:(unsigned int)value; -- (id)initWithLong:(long)value; -- (id)initWithUnsignedLong:(unsigned long)value; -- (id)initWithLongLong:(long long)value; -- (id)initWithUnsignedLongLong:(unsigned long long)value; -- (id)initWithFloat:(float)value; -- (id)initWithDouble:(double)value; -- (id)initWithBool:(BOOL)value; -- (id)initWithInteger:(NSInteger)value; -- (id)initWithUnsignedInteger:(NSUInteger)value; - -+ (NSNumber *)numberWithChar:(char)value; -+ (NSNumber *)numberWithUnsignedChar:(unsigned char)value; -+ (NSNumber *)numberWithShort:(short)value; -+ (NSNumber *)numberWithUnsignedShort:(unsigned short)value; -+ (NSNumber *)numberWithInt:(int)value; -+ (NSNumber *)numberWithUnsignedInt:(unsigned int)value; -+ (NSNumber *)numberWithLong:(long)value; -+ (NSNumber *)numberWithUnsignedLong:(unsigned long)value; -+ (NSNumber *)numberWithLongLong:(long long)value; -+ (NSNumber *)numberWithUnsignedLongLong:(unsigned long long)value; -+ (NSNumber *)numberWithFloat:(float)value; -+ (NSNumber *)numberWithDouble:(double)value; -+ (NSNumber *)numberWithBool:(BOOL)value; -+ (NSNumber *)numberWithInteger:(NSInteger)value; -+ (NSNumber *)numberWithUnsignedInteger:(NSUInteger)value; -@end - -#define VAL_INT 2 -#define VAL_UINT 2U -#define VAL_CHAR 'a' - -void foo() { - @'a'; - [NSNumber numberWithChar:L'a']; - [NSNumber numberWithChar:2]; - [NSNumber numberWithChar:2U]; - [NSNumber numberWithChar:2u]; - [NSNumber numberWithChar:2L]; - [NSNumber numberWithChar:2l]; - [NSNumber numberWithChar:2LL]; - [NSNumber numberWithChar:2ll]; - [NSNumber numberWithChar:2ul]; - [NSNumber numberWithChar:2lu]; - [NSNumber numberWithChar:2ull]; - [NSNumber numberWithChar:2llu]; - [NSNumber numberWithChar:2.0]; - [NSNumber numberWithChar:2.0f]; - [NSNumber numberWithChar:2.0F]; - [NSNumber numberWithChar:2.0l]; - [NSNumber numberWithChar:2.0L]; - [NSNumber numberWithChar:0x2f]; - [NSNumber numberWithChar:04]; - [NSNumber numberWithChar:0]; - [NSNumber numberWithChar:0.0]; - [NSNumber numberWithChar:YES]; - [NSNumber numberWithChar:NO]; - [NSNumber numberWithChar:true]; - [NSNumber numberWithChar:false]; - [NSNumber numberWithChar:VAL_INT]; - [NSNumber numberWithChar:VAL_UINT]; - @VAL_CHAR; - - [NSNumber numberWithUnsignedChar:'a']; - [NSNumber numberWithUnsignedChar:L'a']; - [NSNumber numberWithUnsignedChar:2]; - [NSNumber numberWithUnsignedChar:2U]; - [NSNumber numberWithUnsignedChar:2u]; - [NSNumber numberWithUnsignedChar:2L]; - [NSNumber numberWithUnsignedChar:2l]; - [NSNumber numberWithUnsignedChar:2LL]; - [NSNumber numberWithUnsignedChar:2ll]; - [NSNumber numberWithUnsignedChar:2ul]; - [NSNumber numberWithUnsignedChar:2lu]; - [NSNumber numberWithUnsignedChar:2ull]; - [NSNumber numberWithUnsignedChar:2llu]; - [NSNumber numberWithUnsignedChar:2.0]; - [NSNumber numberWithUnsignedChar:2.0f]; - [NSNumber numberWithUnsignedChar:2.0F]; - [NSNumber numberWithUnsignedChar:2.0l]; - [NSNumber numberWithUnsignedChar:2.0L]; - [NSNumber numberWithUnsignedChar:0x2f]; - [NSNumber numberWithUnsignedChar:04]; - [NSNumber numberWithUnsignedChar:0]; - [NSNumber numberWithUnsignedChar:0.0]; - [NSNumber numberWithUnsignedChar:YES]; - [NSNumber numberWithUnsignedChar:NO]; - [NSNumber numberWithUnsignedChar:true]; - [NSNumber numberWithUnsignedChar:false]; - [NSNumber numberWithUnsignedChar:VAL_INT]; - [NSNumber numberWithUnsignedChar:VAL_UINT]; - [NSNumber numberWithUnsignedChar:VAL_CHAR]; - - [NSNumber numberWithShort:'a']; - [NSNumber numberWithShort:L'a']; - [NSNumber numberWithShort:2]; - [NSNumber numberWithShort:2U]; - [NSNumber numberWithShort:2u]; - [NSNumber numberWithShort:2L]; - [NSNumber numberWithShort:2l]; - [NSNumber numberWithShort:2LL]; - [NSNumber numberWithShort:2ll]; - [NSNumber numberWithShort:2ul]; - [NSNumber numberWithShort:2lu]; - [NSNumber numberWithShort:2ull]; - [NSNumber numberWithShort:2llu]; - [NSNumber numberWithShort:2.0]; - [NSNumber numberWithShort:2.0f]; - [NSNumber numberWithShort:2.0F]; - [NSNumber numberWithShort:2.0l]; - [NSNumber numberWithShort:2.0L]; - [NSNumber numberWithShort:0x2f]; - [NSNumber numberWithShort:04]; - [NSNumber numberWithShort:0]; - [NSNumber numberWithShort:0.0]; - [NSNumber numberWithShort:YES]; - [NSNumber numberWithShort:NO]; - [NSNumber numberWithShort:true]; - [NSNumber numberWithShort:false]; - [NSNumber numberWithShort:VAL_INT]; - [NSNumber numberWithShort:VAL_UINT]; - - [NSNumber numberWithUnsignedShort:'a']; - [NSNumber numberWithUnsignedShort:L'a']; - [NSNumber numberWithUnsignedShort:2]; - [NSNumber numberWithUnsignedShort:2U]; - [NSNumber numberWithUnsignedShort:2u]; - [NSNumber numberWithUnsignedShort:2L]; - [NSNumber numberWithUnsignedShort:2l]; - [NSNumber numberWithUnsignedShort:2LL]; - [NSNumber numberWithUnsignedShort:2ll]; - [NSNumber numberWithUnsignedShort:2ul]; - [NSNumber numberWithUnsignedShort:2lu]; - [NSNumber numberWithUnsignedShort:2ull]; - [NSNumber numberWithUnsignedShort:2llu]; - [NSNumber numberWithUnsignedShort:2.0]; - [NSNumber numberWithUnsignedShort:2.0f]; - [NSNumber numberWithUnsignedShort:2.0F]; - [NSNumber numberWithUnsignedShort:2.0l]; - [NSNumber numberWithUnsignedShort:2.0L]; - [NSNumber numberWithUnsignedShort:0x2f]; - [NSNumber numberWithUnsignedShort:04]; - [NSNumber numberWithUnsignedShort:0]; - [NSNumber numberWithUnsignedShort:0.0]; - [NSNumber numberWithUnsignedShort:YES]; - [NSNumber numberWithUnsignedShort:NO]; - [NSNumber numberWithUnsignedShort:true]; - [NSNumber numberWithUnsignedShort:false]; - [NSNumber numberWithUnsignedShort:VAL_INT]; - [NSNumber numberWithUnsignedShort:VAL_UINT]; - - [NSNumber numberWithInt:'a']; - [NSNumber numberWithInt:L'a']; - @2; - @2; - @2; - @2; - @2; - @2; - @2; - @2; - @2; - @2; - @2; - [NSNumber numberWithInt:2.0]; - [NSNumber numberWithInt:2.0f]; - [NSNumber numberWithInt:2.0F]; - [NSNumber numberWithInt:2.0l]; - [NSNumber numberWithInt:2.0L]; - @0x2f; - @04; - @0; - [NSNumber numberWithInt:0.0]; - [NSNumber numberWithInt:YES]; - [NSNumber numberWithInt:NO]; - [NSNumber numberWithInt:true]; - [NSNumber numberWithInt:false]; - @VAL_INT; - [NSNumber numberWithInt:VAL_UINT]; - - (void)[[NSNumber alloc] initWithInt:2]; - (void)[[NSNumber alloc] initWithInt:2U]; - - @+2; - @-2; - - [NSNumber numberWithUnsignedInt:'a']; - [NSNumber numberWithUnsignedInt:L'a']; - @2U; - @2U; - @2u; - @2U; - @2u; - @2U; - @2u; - @2u; - @2u; - @2u; - @2u; - [NSNumber numberWithUnsignedInt:2.0]; - [NSNumber numberWithUnsignedInt:2.0f]; - [NSNumber numberWithUnsignedInt:2.0F]; - [NSNumber numberWithUnsignedInt:2.0l]; - [NSNumber numberWithUnsignedInt:2.0L]; - @0x2fU; - @04U; - @0U; - [NSNumber numberWithUnsignedInt:0.0]; - [NSNumber numberWithUnsignedInt:YES]; - [NSNumber numberWithUnsignedInt:NO]; - [NSNumber numberWithUnsignedInt:true]; - [NSNumber numberWithUnsignedInt:false]; - [NSNumber numberWithUnsignedInt:VAL_INT]; - @VAL_UINT; - - [NSNumber numberWithLong:'a']; - [NSNumber numberWithLong:L'a']; - @2L; - @2L; - @2l; - @2L; - @2l; - @2L; - @2l; - @2l; - @2l; - @2l; - @2l; - [NSNumber numberWithLong:2.0]; - [NSNumber numberWithLong:2.0f]; - [NSNumber numberWithLong:2.0F]; - [NSNumber numberWithLong:2.0l]; - [NSNumber numberWithLong:2.0L]; - @0x2fL; - @04L; - @0L; - [NSNumber numberWithLong:0.0]; - [NSNumber numberWithLong:YES]; - [NSNumber numberWithLong:NO]; - [NSNumber numberWithLong:true]; - [NSNumber numberWithLong:false]; - [NSNumber numberWithLong:VAL_INT]; - [NSNumber numberWithLong:VAL_UINT]; - - [NSNumber numberWithUnsignedLong:'a']; - [NSNumber numberWithUnsignedLong:L'a']; - @2UL; - @2UL; - @2ul; - @2UL; - @2ul; - @2UL; - @2ul; - @2ul; - @2lu; - @2ul; - @2ul; - [NSNumber numberWithUnsignedLong:2.0]; - [NSNumber numberWithUnsignedLong:2.0f]; - [NSNumber numberWithUnsignedLong:2.0F]; - [NSNumber numberWithUnsignedLong:2.0l]; - [NSNumber numberWithUnsignedLong:2.0L]; - @0x2fUL; - @04UL; - @0UL; - [NSNumber numberWithUnsignedLong:0.0]; - [NSNumber numberWithUnsignedLong:YES]; - [NSNumber numberWithUnsignedLong:NO]; - [NSNumber numberWithUnsignedLong:true]; - [NSNumber numberWithUnsignedLong:false]; - [NSNumber numberWithUnsignedLong:VAL_INT]; - [NSNumber numberWithUnsignedLong:VAL_UINT]; - - [NSNumber numberWithLongLong:'a']; - [NSNumber numberWithLongLong:L'a']; - @2LL; - @2LL; - @2ll; - @2LL; - @2ll; - @2LL; - @2ll; - @2ll; - @2ll; - @2ll; - @2ll; - [NSNumber numberWithLongLong:2.0]; - [NSNumber numberWithLongLong:2.0f]; - [NSNumber numberWithLongLong:2.0F]; - [NSNumber numberWithLongLong:2.0l]; - [NSNumber numberWithLongLong:2.0L]; - @0x2fLL; - @04LL; - @0LL; - [NSNumber numberWithLongLong:0.0]; - [NSNumber numberWithLongLong:YES]; - [NSNumber numberWithLongLong:NO]; - [NSNumber numberWithLongLong:true]; - [NSNumber numberWithLongLong:false]; - [NSNumber numberWithLongLong:VAL_INT]; - [NSNumber numberWithLongLong:VAL_UINT]; - - [NSNumber numberWithUnsignedLongLong:'a']; - [NSNumber numberWithUnsignedLongLong:L'a']; - @2ULL; - @2ULL; - @2ull; - @2ULL; - @2ull; - @2ULL; - @2ull; - @2ull; - @2ull; - @2ull; - @2llu; - [NSNumber numberWithUnsignedLongLong:2.0]; - [NSNumber numberWithUnsignedLongLong:2.0f]; - [NSNumber numberWithUnsignedLongLong:2.0F]; - [NSNumber numberWithUnsignedLongLong:2.0l]; - [NSNumber numberWithUnsignedLongLong:2.0L]; - @0x2fULL; - @04ULL; - @0ULL; - [NSNumber numberWithUnsignedLongLong:0.0]; - [NSNumber numberWithUnsignedLongLong:YES]; - [NSNumber numberWithUnsignedLongLong:NO]; - [NSNumber numberWithUnsignedLongLong:true]; - [NSNumber numberWithUnsignedLongLong:false]; - [NSNumber numberWithUnsignedLongLong:VAL_INT]; - [NSNumber numberWithUnsignedLongLong:VAL_UINT]; - - [NSNumber numberWithFloat:'a']; - [NSNumber numberWithFloat:L'a']; - @2.0f; - @2.0f; - @2.0f; - @2.0f; - @2.0f; - @2.0f; - @2.0f; - @2.0f; - @2.0f; - @2.0f; - @2.0f; - @2.0f; - @2.0f; - @2.0F; - @2.0f; - @2.0f; - [NSNumber numberWithFloat:0x2f]; - [NSNumber numberWithFloat:04]; - @0.0f; - @0.0f; - [NSNumber numberWithFloat:YES]; - [NSNumber numberWithFloat:NO]; - [NSNumber numberWithFloat:true]; - [NSNumber numberWithFloat:false]; - [NSNumber numberWithFloat:VAL_INT]; - [NSNumber numberWithFloat:VAL_UINT]; - - [NSNumber numberWithDouble:'a']; - [NSNumber numberWithDouble:L'a']; - @2.0; - @2.0; - @2.0; - @2.0; - @2.0; - @2.0; - @2.0; - @2.0; - @2.0; - @2.0; - @2.0; - @2.0; - @2.0; - @2.0; - @2.0; - @2.0; - [NSNumber numberWithDouble:0x2f]; - [NSNumber numberWithDouble:04]; - @0.0; - @0.0; - [NSNumber numberWithDouble:YES]; - [NSNumber numberWithDouble:NO]; - [NSNumber numberWithDouble:true]; - [NSNumber numberWithDouble:false]; - [NSNumber numberWithDouble:VAL_INT]; - [NSNumber numberWithDouble:VAL_UINT]; - - [NSNumber numberWithBool:'a']; - [NSNumber numberWithBool:L'a']; - [NSNumber numberWithBool:2]; - [NSNumber numberWithBool:2U]; - [NSNumber numberWithBool:2u]; - [NSNumber numberWithBool:2L]; - [NSNumber numberWithBool:2l]; - [NSNumber numberWithBool:2LL]; - [NSNumber numberWithBool:2ll]; - [NSNumber numberWithBool:2ul]; - [NSNumber numberWithBool:2lu]; - [NSNumber numberWithBool:2ull]; - [NSNumber numberWithBool:2llu]; - [NSNumber numberWithBool:2.0]; - [NSNumber numberWithBool:2.0f]; - [NSNumber numberWithBool:2.0F]; - [NSNumber numberWithBool:2.0l]; - [NSNumber numberWithBool:2.0L]; - [NSNumber numberWithBool:0x2f]; - [NSNumber numberWithBool:04]; - [NSNumber numberWithBool:0]; - [NSNumber numberWithBool:0.0]; - @YES; - @NO; - @true; - @false; - [NSNumber numberWithBool:VAL_INT]; - [NSNumber numberWithBool:VAL_UINT]; - - [NSNumber numberWithInteger:'a']; - [NSNumber numberWithInteger:L'a']; - @2; - @2; - @2; - @2L; - @2l; - @2; - @2; - @2; - @2; - @2; - @2; - [NSNumber numberWithInteger:2.0]; - [NSNumber numberWithInteger:2.0f]; - [NSNumber numberWithInteger:2.0F]; - [NSNumber numberWithInteger:2.0l]; - [NSNumber numberWithInteger:2.0L]; - @0x2f; - @04; - @0; - [NSNumber numberWithInteger:0.0]; - [NSNumber numberWithInteger:YES]; - [NSNumber numberWithInteger:NO]; - [NSNumber numberWithInteger:true]; - [NSNumber numberWithInteger:false]; - @VAL_INT; - [NSNumber numberWithInteger:VAL_UINT]; - - [NSNumber numberWithUnsignedInteger:'a']; - [NSNumber numberWithUnsignedInteger:L'a']; - @2U; - @2U; - @2u; - @2U; - @2u; - @2U; - @2u; - @2ul; - @2lu; - @2u; - @2u; - [NSNumber numberWithUnsignedInteger:2.0]; - [NSNumber numberWithUnsignedInteger:2.0f]; - [NSNumber numberWithUnsignedInteger:2.0F]; - [NSNumber numberWithUnsignedInteger:2.0l]; - [NSNumber numberWithUnsignedInteger:2.0L]; - @0x2fU; - @04U; - @0U; - [NSNumber numberWithUnsignedInteger:0.0]; - [NSNumber numberWithUnsignedInteger:YES]; - [NSNumber numberWithUnsignedInteger:NO]; - [NSNumber numberWithUnsignedInteger:true]; - [NSNumber numberWithUnsignedInteger:false]; - [NSNumber numberWithUnsignedInteger:VAL_INT]; - @VAL_UINT; -} diff --git a/test/ARCMT/objcmt-property-availability.m b/test/ARCMT/objcmt-property-availability.m deleted file mode 100644 index d499221a74cd..000000000000 --- a/test/ARCMT/objcmt-property-availability.m +++ /dev/null @@ -1,46 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -objcmt-migrate-readwrite-property -objcmt-migrate-readonly-property -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11 -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result -// rdar://15300059 - - -#define __NSi_7_0 introduced=7.0 -#define __NSi_6_0 introduced=6.0 - -#define CF_AVAILABLE(_mac, _ios) __attribute__((availability(ios,__NSi_##_ios))) -#define CF_AVAILABLE_MAC(_mac) __attribute__((availability(macosx,__NSi_##_mac))) -#define CF_AVAILABLE_IOS(_ios) __attribute__((availability(macosx,unavailable))) - -#define NS_AVAILABLE(_mac, _ios) CF_AVAILABLE(_mac, _ios) -#define NS_AVAILABLE_MAC(_mac) CF_AVAILABLE_MAC(_mac) -#define NS_AVAILABLE_IOS(_ios) CF_AVAILABLE_IOS(_ios) - -#define UNAVAILABLE __attribute__((unavailable("not available in automatic reference counting mode"))) - -@interface MKMapItem -- (MKMapItem *)source NS_AVAILABLE(10_9, 6_0); -- (void)setSource:(MKMapItem *)source NS_AVAILABLE(10_9, 7_0); - -- (void)setDest:(MKMapItem *)source NS_AVAILABLE(10_9, 6_0); -- (MKMapItem *)dest NS_AVAILABLE(10_9, 6_0); - -- (MKMapItem *)final; -- (void)setFinal:(MKMapItem *)source; - -- (MKMapItem *)total NS_AVAILABLE(10_9, 6_0); -- (void)setTotal:(MKMapItem *)source; - -- (MKMapItem *)comp NS_AVAILABLE(10_9, 6_0); -- (void)setComp:(MKMapItem *)source UNAVAILABLE; - -- (MKMapItem *)tally UNAVAILABLE NS_AVAILABLE(10_9, 6_0); -- (void)setTally:(MKMapItem *)source UNAVAILABLE NS_AVAILABLE(10_9, 6_0); - -- (MKMapItem *)itally NS_AVAILABLE(10_9, 6_0); -- (void)setItally:(MKMapItem *)source UNAVAILABLE NS_AVAILABLE(10_9, 6_0); - -- (MKMapItem *)normal UNAVAILABLE; -- (void)setNormal:(MKMapItem *)source UNAVAILABLE NS_AVAILABLE(10_9, 6_0); -@end - diff --git a/test/ARCMT/objcmt-property-availability.m.result b/test/ARCMT/objcmt-property-availability.m.result deleted file mode 100644 index a5a45e37929c..000000000000 --- a/test/ARCMT/objcmt-property-availability.m.result +++ /dev/null @@ -1,43 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -objcmt-migrate-readwrite-property -objcmt-migrate-readonly-property -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11 -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result -// rdar://15300059 - - -#define __NSi_7_0 introduced=7.0 -#define __NSi_6_0 introduced=6.0 - -#define CF_AVAILABLE(_mac, _ios) __attribute__((availability(ios,__NSi_##_ios))) -#define CF_AVAILABLE_MAC(_mac) __attribute__((availability(macosx,__NSi_##_mac))) -#define CF_AVAILABLE_IOS(_ios) __attribute__((availability(macosx,unavailable))) - -#define NS_AVAILABLE(_mac, _ios) CF_AVAILABLE(_mac, _ios) -#define NS_AVAILABLE_MAC(_mac) CF_AVAILABLE_MAC(_mac) -#define NS_AVAILABLE_IOS(_ios) CF_AVAILABLE_IOS(_ios) - -#define UNAVAILABLE __attribute__((unavailable("not available in automatic reference counting mode"))) - -@interface MKMapItem -@property (nonatomic, strong) MKMapItem *source NS_AVAILABLE(10_9, 6_0); -- (void)setSource:(MKMapItem *)source NS_AVAILABLE(10_9, 7_0); - -@property (nonatomic, strong) MKMapItem *dest NS_AVAILABLE(10_9, 6_0); - -@property (nonatomic, strong) MKMapItem *final; - -@property (nonatomic, strong) MKMapItem *total NS_AVAILABLE(10_9, 6_0); -- (void)setTotal:(MKMapItem *)source; - -- (MKMapItem *)comp NS_AVAILABLE(10_9, 6_0); -- (void)setComp:(MKMapItem *)source UNAVAILABLE; - -@property (nonatomic, strong) MKMapItem *tally UNAVAILABLE NS_AVAILABLE(10_9, 6_0); - -- (MKMapItem *)itally NS_AVAILABLE(10_9, 6_0); -- (void)setItally:(MKMapItem *)source UNAVAILABLE NS_AVAILABLE(10_9, 6_0); - -- (MKMapItem *)normal UNAVAILABLE; -- (void)setNormal:(MKMapItem *)source UNAVAILABLE NS_AVAILABLE(10_9, 6_0); -@end - diff --git a/test/ARCMT/objcmt-property-dot-syntax.m b/test/ARCMT/objcmt-property-dot-syntax.m deleted file mode 100644 index 5c71186b274f..000000000000 --- a/test/ARCMT/objcmt-property-dot-syntax.m +++ /dev/null @@ -1,122 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -objcmt-migrate-property-dot-syntax -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11 -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result - -@class NSString; - -// rdar://19140267 -@protocol NSObject -@property (readonly, copy) NSString *description; -@end - -// rdar://18498572 -@interface NSObject <NSObject> @end - -@interface P : NSObject -{ - P* obj; - int i1, i2, i3; -} -@property int count; -@property (copy) P* PropertyReturnsPObj; -- (P*) MethodReturnsPObj; -@end - -P* fun(); - -@implementation P -- (int) Meth : (P*)array { - [obj setCount : 100]; - - [(P*)0 setCount : [array count]]; - - [[obj PropertyReturnsPObj] setCount : [array count]]; - - [obj setCount : (i1+i2*i3 - 100)]; - - return [obj count] - - [(P*)0 count] + [array count] + - [fun() count] - - [[obj PropertyReturnsPObj] count] + - [self->obj count]; -} - -- (P*) MethodReturnsPObj { return 0; } - -- (NSString *)description { return [super description]; } -@end - -// rdar://19140267 -@interface Sub : P -@end - -@implementation Sub -- (int) Meth : (P*)array { - [super setCount : 100]; - - [super setCount : [array count]]; - - [[super PropertyReturnsPObj] setCount : [array count]]; - - [super setCount : (i1+i2*i3 - 100)]; - - return [super count] - - [(P*)0 count] + [array count] + - [fun() count] - - [[super PropertyReturnsPObj] count] + - [self->obj count]; -} -@end - - -@interface Rdar19038838 -@property id newItem; // should be marked objc_method_family(none), but isn't. -@end - -id testRdar19038838(Rdar19038838 *obj) { - return [obj newItem]; -} - -// rdar://19381786 -@interface rdar19381786 : NSObject -{ - rdar19381786* obj; -} -@property int count; -@end - -@protocol PR -@property int count; -@end - -@implementation rdar19381786 --(void)test:(id)some : (id<PR>)qsome : (SEL)selsome -{ - [obj setCount : 100]; - [some setCount : [some count]]; - [qsome setCount : [qsome count]]; -} -@end - -// rdar://19140114 -int NSOnState; -int ArrNSOnState[4]; -@interface rdar19140114 : NSObject -{ - rdar19140114* menuItem; -} -@property int state; -@end - -@implementation rdar19140114 -- (void) Meth { - [menuItem setState:NSOnState]; - [menuItem setState :NSOnState]; - [menuItem setState :ArrNSOnState[NSOnState]]; - [menuItem setState : NSOnState]; - [menuItem setState: NSOnState]; - [menuItem setState: NSOnState]; - [menuItem setState : NSOnState]; -} -@end diff --git a/test/ARCMT/objcmt-property-dot-syntax.m.result b/test/ARCMT/objcmt-property-dot-syntax.m.result deleted file mode 100644 index 09b93f6ff8f2..000000000000 --- a/test/ARCMT/objcmt-property-dot-syntax.m.result +++ /dev/null @@ -1,122 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -objcmt-migrate-property-dot-syntax -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11 -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result - -@class NSString; - -// rdar://19140267 -@protocol NSObject -@property (readonly, copy) NSString *description; -@end - -// rdar://18498572 -@interface NSObject <NSObject> @end - -@interface P : NSObject -{ - P* obj; - int i1, i2, i3; -} -@property int count; -@property (copy) P* PropertyReturnsPObj; -- (P*) MethodReturnsPObj; -@end - -P* fun(); - -@implementation P -- (int) Meth : (P*)array { - obj.count = 100; - - ((P*)0).count = array.count; - - obj.PropertyReturnsPObj.count = array.count; - - obj.count = (i1+i2*i3 - 100); - - return obj.count - - ((P*)0).count + array.count + - fun().count - - obj.PropertyReturnsPObj.count + - self->obj.count; -} - -- (P*) MethodReturnsPObj { return 0; } - -- (NSString *)description { return super.description; } -@end - -// rdar://19140267 -@interface Sub : P -@end - -@implementation Sub -- (int) Meth : (P*)array { - super.count = 100; - - super.count = array.count; - - super.PropertyReturnsPObj.count = array.count; - - super.count = (i1+i2*i3 - 100); - - return super.count - - ((P*)0).count + array.count + - fun().count - - super.PropertyReturnsPObj.count + - self->obj.count; -} -@end - - -@interface Rdar19038838 -@property id newItem; // should be marked objc_method_family(none), but isn't. -@end - -id testRdar19038838(Rdar19038838 *obj) { - return obj.newItem; -} - -// rdar://19381786 -@interface rdar19381786 : NSObject -{ - rdar19381786* obj; -} -@property int count; -@end - -@protocol PR -@property int count; -@end - -@implementation rdar19381786 --(void)test:(id)some : (id<PR>)qsome : (SEL)selsome -{ - obj.count = 100; - [some setCount : [some count]]; - qsome.count = qsome.count; -} -@end - -// rdar://19140114 -int NSOnState; -int ArrNSOnState[4]; -@interface rdar19140114 : NSObject -{ - rdar19140114* menuItem; -} -@property int state; -@end - -@implementation rdar19140114 -- (void) Meth { - menuItem.state = NSOnState; - menuItem.state = NSOnState; - menuItem.state = ArrNSOnState[NSOnState]; - menuItem.state = NSOnState; - menuItem.state = NSOnState; - menuItem.state = NSOnState; - menuItem.state = NSOnState; -} -@end diff --git a/test/ARCMT/objcmt-property.m b/test/ARCMT/objcmt-property.m deleted file mode 100644 index 1ea41093850d..000000000000 --- a/test/ARCMT/objcmt-property.m +++ /dev/null @@ -1,248 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -fblocks -objcmt-migrate-readwrite-property -objcmt-migrate-readonly-property -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11 -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result - -#define WEBKIT_OBJC_METHOD_ANNOTATION(ANNOTATION) ANNOTATION -#define WEAK_IMPORT_ATTRIBUTE __attribute__((objc_arc_weak_reference_unavailable)) -#define AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER -#define DEPRECATED __attribute__((deprecated)) - -typedef char BOOL; -@class NSString; -@protocol NSCopying @end - -@interface NSObject <NSCopying> -@end - -@interface NSDictionary : NSObject -@end - -@interface I : NSObject { - int ivarVal; -} -- (void) setWeakProp : (NSString *__weak)Val; -- (NSString *__weak) WeakProp; - -- (NSString *) StrongProp; -- (void) setStrongProp : (NSString *)Val; - -- (NSString *) UnavailProp __attribute__((unavailable)); -- (void) setUnavailProp : (NSString *)Val; - -- (NSString *) UnavailProp1 __attribute__((unavailable)); -- (void) setUnavailProp1 : (NSString *)Val __attribute__((unavailable)); - -- (NSString *) UnavailProp2; -- (void) setUnavailProp2 : (NSString *)Val __attribute__((unavailable)); - -- (NSDictionary*) undoAction; -- (void) setUndoAction: (NSDictionary*)Arg; -@end - -@implementation I -@end - -@class NSArray; - -@interface MyClass2 { -@private - NSArray *_names1; - NSArray *_names2; - NSArray *_names3; - NSArray *_names4; -} -- (void)setNames1:(NSArray *)names; -- (void)setNames4:(__strong NSArray *)names; -- (void)setNames3:(__strong NSArray *)names; -- (void)setNames2:(NSArray *)names; -- (NSArray *) names2; -- (NSArray *)names3; -- (__strong NSArray *)names4; -- (NSArray *) names1; -@end - -// Properties that contain the name "delegate" or "dataSource", -// or have exact name "target" have unsafe_unretained attribute. -@interface NSInvocation -- (id)target; -- (void)setTarget:(id)target; - -- (id) dataSource; - -// rdar://15509831 -- (id)delegate; - -- (id)xxxdelegateYYY; -- (void)setXxxdelegateYYY:(id)delegate; - -- (void)setDataSource:(id)source; - -- (id)MYtarget; -- (void)setMYtarget: (id)target; - -- (id)targetX; -- (void)setTargetX: (id)t; - -- (int)value; -- (void)setValue: (int)val; - --(BOOL) isContinuous; --(void) setContinuous:(BOOL)value; - -- (id) isAnObject; -- (void)setAnObject : (id) object; - -- (BOOL) isinValid; -- (void) setInValid : (BOOL) arg; - -- (void) Nothing; -- (int) Length; -- (id) object; -+ (double) D; -- (void *)JSObject WEBKIT_OBJC_METHOD_ANNOTATION(AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER); -- (BOOL)isIgnoringInteractionEvents; - -- (NSString *)getStringValue; -- (BOOL)getCounterValue; -- (void)setStringValue:(NSString *)stringValue AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; -- (NSDictionary *)getns_dixtionary; - -- (BOOL)is3bar; // watch out -- (NSString *)get3foo; // watch out - -- (BOOL) getM; -- (BOOL) getMA; -- (BOOL) getALL; -- (BOOL) getMANY; -- (BOOL) getSome; -@end - - -@interface NSInvocation(CAT) -- (id)target; -- (void)setTarget:(id)target; - -- (id) dataSource; - -- (id)xxxdelegateYYY; -- (void)setXxxdelegateYYY:(id)delegate; - -- (void)setDataSource:(id)source; - -- (id)MYtarget; -- (void)setMYtarget: (id)target; - -- (id)targetX; -- (void)setTargetX: (id)t; - -- (int)value; -- (void)setValue: (int)val; - --(BOOL) isContinuous; --(void) setContinuous:(BOOL)value; - -- (id) isAnObject; -- (void)setAnObject : (id) object; - -- (BOOL) isinValid; -- (void) setInValid : (BOOL) arg; - -- (void) Nothing; -- (int) Length; -- (id) object; -+ (double) D; - -- (BOOL)is3bar; // watch out -- (NSString *)get3foo; // watch out - -- (BOOL) getM; -- (BOOL) getMA; -- (BOOL) getALL; -- (BOOL) getMANY; -- (BOOL) getSome; -@end - -DEPRECATED -@interface I_DEP -- (BOOL) isinValid; -- (void) setInValid : (BOOL) arg; -@end - -@interface AnotherOne -- (BOOL) isinValid DEPRECATED; -- (void) setInValid : (BOOL) arg; -- (id)MYtarget; -- (void)setMYtarget: (id)target DEPRECATED; -- (BOOL) getM DEPRECATED; - -- (id)xxxdelegateYYY DEPRECATED; -- (void)setXxxdelegateYYY:(id)delegate DEPRECATED; -@end - -// rdar://14987909 -#define NS_AVAILABLE __attribute__((availability(macosx,introduced=10.0))) -#define NORETURN __attribute__((noreturn)) -#define ALIGNED __attribute__((aligned(16))) - -@interface NSURL -// Do not infer a property. -- (NSURL *)appStoreReceiptURL NS_AVAILABLE; -- (void) setAppStoreReceiptURL : (NSURL *)object; - -- (NSURL *)appStoreReceiptURLX NS_AVAILABLE; -- (void) setAppStoreReceiptURLX : (NSURL *)object NS_AVAILABLE; - -// Do not infer a property. -- (NSURL *)appStoreReceiptURLY ; -- (void) setAppStoreReceiptURLY : (NSURL *)object NS_AVAILABLE; - -- (id)OkToInfer NS_AVAILABLE; - -// Do not infer a property. -- (NSURL *)appStoreReceiptURLZ ; -- (void) setAppStoreReceiptURLZ : (NSURL *)object NS_AVAILABLE; - -// Do not infer a property. -- (id) t1 NORETURN NS_AVAILABLE; -- (void) setT1 : (id) arg NS_AVAILABLE; - -- (id)method1 ALIGNED NS_AVAILABLE; -- (void) setMethod1 : (id) object NS_AVAILABLE ALIGNED; - -- (NSURL *)init; // No Change -+ (id)alloc; // No Change - -- (BOOL)is1stClass; // Not a valid property -- (BOOL)isClass; // This is a valid property 'class' is not a keyword in ObjC -- (BOOL)isDouble; // Not a valid property - -@end - -// rdar://15082818 -@class NSMutableDictionary; - -@interface NSArray -- (id (^)(id, NSArray *, NSMutableDictionary *)) expressionBlock; -- (id (^)(id, NSArray *, NSMutableDictionary *)) MyBlock; -- (void) setMyBlock : (id (^)(id, NSArray *, NSMutableDictionary *)) bl; -- (id (*)(id, NSArray *, NSMutableDictionary *)) expressionFuncptr; -- (id (*)(id, NSArray *, NSMutableDictionary *)) MyFuncptr; -- (void) setMyFuncptr : (id (*)(id, NSArray *, NSMutableDictionary *)) bl; -@end - -// rdar://15231241 -@interface rdar15231241 -@property (nonatomic, readonly) double Ddelegate; -@property (nonatomic, readonly) float Fdelegate; -@property (nonatomic, readonly) int Idelegate; -@property (nonatomic, readonly) BOOL Bdelegate; -@end - -// rdar://19372798 -@protocol NSObject @end -@protocol MyProtocol <NSObject> -- (id)readonlyProperty; -- (id)readWriteProperty; -- (void)setReadWriteProperty:(id)readWriteProperty; -@end diff --git a/test/ARCMT/objcmt-property.m.result b/test/ARCMT/objcmt-property.m.result deleted file mode 100644 index 58f8ce2e0715..000000000000 --- a/test/ARCMT/objcmt-property.m.result +++ /dev/null @@ -1,220 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -fblocks -objcmt-migrate-readwrite-property -objcmt-migrate-readonly-property -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11 -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result - -#define WEBKIT_OBJC_METHOD_ANNOTATION(ANNOTATION) ANNOTATION -#define WEAK_IMPORT_ATTRIBUTE __attribute__((objc_arc_weak_reference_unavailable)) -#define AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER -#define DEPRECATED __attribute__((deprecated)) - -typedef char BOOL; -@class NSString; -@protocol NSCopying @end - -@interface NSObject <NSCopying> -@end - -@interface NSDictionary : NSObject -@end - -@interface I : NSObject { - int ivarVal; -} -@property (nonatomic, weak) NSString *WeakProp; - -@property (nonatomic, strong) NSString *StrongProp; - -@property (nonatomic, strong) NSString *UnavailProp __attribute__((unavailable)); -- (void) setUnavailProp : (NSString *)Val; - -@property (nonatomic, strong) NSString *UnavailProp1 __attribute__((unavailable)); - -@property (nonatomic, strong) NSString *UnavailProp2; -- (void) setUnavailProp2 : (NSString *)Val __attribute__((unavailable)); - -@property (nonatomic, copy) NSDictionary *undoAction; -@end - -@implementation I -@end - -@class NSArray; - -@interface MyClass2 { -@private - NSArray *_names1; - NSArray *_names2; - NSArray *_names3; - NSArray *_names4; -} -@property (nonatomic, strong) NSArray *names2; -@property (nonatomic, strong) NSArray *names3; -@property (nonatomic, strong) NSArray *names4; -@property (nonatomic, strong) NSArray *names1; -@end - -// Properties that contain the name "delegate" or "dataSource", -// or have exact name "target" have unsafe_unretained attribute. -@interface NSInvocation -@property (nonatomic, assign) id target; - -@property (nonatomic, assign) id dataSource; - -// rdar://15509831 -@property (nonatomic, readonly, assign) id delegate; - -@property (nonatomic, assign) id xxxdelegateYYY; - - -@property (nonatomic, strong) id MYtarget; - -@property (nonatomic, strong) id targetX; - -@property (nonatomic) int value; - -@property (nonatomic, getter=isContinuous) BOOL continuous; - -- (id) isAnObject; -- (void)setAnObject : (id) object; - -@property (nonatomic, getter=isinValid, readonly) BOOL inValid; -- (void) setInValid : (BOOL) arg; - -- (void) Nothing; -@property (nonatomic, readonly) int Length; -@property (nonatomic, readonly, strong) id object; -+ (double) D; -@property (nonatomic, readonly) void *JSObject WEBKIT_OBJC_METHOD_ANNOTATION(AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER); -@property (nonatomic, getter=isIgnoringInteractionEvents, readonly) BOOL ignoringInteractionEvents; - -@property (nonatomic, getter=getStringValue, strong) NSString *stringValue; -@property (nonatomic, getter=getCounterValue, readonly) BOOL counterValue; -@property (nonatomic, getter=getns_dixtionary, readonly, copy) NSDictionary *ns_dixtionary; - -- (BOOL)is3bar; // watch out -- (NSString *)get3foo; // watch out - -@property (nonatomic, getter=getM, readonly) BOOL m; -@property (nonatomic, getter=getMA, readonly) BOOL MA; -@property (nonatomic, getter=getALL, readonly) BOOL ALL; -@property (nonatomic, getter=getMANY, readonly) BOOL MANY; -@property (nonatomic, getter=getSome, readonly) BOOL some; -@end - - -@interface NSInvocation(CAT) -@property (nonatomic, assign) id target; - -@property (nonatomic, assign) id dataSource; - -@property (nonatomic, assign) id xxxdelegateYYY; - - -@property (nonatomic, strong) id MYtarget; - -@property (nonatomic, strong) id targetX; - -@property (nonatomic) int value; - -@property (nonatomic, getter=isContinuous) BOOL continuous; - -- (id) isAnObject; -- (void)setAnObject : (id) object; - -@property (nonatomic, getter=isinValid, readonly) BOOL inValid; -- (void) setInValid : (BOOL) arg; - -- (void) Nothing; -@property (nonatomic, readonly) int Length; -@property (nonatomic, readonly, strong) id object; -+ (double) D; - -- (BOOL)is3bar; // watch out -- (NSString *)get3foo; // watch out - -@property (nonatomic, getter=getM, readonly) BOOL m; -@property (nonatomic, getter=getMA, readonly) BOOL MA; -@property (nonatomic, getter=getALL, readonly) BOOL ALL; -@property (nonatomic, getter=getMANY, readonly) BOOL MANY; -@property (nonatomic, getter=getSome, readonly) BOOL some; -@end - -DEPRECATED -@interface I_DEP -- (BOOL) isinValid; -- (void) setInValid : (BOOL) arg; -@end - -@interface AnotherOne -- (BOOL) isinValid DEPRECATED; -- (void) setInValid : (BOOL) arg; -- (id)MYtarget; -- (void)setMYtarget: (id)target DEPRECATED; -- (BOOL) getM DEPRECATED; - -- (id)xxxdelegateYYY DEPRECATED; -- (void)setXxxdelegateYYY:(id)delegate DEPRECATED; -@end - -// rdar://14987909 -#define NS_AVAILABLE __attribute__((availability(macosx,introduced=10.0))) -#define NORETURN __attribute__((noreturn)) -#define ALIGNED __attribute__((aligned(16))) - -@interface NSURL -// Do not infer a property. -@property (nonatomic, strong) NSURL *appStoreReceiptURL NS_AVAILABLE; -- (void) setAppStoreReceiptURL : (NSURL *)object; - -@property (nonatomic, strong) NSURL *appStoreReceiptURLX NS_AVAILABLE; - -// Do not infer a property. -@property (nonatomic, strong) NSURL *appStoreReceiptURLY ; -- (void) setAppStoreReceiptURLY : (NSURL *)object NS_AVAILABLE; - -@property (nonatomic, readonly, strong) id OkToInfer NS_AVAILABLE; - -// Do not infer a property. -@property (nonatomic, strong) NSURL *appStoreReceiptURLZ ; -- (void) setAppStoreReceiptURLZ : (NSURL *)object NS_AVAILABLE; - -// Do not infer a property. -- (id) t1 NORETURN NS_AVAILABLE; -- (void) setT1 : (id) arg NS_AVAILABLE; - -@property (nonatomic, strong) id method1 ALIGNED NS_AVAILABLE; - -- (NSURL *)init; // No Change -+ (id)alloc; // No Change - -- (BOOL)is1stClass; // Not a valid property -@property (nonatomic, getter=isClass, readonly) BOOL class; // This is a valid property 'class' is not a keyword in ObjC -- (BOOL)isDouble; // Not a valid property - -@end - -// rdar://15082818 -@class NSMutableDictionary; - -@interface NSArray -@property (nonatomic, readonly, copy) id (^expressionBlock)(id, NSArray *, NSMutableDictionary *); -@property (nonatomic, copy) id (^MyBlock)(id, NSArray *, NSMutableDictionary *); -@property (nonatomic, readonly) id (*expressionFuncptr)(id, NSArray *, NSMutableDictionary *); -@property (nonatomic) id (*MyFuncptr)(id, NSArray *, NSMutableDictionary *); -@end - -// rdar://15231241 -@interface rdar15231241 -@property (nonatomic, readonly) double Ddelegate; -@property (nonatomic, readonly) float Fdelegate; -@property (nonatomic, readonly) int Idelegate; -@property (nonatomic, readonly) BOOL Bdelegate; -@end - -// rdar://19372798 -@protocol NSObject @end -@protocol MyProtocol <NSObject> -@property (nonatomic, readonly, strong) id readonlyProperty; -@property (nonatomic, strong) id readWriteProperty; -@end diff --git a/test/ARCMT/objcmt-protocol-conformance.m b/test/ARCMT/objcmt-protocol-conformance.m deleted file mode 100644 index f4c8f5112a62..000000000000 --- a/test/ARCMT/objcmt-protocol-conformance.m +++ /dev/null @@ -1,130 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -objcmt-migrate-protocol-conformance -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11 -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result - -@interface NSObject @end - -@protocol P -- (id) Meth1: (double) arg; -@end - -@interface Test1 // Test for no super class and no protocol list -@end - -@implementation Test1 -- (id) Meth1: (double) arg { return 0; } -@end - -@protocol P1 @end -@protocol P2 @end - -@interface Test2 <P1, P2> // Test for no super class and with protocol list -{ - id IVAR1; - id IVAR2; -} -@end - -@implementation Test2 -- (id) Meth1: (double) arg { return 0; } -@end - -@interface Test3 : NSObject { // Test for Super class and no protocol list - id IV1; -} -@end - -@implementation Test3 -- (id) Meth1: (double) arg { return 0; } -@end - -@interface Test4 : NSObject <P1, P2> // Test for Super class and protocol list -@end - -@implementation Test4 -- (id) Meth1: (double) arg { return 0; } -@end - -// Test5 - conforms to P3 because it implement's P3's property. -@protocol P3 -@property (copy) id Prop; -@end - -@protocol P4 -@property (copy) id Prop; -@end - -@interface Test5 : NSObject<P3> -@end - -@implementation Test5 -@synthesize Prop=_XXX; -@end - -@protocol P5 <P3, P4> -@property (copy) id Prop; -@end - -@protocol P6 <P3, P4, P5> -@property (copy) id Prop; -@end - -@interface Test6 : NSObject // Test for minimal listing of conforming protocols -@property (copy) id Prop; -@end - -@implementation Test6 -@end - -@class UIDynamicAnimator, UIWindow; -@interface UIResponder : NSObject -@end - -@protocol EmptyProtocol -@end - -@protocol OptionalMethodsOnly -@optional -- (void)dynamicAnimatorWillResume:(UIDynamicAnimator*)animator; -- (void)dynamicAnimatorDidPause:(UIDynamicAnimator*)animator; -@end - -@protocol OptionalPropertiesOnly -@optional -@property (strong, nonatomic) id OptionalProperty; -@end - -@protocol OptionalEvrything -@optional -- (void)dynamicAnimatorWillResume:(UIDynamicAnimator*)animator; -@property (strong, nonatomic) id OptionalProperty; -- (void)dynamicAnimatorDidPause:(UIDynamicAnimator*)animator; -@end - -@protocol UIApplicationDelegate -@end - -@interface Test7 : UIResponder <UIApplicationDelegate> -@property (strong, nonatomic) UIWindow *window; -@end - -@implementation Test7 -@end - -// rdar://15515206 -@interface BTLEBrowser -@end - -@protocol CBCentralManagerDelegate; - -@protocol CBCentralManagerDelegate -- (id) Meth1: (double) arg; -@end - -@interface BTLEBrowser() <CBCentralManagerDelegate> -@end - -@implementation BTLEBrowser -- (id) Meth15515206: (double) arg { return 0; } -@end diff --git a/test/ARCMT/objcmt-protocol-conformance.m.result b/test/ARCMT/objcmt-protocol-conformance.m.result deleted file mode 100644 index 0322ab81d6af..000000000000 --- a/test/ARCMT/objcmt-protocol-conformance.m.result +++ /dev/null @@ -1,130 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -objcmt-migrate-protocol-conformance -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11 -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -fobjc-runtime-has-weak -fobjc-arc %s.result - -@interface NSObject @end - -@protocol P -- (id) Meth1: (double) arg; -@end - -@interface Test1<P> // Test for no super class and no protocol list -@end - -@implementation Test1 -- (id) Meth1: (double) arg { return 0; } -@end - -@protocol P1 @end -@protocol P2 @end - -@interface Test2 <P1, P2, P> // Test for no super class and with protocol list -{ - id IVAR1; - id IVAR2; -} -@end - -@implementation Test2 -- (id) Meth1: (double) arg { return 0; } -@end - -@interface Test3 : NSObject<P> { // Test for Super class and no protocol list - id IV1; -} -@end - -@implementation Test3 -- (id) Meth1: (double) arg { return 0; } -@end - -@interface Test4 : NSObject <P1, P2, P> // Test for Super class and protocol list -@end - -@implementation Test4 -- (id) Meth1: (double) arg { return 0; } -@end - -// Test5 - conforms to P3 because it implement's P3's property. -@protocol P3 -@property (copy) id Prop; -@end - -@protocol P4 -@property (copy) id Prop; -@end - -@interface Test5 : NSObject<P3, P4> -@end - -@implementation Test5 -@synthesize Prop=_XXX; -@end - -@protocol P5 <P3, P4> -@property (copy) id Prop; -@end - -@protocol P6 <P3, P4, P5> -@property (copy) id Prop; -@end - -@interface Test6 : NSObject<P6> // Test for minimal listing of conforming protocols -@property (copy) id Prop; -@end - -@implementation Test6 -@end - -@class UIDynamicAnimator, UIWindow; -@interface UIResponder : NSObject -@end - -@protocol EmptyProtocol -@end - -@protocol OptionalMethodsOnly -@optional -- (void)dynamicAnimatorWillResume:(UIDynamicAnimator*)animator; -- (void)dynamicAnimatorDidPause:(UIDynamicAnimator*)animator; -@end - -@protocol OptionalPropertiesOnly -@optional -@property (strong, nonatomic) id OptionalProperty; -@end - -@protocol OptionalEvrything -@optional -- (void)dynamicAnimatorWillResume:(UIDynamicAnimator*)animator; -@property (strong, nonatomic) id OptionalProperty; -- (void)dynamicAnimatorDidPause:(UIDynamicAnimator*)animator; -@end - -@protocol UIApplicationDelegate -@end - -@interface Test7 : UIResponder <UIApplicationDelegate> -@property (strong, nonatomic) UIWindow *window; -@end - -@implementation Test7 -@end - -// rdar://15515206 -@interface BTLEBrowser -@end - -@protocol CBCentralManagerDelegate; - -@protocol CBCentralManagerDelegate -- (id) Meth1: (double) arg; -@end - -@interface BTLEBrowser() <CBCentralManagerDelegate> -@end - -@implementation BTLEBrowser -- (id) Meth15515206: (double) arg { return 0; } -@end diff --git a/test/ARCMT/objcmt-subscripting-literals-in-arc.m b/test/ARCMT/objcmt-subscripting-literals-in-arc.m deleted file mode 100644 index 1f56f4a2cf51..000000000000 --- a/test/ARCMT/objcmt-subscripting-literals-in-arc.m +++ /dev/null @@ -1,108 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -fobjc-arc -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c -triple x86_64-apple-darwin11 -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -fobjc-arc -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s.result - -typedef signed char BOOL; -#define nil ((void*) 0) - -typedef const struct __CFString * CFStringRef; - -@interface NSObject -+ (id)alloc; -@end - -@protocol NSCopying -@end - -@interface NSString : NSObject -+ (id)stringWithString:(NSString *)string; -- (id)initWithString:(NSString *)aString; -@end - -@interface NSArray : NSObject -- (id)objectAtIndex:(unsigned long)index; -@end - -@interface NSArray (NSExtendedArray) -- (id)objectAtIndexedSubscript:(unsigned)idx; -@end - -@interface NSArray (NSArrayCreation) -+ (id)array; -+ (id)arrayWithObject:(id)anObject; -+ (id)arrayWithObjects:(const id [])objects count:(unsigned long)cnt; -+ (id)arrayWithObjects:(id)firstObj, ...; -+ (id)arrayWithArray:(NSArray *)array; - -- (id)initWithObjects:(const id [])objects count:(unsigned long)cnt; -- (id)initWithObjects:(id)firstObj, ...; -- (id)initWithArray:(NSArray *)array; -@end - -@interface NSMutableArray : NSArray -- (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject; -@end - -@interface NSMutableArray (NSExtendedMutableArray) -- (void)setObject:(id)obj atIndexedSubscript:(unsigned)idx; -@end - -@interface NSDictionary : NSObject -- (id)objectForKey:(id)aKey; -@end - -@interface NSDictionary (NSExtendedDictionary) -- (id)objectForKeyedSubscript:(id)key; -@end - -@interface NSDictionary (NSDictionaryCreation) -+ (id)dictionary; -+ (id)dictionaryWithObject:(id)object forKey:(id)key; -+ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt; -+ (id)dictionaryWithObjectsAndKeys:(id)firstObject, ...; -+ (id)dictionaryWithDictionary:(NSDictionary *)dict; -+ (id)dictionaryWithObjects:(NSArray *)objects forKeys:(NSArray *)keys; - -- (id)initWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt; -- (id)initWithObjectsAndKeys:(id)firstObject, ...; -- (id)initWithDictionary:(NSDictionary *)otherDictionary; -- (id)initWithObjects:(NSArray *)objects forKeys:(NSArray *)keys; -@end - -@interface NSMutableDictionary : NSDictionary -- (void)setObject:(id)anObject forKey:(id)aKey; -@end - -@interface NSMutableDictionary (NSExtendedMutableDictionary) -- (void)setObject:(id)obj forKeyedSubscript:(id <NSCopying>)key; -@end - -@interface NSNumber : NSObject -@end - -@interface NSNumber (NSNumberCreation) -+ (NSNumber *)numberWithInt:(int)value; -- (id)initWithInt:(int)value; -@end - -@interface I { - NSArray *ivarArr; -} -@end -@implementation I --(void) foo { - NSString *str; - NSArray *arr; - NSDictionary *dict; - - arr = [NSArray arrayWithObjects:str, str, nil]; - arr = [[NSArray alloc] initWithObjects:str, str, nil]; - dict = [NSDictionary dictionaryWithObjectsAndKeys: @"value1", @"key1", @"value2", @"key2", nil]; - dict = [[NSDictionary alloc] initWithObjectsAndKeys: @"value1", @"key1", @"value2", @"key2", nil]; - - dict = [[NSDictionary alloc] initWithObjects:[[NSArray alloc] initWithObjects:@"1", @"2", nil] forKeys:[NSArray arrayWithObjects:@"A", @"B", nil]]; - - NSNumber *n = [[NSNumber alloc] initWithInt:2]; -} -@end diff --git a/test/ARCMT/objcmt-subscripting-literals-in-arc.m.result b/test/ARCMT/objcmt-subscripting-literals-in-arc.m.result deleted file mode 100644 index d974a2564d43..000000000000 --- a/test/ARCMT/objcmt-subscripting-literals-in-arc.m.result +++ /dev/null @@ -1,108 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -fobjc-arc -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c -triple x86_64-apple-darwin11 -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -fobjc-arc -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s.result - -typedef signed char BOOL; -#define nil ((void*) 0) - -typedef const struct __CFString * CFStringRef; - -@interface NSObject -+ (id)alloc; -@end - -@protocol NSCopying -@end - -@interface NSString : NSObject -+ (id)stringWithString:(NSString *)string; -- (id)initWithString:(NSString *)aString; -@end - -@interface NSArray : NSObject -- (id)objectAtIndex:(unsigned long)index; -@end - -@interface NSArray (NSExtendedArray) -- (id)objectAtIndexedSubscript:(unsigned)idx; -@end - -@interface NSArray (NSArrayCreation) -+ (id)array; -+ (id)arrayWithObject:(id)anObject; -+ (id)arrayWithObjects:(const id [])objects count:(unsigned long)cnt; -+ (id)arrayWithObjects:(id)firstObj, ...; -+ (id)arrayWithArray:(NSArray *)array; - -- (id)initWithObjects:(const id [])objects count:(unsigned long)cnt; -- (id)initWithObjects:(id)firstObj, ...; -- (id)initWithArray:(NSArray *)array; -@end - -@interface NSMutableArray : NSArray -- (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject; -@end - -@interface NSMutableArray (NSExtendedMutableArray) -- (void)setObject:(id)obj atIndexedSubscript:(unsigned)idx; -@end - -@interface NSDictionary : NSObject -- (id)objectForKey:(id)aKey; -@end - -@interface NSDictionary (NSExtendedDictionary) -- (id)objectForKeyedSubscript:(id)key; -@end - -@interface NSDictionary (NSDictionaryCreation) -+ (id)dictionary; -+ (id)dictionaryWithObject:(id)object forKey:(id)key; -+ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt; -+ (id)dictionaryWithObjectsAndKeys:(id)firstObject, ...; -+ (id)dictionaryWithDictionary:(NSDictionary *)dict; -+ (id)dictionaryWithObjects:(NSArray *)objects forKeys:(NSArray *)keys; - -- (id)initWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt; -- (id)initWithObjectsAndKeys:(id)firstObject, ...; -- (id)initWithDictionary:(NSDictionary *)otherDictionary; -- (id)initWithObjects:(NSArray *)objects forKeys:(NSArray *)keys; -@end - -@interface NSMutableDictionary : NSDictionary -- (void)setObject:(id)anObject forKey:(id)aKey; -@end - -@interface NSMutableDictionary (NSExtendedMutableDictionary) -- (void)setObject:(id)obj forKeyedSubscript:(id <NSCopying>)key; -@end - -@interface NSNumber : NSObject -@end - -@interface NSNumber (NSNumberCreation) -+ (NSNumber *)numberWithInt:(int)value; -- (id)initWithInt:(int)value; -@end - -@interface I { - NSArray *ivarArr; -} -@end -@implementation I --(void) foo { - NSString *str; - NSArray *arr; - NSDictionary *dict; - - arr = @[str, str]; - arr = @[str, str]; - dict = @{@"key1": @"value1", @"key2": @"value2"}; - dict = @{@"key1": @"value1", @"key2": @"value2"}; - - dict = @{@"A": @"1", @"B": @"2"}; - - NSNumber *n = @2; -} -@end diff --git a/test/ARCMT/objcmt-subscripting-literals.m b/test/ARCMT/objcmt-subscripting-literals.m deleted file mode 100644 index 0974c3b8bb0f..000000000000 --- a/test/ARCMT/objcmt-subscripting-literals.m +++ /dev/null @@ -1,230 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c -triple x86_64-apple-darwin11 -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s.result - -typedef signed char BOOL; -#define nil ((void*) 0) - -typedef const struct __CFString * CFStringRef; - -@interface NSObject -+ (id)alloc; -@end - -@protocol NSCopying -@end - -@interface NSString : NSObject -+ (id)stringWithString:(NSString *)string; -- (id)initWithString:(NSString *)aString; -@end - -@interface NSArray : NSObject -- (id)objectAtIndex:(unsigned long)index; -@end - -@interface NSArray (NSExtendedArray) -- (id)objectAtIndexedSubscript:(unsigned)idx; -@end - -@interface NSArray (NSArrayCreation) -+ (id)array; -+ (id)arrayWithObject:(id)anObject; -+ (id)arrayWithObjects:(const id [])objects count:(unsigned long)cnt; -+ (id)arrayWithObjects:(id)firstObj, ...; -+ (id)arrayWithArray:(NSArray *)array; - -- (id)initWithObjects:(const id [])objects count:(unsigned long)cnt; -- (id)initWithObjects:(id)firstObj, ...; -- (id)initWithArray:(NSArray *)array; -@end - -@interface NSMutableArray : NSArray -- (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject; -@end - -@interface NSMutableArray (NSExtendedMutableArray) -- (void)setObject:(id)obj atIndexedSubscript:(unsigned)idx; -@end - -@interface NSDictionary : NSObject -- (id)objectForKey:(id)aKey; -@end - -@interface NSDictionary (NSExtendedDictionary) -- (id)objectForKeyedSubscript:(id)key; -@end - -@interface NSDictionary (NSDictionaryCreation) -+ (id)dictionary; -+ (id)dictionaryWithObject:(id)object forKey:(id)key; -+ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt; -+ (id)dictionaryWithObjectsAndKeys:(id)firstObject, ...; -+ (id)dictionaryWithDictionary:(NSDictionary *)dict; -+ (id)dictionaryWithObjects:(NSArray *)objects forKeys:(NSArray *)keys; - -- (id)initWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt; -- (id)initWithObjectsAndKeys:(id)firstObject, ...; -- (id)initWithDictionary:(NSDictionary *)otherDictionary; -- (id)initWithObjects:(NSArray *)objects forKeys:(NSArray *)keys; -@end - -@interface NSMutableDictionary : NSDictionary -- (void)setObject:(id)anObject forKey:(id)aKey; -@end - -@interface NSMutableDictionary (NSExtendedMutableDictionary) -- (void)setObject:(id)obj forKeyedSubscript:(id <NSCopying>)key; -@end - -@interface NSNumber : NSObject -@end - -@interface NSNumber (NSNumberCreation) -+ (NSNumber *)numberWithInt:(int)value; -@end - -#define M(x) (x) -#define PAIR(x) @#x, [NSNumber numberWithInt:(x)] -#define TWO(x) ((x), (x)) -#define TWO_SEP(x,y) ((x), (y)) - -@interface I { - NSArray *ivarArr; -} -@end -@implementation I --(void) foo { - NSString *str; - NSArray *arr; - NSDictionary *dict; - - arr = [NSArray array]; - arr = [NSArray arrayWithObject:str]; - arr = [NSArray arrayWithObjects:str, str, nil]; - dict = [NSDictionary dictionary]; - dict = [NSDictionary dictionaryWithObject:arr forKey:str]; - dict = [NSDictionary dictionaryWithObjectsAndKeys: @"value1", @"key1", @"value2", @"key2", nil]; - dict = [NSDictionary dictionaryWithObjectsAndKeys: PAIR(1), PAIR(2), nil]; - dict = [NSDictionary dictionaryWithObjectsAndKeys: - @"value1", @"key1", -#ifdef BLAH - @"value2", @"key2", -#else - @"value3", @"key3", -#endif - nil ]; - - id o = [arr objectAtIndex:2]; - o = [dict objectForKey:@"key"]; - o = TWO([dict objectForKey:@"key"]); - o = TWO_SEP([dict objectForKey:@"key"], [arr objectAtIndex:2]); - o = [NSDictionary dictionaryWithObject:[NSDictionary dictionary] forKey:@"key"]; - NSMutableArray *marr = 0; - NSMutableDictionary *mdict = 0; - [marr replaceObjectAtIndex:2 withObject:@"val"]; - [mdict setObject:@"value" forKey:@"key"]; - [marr replaceObjectAtIndex:2 withObject:[arr objectAtIndex:4]]; - [mdict setObject:[dict objectForKey:@"key2"] forKey:@"key"]; - [mdict setObject:[dict objectForKey:@"key2"] forKey: -#if 1 - @"key1" -#else - @"key2" -#endif - ]; - [mdict setObject:[dict objectForKey: -#if 2 - @"key3" -#else - @"key4" -#endif - ] forKey:@"key"]; - [mdict setObject:@"value" forKey:[dict objectForKey: -#if 3 - @"key5" -#else - @"key6" -#endif - ] ]; - [mdict setObject:@"val" forKey:[dict objectForKey:@"key2"]]; - [mdict setObject:[dict objectForKey:@"key1"] forKey:[dict objectForKey:[NSArray arrayWithObject:@"arrkey"]]]; - __strong NSArray **parr = 0; - o = [*parr objectAtIndex:2]; - void *hd; - o = [(NSArray*)hd objectAtIndex:2]; - o = [ivarArr objectAtIndex:2]; - - dict = [NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@"1", [NSArray array], nil] forKeys:[NSArray arrayWithObjects:@"A", [arr objectAtIndex:2], nil]]; - dict = [NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@"1", @"2", nil] forKeys:arr]; - dict = [NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@"1", @"2", nil] forKeys:@[@"A", @"B"]]; - dict = [NSDictionary dictionaryWithObjectsAndKeys:[NSArray array], @"A", [NSArray array], @"B", nil]; -} -@end - -extern const CFStringRef globStr; - -void test1(NSString *str) { - NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys: str, globStr, nil]; - dict = [NSDictionary dictionaryWithObjectsAndKeys: globStr, str, nil]; - dict = [NSDictionary dictionaryWithObject:str forKey:globStr]; - dict = [NSDictionary dictionaryWithObject:globStr forKey:str]; - - NSArray *arr = [NSArray arrayWithObjects: globStr, globStr, nil]; - arr = [NSArray arrayWithObjects: str, globStr, nil]; - arr = [NSArray arrayWithObjects: globStr, str, nil]; - arr = [NSArray arrayWithObject:globStr]; -} - -@interface Custom : NSObject -- (id)objectAtIndex:(unsigned long)index; -@end - -@interface Custom (Extended) -- (id)objectAtIndexedSubscript:(unsigned)idx; -@end - -@interface MutableCustom : Custom -- (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject; -@end - -@interface MutableCustom (Extended) -- (void)setObject:(id)obj atIndexedSubscript:(unsigned)idx; -@end - -@interface CustomUnavail : NSObject -- (id)objectAtIndex:(unsigned long)index; -@end - -@interface CustomUnavail (Extended) -- (id)objectAtIndexedSubscript:(unsigned)idx __attribute__((unavailable)); -@end - -@interface MutableCustomUnavail : CustomUnavail -- (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject; -@end - -@interface MutableCustomUnavail (Extended) -- (void)setObject:(id)obj atIndexedSubscript:(unsigned)idx __attribute__((unavailable)); -@end - -void test2() { - MutableCustom *mutc; - id o = [mutc objectAtIndex:4]; - [mutc replaceObjectAtIndex:2 withObject:@"val"]; - - MutableCustomUnavail *mutcunaval; - o = [mutcunaval objectAtIndex:4]; - [mutcunaval replaceObjectAtIndex:2 withObject:@"val"]; -} - -@interface NSLocale : NSObject -+ (id)systemLocale; -+ (id)currentLocale; -- (id)objectForKey:(id)key; -@end - -void test3(id key) { - id o = [[NSLocale currentLocale] objectForKey:key]; -} diff --git a/test/ARCMT/objcmt-subscripting-literals.m.result b/test/ARCMT/objcmt-subscripting-literals.m.result deleted file mode 100644 index ed7879bb139e..000000000000 --- a/test/ARCMT/objcmt-subscripting-literals.m.result +++ /dev/null @@ -1,230 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c -triple x86_64-apple-darwin11 -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s.result - -typedef signed char BOOL; -#define nil ((void*) 0) - -typedef const struct __CFString * CFStringRef; - -@interface NSObject -+ (id)alloc; -@end - -@protocol NSCopying -@end - -@interface NSString : NSObject -+ (id)stringWithString:(NSString *)string; -- (id)initWithString:(NSString *)aString; -@end - -@interface NSArray : NSObject -- (id)objectAtIndex:(unsigned long)index; -@end - -@interface NSArray (NSExtendedArray) -- (id)objectAtIndexedSubscript:(unsigned)idx; -@end - -@interface NSArray (NSArrayCreation) -+ (id)array; -+ (id)arrayWithObject:(id)anObject; -+ (id)arrayWithObjects:(const id [])objects count:(unsigned long)cnt; -+ (id)arrayWithObjects:(id)firstObj, ...; -+ (id)arrayWithArray:(NSArray *)array; - -- (id)initWithObjects:(const id [])objects count:(unsigned long)cnt; -- (id)initWithObjects:(id)firstObj, ...; -- (id)initWithArray:(NSArray *)array; -@end - -@interface NSMutableArray : NSArray -- (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject; -@end - -@interface NSMutableArray (NSExtendedMutableArray) -- (void)setObject:(id)obj atIndexedSubscript:(unsigned)idx; -@end - -@interface NSDictionary : NSObject -- (id)objectForKey:(id)aKey; -@end - -@interface NSDictionary (NSExtendedDictionary) -- (id)objectForKeyedSubscript:(id)key; -@end - -@interface NSDictionary (NSDictionaryCreation) -+ (id)dictionary; -+ (id)dictionaryWithObject:(id)object forKey:(id)key; -+ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt; -+ (id)dictionaryWithObjectsAndKeys:(id)firstObject, ...; -+ (id)dictionaryWithDictionary:(NSDictionary *)dict; -+ (id)dictionaryWithObjects:(NSArray *)objects forKeys:(NSArray *)keys; - -- (id)initWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt; -- (id)initWithObjectsAndKeys:(id)firstObject, ...; -- (id)initWithDictionary:(NSDictionary *)otherDictionary; -- (id)initWithObjects:(NSArray *)objects forKeys:(NSArray *)keys; -@end - -@interface NSMutableDictionary : NSDictionary -- (void)setObject:(id)anObject forKey:(id)aKey; -@end - -@interface NSMutableDictionary (NSExtendedMutableDictionary) -- (void)setObject:(id)obj forKeyedSubscript:(id <NSCopying>)key; -@end - -@interface NSNumber : NSObject -@end - -@interface NSNumber (NSNumberCreation) -+ (NSNumber *)numberWithInt:(int)value; -@end - -#define M(x) (x) -#define PAIR(x) @#x, [NSNumber numberWithInt:(x)] -#define TWO(x) ((x), (x)) -#define TWO_SEP(x,y) ((x), (y)) - -@interface I { - NSArray *ivarArr; -} -@end -@implementation I --(void) foo { - NSString *str; - NSArray *arr; - NSDictionary *dict; - - arr = @[]; - arr = @[str]; - arr = @[str, str]; - dict = @{}; - dict = @{str: arr}; - dict = @{@"key1": @"value1", @"key2": @"value2"}; - dict = [NSDictionary dictionaryWithObjectsAndKeys: PAIR(1), PAIR(2), nil]; - dict = [NSDictionary dictionaryWithObjectsAndKeys: - @"value1", @"key1", -#ifdef BLAH - @"value2", @"key2", -#else - @"value3", @"key3", -#endif - nil ]; - - id o = arr[2]; - o = dict[@"key"]; - o = TWO(dict[@"key"]); - o = TWO_SEP(dict[@"key"], arr[2]); - o = @{@"key": @{}}; - NSMutableArray *marr = 0; - NSMutableDictionary *mdict = 0; - marr[2] = @"val"; - mdict[@"key"] = @"value"; - marr[2] = arr[4]; - mdict[@"key"] = dict[@"key2"]; - [mdict setObject:dict[@"key2"] forKey: -#if 1 - @"key1" -#else - @"key2" -#endif - ]; - mdict[@"key"] = [dict objectForKey: -#if 2 - @"key3" -#else - @"key4" -#endif - ]; - mdict[[dict objectForKey: -#if 3 - @"key5" -#else - @"key6" -#endif - ]] = @"value"; - mdict[dict[@"key2"]] = @"val"; - mdict[dict[@[@"arrkey"]]] = dict[@"key1"]; - __strong NSArray **parr = 0; - o = (*parr)[2]; - void *hd; - o = ((NSArray*)hd)[2]; - o = ivarArr[2]; - - dict = @{@"A": @"1", arr[2]: @[]}; - dict = [NSDictionary dictionaryWithObjects:@[@"1", @"2"] forKeys:arr]; - dict = @{@"A": @"1", @"B": @"2"}; - dict = @{@"A": @[], @"B": @[]}; -} -@end - -extern const CFStringRef globStr; - -void test1(NSString *str) { - NSDictionary *dict = @{(id)globStr: str}; - dict = @{str: (id)globStr}; - dict = @{(id)globStr: str}; - dict = @{str: (id)globStr}; - - NSArray *arr = @[(id)globStr, (id)globStr]; - arr = @[str, (id)globStr]; - arr = @[(id)globStr, str]; - arr = @[(id)globStr]; -} - -@interface Custom : NSObject -- (id)objectAtIndex:(unsigned long)index; -@end - -@interface Custom (Extended) -- (id)objectAtIndexedSubscript:(unsigned)idx; -@end - -@interface MutableCustom : Custom -- (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject; -@end - -@interface MutableCustom (Extended) -- (void)setObject:(id)obj atIndexedSubscript:(unsigned)idx; -@end - -@interface CustomUnavail : NSObject -- (id)objectAtIndex:(unsigned long)index; -@end - -@interface CustomUnavail (Extended) -- (id)objectAtIndexedSubscript:(unsigned)idx __attribute__((unavailable)); -@end - -@interface MutableCustomUnavail : CustomUnavail -- (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject; -@end - -@interface MutableCustomUnavail (Extended) -- (void)setObject:(id)obj atIndexedSubscript:(unsigned)idx __attribute__((unavailable)); -@end - -void test2() { - MutableCustom *mutc; - id o = mutc[4]; - mutc[2] = @"val"; - - MutableCustomUnavail *mutcunaval; - o = [mutcunaval objectAtIndex:4]; - [mutcunaval replaceObjectAtIndex:2 withObject:@"val"]; -} - -@interface NSLocale : NSObject -+ (id)systemLocale; -+ (id)currentLocale; -- (id)objectForKey:(id)key; -@end - -void test3(id key) { - id o = [[NSLocale currentLocale] objectForKey:key]; -} diff --git a/test/ARCMT/objcmt-subscripting-unavailable.m b/test/ARCMT/objcmt-subscripting-unavailable.m deleted file mode 100644 index d72c362e30f4..000000000000 --- a/test/ARCMT/objcmt-subscripting-unavailable.m +++ /dev/null @@ -1,79 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c -triple x86_64-apple-darwin11 -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s.result - -typedef signed char BOOL; -#define nil ((void*) 0) - -@interface NSObject -+ (id)alloc; -@end - -@interface NSArray : NSObject -- (id)objectAtIndex:(unsigned long)index; -@end - -@interface NSArray (NSArrayCreation) -+ (id)array; -+ (id)arrayWithObject:(id)anObject; -+ (id)arrayWithObjects:(const id [])objects count:(unsigned long)cnt; -+ (id)arrayWithObjects:(id)firstObj, ...; -+ (id)arrayWithArray:(NSArray *)array; - -- (id)initWithObjects:(const id [])objects count:(unsigned long)cnt; -- (id)initWithObjects:(id)firstObj, ...; -- (id)initWithArray:(NSArray *)array; -@end - -@interface NSMutableArray : NSArray -- (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject; -@end - -@interface NSDictionary : NSObject -@end - -@interface NSDictionary (NSDictionaryCreation) -+ (id)dictionary; -+ (id)dictionaryWithObject:(id)object forKey:(id)key; -+ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt; -+ (id)dictionaryWithObjectsAndKeys:(id)firstObject, ...; -+ (id)dictionaryWithDictionary:(NSDictionary *)dict; -+ (id)dictionaryWithObjects:(NSArray *)objects forKeys:(NSArray *)keys; - -- (id)initWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt; -- (id)initWithObjectsAndKeys:(id)firstObject, ...; -- (id)initWithDictionary:(NSDictionary *)otherDictionary; -- (id)initWithObjects:(NSArray *)objects forKeys:(NSArray *)keys; - -- (id)objectForKey:(id)aKey; -@end - -@interface NSMutableDictionary : NSDictionary -- (void)setObject:(id)anObject forKey:(id)aKey; -@end - -@interface I -@end -@implementation I --(void) foo { - id str; - NSArray *arr; - NSDictionary *dict; - - arr = [NSArray array]; - arr = [NSArray arrayWithObject:str]; - arr = [NSArray arrayWithObjects:str, str, nil]; - dict = [NSDictionary dictionary]; - dict = [NSDictionary dictionaryWithObject:arr forKey:str]; - - id o = [arr objectAtIndex:2]; - o = [dict objectForKey:@"key"]; - NSMutableArray *marr = 0; - NSMutableDictionary *mdict = 0; - [marr replaceObjectAtIndex:2 withObject:@"val"]; - [mdict setObject:@"value" forKey:@"key"]; - [marr replaceObjectAtIndex:2 withObject:[arr objectAtIndex:4]]; - [mdict setObject:[dict objectForKey:@"key2"] forKey:@"key"]; -} -@end diff --git a/test/ARCMT/objcmt-subscripting-unavailable.m.result b/test/ARCMT/objcmt-subscripting-unavailable.m.result deleted file mode 100644 index bd74d5583860..000000000000 --- a/test/ARCMT/objcmt-subscripting-unavailable.m.result +++ /dev/null @@ -1,79 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c -triple x86_64-apple-darwin11 -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s.result - -typedef signed char BOOL; -#define nil ((void*) 0) - -@interface NSObject -+ (id)alloc; -@end - -@interface NSArray : NSObject -- (id)objectAtIndex:(unsigned long)index; -@end - -@interface NSArray (NSArrayCreation) -+ (id)array; -+ (id)arrayWithObject:(id)anObject; -+ (id)arrayWithObjects:(const id [])objects count:(unsigned long)cnt; -+ (id)arrayWithObjects:(id)firstObj, ...; -+ (id)arrayWithArray:(NSArray *)array; - -- (id)initWithObjects:(const id [])objects count:(unsigned long)cnt; -- (id)initWithObjects:(id)firstObj, ...; -- (id)initWithArray:(NSArray *)array; -@end - -@interface NSMutableArray : NSArray -- (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject; -@end - -@interface NSDictionary : NSObject -@end - -@interface NSDictionary (NSDictionaryCreation) -+ (id)dictionary; -+ (id)dictionaryWithObject:(id)object forKey:(id)key; -+ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt; -+ (id)dictionaryWithObjectsAndKeys:(id)firstObject, ...; -+ (id)dictionaryWithDictionary:(NSDictionary *)dict; -+ (id)dictionaryWithObjects:(NSArray *)objects forKeys:(NSArray *)keys; - -- (id)initWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt; -- (id)initWithObjectsAndKeys:(id)firstObject, ...; -- (id)initWithDictionary:(NSDictionary *)otherDictionary; -- (id)initWithObjects:(NSArray *)objects forKeys:(NSArray *)keys; - -- (id)objectForKey:(id)aKey; -@end - -@interface NSMutableDictionary : NSDictionary -- (void)setObject:(id)anObject forKey:(id)aKey; -@end - -@interface I -@end -@implementation I --(void) foo { - id str; - NSArray *arr; - NSDictionary *dict; - - arr = @[]; - arr = @[str]; - arr = @[str, str]; - dict = @{}; - dict = @{str: arr}; - - id o = [arr objectAtIndex:2]; - o = [dict objectForKey:@"key"]; - NSMutableArray *marr = 0; - NSMutableDictionary *mdict = 0; - [marr replaceObjectAtIndex:2 withObject:@"val"]; - [mdict setObject:@"value" forKey:@"key"]; - [marr replaceObjectAtIndex:2 withObject:[arr objectAtIndex:4]]; - [mdict setObject:[dict objectForKey:@"key2"] forKey:@"key"]; -} -@end diff --git a/test/ARCMT/objcmt-undefined-ns-macros.m b/test/ARCMT/objcmt-undefined-ns-macros.m deleted file mode 100644 index 2e1fa51d04b8..000000000000 --- a/test/ARCMT/objcmt-undefined-ns-macros.m +++ /dev/null @@ -1,24 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -fmodules -objcmt-migrate-ns-macros -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11 -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result - -// rdar://18498550 - -typedef long NSInteger; -enum { - UIViewNone = 0x0, - UIViewMargin = 0x1, - UIViewWidth = 0x2, - UIViewRightMargin = 0x3, - UIViewBottomMargin = 0xbadbeef -}; -typedef NSInteger UITableStyle; - - -typedef - enum { two = 1 } NumericEnum2; - -typedef enum { three = 1 } NumericEnum3; - -typedef enum { four = 1 } NumericEnum4; - diff --git a/test/ARCMT/objcmt-undefined-ns-macros.m.result b/test/ARCMT/objcmt-undefined-ns-macros.m.result deleted file mode 100644 index 30277ac57d49..000000000000 --- a/test/ARCMT/objcmt-undefined-ns-macros.m.result +++ /dev/null @@ -1,26 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -fmodules -objcmt-migrate-ns-macros -mt-migrate-directory %t %s -x objective-c -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin11 -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result - -// rdar://18498550 - -typedef long NSInteger; -#ifndef NS_ENUM -@import Foundation; -#endif -typedef NS_OPTIONS(NSUInteger, UITableStyle) { - UIViewNone = 0x0, - UIViewMargin = 0x1, - UIViewWidth = 0x2, - UIViewRightMargin = 0x3, - UIViewBottomMargin = 0xbadbeef -}; - - -typedef - NS_ENUM(unsigned int, NumericEnum2) { two = 1 }; - -typedef NS_ENUM(unsigned int, NumericEnum3) { three = 1 }; - -typedef NS_ENUM(unsigned int, NumericEnum4) { four = 1 }; - diff --git a/test/ARCMT/objcmt-with-pch.m b/test/ARCMT/objcmt-with-pch.m deleted file mode 100644 index 61c87a2b007d..000000000000 --- a/test/ARCMT/objcmt-with-pch.m +++ /dev/null @@ -1,17 +0,0 @@ -// REQUIRES: x86-registered-target -// RUN: rm -rf %t -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -x objective-c %S/Common.h -emit-pch -o %t.pch -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c -include-pch %t.pch -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s.result -include-pch %t.pch - -@interface NSNumber : NSObject -@end - -@interface NSNumber (NSNumberCreation) -+ (NSNumber *)numberWithInt:(int)value; -@end - -void foo() { - NSNumber *n = [NSNumber numberWithInt:1]; -} diff --git a/test/ARCMT/objcmt-with-pch.m.result b/test/ARCMT/objcmt-with-pch.m.result deleted file mode 100644 index 7e2570cfc456..000000000000 --- a/test/ARCMT/objcmt-with-pch.m.result +++ /dev/null @@ -1,17 +0,0 @@ -// REQUIRES: x86-registered-target -// RUN: rm -rf %t -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -x objective-c %S/Common.h -emit-pch -o %t.pch -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c -include-pch %t.pch -// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s.result -include-pch %t.pch - -@interface NSNumber : NSObject -@end - -@interface NSNumber (NSNumberCreation) -+ (NSNumber *)numberWithInt:(int)value; -@end - -void foo() { - NSNumber *n = @1; -} diff --git a/test/ARCMT/protected-scope.m b/test/ARCMT/protected-scope.m deleted file mode 100644 index b522f54cdf7c..000000000000 --- a/test/ARCMT/protected-scope.m +++ /dev/null @@ -1,36 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t -// RUN: diff %t %s.result - -#include "Common.h" - -void test(id p, int x) { - int v; - switch(x) { - case 0: - v++; - id w1 = p; - id w2 = p; - break; - case 1: - v++; - id w3 = p; - break; - case 2: - case 3: - break; - default: - break; - } -} - -void test2(int p) { - switch (p) { - case 3:; - NSObject *o = [[NSObject alloc] init]; - [o release]; - break; - default: - break; - } -} diff --git a/test/ARCMT/protected-scope.m.result b/test/ARCMT/protected-scope.m.result deleted file mode 100644 index 55070f273227..000000000000 --- a/test/ARCMT/protected-scope.m.result +++ /dev/null @@ -1,38 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t -// RUN: diff %t %s.result - -#include "Common.h" - -void test(id p, int x) { - int v; - switch(x) { - case 0: { - v++; - id w1 = p; - id w2 = p; - break; - } - case 1: { - v++; - id w3 = p; - break; - } - case 2: - case 3: - break; - default: - break; - } -} - -void test2(int p) { - switch (p) { - case 3: {; - NSObject *o = [[NSObject alloc] init]; - break; - } - default: - break; - } -} diff --git a/test/ARCMT/releases-driver.m b/test/ARCMT/releases-driver.m deleted file mode 100644 index 3dd546fd6cd5..000000000000 --- a/test/ARCMT/releases-driver.m +++ /dev/null @@ -1,67 +0,0 @@ -// RUN: %clang_cc1 -fblocks -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: cat %s > %t -// RUN: %clang_cc1 -arcmt-modify -triple x86_64-apple-macosx10.6 -x objective-c %t -// RUN: diff %t %s.result -// RUN: rm %t - -typedef int BOOL; - -id IhaveSideEffect(); - -@protocol NSObject -- (BOOL)isEqual:(id)object; -- (id)retain; -- (oneway void)release; -@end - -@interface NSObject <NSObject> {} -@end - -@interface Foo : NSObject { - id bar; -} -@property (retain) id bar; --(void)test:(id)obj; -@end - -@implementation Foo - -@synthesize bar; - --(void)test:(id)obj { - id x = self.bar; - [x retain]; - self.bar = obj; - // do stuff with x; - [x release]; - - [IhaveSideEffect() release]; - - [x release], x = 0; -} - -@end - -void func(Foo *p) { - [p release]; - (([p release])); -} - -@interface Baz { - id <NSObject> _foo; -} -@end - -@implementation Baz -- (void) dealloc { - [_foo release]; -} -@end - -#define RELEASE_MACRO(x) [x release] -#define RELEASE_MACRO2(x) RELEASE_MACRO(x) - -void test2(id p) { - RELEASE_MACRO(p); - RELEASE_MACRO2(p); -} diff --git a/test/ARCMT/releases-driver.m.result b/test/ARCMT/releases-driver.m.result deleted file mode 100644 index e9aa2d5ac44e..000000000000 --- a/test/ARCMT/releases-driver.m.result +++ /dev/null @@ -1,58 +0,0 @@ -// RUN: %clang_cc1 -fblocks -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: cat %s > %t -// RUN: %clang_cc1 -arcmt-modify -triple x86_64-apple-macosx10.6 -x objective-c %t -// RUN: diff %t %s.result -// RUN: rm %t - -typedef int BOOL; - -id IhaveSideEffect(); - -@protocol NSObject -- (BOOL)isEqual:(id)object; -- (id)retain; -- (oneway void)release; -@end - -@interface NSObject <NSObject> {} -@end - -@interface Foo : NSObject { - id bar; -} -@property (strong) id bar; --(void)test:(id)obj; -@end - -@implementation Foo - -@synthesize bar; - --(void)test:(id)obj { - id x = self.bar; - self.bar = obj; - // do stuff with x; - - IhaveSideEffect(); - - x = 0; -} - -@end - -void func(Foo *p) { -} - -@interface Baz { - id <NSObject> _foo; -} -@end - -@implementation Baz -@end - -#define RELEASE_MACRO(x) [x release] -#define RELEASE_MACRO2(x) RELEASE_MACRO(x) - -void test2(id p) { -} diff --git a/test/ARCMT/releases.m b/test/ARCMT/releases.m deleted file mode 100644 index 55008959efc4..000000000000 --- a/test/ARCMT/releases.m +++ /dev/null @@ -1,98 +0,0 @@ -// RUN: %clang_cc1 -fobjc-exceptions -fblocks -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fobjc-exceptions -fblocks -fsyntax-only -x objective-c %s > %t -// RUN: diff %t %s.result - -#define nil 0 - -typedef int BOOL; - -id IhaveSideEffect(); - -@protocol NSObject -- (BOOL)isEqual:(id)object; -- (id)retain; -- (oneway void)release; -@end - -@interface NSObject <NSObject> {} -@end - -@interface Foo : NSObject { - id bar; -} -@property (retain) id bar; --(void)test:(id)obj; -@end - -@implementation Foo - -@synthesize bar; - --(void)test:(id)obj { - id x = self.bar; - [x retain]; - self.bar = obj; - // do stuff with x; - [x release]; - - [IhaveSideEffect() release]; - - [x release], x = 0; - - @try { - } @finally { - [x release]; - } -} - -@end - -void func(Foo *p) { - [p release]; - (([p release])); -} - -@interface Baz { - id <NSObject> _foo; -} -@end - -@implementation Baz -- (void) dealloc { - [_foo release]; -} -@end - -void block_test(Foo *p) { - id (^B)() = ^() { - if (p) { - id (^IB)() = ^() { - id bar = [p retain]; - [p release]; - return bar; - }; - IB(); - } - return [p retain]; - }; -} - -#define RELEASE_MACRO(x) [x release] -#define RELEASE_MACRO2(x) RELEASE_MACRO(x) - -void test2(id p) { - RELEASE_MACRO(p); - RELEASE_MACRO2(p); -} - -@implementation Foo2 - -static id internal_var = 0; - -+ (void)setIt:(id)newone { - if (internal_var != newone) { - [internal_var release]; - internal_var = [newone retain]; - } -} -@end diff --git a/test/ARCMT/releases.m.result b/test/ARCMT/releases.m.result deleted file mode 100644 index 473750e4e899..000000000000 --- a/test/ARCMT/releases.m.result +++ /dev/null @@ -1,87 +0,0 @@ -// RUN: %clang_cc1 -fobjc-exceptions -fblocks -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fobjc-exceptions -fblocks -fsyntax-only -x objective-c %s > %t -// RUN: diff %t %s.result - -#define nil 0 - -typedef int BOOL; - -id IhaveSideEffect(); - -@protocol NSObject -- (BOOL)isEqual:(id)object; -- (id)retain; -- (oneway void)release; -@end - -@interface NSObject <NSObject> {} -@end - -@interface Foo : NSObject { - id bar; -} -@property (strong) id bar; --(void)test:(id)obj; -@end - -@implementation Foo - -@synthesize bar; - --(void)test:(id)obj { - id x = self.bar; - self.bar = obj; - // do stuff with x; - - IhaveSideEffect(); - - x = 0; - - @try { - } @finally { - x = nil; - } -} - -@end - -void func(Foo *p) { -} - -@interface Baz { - id <NSObject> _foo; -} -@end - -@implementation Baz -@end - -void block_test(Foo *p) { - id (^B)() = ^() { - if (p) { - id (^IB)() = ^() { - id bar = p; - return bar; - }; - IB(); - } - return p; - }; -} - -#define RELEASE_MACRO(x) [x release] -#define RELEASE_MACRO2(x) RELEASE_MACRO(x) - -void test2(id p) { -} - -@implementation Foo2 - -static id internal_var = 0; - -+ (void)setIt:(id)newone { - if (internal_var != newone) { - internal_var = newone; - } -} -@end diff --git a/test/ARCMT/remap-applying.c b/test/ARCMT/remap-applying.c deleted file mode 100644 index dee2e391d5bd..000000000000 --- a/test/ARCMT/remap-applying.c +++ /dev/null @@ -1,4 +0,0 @@ -a bc - -// RUN: echo "[{\"file\": \"%/s\", \"offset\": 1, \"remove\": 2, }]" > %t.remap -// RUN: c-arcmt-test %t.remap | arcmt-test -verify-transformed-files %s.result diff --git a/test/ARCMT/remap-applying.c.result b/test/ARCMT/remap-applying.c.result deleted file mode 100644 index 514e9c264915..000000000000 --- a/test/ARCMT/remap-applying.c.result +++ /dev/null @@ -1,4 +0,0 @@ -ac - -// RUN: echo "[{\"file\": \"%/s\", \"offset\": 1, \"remove\": 2, }]" > %t.remap -// RUN: c-arcmt-test %t.remap | arcmt-test -verify-transformed-files %s.result diff --git a/test/ARCMT/remove-dealloc-method.m b/test/ARCMT/remove-dealloc-method.m deleted file mode 100644 index 8e39fc874c95..000000000000 --- a/test/ARCMT/remove-dealloc-method.m +++ /dev/null @@ -1,26 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t -// RUN: diff %t %s.result - -#define nil ((void*) 0) - -@interface Foo -@property (retain) id x; -@property (retain) id y; -@property (retain) id w; -@property (retain) id z; -@end - -@implementation Foo -@synthesize x; -@synthesize y; -@synthesize w; -@synthesize z; - -- (void) dealloc { - self.x = 0; - [self setY:nil]; - w = nil; - self.z = nil; -} -@end diff --git a/test/ARCMT/remove-dealloc-method.m.result b/test/ARCMT/remove-dealloc-method.m.result deleted file mode 100644 index 47e31f9d249a..000000000000 --- a/test/ARCMT/remove-dealloc-method.m.result +++ /dev/null @@ -1,20 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t -// RUN: diff %t %s.result - -#define nil ((void*) 0) - -@interface Foo -@property (strong) id x; -@property (strong) id y; -@property (strong) id w; -@property (strong) id z; -@end - -@implementation Foo -@synthesize x; -@synthesize y; -@synthesize w; -@synthesize z; - -@end diff --git a/test/ARCMT/remove-dealloc-zerouts.m b/test/ARCMT/remove-dealloc-zerouts.m deleted file mode 100644 index 4176ec580c3e..000000000000 --- a/test/ARCMT/remove-dealloc-zerouts.m +++ /dev/null @@ -1,44 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t -// RUN: diff %t %s.result - -@interface Foo -@property (retain) id x; -@property (retain) id y; -@property (retain) id w; -@property (retain) id z; -@property (strong) id q; -@end - -@implementation Foo -@synthesize x; -@synthesize y; -@synthesize w; -@synthesize q; -@dynamic z; - -- (void) dealloc { - self.x = self.y = self.w = 0; - self.x = 0, w = 0, y = 0; - [self setY:0]; - w = 0; - q = 0; - self.z = 0; -} -@end - -@interface Bar -@property (retain) Foo *a; -- (void) setA:(Foo*) val; -- (id) a; -@end - -@implementation Bar -- (void) dealloc { - [self setA:0]; // This is user-defined setter overriding synthesize, don't touch it. - self.a.x = 0; // every dealloc must zero out its own ivar. This patter is not recognized. -} -@synthesize a; -- (void) setA:(Foo*) val { } -- (id) a {return 0;} -@end diff --git a/test/ARCMT/remove-dealloc-zerouts.m.result b/test/ARCMT/remove-dealloc-zerouts.m.result deleted file mode 100644 index 9ae831abacf2..000000000000 --- a/test/ARCMT/remove-dealloc-zerouts.m.result +++ /dev/null @@ -1,39 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t -// RUN: diff %t %s.result - -@interface Foo -@property (strong) id x; -@property (strong) id y; -@property (strong) id w; -@property (strong) id z; -@property (strong) id q; -@end - -@implementation Foo -@synthesize x; -@synthesize y; -@synthesize w; -@synthesize q; -@dynamic z; - -- (void) dealloc { - self.z = 0; -} -@end - -@interface Bar -@property (strong) Foo *a; -- (void) setA:(Foo*) val; -- (id) a; -@end - -@implementation Bar -- (void) dealloc { - [self setA:0]; // This is user-defined setter overriding synthesize, don't touch it. - self.a.x = 0; // every dealloc must zero out its own ivar. This patter is not recognized. -} -@synthesize a; -- (void) setA:(Foo*) val { } -- (id) a {return 0;} -@end diff --git a/test/ARCMT/remove-statements.m b/test/ARCMT/remove-statements.m deleted file mode 100644 index 286a8e715e0d..000000000000 --- a/test/ARCMT/remove-statements.m +++ /dev/null @@ -1,45 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t -// RUN: diff %t %s.result - -#include "Common.h" - -@interface myController : NSObject --(id)test:(id)x; -@end - -#define MY_MACRO1(x) -#define MY_MACRO2(x) (void)x - -@implementation myController --(id) test:(id) x { - [[x retain] release]; - return [[x retain] autorelease]; -} - --(void)dealloc -{ - id array, array_already_empty; - for (id element in array_already_empty) { - } - - [array release]; - ; - - int b, b_array_already_empty; - if (b) - [array release]; - if (b_array_already_empty) ; - - if (b) { - [array release]; - } - if (b_array_already_empty) { - } - - if (b) - MY_MACRO1(array); - if (b) - MY_MACRO2(array); -} -@end diff --git a/test/ARCMT/remove-statements.m.result b/test/ARCMT/remove-statements.m.result deleted file mode 100644 index 6a4ea08b8c95..000000000000 --- a/test/ARCMT/remove-statements.m.result +++ /dev/null @@ -1,38 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t -// RUN: diff %t %s.result - -#include "Common.h" - -@interface myController : NSObject --(id)test:(id)x; -@end - -#define MY_MACRO1(x) -#define MY_MACRO2(x) (void)x - -@implementation myController --(id) test:(id) x { - return x; -} - --(void)dealloc -{ - id array, array_already_empty; - for (id element in array_already_empty) { - } - - ; - - int b, b_array_already_empty; - if (b_array_already_empty) ; - - if (b_array_already_empty) { - } - - if (b) - MY_MACRO1(array); - if (b) - MY_MACRO2(array); -} -@end diff --git a/test/ARCMT/retains.m b/test/ARCMT/retains.m deleted file mode 100644 index 60283a695ff4..000000000000 --- a/test/ARCMT/retains.m +++ /dev/null @@ -1,71 +0,0 @@ -// RUN: %clang_cc1 -fblocks -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fblocks -fsyntax-only -x objective-c %s > %t -// RUN: diff %t %s.result - -#include "Common.h" - -id IhaveSideEffect(); - -@interface Foo : NSObject { - id bar; -} -@property (retain) id bar; --(id)test:(id)obj; --(id)something; -@end - -#define Something_Macro(key, comment) \ - [[Foo new] something] - -@implementation Foo - -@synthesize bar; - --(id)something {} - --(id)test:(id)obj { - id x = self.bar; - [x retain]; - self.bar = obj; - if (obj) - [obj retain]; - - [Something_Macro(@"foo", "@bar") retain]; - - [IhaveSideEffect() retain]; - - [[self something] retain]; - - [[self retain] something]; - - [[IhaveSideEffect() retain] release]; - [[x retain] release]; - // do stuff with x; - [x release]; - return [self retain]; -} - -- (id)test1 { - id x=0; - ([x retain]); - return ((([x retain]))); -} -@end - -id foo (Foo *p) { - p = [p retain]; - return ([p retain]); -} - -void block_tests(Foo *p) { - id (^B)() = ^() { - if (p) { - id (^IB)() = ^() { - id bar = [p retain]; - return bar; - }; - IB(); - } - return [p retain]; - }; -} diff --git a/test/ARCMT/retains.m.result b/test/ARCMT/retains.m.result deleted file mode 100644 index 2011e506360c..000000000000 --- a/test/ARCMT/retains.m.result +++ /dev/null @@ -1,65 +0,0 @@ -// RUN: %clang_cc1 -fblocks -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fblocks -fsyntax-only -x objective-c %s > %t -// RUN: diff %t %s.result - -#include "Common.h" - -id IhaveSideEffect(); - -@interface Foo : NSObject { - id bar; -} -@property (strong) id bar; --(id)test:(id)obj; --(id)something; -@end - -#define Something_Macro(key, comment) \ - [[Foo new] something] - -@implementation Foo - -@synthesize bar; - --(id)something {} - --(id)test:(id)obj { - id x = self.bar; - self.bar = obj; - - Something_Macro(@"foo", "@bar"); - - IhaveSideEffect(); - - [self something]; - - [self something]; - - IhaveSideEffect(); - // do stuff with x; - return self; -} - -- (id)test1 { - id x=0; - return (((x))); -} -@end - -id foo (Foo *p) { - p = p; - return (p); -} - -void block_tests(Foo *p) { - id (^B)() = ^() { - if (p) { - id (^IB)() = ^() { - id bar = p; - return bar; - }; - IB(); - } - return p; - }; -} diff --git a/test/ARCMT/rewrite-block-var.m b/test/ARCMT/rewrite-block-var.m deleted file mode 100644 index 538f16c25574..000000000000 --- a/test/ARCMT/rewrite-block-var.m +++ /dev/null @@ -1,45 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fblocks -fsyntax-only -fobjc-arc -x objective-c -fobjc-runtime-has-weak %s.result -// RUN: arcmt-test --args -triple x86_64-apple-macosx10.7 -fblocks -fsyntax-only %s > %t -// RUN: diff %t %s.result - -#include "Common.h" - -@interface Foo : NSObject --(Foo *)something; -@end - -void bar(void (^block)()); - -void test1(Foo *p) { - __block Foo *x = p; // __block used just to break cycle. - bar(^{ - [x something]; - }); -} - -void test2(Foo *p) { - __block Foo *x; // __block used as output variable. - bar(^{ - x = [p something]; - }); -} - -void test3(Foo *p) { - __block Foo *x; // __block used as output variable. - bar(^{ - [x something]; - }); - bar(^{ - x = 0; - }); -} - -void test4(Foo *p) { - __block Foo *x = p; // __block used just to break cycle. - bar(^{ - [x something]; - }); - bar(^{ - [x something]; - }); -} diff --git a/test/ARCMT/rewrite-block-var.m.result b/test/ARCMT/rewrite-block-var.m.result deleted file mode 100644 index a9d0b0f7fad8..000000000000 --- a/test/ARCMT/rewrite-block-var.m.result +++ /dev/null @@ -1,45 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fblocks -fsyntax-only -fobjc-arc -x objective-c -fobjc-runtime-has-weak %s.result -// RUN: arcmt-test --args -triple x86_64-apple-macosx10.7 -fblocks -fsyntax-only %s > %t -// RUN: diff %t %s.result - -#include "Common.h" - -@interface Foo : NSObject --(Foo *)something; -@end - -void bar(void (^block)()); - -void test1(Foo *p) { - __weak Foo *x = p; // __block used just to break cycle. - bar(^{ - [x something]; - }); -} - -void test2(Foo *p) { - __block Foo *x; // __block used as output variable. - bar(^{ - x = [p something]; - }); -} - -void test3(Foo *p) { - __block Foo *x; // __block used as output variable. - bar(^{ - [x something]; - }); - bar(^{ - x = 0; - }); -} - -void test4(Foo *p) { - __weak Foo *x = p; // __block used just to break cycle. - bar(^{ - [x something]; - }); - bar(^{ - [x something]; - }); -} diff --git a/test/ARCMT/safe-arc-assign.m b/test/ARCMT/safe-arc-assign.m deleted file mode 100644 index 4a0a575794e1..000000000000 --- a/test/ARCMT/safe-arc-assign.m +++ /dev/null @@ -1,14 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t -// RUN: diff %t %s.result - -void test12(id collection) { - for (id x in collection) { - x = 0; - x = 0; - } - - for (__strong id x in collection) { - x = 0; - } -} diff --git a/test/ARCMT/safe-arc-assign.m.result b/test/ARCMT/safe-arc-assign.m.result deleted file mode 100644 index c25955ea7d1c..000000000000 --- a/test/ARCMT/safe-arc-assign.m.result +++ /dev/null @@ -1,14 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s > %t -// RUN: diff %t %s.result - -void test12(id collection) { - for (__strong id x in collection) { - x = 0; - x = 0; - } - - for (__strong id x in collection) { - x = 0; - } -} diff --git a/test/ARCMT/verify.m b/test/ARCMT/verify.m deleted file mode 100644 index 02f7fccc6899..000000000000 --- a/test/ARCMT/verify.m +++ /dev/null @@ -1,14 +0,0 @@ -// RUN: %clang_cc1 -arcmt-check -verify %s -// RUN: not %clang_cc1 -arcmt-check -verify %t.invalid 2>&1 | FileCheck %s - -#if 0 -// expected-error {{should be ignored}} -#endif - -#error should not be ignored -// expected-error@-1 {{should not be ignored}} - -// CHECK: error: no expected directives found: consider use of 'expected-no-diagnostics' -// CHECK-NEXT: error: 'error' diagnostics seen but not expected: -// CHECK-NEXT: (frontend): error reading '{{.*}}verify.m.tmp.invalid' -// CHECK-NEXT: 2 errors generated. diff --git a/test/ARCMT/whitelisted/Inputs/header1.h b/test/ARCMT/whitelisted/Inputs/header1.h deleted file mode 100644 index 44430f3b77e3..000000000000 --- a/test/ARCMT/whitelisted/Inputs/header1.h +++ /dev/null @@ -1 +0,0 @@ -// the contents are not important diff --git a/test/ARCMT/whitelisted/header1.h b/test/ARCMT/whitelisted/header1.h deleted file mode 100644 index 33f77aa5dd15..000000000000 --- a/test/ARCMT/whitelisted/header1.h +++ /dev/null @@ -1,8 +0,0 @@ - -@interface I1 : NSObject --(int)prop; --(void)setProp:(int)p; -+(id)i1; -@end - -typedef long NSInteger; diff --git a/test/ARCMT/whitelisted/header1.h.result b/test/ARCMT/whitelisted/header1.h.result deleted file mode 100644 index c7cf109a27e9..000000000000 --- a/test/ARCMT/whitelisted/header1.h.result +++ /dev/null @@ -1,7 +0,0 @@ - -@interface I1 : NSObject -@property (nonatomic) int prop; -+(instancetype)i1; -@end - -typedef long NSInteger; diff --git a/test/ARCMT/whitelisted/header2.h b/test/ARCMT/whitelisted/header2.h deleted file mode 100644 index ac3888ccdf8c..000000000000 --- a/test/ARCMT/whitelisted/header2.h +++ /dev/null @@ -1,8 +0,0 @@ - -#define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type -typedef enum : NSInteger {five} ApplicableEnum; - -@interface I2 : NSObject --(int)prop; --(void)setProp:(int)p; -@end diff --git a/test/ARCMT/whitelisted/header2.h.result b/test/ARCMT/whitelisted/header2.h.result deleted file mode 100644 index 3226e711b98a..000000000000 --- a/test/ARCMT/whitelisted/header2.h.result +++ /dev/null @@ -1,7 +0,0 @@ - -#define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type -typedef NS_ENUM(NSInteger, ApplicableEnum) {five}; - -@interface I2 : NSObject -@property (nonatomic) int prop; -@end diff --git a/test/ARCMT/whitelisted/objcmt-with-whitelist-impl.m b/test/ARCMT/whitelisted/objcmt-with-whitelist-impl.m deleted file mode 100644 index d734eaa10bdf..000000000000 --- a/test/ARCMT/whitelisted/objcmt-with-whitelist-impl.m +++ /dev/null @@ -1,18 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -objcmt-migrate-readwrite-property -objcmt-migrate-instancetype -objcmt-white-list-dir-path=%S/Inputs %s -triple x86_64-apple-darwin11 -migrate -o %t.remap -// RUN: c-arcmt-test %t.remap | arcmt-test -verify-transformed-files %S/header1.h.result %s.result - -@interface NSObject -+ (id)alloc; -@end - -#include "header1.h" -#include "header2.h" - -@interface I2(cat) --(id)initInCat; -@end - -@implementation I1 -+(id)i1 {} -@end diff --git a/test/ARCMT/whitelisted/objcmt-with-whitelist-impl.m.result b/test/ARCMT/whitelisted/objcmt-with-whitelist-impl.m.result deleted file mode 100644 index b936b52b729b..000000000000 --- a/test/ARCMT/whitelisted/objcmt-with-whitelist-impl.m.result +++ /dev/null @@ -1,18 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -objcmt-migrate-readwrite-property -objcmt-migrate-instancetype -objcmt-white-list-dir-path=%S/Inputs %s -triple x86_64-apple-darwin11 -migrate -o %t.remap -// RUN: c-arcmt-test %t.remap | arcmt-test -verify-transformed-files %S/header1.h.result %s.result - -@interface NSObject -+ (id)alloc; -@end - -#include "header1.h" -#include "header2.h" - -@interface I2(cat) --(id)initInCat; -@end - -@implementation I1 -+(instancetype)i1 {} -@end diff --git a/test/ARCMT/whitelisted/objcmt-with-whitelist.m b/test/ARCMT/whitelisted/objcmt-with-whitelist.m deleted file mode 100644 index 0ea714fe5937..000000000000 --- a/test/ARCMT/whitelisted/objcmt-with-whitelist.m +++ /dev/null @@ -1,12 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -objcmt-migrate-readwrite-property -objcmt-migrate-instancetype -objcmt-migrate-ns-macros %s -triple x86_64-apple-darwin11 -migrate -o %t.remap -// RUN: c-arcmt-test %t.remap | arcmt-test -verify-transformed-files %S/header1.h.result %S/header2.h.result -// RUN: %clang_cc1 -objcmt-migrate-readwrite-property -objcmt-migrate-instancetype -objcmt-migrate-ns-macros -objcmt-white-list-dir-path=%S/Inputs %s -triple x86_64-apple-darwin11 -migrate -o %t.remap -// RUN: c-arcmt-test %t.remap | arcmt-test -verify-transformed-files %S/header1.h.result - -@interface NSObject -+ (id)alloc; -@end - -#include "header1.h" -#include "header2.h" diff --git a/test/ARCMT/with-arc-mode-modify.m b/test/ARCMT/with-arc-mode-modify.m deleted file mode 100644 index bc4662de23e8..000000000000 --- a/test/ARCMT/with-arc-mode-modify.m +++ /dev/null @@ -1,13 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: cat %s > %t -// RUN: %clang_cc1 -arcmt-modify -fsyntax-only -fobjc-arc -x objective-c %t -// RUN: diff %t %s.result -// RUN: rm %t - -@protocol NSObject -- (oneway void)release; -@end - -void test1(id p) { - [p release]; -} diff --git a/test/ARCMT/with-arc-mode-modify.m.result b/test/ARCMT/with-arc-mode-modify.m.result deleted file mode 100644 index b847c13f6b4c..000000000000 --- a/test/ARCMT/with-arc-mode-modify.m.result +++ /dev/null @@ -1,12 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: cat %s > %t -// RUN: %clang_cc1 -arcmt-modify -fsyntax-only -fobjc-arc -x objective-c %t -// RUN: diff %t %s.result -// RUN: rm %t - -@protocol NSObject -- (oneway void)release; -@end - -void test1(id p) { -} |