HomePhabricator

Add support for attribute enum_extensibility.

Description

Add support for attribute enum_extensibility.

This commit adds support for a new attribute that will be used to
distinguish between extensible and inextensible enums. There are three
main purposes of this attribute:

  1. Give better control over when enum-related warnings are issued.

For example, in the code below, clang will not issue a -Wassign-enum
warning if the enum is marked "open":

enum attribute((enum_extensibility(closed))) EnumClosed {

B0 = 1, B1 = 10

};

enum attribute((enum_extensibility(open))) EnumOpen {

C0 = 1, C1 = 10

};

enum EnumClosed ec = 100; warning issued
enum EnumOpen eo = 100;
no warning

  1. Enable code-completion and debugging tools to offer better

suggestions.

  1. Make it easier for swift's clang importer to determine which swift

type an enum should be mapped to.

For more details, see the discussion I started on cfe-dev:
http://lists.llvm.org/pipermail/cfe-dev/2017-February/052748.html

rdar://problem/12764379
rdar://problem/23145650

Differential Revision: https://reviews.llvm.org/D30766

Details

Committed
ahatanakMar 20 2017, 7:23 PM
Differential Revision
D30766: Add support for attribute "enum_extensibility"
Parents
rL298331: FindTypes should find "struct TypeName" as well as "TypeName".
Branches
Unknown
Tags
Unknown