diff options
Diffstat (limited to 'test/ARCMT')
51 files changed, 2174 insertions, 31 deletions
diff --git a/test/ARCMT/Common.h b/test/ARCMT/Common.h index 2603730cad9d..16856ed1b444 100644 --- a/test/ARCMT/Common.h +++ b/test/ARCMT/Common.h @@ -4,8 +4,10 @@ #define NS_AUTOMATED_REFCOUNT_UNAVAILABLE #endif +#define NS_RETURNS_RETAINED __attribute__((ns_returns_retained)) #define CF_CONSUMED __attribute__((cf_consumed)) +#define NS_INLINE static __inline__ __attribute__((always_inline)) #define nil ((void*) 0) typedef int BOOL; @@ -19,6 +21,9 @@ typedef struct _NSZone NSZone; typedef const void * CFTypeRef; CFTypeRef CFRetain(CFTypeRef cf); +id CFBridgingRelease(CFTypeRef CF_CONSUMED X); + +NS_INLINE NS_RETURNS_RETAINED id NSMakeCollectable(CFTypeRef CF_CONSUMED cf) NS_AUTOMATED_REFCOUNT_UNAVAILABLE; @protocol NSObject - (BOOL)isEqual:(id)object; diff --git a/test/ARCMT/GC-check-warn-nsalloc.m b/test/ARCMT/GC-check-warn-nsalloc.m new file mode 100644 index 000000000000..5ce36c40d659 --- /dev/null +++ b/test/ARCMT/GC-check-warn-nsalloc.m @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -arcmt-check -verify -no-ns-alloc-error -triple x86_64-apple-darwin10 -fobjc-gc-only %s +// RUN: %clang_cc1 -arcmt-check -verify -no-ns-alloc-error -triple x86_64-apple-darwin10 -fobjc-gc-only -x objective-c++ %s +// DISABLE: mingw32 +// rdar://10532541 +// XFAIL: * + +typedef unsigned NSUInteger; +void *__strong NSAllocateCollectable(NSUInteger size, NSUInteger options); + +void test1() { + NSAllocateCollectable(100, 0); // expected-warning {{call returns pointer to GC managed memory; it will become unmanaged in ARC}} +} diff --git a/test/ARCMT/GC-check.m b/test/ARCMT/GC-check.m new file mode 100644 index 000000000000..3a1b67ce2183 --- /dev/null +++ b/test/ARCMT/GC-check.m @@ -0,0 +1,20 @@ +// 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 +// DISABLE: mingw32 + +#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 new file mode 100644 index 000000000000..f0699927eda5 --- /dev/null +++ b/test/ARCMT/GC-no-arc-runtime.m @@ -0,0 +1,78 @@ +// 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 +// DISABLE: mingw32 + +#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 new file mode 100644 index 000000000000..f55ca38070e9 --- /dev/null +++ b/test/ARCMT/GC-no-arc-runtime.m.result @@ -0,0 +1,73 @@ +// 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 +// DISABLE: mingw32 + +#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 new file mode 100644 index 000000000000..14e8602446c3 --- /dev/null +++ b/test/ARCMT/GC-no-finalize-removal.m @@ -0,0 +1,90 @@ +// 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 +// DISABLE: mingw32 + +#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 new file mode 100644 index 000000000000..ea14873ec353 --- /dev/null +++ b/test/ARCMT/GC-no-finalize-removal.m.result @@ -0,0 +1,98 @@ +// 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 +// DISABLE: mingw32 + +#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 new file mode 100644 index 000000000000..4301baf27246 --- /dev/null +++ b/test/ARCMT/GC.h @@ -0,0 +1,6 @@ + +@interface ExtInterface { + __strong ExtInterface *myivar; + __strong void *gcVar; +} +@end diff --git a/test/ARCMT/GC.m b/test/ARCMT/GC.m new file mode 100644 index 000000000000..eebbaf6854d9 --- /dev/null +++ b/test/ARCMT/GC.m @@ -0,0 +1,95 @@ +// 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 +// DISABLE: mingw32 + +#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 new file mode 100644 index 000000000000..c2c523f77e99 --- /dev/null +++ b/test/ARCMT/GC.m.result @@ -0,0 +1,90 @@ +// 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 +// DISABLE: mingw32 + +#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/api.m b/test/ARCMT/api.m index b186ec724745..ba122c42bff3 100644 --- a/test/ARCMT/api.m +++ b/test/ARCMT/api.m @@ -1,6 +1,7 @@ // 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 +// DISABLE: mingw32 #include "Common.h" diff --git a/test/ARCMT/api.m.result b/test/ARCMT/api.m.result index e3093751b626..7e04e7dc0c88 100644 --- a/test/ARCMT/api.m.result +++ b/test/ARCMT/api.m.result @@ -1,6 +1,7 @@ // 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 +// DISABLE: mingw32 #include "Common.h" diff --git a/test/ARCMT/assign-prop-with-arc-runtime.m b/test/ARCMT/assign-prop-with-arc-runtime.m index 9e10b58f621f..c357eeb17177 100644 --- a/test/ARCMT/assign-prop-with-arc-runtime.m +++ b/test/ARCMT/assign-prop-with-arc-runtime.m @@ -1,6 +1,7 @@ // 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 +// DISABLE: mingw32 #include "Common.h" @@ -36,12 +37,18 @@ typedef _NSCachedAttributedString *BadClassForWeak; @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]; @@ -49,3 +56,18 @@ typedef _NSCachedAttributedString *BadClassForWeak; 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 index 8a3a0f78b6b6..a255a36f2494 100644 --- a/test/ARCMT/assign-prop-with-arc-runtime.m.result +++ b/test/ARCMT/assign-prop-with-arc-runtime.m.result @@ -1,6 +1,7 @@ // 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 +// DISABLE: mingw32 #include "Common.h" @@ -22,7 +23,7 @@ typedef _NSCachedAttributedString *BadClassForWeak; Forw *__unsafe_unretained not_safe3; Foo *assign_plus1; } -@property (readonly) Foo *x; +@property (weak, readonly) Foo *x; @property (weak) Foo *w; @property (weak) Foo *q1, *q2; @property (unsafe_unretained) WeakOptOut *oo; @@ -31,17 +32,23 @@ typedef _NSCachedAttributedString *BadClassForWeak; @property (unsafe_unretained) NSObject *not_safe2; @property (unsafe_unretained) Forw *not_safe3; @property (readonly) Foo *assign_plus1; -@property (strong, readonly) Foo *assign_plus2; -@property (strong, readonly) Foo *assign_plus3; +@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]; @@ -49,3 +56,18 @@ typedef _NSCachedAttributedString *BadClassForWeak; 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 index b9bc10655325..5c2cd6b922fd 100644 --- a/test/ARCMT/atautorelease-2.m +++ b/test/ARCMT/atautorelease-2.m @@ -1,6 +1,7 @@ // 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 +// DISABLE: mingw32 @interface NSAutoreleasePool - drain; diff --git a/test/ARCMT/atautorelease-2.m.result b/test/ARCMT/atautorelease-2.m.result index 205473380b73..06bf0d51e4bb 100644 --- a/test/ARCMT/atautorelease-2.m.result +++ b/test/ARCMT/atautorelease-2.m.result @@ -1,6 +1,7 @@ // 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 +// DISABLE: mingw32 @interface NSAutoreleasePool - drain; diff --git a/test/ARCMT/atautorelease-3.m b/test/ARCMT/atautorelease-3.m index 87b80af9350e..0b6abdf83c46 100644 --- a/test/ARCMT/atautorelease-3.m +++ b/test/ARCMT/atautorelease-3.m @@ -1,6 +1,7 @@ // 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 +// DISABLE: mingw32 @interface NSAutoreleasePool - drain; diff --git a/test/ARCMT/atautorelease-3.m.result b/test/ARCMT/atautorelease-3.m.result index 801376a7e82b..9103de4167ef 100644 --- a/test/ARCMT/atautorelease-3.m.result +++ b/test/ARCMT/atautorelease-3.m.result @@ -1,6 +1,7 @@ // 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 +// DISABLE: mingw32 @interface NSAutoreleasePool - drain; diff --git a/test/ARCMT/atautorelease-check.m b/test/ARCMT/atautorelease-check.m index d74ef3b61d1f..8daf9d6bdeed 100644 --- a/test/ARCMT/atautorelease-check.m +++ b/test/ARCMT/atautorelease-check.m @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -arcmt-check -verify -triple x86_64-apple-darwin10 %s +// DISABLE: mingw32 #if __has_feature(objc_arr) #define NS_AUTOMATED_REFCOUNT_UNAVAILABLE __attribute__((unavailable("not available in automatic reference counting mode"))) diff --git a/test/ARCMT/atautorelease.m b/test/ARCMT/atautorelease.m index a6aed146497b..132553bdd331 100644 --- a/test/ARCMT/atautorelease.m +++ b/test/ARCMT/atautorelease.m @@ -1,6 +1,7 @@ // 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 +// DISABLE: mingw32 #include "Common.h" diff --git a/test/ARCMT/atautorelease.m.result b/test/ARCMT/atautorelease.m.result index e24339a3b9e3..5191f4738eb8 100644 --- a/test/ARCMT/atautorelease.m.result +++ b/test/ARCMT/atautorelease.m.result @@ -1,6 +1,7 @@ // 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 +// DISABLE: mingw32 #include "Common.h" diff --git a/test/ARCMT/autoreleases.m b/test/ARCMT/autoreleases.m index ed78cb4e2e57..3acddb71e7c8 100644 --- a/test/ARCMT/autoreleases.m +++ b/test/ARCMT/autoreleases.m @@ -1,6 +1,7 @@ // 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 +// DISABLE: mingw32 typedef unsigned char BOOL; diff --git a/test/ARCMT/autoreleases.m.result b/test/ARCMT/autoreleases.m.result index acb81b50647a..49bc32141ec5 100644 --- a/test/ARCMT/autoreleases.m.result +++ b/test/ARCMT/autoreleases.m.result @@ -1,6 +1,7 @@ // 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 +// DISABLE: mingw32 typedef unsigned char BOOL; diff --git a/test/ARCMT/check-with-serialized-diag.m b/test/ARCMT/check-with-serialized-diag.m new file mode 100644 index 000000000000..d8073d046931 --- /dev/null +++ b/test/ARCMT/check-with-serialized-diag.m @@ -0,0 +1,55 @@ + +@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:4: error: ARC forbids explicit message send of 'retain' +// CHECK-NEXT: Range: {{.*}}check-with-serialized-diag.m:32:23 {{.*}}check-with-serialized-diag.m:32:29 +// CHECK-NEXT: Number FIXITs = 0 +// CHECK-NEXT: {{.*}}check-with-serialized-diag.m:34:4: error: ARC forbids explicit message send of 'retain' +// CHECK-NEXT: Range: {{.*}}check-with-serialized-diag.m:34:15 {{.*}}check-with-serialized-diag.m:34:21 +// CHECK-NEXT: Number FIXITs = 0 +// CHECK-NEXT: {{.*}}check-with-serialized-diag.m:35:4: error: ARC forbids explicit message send of 'retainCount' +// CHECK-NEXT: Range: {{.*}}check-with-serialized-diag.m:35:6 {{.*}}check-with-serialized-diag.m:35:17 +// CHECK-NEXT: Number FIXITs = 0 + diff --git a/test/ARCMT/checking.m b/test/ARCMT/checking.m index 7c24dc485a2d..cf7161187fb1 100644 --- a/test/ARCMT/checking.m +++ b/test/ARCMT/checking.m @@ -1,6 +1,38 @@ // RUN: %clang_cc1 -arcmt-check -verify -triple x86_64-apple-darwin10 %s +// DISABLE: mingw32 + +#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; -#include "Common.h" ++ (id)new; ++ (id)alloc; +- (void)dealloc; + +- (void)finalize; + +- (id)copy; +- (id)mutableCopy; +@end typedef const struct __CFString * CFStringRef; extern const CFStringRef kUTTypePlainText; @@ -62,8 +94,8 @@ void test1(A *a, BOOL b, struct UnsafeS *unsafeS) { 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 __bridge_transfer to transfer ownership of a +1 'CFStringRef' (aka 'const struct __CFString *') into ARC}} + // 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); @@ -120,11 +152,11 @@ void * cvt(id arg) (void)(__autoreleasing id**)voidp_val; (void)(void*)voidp_val; (void)(void**)arg; // expected-error {{disallowed}} - cvt((void*)arg); // expected-error {{requires a bridged cast}} expected-error {{disallowed}} \ - // expected-note {{use __bridge}} expected-note {{use __bridge_retained}} + 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 {{disallowed}} + return arg; // expected-error {{requires a bridged cast}} expected-note {{use __bridge}} expected-note {{use CFBridgingRetain call}} } diff --git a/test/ARCMT/cxx-checking.mm b/test/ARCMT/cxx-checking.mm index ab6b29bafe62..9f9e3d864312 100644 --- a/test/ARCMT/cxx-checking.mm +++ b/test/ARCMT/cxx-checking.mm @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -arcmt-check -verify -triple x86_64-apple-darwin10 -fsyntax-only -fblocks -Warc-abi %s +// DISABLE: mingw32 // Classes that have an Objective-C object pointer. struct HasObjectMember0 { // expected-warning{{'HasObjectMember0' cannot be shared between ARC and non-ARC code; add a copy constructor, a copy assignment operator, and a destructor to make it ABI-compatible}} diff --git a/test/ARCMT/cxx-rewrite.mm b/test/ARCMT/cxx-rewrite.mm index 4a9c50c92426..92bb71807d00 100644 --- a/test/ARCMT/cxx-rewrite.mm +++ b/test/ARCMT/cxx-rewrite.mm @@ -1,6 +1,7 @@ // 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 +// DISABLE: mingw32 #include "Common.h" diff --git a/test/ARCMT/cxx-rewrite.mm.result b/test/ARCMT/cxx-rewrite.mm.result index 0dd67e8b27f4..a2dc9a51f006 100644 --- a/test/ARCMT/cxx-rewrite.mm.result +++ b/test/ARCMT/cxx-rewrite.mm.result @@ -1,6 +1,7 @@ // 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 +// DISABLE: mingw32 #include "Common.h" diff --git a/test/ARCMT/dealloc.m b/test/ARCMT/dealloc.m index d7a72af4f726..34df1a49b693 100644 --- a/test/ARCMT/dealloc.m +++ b/test/ARCMT/dealloc.m @@ -1,6 +1,7 @@ // 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 +// DISABLE: mingw32 @interface A - (id)retain; diff --git a/test/ARCMT/dealloc.m.result b/test/ARCMT/dealloc.m.result index fbd9e445d275..3ff2885341c4 100644 --- a/test/ARCMT/dealloc.m.result +++ b/test/ARCMT/dealloc.m.result @@ -1,6 +1,7 @@ // 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 +// DISABLE: mingw32 @interface A - (id)retain; diff --git a/test/ARCMT/dispatch.m b/test/ARCMT/dispatch.m new file mode 100644 index 000000000000..75c4a83459c7 --- /dev/null +++ b/test/ARCMT/dispatch.m @@ -0,0 +1,29 @@ +// 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" + +#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); + +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 new file mode 100644 index 000000000000..e897672a264b --- /dev/null +++ b/test/ARCMT/dispatch.m.result @@ -0,0 +1,25 @@ +// 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" + +#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); + +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 index 32e84d757819..a912ad95b156 100644 --- a/test/ARCMT/driver-migrate.m +++ b/test/ARCMT/driver-migrate.m @@ -1,11 +1,11 @@ // RUN: %clang -### -ccc-arcmt-migrate /foo/bar -fsyntax-only %s 2>&1 | FileCheck %s -// CHECK: "-arcmt-migrate" "-arcmt-migrate-directory" "{{[^"]*}}/foo/bar" +// CHECK: "-arcmt-migrate" "-mt-migrate-directory" "{{[^"]*}}/foo/bar" // RUN: touch %t.o -// RUN: %clang -ccc-arcmt-check -ccc-host-triple i386-apple-darwin9 -### %t.o 2> %t.log +// 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 -ccc-host-triple i386-apple-darwin9 -### %t.o 2> %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)?"}} diff --git a/test/ARCMT/init.m b/test/ARCMT/init.m index 8636e3733d22..9dbb1f82b828 100644 --- a/test/ARCMT/init.m +++ b/test/ARCMT/init.m @@ -1,6 +1,9 @@ // 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 +// DISABLE: mingw32 + +#define nil (void *)0 @interface NSObject -init; diff --git a/test/ARCMT/init.m.result b/test/ARCMT/init.m.result index 0140bb96919c..d7f730083aab 100644 --- a/test/ARCMT/init.m.result +++ b/test/ARCMT/init.m.result @@ -1,6 +1,9 @@ // 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 +// DISABLE: mingw32 + +#define nil (void *)0 @interface NSObject -init; @@ -15,7 +18,7 @@ @implementation A -(id) init { - self = [self init]; + if (!(self = [self init])) return nil; id a; [a init]; a = [[A alloc] init]; @@ -24,7 +27,7 @@ } -(id) init2 { - self = [super init]; + if (!(self = [super init])) return nil; return self; } diff --git a/test/ARCMT/migrate-emit-errors.m b/test/ARCMT/migrate-emit-errors.m index 6a4a3963ca0b..95c0d2f8f073 100644 --- a/test/ARCMT/migrate-emit-errors.m +++ b/test/ARCMT/migrate-emit-errors.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -arcmt-migrate -arcmt-migrate-directory %t -arcmt-migrate-emit-errors %s 2>&1 | FileCheck %s +// RUN: %clang_cc1 -arcmt-migrate -mt-migrate-directory %t -arcmt-migrate-emit-errors %s 2>&1 | FileCheck %s // RUN: rm -rf %t @protocol NSObject diff --git a/test/ARCMT/migrate-plist-output.m b/test/ARCMT/migrate-plist-output.m index e5b74e91f8d0..12efa93f0752 100644 --- a/test/ARCMT/migrate-plist-output.m +++ b/test/ARCMT/migrate-plist-output.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -arcmt-migrate -arcmt-migrate-directory %t.dir -arcmt-migrate-report-output %t.plist %s +// 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 @@ -21,7 +21,7 @@ void test(id p) { // CHECK: <array> // CHECK: <dict> // CHECK: <key>description</key><string>ARC forbids explicit message send of 'release'</string> -// CHECK: <key>category</key><string>Automatic Reference Counting Issue</string> +// CHECK: <key>category</key><string>ARC Restrictions</string> // CHECK: <key>type</key><string>error</string> // CHECK: <key>location</key> // CHECK: <dict> @@ -48,3 +48,5 @@ void test(id p) { // CHECK: </array> // CHECK: </dict> // CHECK: </plist> + +// DISABLE: mingw32 diff --git a/test/ARCMT/migrate-space-in-path.m b/test/ARCMT/migrate-space-in-path.m index 32617666a96e..89dfe1475cfe 100644 --- a/test/ARCMT/migrate-space-in-path.m +++ b/test/ARCMT/migrate-space-in-path.m @@ -1,5 +1,6 @@ // RUN: rm -rf %t.migrate -// RUN: %clang_cc1 -arcmt-migrate -arcmt-migrate-directory %t.migrate %S/"with space"/test1.m.in -x objective-c -// RUN: %clang_cc1 -arcmt-migrate -arcmt-migrate-directory %t.migrate %S/"with space"/test2.m.in -x objective-c -// RUN: c-arcmt-test -arcmt-migrate-directory %t.migrate | arcmt-test -verify-transformed-files %S/"with space"/test1.m.in.result %S/"with space"/test2.m.in.result %S/"with space"/test.h.result +// RUN: %clang_cc1 -arcmt-migrate -mt-migrate-directory %t.migrate %S/"with space"/test1.m.in -x objective-c +// RUN: %clang_cc1 -arcmt-migrate -mt-migrate-directory %t.migrate %S/"with space"/test2.m.in -x objective-c +// RUN: c-arcmt-test -mt-migrate-directory %t.migrate | arcmt-test -verify-transformed-files %S/"with space"/test1.m.in.result %S/"with space"/test2.m.in.result %S/"with space"/test.h.result // RUN: rm -rf %t.migrate +// DISABLE: mingw32 diff --git a/test/ARCMT/migrate.m b/test/ARCMT/migrate.m index cfd7115acc1e..6f41258e59d6 100644 --- a/test/ARCMT/migrate.m +++ b/test/ARCMT/migrate.m @@ -1,5 +1,6 @@ // RUN: rm -rf %t -// RUN: %clang_cc1 -arcmt-migrate -arcmt-migrate-directory %t %S/Inputs/test1.m.in -x objective-c -// RUN: %clang_cc1 -arcmt-migrate -arcmt-migrate-directory %t %S/Inputs/test2.m.in -x objective-c -// RUN: c-arcmt-test -arcmt-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: %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 +// DISABLE: mingw32 diff --git a/test/ARCMT/no-canceling-bridge-to-bridge-cast.m b/test/ARCMT/no-canceling-bridge-to-bridge-cast.m new file mode 100644 index 000000000000..81841fbf1e89 --- /dev/null +++ b/test/ARCMT/no-canceling-bridge-to-bridge-cast.m @@ -0,0 +1,43 @@ +// RUN: %clang_cc1 -arcmt-check -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -verify %s +// DISABLE: mingw32 +// 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 index 5dba61f023fd..1ec0089f08e8 100644 --- a/test/ARCMT/nonobjc-to-objc-cast-2.m +++ b/test/ARCMT/nonobjc-to-objc-cast-2.m @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -arcmt-check -verify -triple x86_64-apple-darwin10 %s +// DISABLE: mingw32 #include "Common.h" @@ -8,21 +9,24 @@ @end typedef const struct __CFString * CFStringRef; +typedef const void * CFTypeRef; +CFTypeRef CFBridgingRetain(id X); +id CFBridgingRelease(CFTypeRef); 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 __bridge_transfer to transfer ownership of a +1 'CFStringRef' (aka 'const struct __CFString *') into ARC}} - void *vp = str; // expected-error {{disallowed}} + // 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-error {{bad receiver type 'CFStringRef' (aka 'const struct __CFString *')}} \ // expected-note{{use __bridge to convert directly (no change in ownership)}} \ - // expected-note{{use __bridge_retained to make an ARC object available as a +1 'CFStringRef' (aka 'const struct __CFString *')}} + // expected-note{{use CFBridgingRetain call to make an ARC object available as a +1 'CFStringRef' (aka 'const struct __CFString *')}} } CFStringRef f3() { diff --git a/test/ARCMT/nonobjc-to-objc-cast.m b/test/ARCMT/nonobjc-to-objc-cast.m index 4fa110919917..fcdcd89c9c83 100644 --- a/test/ARCMT/nonobjc-to-objc-cast.m +++ b/test/ARCMT/nonobjc-to-objc-cast.m @@ -1,6 +1,7 @@ // 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 +// DISABLE: mingw32 #include "Common.h" diff --git a/test/ARCMT/nonobjc-to-objc-cast.m.result b/test/ARCMT/nonobjc-to-objc-cast.m.result index bf6aad931948..b50a948e27ca 100644 --- a/test/ARCMT/nonobjc-to-objc-cast.m.result +++ b/test/ARCMT/nonobjc-to-objc-cast.m.result @@ -1,6 +1,7 @@ // 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 +// DISABLE: mingw32 #include "Common.h" diff --git a/test/ARCMT/objcmt-numeric-literals.m b/test/ARCMT/objcmt-numeric-literals.m new file mode 100644 index 000000000000..b86af4d056a1 --- /dev/null +++ b/test/ARCMT/objcmt-numeric-literals.m @@ -0,0 +1,501 @@ +// 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 + +#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 new file mode 100644 index 000000000000..1c4187aaef5c --- /dev/null +++ b/test/ARCMT/objcmt-numeric-literals.m.result @@ -0,0 +1,501 @@ +// 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 + +#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]; + [NSNumber numberWithInteger: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]; + [NSNumber numberWithUnsignedInteger:VAL_UINT]; +} diff --git a/test/ARCMT/objcmt-subscripting-literals.m b/test/ARCMT/objcmt-subscripting-literals.m new file mode 100644 index 000000000000..3d26efefda82 --- /dev/null +++ b/test/ARCMT/objcmt-subscripting-literals.m @@ -0,0 +1,137 @@ +// 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 + +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 + +@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, ...; ++ (id)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 + +@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; ++ (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; +- (void)setObject:(id)object forKeyedSubscript:(id)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)) + +@interface I +@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 = [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]; +} +@end diff --git a/test/ARCMT/objcmt-subscripting-literals.m.result b/test/ARCMT/objcmt-subscripting-literals.m.result new file mode 100644 index 000000000000..8ac6dcc20751 --- /dev/null +++ b/test/ARCMT/objcmt-subscripting-literals.m.result @@ -0,0 +1,137 @@ +// 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 + +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 + +@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, ...; ++ (id)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 + +@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; ++ (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; +- (void)setObject:(id)object forKeyedSubscript:(id)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)) + +@interface I +@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 = @{@"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]; +} +@end diff --git a/test/ARCMT/rewrite-block-var.m b/test/ARCMT/rewrite-block-var.m index e6a8fb72e00a..538f16c25574 100644 --- a/test/ARCMT/rewrite-block-var.m +++ b/test/ARCMT/rewrite-block-var.m @@ -23,3 +23,23 @@ void test2(Foo *p) { 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 index 27c81bd58825..a9d0b0f7fad8 100644 --- a/test/ARCMT/rewrite-block-var.m.result +++ b/test/ARCMT/rewrite-block-var.m.result @@ -23,3 +23,23 @@ void test2(Foo *p) { 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/with-arc-mode-migrate.m b/test/ARCMT/with-arc-mode-migrate.m index 32bcad195042..468859478eb0 100644 --- a/test/ARCMT/with-arc-mode-migrate.m +++ b/test/ARCMT/with-arc-mode-migrate.m @@ -1,7 +1,7 @@ // RUN: rm -rf %t // RUN: %clang_cc1 -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: %clang_cc1 -arcmt-migrate -arcmt-migrate-directory %t -fsyntax-only -fobjc-arc %s -// RUN: c-arcmt-test -arcmt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result +// RUN: %clang_cc1 -arcmt-migrate -mt-migrate-directory %t -fsyntax-only -fobjc-arc %s +// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result // RUN: rm -rf %t @protocol NSObject diff --git a/test/ARCMT/with-arc-mode-migrate.m.result b/test/ARCMT/with-arc-mode-migrate.m.result index f060793f6eb4..dd34b9990878 100644 --- a/test/ARCMT/with-arc-mode-migrate.m.result +++ b/test/ARCMT/with-arc-mode-migrate.m.result @@ -1,7 +1,7 @@ // RUN: rm -rf %t // RUN: %clang_cc1 -fsyntax-only -fobjc-arc -x objective-c %s.result -// RUN: %clang_cc1 -arcmt-migrate -arcmt-migrate-directory %t -fsyntax-only -fobjc-arc %s -// RUN: c-arcmt-test -arcmt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result +// RUN: %clang_cc1 -arcmt-migrate -mt-migrate-directory %t -fsyntax-only -fobjc-arc %s +// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result // RUN: rm -rf %t @protocol NSObject |