[cxx-interop] Support bool-based enums.#34365
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.
You could simplify this a little bit by using dyn_cast_or_null.
varungandhi-apple
left a comment
There was a problem hiding this comment.
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
boolbranch 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.