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