From 89deb3f041a1aa2e302b8cd778095ad2cac5e4d7 Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Tue, 15 May 2012 20:45:35 +0000 Subject: [PATCH] Add documentation about boxing enum types and a codegen test to make sure we pick up the underlying type, per suggestion by Fariborz. No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156851 91177308-0d34-0410-b5e6-96231b3b80d8 --- docs/ObjectiveCLiterals.html | 12 ++++++++++++ test/CodeGenObjC/boxing.m | 7 +++++++ 2 files changed, 19 insertions(+) diff --git a/docs/ObjectiveCLiterals.html b/docs/ObjectiveCLiterals.html index ca7704d0a2..33f73e4a5b 100644 --- a/docs/ObjectiveCLiterals.html +++ b/docs/ObjectiveCLiterals.html @@ -157,6 +157,18 @@ NSNumber *red = @(Red), *green = @(Green), *blue = @(Blue); // => [NSNumber numb then the fixed underlying type will be used to select the correct NSNumber creation method.

+

+Boxing a value of enum type will result in a NSNumber pointer with a creation method according to the underlying type of the enum, +which can be a fixed underlying type or a compiler-defined +integer type capable of representing the values of all the members of the enumeration: +

+ +
+typedef enum : unsigned char { Red, Green, Blue } Color;
+Color col = Red;
+NSNumber *nsCol = @(col); // => [NSNumber numberWithUnsignedChar:]
+
+

Boxed C Strings

diff --git a/test/CodeGenObjC/boxing.m b/test/CodeGenObjC/boxing.m index 3c24779f9a..9664298154 100644 --- a/test/CodeGenObjC/boxing.m +++ b/test/CodeGenObjC/boxing.m @@ -85,4 +85,11 @@ int main() { @((NSUInteger)i); // CHECK: load i8** [[stringWithUTF8StringSEL]] const char *s; @(s); + + typedef enum : NSInteger { Red, Green, Blue } Color; + // CHECK: load i8** [[WithIntegerSEL]] + @(Red); + Color col = Red; + // CHECK: load i8** [[WithIntegerSEL]] + @(col); } -- 2.40.0