Home | History | Annotate | Download | only in CodeGenObjC
      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: [[WithIntMeth:@.*]] = private global [15 x i8] c"numberWithInt:\00"
     57 // CHECK: [[WithIntSEL:@.*]] = private externally_initialized global i8* getelementptr inbounds ([15 x i8], [15 x i8]* [[WithIntMeth]]
     58 // CHECK: [[WithCharMeth:@.*]] = private global [16 x i8] c"numberWithChar:\00"
     59 // CHECK: [[WithCharSEL:@.*]] = private externally_initialized global i8* getelementptr inbounds ([16 x i8], [16 x i8]* [[WithCharMeth]]
     60 // CHECK: [[WithBoolMeth:@.*]] = private global [16 x i8] c"numberWithBool:\00"
     61 // CHECK: [[WithBoolSEL:@.*]] = private externally_initialized global i8* getelementptr inbounds ([16 x i8], [16 x i8]* [[WithBoolMeth]]
     62 // CHECK: [[WithIntegerMeth:@.*]] = private global [19 x i8] c"numberWithInteger:\00"
     63 // CHECK: [[WithIntegerSEL:@.*]] = private externally_initialized global i8* getelementptr inbounds ([19 x i8], [19 x i8]* [[WithIntegerMeth]]
     64 // CHECK: [[WithUnsignedIntegerMeth:@.*]] = private global [27 x i8] c"numberWithUnsignedInteger:\00"
     65 // CHECK: [[WithUnsignedIntegerSEL:@.*]] = private externally_initialized global i8* getelementptr inbounds ([27 x i8], [27 x i8]* [[WithUnsignedIntegerMeth]]
     66 // CHECK: [[stringWithUTF8StringMeth:@.*]] = private global [22 x i8] c"stringWithUTF8String:\00"
     67 // CHECK: [[stringWithUTF8StringSEL:@.*]] = private externally_initialized global i8* getelementptr inbounds ([22 x i8], [22 x i8]* [[stringWithUTF8StringMeth]]
     68 
     69 int main() {
     70   // CHECK: load i8*, i8** [[WithIntSEL]]
     71   int i; @(i);
     72   // CHECK: load i8*, i8** [[WithCharSEL]]
     73   signed char sc; @(sc);
     74   // CHECK: load i8*, i8** [[WithBoolSEL]]
     75   BOOL b; @(b);
     76   // CHECK: load i8*, i8** [[WithBoolSEL]]
     77   typeof(b) b2; @(b2);
     78   // CHECK: load i8*, i8** [[WithBoolSEL]]
     79   typedef const typeof(b) MyBOOL; MyBOOL b3; @(b3);
     80   // CHECK: load i8*, i8** [[WithBoolSEL]]
     81   @((BOOL)i);
     82   // CHECK: load i8*, i8** [[WithIntegerSEL]]
     83   @((NSInteger)i);
     84   // CHECK: load i8*, i8** [[WithUnsignedIntegerSEL]]
     85   @((NSUInteger)i);
     86   // CHECK: load i8*, i8** [[stringWithUTF8StringSEL]]
     87   const char *s; @(s);
     88 
     89   typedef enum : NSInteger { Red, Green, Blue } Color;
     90   // CHECK: load i8*, i8** [[WithIntegerSEL]]
     91   @(Red);
     92   Color col = Red;
     93   // CHECK: load i8*, i8** [[WithIntegerSEL]]
     94   @(col);
     95 }
     96