-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[cxx-interop] Support bool-based enums. #34365
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
@swift-ci please smoke test. |
e8e6de4
to
7546ea3
Compare
@swift-ci please smoke test and merge. |
1 similar comment
@swift-ci please smoke test and merge. |
@swift-ci please test Windows. |
1 similar comment
@swift-ci please test Windows. |
It looks like I'll need to switch back to my original implementation. Sometimes a user of |
If that's the case, please add a comment indicating why the APInt condition doesn't imply the Bool condition. Otherwise, someone reading the code later might have the same question that I had. |
@varungandhi-apple I've updated |
This is a small fix to prevent a crash. This change simply adds another condition for the "bool" branch that checks if "type" is associated with a "clang::EnumDecl" with an underlying type of "bool", and if so, treats "type" as a "Bool".
7546ea3
to
05faa07
Compare
@swift-ci please smoke test. |
4 similar comments
@swift-ci please smoke test. |
@swift-ci please smoke test. |
@swift-ci please smoke test. |
@swift-ci please smoke test. |
type->getStructOrBoundGenericStruct()->getClangDecl()) { | ||
if (auto enumDecl = dyn_cast<clang::EnumDecl>( | ||
type->getStructOrBoundGenericStruct()->getClangDecl())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could simplify this a little bit by using dyn_cast_or_null
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. This code is a bit longer than what you had earlier, but it seems much more understandable.
Testing again now that #34440 has landed. |
@swift-ci please smoke test and merge. |
1 similar comment
@swift-ci please smoke test and merge. |
This is a small fix to prevent a crash. This change simply adds another condition for the
bool
branch that checks if the APInt has a bit-width of1
.There are some big changes we should make in the future around enums. But, this patch is only to prevent a crash.