diff options
author | Akira Hatanaka <ahatanaka@apple.com> | 2017-03-21 02:23:00 +0000 |
---|---|---|
committer | Akira Hatanaka <ahatanaka@apple.com> | 2017-03-21 02:23:00 +0000 |
commit | 18021952cce94fde55068790887992c1c9e0e2e8 (patch) | |
tree | da4768b15b3b03e0537c7846cc457b663b838c88 /include/clang/Basic/Attr.td | |
parent | 5f5f6d1226b8977ca12b009bb82ed983653d4ac3 (diff) |
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
2. Enable code-completion and debugging tools to offer better
suggestions.
3. 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
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@298332 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Basic/Attr.td')
-rw-r--r-- | include/clang/Basic/Attr.td | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/include/clang/Basic/Attr.td b/include/clang/Basic/Attr.td index 5960cca1e7..ff62e10f8a 100644 --- a/include/clang/Basic/Attr.td +++ b/include/clang/Basic/Attr.td @@ -881,7 +881,15 @@ def FlagEnum : InheritableAttr { let Spellings = [GNU<"flag_enum">]; let Subjects = SubjectList<[Enum]>; let Documentation = [FlagEnumDocs]; - let LangOpts = [COnly]; +} + +def EnumExtensibility : InheritableAttr { + let Spellings = [GNU<"enum_extensibility">, + CXX11<"clang", "enum_extensibility">]; + let Subjects = SubjectList<[Enum]>; + let Args = [EnumArgument<"Extensibility", "Kind", + ["closed", "open"], ["Closed", "Open"]>]; + let Documentation = [EnumExtensibilityDocs]; } def Flatten : InheritableAttr { |