[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / PCH / objc_literals.m
blob16ed6aeb9b9339a11f5696bfea15daf84aaff963
1 // UNSUPPORTED: target={{.*}}-zos{{.*}}, target={{.*}}-aix{{.*}}
2 // RUN: %clang_cc1 -emit-pch -o %t %s
3 // RUN: %clang_cc1 -include-pch %t -verify %s
4 // RUN: %clang_cc1 -include-pch %t -ast-print %s | FileCheck -check-prefix=CHECK-PRINT %s
5 // RUN: %clang_cc1 -include-pch %t -emit-llvm -o - %s | FileCheck -check-prefix=CHECK-IR %s
7 // expected-no-diagnostics
9 #ifndef HEADER
10 #define HEADER
12 typedef unsigned char BOOL;
14 @interface NSNumber @end
16 @interface NSNumber (NSNumberCreation)
17 + (NSNumber *)numberWithChar:(char)value;
18 + (NSNumber *)numberWithUnsignedChar:(unsigned char)value;
19 + (NSNumber *)numberWithShort:(short)value;
20 + (NSNumber *)numberWithUnsignedShort:(unsigned short)value;
21 + (NSNumber *)numberWithInt:(int)value;
22 + (NSNumber *)numberWithUnsignedInt:(unsigned int)value;
23 + (NSNumber *)numberWithLong:(long)value;
24 + (NSNumber *)numberWithUnsignedLong:(unsigned long)value;
25 + (NSNumber *)numberWithLongLong:(long long)value;
26 + (NSNumber *)numberWithUnsignedLongLong:(unsigned long long)value;
27 + (NSNumber *)numberWithFloat:(float)value;
28 + (NSNumber *)numberWithDouble:(double)value;
29 + (NSNumber *)numberWithBool:(BOOL)value;
30 @end
32 @interface NSArray
33 @end
35 @interface NSArray (NSArrayCreation)
36 + (id)arrayWithObjects:(const id [])objects count:(unsigned long)cnt;
37 @end
39 @interface NSDictionary
40 + (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt;
41 @end
43 // CHECK-IR: define internal {{.*}}void @test_numeric_literals()
44 static inline void test_numeric_literals(void) {
45   // CHECK-PRINT: id intlit = @17
46   // CHECK-IR: {{call.*17}}
47   id intlit = @17;
48   // CHECK-PRINT: id floatlit = @17.449999999999999
49   // CHECK-IR: {{call.*1.745}}
50   id floatlit = @17.45;
53 static inline void test_array_literals(void) {
54   // CHECK-PRINT: id arraylit = @[ @17, @17.449999999999999
55   id arraylit = @[@17, @17.45];
58 static inline void test_dictionary_literals(void) {
59   // CHECK-PRINT: id dictlit = @{ @17 : {{@17.449999999999999[^,]*}}, @"hello" : @"world" };
60   id dictlit = @{@17 : @17.45, @"hello" : @"world" };
63 #else
64 void test_all(void) {
65   test_numeric_literals();
66   test_array_literals();
67   test_dictionary_literals();
69 #endif