Home | History | Annotate | Download | only in PCH
      1 // RUN: %clang -cc1 -emit-pch -o %t %s
      2 // RUN: %clang -cc1 -include-pch %t -verify %s
      3 // RUN: %clang -cc1 -include-pch %t -ast-print %s | FileCheck -check-prefix=PRINT %s
      4 // RUN: %clang -cc1 -include-pch %t -emit-llvm -o - %s | FileCheck -check-prefix=IR %s
      5 
      6 #ifndef HEADER
      7 #define HEADER
      8 
      9 typedef unsigned char BOOL;
     10 
     11 @interface NSNumber @end
     12 
     13 @interface NSNumber (NSNumberCreation)
     14 + (NSNumber *)numberWithChar:(char)value;
     15 + (NSNumber *)numberWithUnsignedChar:(unsigned char)value;
     16 + (NSNumber *)numberWithShort:(short)value;
     17 + (NSNumber *)numberWithUnsignedShort:(unsigned short)value;
     18 + (NSNumber *)numberWithInt:(int)value;
     19 + (NSNumber *)numberWithUnsignedInt:(unsigned int)value;
     20 + (NSNumber *)numberWithLong:(long)value;
     21 + (NSNumber *)numberWithUnsignedLong:(unsigned long)value;
     22 + (NSNumber *)numberWithLongLong:(long long)value;
     23 + (NSNumber *)numberWithUnsignedLongLong:(unsigned long long)value;
     24 + (NSNumber *)numberWithFloat:(float)value;
     25 + (NSNumber *)numberWithDouble:(double)value;
     26 + (NSNumber *)numberWithBool:(BOOL)value;
     27 @end
     28 
     29 @interface NSArray
     30 @end
     31 
     32 @interface NSArray (NSArrayCreation)
     33 + (id)arrayWithObjects:(const id [])objects count:(unsigned long)cnt;
     34 @end
     35 
     36 @interface NSDictionary
     37 + (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt;
     38 @end
     39 
     40 // CHECK-IR: define internal void @test_numeric_literals()
     41 static inline void test_numeric_literals() {
     42   // CHECK-PRINT: id intlit = @17
     43   // CHECK-IR: {{call.*17}}
     44   id intlit = @17;
     45   // CHECK-PRINT: id floatlit = @17.45
     46   // CHECK-IR: {{call.*1.745}}
     47   id floatlit = @17.45;
     48 }
     49 
     50 static inline void test_array_literals() {
     51   // CHECK-PRINT: id arraylit = @[ @17, @17.45
     52   id arraylit = @[@17, @17.45];
     53 }
     54 
     55 static inline void test_dictionary_literals() {
     56   // CHECK-PRINT: id dictlit = @{ @17 : {{@17.45[^,]*}}, @"hello" : @"world" };
     57   id dictlit = @{@17 : @17.45, @"hello" : @"world" };
     58 }
     59 
     60 #else
     61 void test_all() {
     62   test_numeric_literals();
     63   test_array_literals();
     64   test_dictionary_literals();
     65 }
     66 #endif
     67