Revert "[llvm] Improve llvm.objectsize computation by computing GEP, alloca and mallo...
[llvm-project.git] / clang / test / Rewriter / objc-modern-numeric-literal.mm
blob3c7582a3e4d2a99b83e752d35b208b260f777e1b
1 // RUN: %clang_cc1 -E %s -o %t.mm
2 // RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %t.mm -o - | FileCheck %s 
4 extern "C" void *sel_registerName(const char *);
6 typedef bool BOOL;
7 typedef long NSInteger;
8 typedef unsigned long NSUInteger;
10 #if __has_feature(objc_bool)
11 #define YES             __objc_yes
12 #define NO              __objc_no
13 #else
14 #define YES             ((BOOL)1)
15 #define NO              ((BOOL)0)
16 #endif
18 @interface NSNumber
19 + (NSNumber *)numberWithChar:(char)value;
20 + (NSNumber *)numberWithUnsignedChar:(unsigned char)value;
21 + (NSNumber *)numberWithShort:(short)value;
22 + (NSNumber *)numberWithUnsignedShort:(unsigned short)value;
23 + (NSNumber *)numberWithInt:(int)value;
24 + (NSNumber *)numberWithUnsignedInt:(unsigned int)value;
25 + (NSNumber *)numberWithLong:(long)value;
26 + (NSNumber *)numberWithUnsignedLong:(unsigned long)value;
27 + (NSNumber *)numberWithLongLong:(long long)value;
28 + (NSNumber *)numberWithUnsignedLongLong:(unsigned long long)value;
29 + (NSNumber *)numberWithFloat:(float)value;
30 + (NSNumber *)numberWithDouble:(double)value;
31 + (NSNumber *)numberWithBool:(BOOL)value;
32 + (NSNumber *)numberWithInteger:(NSInteger)value ;
33 + (NSNumber *)numberWithUnsignedInteger:(NSUInteger)value ;
34 @end
36 int main(int argc, const char *argv[]) {
37   // character literals.
38   NSNumber *theLetterZ = @'Z';          // equivalent to [NSNumber numberWithChar:'Z']
40   // integral literals.
41   NSNumber *fortyTwo = @42;             // equivalent to [NSNumber numberWithInt:42]
42   NSNumber *fortyTwoUnsigned = @42U;    // equivalent to [NSNumber numberWithUnsignedInt:42U]
43   NSNumber *fortyTwoLong = @42L;        // equivalent to [NSNumber numberWithLong:42L]
44   NSNumber *fortyTwoLongLong = @42LL;   // equivalent to [NSNumber numberWithLongLong:42LL]
46   // floating point literals.
47   NSNumber *piFloat = @3.141592654F;    // equivalent to [NSNumber numberWithFloat:3.141592654F]
48   NSNumber *piDouble = @3.1415926535;   // equivalent to [NSNumber numberWithDouble:3.1415926535]
50   // BOOL literals.
51   NSNumber *yesNumber = @YES;           // equivalent to [NSNumber numberWithBool:YES]
52   NSNumber *noNumber = @NO;             // equivalent to [NSNumber numberWithBool:NO]
54   NSNumber *trueNumber = @true;         // equivalent to [NSNumber numberWithBool:(BOOL)true]
55   NSNumber *falseNumber = @false;       // equivalent to [NSNumber numberWithBool:(BOOL)false]
58 // CHECK:  NSNumber *theLetterZ = ((NSNumber *(*)(Class, SEL, char))(void *)objc_msgSend)(objc_getClass("NSNumber"), sel_registerName("numberWithChar:"), 'Z');
59 // CHECK:  NSNumber *fortyTwo = ((NSNumber *(*)(Class, SEL, int))(void *)objc_msgSend)(objc_getClass("NSNumber"), sel_registerName("numberWithInt:"), 42);
60 // CHECK:  NSNumber *fortyTwoUnsigned = ((NSNumber *(*)(Class, SEL, unsigned int))(void *)objc_msgSend)(objc_getClass("NSNumber"), sel_registerName("numberWithUnsignedInt:"), 42U);
61 // CHECK:  NSNumber *fortyTwoLong = ((NSNumber *(*)(Class, SEL, long))(void *)objc_msgSend)(objc_getClass("NSNumber"), sel_registerName("numberWithLong:"), 42L);
62 // CHECK:  NSNumber *fortyTwoLongLong = ((NSNumber *(*)(Class, SEL, long long))(void *)objc_msgSend)(objc_getClass("NSNumber"), sel_registerName("numberWithLongLong:"), 42LL);
63 // CHECK:  NSNumber *piFloat = ((NSNumber *(*)(Class, SEL, float))(void *)objc_msgSend)(objc_getClass("NSNumber"), sel_registerName("numberWithFloat:"), 3.14159274F);
64 // CHECK:  NSNumber *piDouble = ((NSNumber *(*)(Class, SEL, double))(void *)objc_msgSend)(objc_getClass("NSNumber"), sel_registerName("numberWithDouble:"), 3.1415926535000001);
65 // CHECK:  NSNumber *yesNumber = ((NSNumber *(*)(Class, SEL, BOOL))(void *)objc_msgSend)(objc_getClass("NSNumber"), sel_registerName("numberWithBool:"), true);
66 // CHECK:  NSNumber *noNumber = ((NSNumber *(*)(Class, SEL, BOOL))(void *)objc_msgSend)(objc_getClass("NSNumber"), sel_registerName("numberWithBool:"), false);
67 // CHECK:  NSNumber *trueNumber = ((NSNumber *(*)(Class, SEL, BOOL))(void *)objc_msgSend)(objc_getClass("NSNumber"), sel_registerName("numberWithBool:"), true);
68 // CHECK:  NSNumber *falseNumber = ((NSNumber *(*)(Class, SEL, BOOL))(void *)objc_msgSend)(objc_getClass("NSNumber"), sel_registerName("numberWithBool:"), false);