xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGenObjC/boxing.m (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1f4a2713aSLionel Sambuc// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s
2f4a2713aSLionel Sambuc
3f4a2713aSLionel Sambuctypedef long NSInteger;
4f4a2713aSLionel Sambuctypedef unsigned long NSUInteger;
5f4a2713aSLionel Sambuctypedef signed char BOOL;
6f4a2713aSLionel Sambuc#define nil ((void*) 0)
7f4a2713aSLionel Sambuc
8f4a2713aSLionel Sambuc@interface NSObject
9f4a2713aSLionel Sambuc+ (id)alloc;
10f4a2713aSLionel Sambuc@end
11f4a2713aSLionel Sambuc
12f4a2713aSLionel Sambuc@interface NSNumber : NSObject
13f4a2713aSLionel Sambuc@end
14f4a2713aSLionel Sambuc
15f4a2713aSLionel Sambuc@interface NSNumber (NSNumberCreation)
16f4a2713aSLionel Sambuc- (id)initWithChar:(char)value;
17f4a2713aSLionel Sambuc- (id)initWithUnsignedChar:(unsigned char)value;
18f4a2713aSLionel Sambuc- (id)initWithShort:(short)value;
19f4a2713aSLionel Sambuc- (id)initWithUnsignedShort:(unsigned short)value;
20f4a2713aSLionel Sambuc- (id)initWithInt:(int)value;
21f4a2713aSLionel Sambuc- (id)initWithUnsignedInt:(unsigned int)value;
22f4a2713aSLionel Sambuc- (id)initWithLong:(long)value;
23f4a2713aSLionel Sambuc- (id)initWithUnsignedLong:(unsigned long)value;
24f4a2713aSLionel Sambuc- (id)initWithLongLong:(long long)value;
25f4a2713aSLionel Sambuc- (id)initWithUnsignedLongLong:(unsigned long long)value;
26f4a2713aSLionel Sambuc- (id)initWithFloat:(float)value;
27f4a2713aSLionel Sambuc- (id)initWithDouble:(double)value;
28f4a2713aSLionel Sambuc- (id)initWithBool:(BOOL)value;
29f4a2713aSLionel Sambuc- (id)initWithInteger:(NSInteger)value;
30f4a2713aSLionel Sambuc- (id)initWithUnsignedInteger:(NSUInteger)value;
31f4a2713aSLionel Sambuc
32f4a2713aSLionel Sambuc+ (NSNumber *)numberWithChar:(char)value;
33f4a2713aSLionel Sambuc+ (NSNumber *)numberWithUnsignedChar:(unsigned char)value;
34f4a2713aSLionel Sambuc+ (NSNumber *)numberWithShort:(short)value;
35f4a2713aSLionel Sambuc+ (NSNumber *)numberWithUnsignedShort:(unsigned short)value;
36f4a2713aSLionel Sambuc+ (NSNumber *)numberWithInt:(int)value;
37f4a2713aSLionel Sambuc+ (NSNumber *)numberWithUnsignedInt:(unsigned int)value;
38f4a2713aSLionel Sambuc+ (NSNumber *)numberWithLong:(long)value;
39f4a2713aSLionel Sambuc+ (NSNumber *)numberWithUnsignedLong:(unsigned long)value;
40f4a2713aSLionel Sambuc+ (NSNumber *)numberWithLongLong:(long long)value;
41f4a2713aSLionel Sambuc+ (NSNumber *)numberWithUnsignedLongLong:(unsigned long long)value;
42f4a2713aSLionel Sambuc+ (NSNumber *)numberWithFloat:(float)value;
43f4a2713aSLionel Sambuc+ (NSNumber *)numberWithDouble:(double)value;
44f4a2713aSLionel Sambuc+ (NSNumber *)numberWithBool:(BOOL)value;
45f4a2713aSLionel Sambuc+ (NSNumber *)numberWithInteger:(NSInteger)value;
46f4a2713aSLionel Sambuc+ (NSNumber *)numberWithUnsignedInteger:(NSUInteger)value;
47f4a2713aSLionel Sambuc@end
48f4a2713aSLionel Sambuc
49f4a2713aSLionel Sambuc@interface NSString : NSObject
50f4a2713aSLionel Sambuc@end
51f4a2713aSLionel Sambuc
52f4a2713aSLionel Sambuc@interface NSString (NSStringExtensionMethods)
53f4a2713aSLionel Sambuc+ (id)stringWithUTF8String:(const char *)nullTerminatedCString;
54f4a2713aSLionel Sambuc@end
55f4a2713aSLionel Sambuc
56*0a6a1f1dSLionel Sambuc// CHECK: [[WithIntMeth:@.*]] = private global [15 x i8] c"numberWithInt:\00"
57*0a6a1f1dSLionel Sambuc// CHECK: [[WithIntSEL:@.*]] = private externally_initialized global i8* getelementptr inbounds ([15 x i8]* [[WithIntMeth]]
58*0a6a1f1dSLionel Sambuc// CHECK: [[WithCharMeth:@.*]] = private global [16 x i8] c"numberWithChar:\00"
59*0a6a1f1dSLionel Sambuc// CHECK: [[WithCharSEL:@.*]] = private externally_initialized global i8* getelementptr inbounds ([16 x i8]* [[WithCharMeth]]
60*0a6a1f1dSLionel Sambuc// CHECK: [[WithBoolMeth:@.*]] = private global [16 x i8] c"numberWithBool:\00"
61*0a6a1f1dSLionel Sambuc// CHECK: [[WithBoolSEL:@.*]] = private externally_initialized global i8* getelementptr inbounds ([16 x i8]* [[WithBoolMeth]]
62*0a6a1f1dSLionel Sambuc// CHECK: [[WithIntegerMeth:@.*]] = private global [19 x i8] c"numberWithInteger:\00"
63*0a6a1f1dSLionel Sambuc// CHECK: [[WithIntegerSEL:@.*]] = private externally_initialized global i8* getelementptr inbounds ([19 x i8]* [[WithIntegerMeth]]
64*0a6a1f1dSLionel Sambuc// CHECK: [[WithUnsignedIntegerMeth:@.*]] = private global [27 x i8] c"numberWithUnsignedInteger:\00"
65*0a6a1f1dSLionel Sambuc// CHECK: [[WithUnsignedIntegerSEL:@.*]] = private externally_initialized global i8* getelementptr inbounds ([27 x i8]* [[WithUnsignedIntegerMeth]]
66*0a6a1f1dSLionel Sambuc// CHECK: [[stringWithUTF8StringMeth:@.*]] = private global [22 x i8] c"stringWithUTF8String:\00"
67*0a6a1f1dSLionel Sambuc// CHECK: [[stringWithUTF8StringSEL:@.*]] = private externally_initialized global i8* getelementptr inbounds ([22 x i8]* [[stringWithUTF8StringMeth]]
68f4a2713aSLionel Sambuc
69f4a2713aSLionel Sambucint main() {
70f4a2713aSLionel Sambuc  // CHECK: load i8** [[WithIntSEL]]
71f4a2713aSLionel Sambuc  int i; @(i);
72f4a2713aSLionel Sambuc  // CHECK: load i8** [[WithCharSEL]]
73f4a2713aSLionel Sambuc  signed char sc; @(sc);
74f4a2713aSLionel Sambuc  // CHECK: load i8** [[WithBoolSEL]]
75f4a2713aSLionel Sambuc  BOOL b; @(b);
76f4a2713aSLionel Sambuc  // CHECK: load i8** [[WithBoolSEL]]
77f4a2713aSLionel Sambuc  typeof(b) b2; @(b2);
78f4a2713aSLionel Sambuc  // CHECK: load i8** [[WithBoolSEL]]
79f4a2713aSLionel Sambuc  typedef const typeof(b) MyBOOL; MyBOOL b3; @(b3);
80f4a2713aSLionel Sambuc  // CHECK: load i8** [[WithBoolSEL]]
81f4a2713aSLionel Sambuc  @((BOOL)i);
82f4a2713aSLionel Sambuc  // CHECK: load i8** [[WithIntegerSEL]]
83f4a2713aSLionel Sambuc  @((NSInteger)i);
84f4a2713aSLionel Sambuc  // CHECK: load i8** [[WithUnsignedIntegerSEL]]
85f4a2713aSLionel Sambuc  @((NSUInteger)i);
86f4a2713aSLionel Sambuc  // CHECK: load i8** [[stringWithUTF8StringSEL]]
87f4a2713aSLionel Sambuc  const char *s; @(s);
88f4a2713aSLionel Sambuc
89f4a2713aSLionel Sambuc  typedef enum : NSInteger { Red, Green, Blue } Color;
90f4a2713aSLionel Sambuc  // CHECK: load i8** [[WithIntegerSEL]]
91f4a2713aSLionel Sambuc  @(Red);
92f4a2713aSLionel Sambuc  Color col = Red;
93f4a2713aSLionel Sambuc  // CHECK: load i8** [[WithIntegerSEL]]
94f4a2713aSLionel Sambuc  @(col);
95f4a2713aSLionel Sambuc}
96