Ted Kremenek | ebcb57a | 2012-03-06 20:05:56 +0000 | [diff] [blame^] | 1 | // RUN: %clang -cc1 -emit-pch -x objective-c++ -std=c++0x -o %t %s |
| 2 | // RUN: %clang -cc1 -include-pch %t -x objective-c++ -std=c++0x -verify %s |
| 3 | // RUN: %clang -cc1 -include-pch %t -x objective-c++ -std=c++0x -ast-print %s | FileCheck -check-prefix=PRINT %s |
| 4 | // RUN: %clang -cc1 -include-pch %t -x objective-c++ -std=c++0x -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 | template<typename T, typename U> |
| 41 | struct pair { |
| 42 | T first; |
| 43 | U second; |
| 44 | }; |
| 45 | |
| 46 | template<typename T, typename U> |
| 47 | pair<T, U> make_pair(const T& first, const U& second) { |
| 48 | return { first, second }; |
| 49 | } |
| 50 | |
| 51 | // CHECK-IR: define linkonce_odr void @_Z29variadic_dictionary_expansionIJP8NSStringS1_EJP8NSNumberS3_EEvDp4pairIT_T0_E |
| 52 | template<typename ...Ts, typename ... Us> |
| 53 | void variadic_dictionary_expansion(pair<Ts, Us>... key_values) { |
| 54 | // CHECK-PRINT: id dict = @{ key_values.first : key_values.second... }; |
| 55 | // CHECK-IR: {{call.*objc_msgSend}} |
| 56 | // CHECK-IR: ret void |
| 57 | id dict = @{ key_values.first : key_values.second ... }; |
| 58 | } |
| 59 | |
| 60 | #else |
| 61 | void test_all() { |
| 62 | variadic_dictionary_expansion(make_pair(@"Seventeen", @17), |
| 63 | make_pair(@"YES", @true)); |
| 64 | } |
| 65 | #endif |