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