Home | History | Annotate | Download | only in PCH
      1 // RUN: %clang_cc1 -triple %itanium_abi_triple -emit-pch -x objective-c++ -std=c++0x -o %t %s
      2 // RUN: %clang_cc1 -triple %itanium_abi_triple -include-pch %t -x objective-c++ -std=c++0x -verify %s
      3 // RUN: %clang_cc1 -triple %itanium_abi_triple -include-pch %t -x objective-c++ -std=c++0x -ast-print %s | FileCheck -check-prefix=CHECK-PRINT %s
      4 // RUN: %clang_cc1 -triple %itanium_abi_triple -include-pch %t -x objective-c++ -std=c++0x -emit-llvm -o - %s | FileCheck -check-prefix=CHECK-IR %s
      5 
      6 // expected-no-diagnostics
      7 
      8 #ifndef HEADER
      9 #define HEADER
     10 
     11 typedef unsigned char BOOL;
     12 
     13 @interface NSNumber @end
     14 
     15 @interface NSNumber (NSNumberCreation)
     16 + (NSNumber *)numberWithChar:(char)value;
     17 + (NSNumber *)numberWithUnsignedChar:(unsigned char)value;
     18 + (NSNumber *)numberWithShort:(short)value;
     19 + (NSNumber *)numberWithUnsignedShort:(unsigned short)value;
     20 + (NSNumber *)numberWithInt:(int)value;
     21 + (NSNumber *)numberWithUnsignedInt:(unsigned int)value;
     22 + (NSNumber *)numberWithLong:(long)value;
     23 + (NSNumber *)numberWithUnsignedLong:(unsigned long)value;
     24 + (NSNumber *)numberWithLongLong:(long long)value;
     25 + (NSNumber *)numberWithUnsignedLongLong:(unsigned long long)value;
     26 + (NSNumber *)numberWithFloat:(float)value;
     27 + (NSNumber *)numberWithDouble:(double)value;
     28 + (NSNumber *)numberWithBool:(BOOL)value;
     29 @end
     30 
     31 @interface NSArray
     32 @end
     33 
     34 @interface NSArray (NSArrayCreation)
     35 + (id)arrayWithObjects:(const id [])objects count:(unsigned long)cnt;
     36 @end
     37 
     38 @interface NSDictionary
     39 + (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt;
     40 @end
     41 
     42 template<typename T, typename U>
     43 struct pair {
     44   T first;
     45   U second;
     46 };
     47 
     48 template<typename T, typename U>
     49 pair<T, U> make_pair(const T& first, const U& second) {
     50   return { first, second };
     51 }
     52 
     53 // CHECK-IR: define linkonce_odr void @_Z29variadic_dictionary_expansionIJP8NSStringS1_EJP8NSNumberS3_EEvDp4pairIT_T0_E
     54 template<typename ...Ts, typename ... Us>
     55 void variadic_dictionary_expansion(pair<Ts, Us>... key_values) {
     56   // CHECK-PRINT: id dict = @{ key_values.first : key_values.second... };
     57   // CHECK-IR: {{call.*objc_msgSend}}
     58   // CHECK-IR: ret void
     59   id dict = @{ key_values.first : key_values.second ... };
     60 }
     61 
     62 #else
     63 void test_all() {
     64   variadic_dictionary_expansion(make_pair(@"Seventeen", @17), 
     65                                 make_pair(@"YES", @true));
     66 }
     67 #endif
     68