Skip to content

[ClangImporter] Classify enums using flag_enum and enum_extensibility #8910

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

jrose-apple
Copy link
Contributor

These new Clang attributes identify whether an enum is intended to represent an option set or not, and whether the set of cases listed in the enum declaration is exhaustive. (Swift doesn't currently have a closed/open distinction for enums, so treat any C enum with enum_extensibility as a proper closed Swift enum, like we do with NS_ENUM.)

Enums with neither attribute will continue to be imported as unique types.

rdar://problem/28476618

These new Clang attributes identify whether an enum is intended to
represent an option set or not, and whether the set of cases listed in
the enum declaration is exhaustive. (Swift doesn't currently have a
closed/open distinction for enums, so treat any C enum with
enum_extensibility as a proper closed Swift enum, like we do with
NS_ENUM.)

Enums with neither attribute will continue to be imported as unique
types.

rdar://problem/28476618
@jrose-apple
Copy link
Contributor Author

apple/swift-clang#80
@swift-ci Please test

@jrose-apple
Copy link
Contributor Author

There's still follow-up work here as well to allow API notes to undo the effect of NS_ENUM.

@jrose-apple
Copy link
Contributor Author

Actually, I guess this particular commit doesn't rely on API notes at all. That would be something for the follow-up.

@jrose-apple jrose-apple merged commit a03c40c into swiftlang:master Apr 21, 2017
@jrose-apple jrose-apple deleted the respect-flag_enum-and-enum_extensibility branch April 21, 2017 15:57
jrose-apple added a commit to jrose-apple/swift that referenced this pull request Apr 25, 2017
…swiftlang#8910)

These new Clang attributes identify whether an enum is intended to
represent an option set or not, and whether the set of cases listed in
the enum declaration is exhaustive. (Swift doesn't currently have a
closed/open distinction for enums, so treat any C enum with
enum_extensibility as a proper closed Swift enum, like we do with
NS_ENUM.)

Enums with neither attribute will continue to be imported as unique
types.

rdar://problem/28476618
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant