1*f4a2713aSLionel Sambuc// RUN: %clang_cc1 -x objective-c -triple x86_64-apple-darwin10 -fblocks -emit-llvm %s -o - | FileCheck %s 2*f4a2713aSLionel Sambuc// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fblocks -emit-llvm %s -o - | FileCheck %s 3*f4a2713aSLionel Sambuc// rdar://10111397 4*f4a2713aSLionel Sambuc 5*f4a2713aSLionel Sambuc#if __has_feature(objc_bool) 6*f4a2713aSLionel Sambuc#define YES __objc_yes 7*f4a2713aSLionel Sambuc#define NO __objc_no 8*f4a2713aSLionel Sambuc#else 9*f4a2713aSLionel Sambuc#define YES ((BOOL)1) 10*f4a2713aSLionel Sambuc#define NO ((BOOL)0) 11*f4a2713aSLionel Sambuc#endif 12*f4a2713aSLionel Sambuc 13*f4a2713aSLionel Sambuc#if __LP64__ || (TARGET_OS_EMBEDDED && !TARGET_OS_IPHONE) || TARGET_OS_WIN32 || NS_BUILD_32_LIKE_64 14*f4a2713aSLionel Sambuctypedef unsigned long NSUInteger; 15*f4a2713aSLionel Sambuctypedef long NSInteger; 16*f4a2713aSLionel Sambuc#else 17*f4a2713aSLionel Sambuctypedef unsigned int NSUInteger; 18*f4a2713aSLionel Sambuctypedef int NSInteger; 19*f4a2713aSLionel Sambuc#endif 20*f4a2713aSLionel Sambuctypedef signed char BOOL; 21*f4a2713aSLionel Sambuc 22*f4a2713aSLionel Sambuc@interface NSNumber @end 23*f4a2713aSLionel Sambuc 24*f4a2713aSLionel Sambuc@interface NSNumber (NSNumberCreation) 25*f4a2713aSLionel Sambuc#if __has_feature(objc_array_literals) 26*f4a2713aSLionel Sambuc+ (NSNumber *)numberWithChar:(char)value; 27*f4a2713aSLionel Sambuc+ (NSNumber *)numberWithUnsignedChar:(unsigned char)value; 28*f4a2713aSLionel Sambuc+ (NSNumber *)numberWithShort:(short)value; 29*f4a2713aSLionel Sambuc+ (NSNumber *)numberWithUnsignedShort:(unsigned short)value; 30*f4a2713aSLionel Sambuc+ (NSNumber *)numberWithInt:(int)value; 31*f4a2713aSLionel Sambuc+ (NSNumber *)numberWithUnsignedInt:(unsigned int)value; 32*f4a2713aSLionel Sambuc+ (NSNumber *)numberWithLong:(long)value; 33*f4a2713aSLionel Sambuc+ (NSNumber *)numberWithUnsignedLong:(unsigned long)value; 34*f4a2713aSLionel Sambuc+ (NSNumber *)numberWithLongLong:(long long)value; 35*f4a2713aSLionel Sambuc+ (NSNumber *)numberWithUnsignedLongLong:(unsigned long long)value; 36*f4a2713aSLionel Sambuc+ (NSNumber *)numberWithFloat:(float)value; 37*f4a2713aSLionel Sambuc+ (NSNumber *)numberWithDouble:(double)value; 38*f4a2713aSLionel Sambuc+ (NSNumber *)numberWithBool:(BOOL)value; 39*f4a2713aSLionel Sambuc+ (NSNumber *)numberWithInteger:(NSInteger)value ; 40*f4a2713aSLionel Sambuc+ (NSNumber *)numberWithUnsignedInteger:(NSUInteger)value ; 41*f4a2713aSLionel Sambuc#endif 42*f4a2713aSLionel Sambuc@end 43*f4a2713aSLionel Sambuc 44*f4a2713aSLionel Sambuc@interface NSDate 45*f4a2713aSLionel Sambuc+ (NSDate *) date; 46*f4a2713aSLionel Sambuc@end 47*f4a2713aSLionel Sambuc 48*f4a2713aSLionel Sambuc#if __has_feature(objc_dictionary_literals) 49*f4a2713aSLionel Sambuc@interface NSDictionary 50*f4a2713aSLionel Sambuc+ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(NSUInteger)cnt; 51*f4a2713aSLionel Sambuc@end 52*f4a2713aSLionel Sambuc#endif 53*f4a2713aSLionel Sambuc 54*f4a2713aSLionel Sambucid NSUserName(); 55*f4a2713aSLionel Sambuc 56*f4a2713aSLionel Sambuc// CHECK: define i32 @main() [[NUW:#[0-9]+]] 57*f4a2713aSLionel Sambucint main() { 58*f4a2713aSLionel Sambuc // CHECK: call{{.*}}@objc_msgSend{{.*}}i8 signext 97 59*f4a2713aSLionel Sambuc NSNumber *aNumber = @'a'; 60*f4a2713aSLionel Sambuc // CHECK: call{{.*}}@objc_msgSend{{.*}}i32 42 61*f4a2713aSLionel Sambuc NSNumber *fortyTwo = @42; 62*f4a2713aSLionel Sambuc // CHECK: call{{.*}}@objc_msgSend{{.*}}i32 -42 63*f4a2713aSLionel Sambuc NSNumber *negativeFortyTwo = @-42; 64*f4a2713aSLionel Sambuc // CHECK: call{{.*}}@objc_msgSend{{.*}}i32 42 65*f4a2713aSLionel Sambuc NSNumber *positiveFortyTwo = @+42; 66*f4a2713aSLionel Sambuc // CHECK: call{{.*}}@objc_msgSend{{.*}}i32 42 67*f4a2713aSLionel Sambuc NSNumber *fortyTwoUnsigned = @42u; 68*f4a2713aSLionel Sambuc // CHECK: call{{.*}}@objc_msgSend{{.*}}i64 42 69*f4a2713aSLionel Sambuc NSNumber *fortyTwoLong = @42l; 70*f4a2713aSLionel Sambuc // CHECK: call{{.*}}@objc_msgSend{{.*}}i64 42 71*f4a2713aSLionel Sambuc NSNumber *fortyTwoLongLong = @42ll; 72*f4a2713aSLionel Sambuc // CHECK: call{{.*}}@objc_msgSend{{.*}}float 0x400921FB60000000 73*f4a2713aSLionel Sambuc NSNumber *piFloat = @3.141592654f; 74*f4a2713aSLionel Sambuc // CHECK: call{{.*}}@objc_msgSend{{.*}}double 0x400921FB54411744 75*f4a2713aSLionel Sambuc NSNumber *piDouble = @3.1415926535; 76*f4a2713aSLionel Sambuc // CHECK: call{{.*}}@objc_msgSend{{.*}}i8 signext 1 77*f4a2713aSLionel Sambuc NSNumber *yesNumber = @__objc_yes; 78*f4a2713aSLionel Sambuc // CHECK: call{{.*}}@objc_msgSend{{.*}}i8 signext 0 79*f4a2713aSLionel Sambuc NSNumber *noNumber = @__objc_no; 80*f4a2713aSLionel Sambuc // CHECK: call{{.*}}@objc_msgSend{{.*}}i8 signext 1 81*f4a2713aSLionel Sambuc NSNumber *yesNumber1 = @YES; 82*f4a2713aSLionel Sambuc // CHECK: call{{.*}}@objc_msgSend{{.*}}i8 signext 0 83*f4a2713aSLionel Sambuc NSNumber *noNumber1 = @NO; 84*f4a2713aSLionel SambucNSDictionary *dictionary = @{@"name" : NSUserName(), 85*f4a2713aSLionel Sambuc @"date" : [NSDate date] }; 86*f4a2713aSLionel Sambuc return __objc_yes == __objc_no; 87*f4a2713aSLionel Sambuc} 88*f4a2713aSLionel Sambuc 89*f4a2713aSLionel Sambuc// rdar://10579122 90*f4a2713aSLionel Sambuctypedef BOOL (^foo)(void); 91*f4a2713aSLionel Sambucextern void bar(foo a); 92*f4a2713aSLionel Sambuc 93*f4a2713aSLionel Sambucvoid baz(void) { 94*f4a2713aSLionel Sambuc bar(^(void) { return YES; }); 95*f4a2713aSLionel Sambuc} 96*f4a2713aSLionel Sambuc 97*f4a2713aSLionel Sambuc// CHECK: attributes [[NUW]] = { nounwind{{.*}} } 98