Skip to content

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

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
merged 1 commit into from
May 3, 2022

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented May 2, 2022

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

CC @Regno

…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 requested a review from bnbarham May 2, 2022 13:52
@ahoppen
Copy link
Member Author

ahoppen commented May 2, 2022

@swift-ci Please smoke test

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.

2 participants