Skip to content

[5.7][Refactoring] Fix a crash that occurred when converting if/else of enum with raw value to switch statement #58635

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

Merged

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented May 3, 2022

Cherry-pick #58611 to release/5.7


…um with raw value to switch statement

If the enum has a raw value, `E` passed in to `BinaryExpr` is a `DeclRefExpr`, not a `DotSyntaxCallExpr`, so we crashed on `dyn_cast<DotSyntaxCallExpr>(E->getFn())->getFn()`.

Only look through `DotSyntaxCallExpr` if `E` is indeed a `DotSyntaxCallExpr`. While at it, fix a few other potential sources of nullptr crashes.

rdar://84707973
@ahoppen ahoppen added the r5.7 label May 3, 2022
@ahoppen ahoppen requested a review from a team as a code owner May 3, 2022 07:42
@ahoppen
Copy link
Member Author

ahoppen commented May 3, 2022

@swift-ci Please test

@ahoppen ahoppen merged commit f3beedf into swiftlang:release/5.7 May 6, 2022
@ahoppen ahoppen deleted the pr-5.7/fix-switch-refactoring branch May 6, 2022 17:28
@AnthonyLatsis AnthonyLatsis added 🍒 release cherry pick Flag: Release branch cherry picks swift 5.7 labels Jan 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍒 release cherry pick Flag: Release branch cherry picks swift 5.7
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants