[cfe-commits] r156851 - in /cfe/trunk: docs/ObjectiveCLiterals.html test/CodeGenObjC/boxing.m

Argyrios Kyrtzidis akyrtzi at gmail.com
Tue May 15 13:45:35 PDT 2012


Author: akirtzidis
Date: Tue May 15 15:45:35 2012
New Revision: 156851

URL: http://llvm.org/viewvc/llvm-project?rev=156851&view=rev
Log:
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.

Modified:
    cfe/trunk/docs/ObjectiveCLiterals.html
    cfe/trunk/test/CodeGenObjC/boxing.m

Modified: cfe/trunk/docs/ObjectiveCLiterals.html
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ObjectiveCLiterals.html?rev=156851&r1=156850&r2=156851&view=diff
==============================================================================
--- cfe/trunk/docs/ObjectiveCLiterals.html (original)
+++ cfe/trunk/docs/ObjectiveCLiterals.html Tue May 15 15:45:35 2012
@@ -157,6 +157,18 @@
 then the fixed underlying type will be used to select the correct <code>NSNumber</code> creation method.
 </p>
 
+<p>
+Boxing a value of enum type will result in a <code>NSNumber</code> pointer with a creation method according to the underlying type of the enum,
+which can be a <a href="http://clang.llvm.org/docs/LanguageExtensions.html#objc_fixed_enum">fixed underlying type</a> or a compiler-defined
+integer type capable of representing the values of all the members of the enumeration:
+</p>
+
+<pre>
+typedef enum : unsigned char { Red, Green, Blue } Color;
+Color col = Red;
+NSNumber *nsCol = @(col); // => [NSNumber numberWithUnsignedChar:]
+</pre>
+
 <h3>Boxed C Strings</h3>
 
 <p>

Modified: cfe/trunk/test/CodeGenObjC/boxing.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/boxing.m?rev=156851&r1=156850&r2=156851&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenObjC/boxing.m (original)
+++ cfe/trunk/test/CodeGenObjC/boxing.m Tue May 15 15:45:35 2012
@@ -85,4 +85,11 @@
   @((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);
 }





More information about the cfe-commits mailing list