diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2012-05-15 20:45:35 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2012-05-15 20:45:35 +0000 |
commit | 89deb3f041a1aa2e302b8cd778095ad2cac5e4d7 (patch) | |
tree | 0893995529a1a679591c7194cff1e8d856fb50ea | |
parent | a63ef1f63f9c2ae847fac25534c9e1a214efabbc (diff) |
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
-rw-r--r-- | docs/ObjectiveCLiterals.html | 12 | ||||
-rw-r--r-- | test/CodeGenObjC/boxing.m | 7 |
2 files changed, 19 insertions, 0 deletions
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 <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> 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); } |