Skip to content
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

Swift: CFG and data flow for nil coalescing operator #14224

Merged
merged 8 commits into from
Oct 4, 2023

Conversation

rdmarsh2
Copy link
Contributor

No description provided.

@rdmarsh2 rdmarsh2 requested a review from a team as a code owner September 14, 2023 16:40
@github-actions github-actions bot added the Swift label Sep 14, 2023
Copy link
Contributor

@geoffw0 geoffw0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fast work, and LGTM!

Probably deserves a short change note and a DCA run.

Copy link

@Lizzyrobin4 Lizzyrobin4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Ok approved

@geoffw0
Copy link
Contributor

geoffw0 commented Sep 18, 2023

The DCA run shows 4 lost results, on lines that use ?. but not ?? - though ?? is used earlier in the function. I've checked locally and this effect is real, and the direct cause is excluding NilCoalescingExpr from ApplyExprTree.

(there's also missing QLDoc in NilCoalescingExpr.qll)

@rdmarsh2
Copy link
Contributor Author

I think the actual cause is that one of the last nodes for ?? has an EmptinessCompletion, but the context requires a BooleanCompletion. The result is that there's only control flow out of the empty branch.

Fixes an issue where a nil-coalescing operation used in a boolean
context would result in no control flow out of the default operand of
the nil-coalescing operator.
geoffw0
geoffw0 previously approved these changes Oct 3, 2023
Copy link
Contributor

@geoffw0 geoffw0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes LGTM. The new DCA run LGTM also. 👍

geoffw0
geoffw0 previously approved these changes Oct 3, 2023
Copy link
Contributor

@MathiasVP MathiasVP left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Contributor

@geoffw0 geoffw0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. 😃

@rdmarsh2 rdmarsh2 merged commit f7ca8e5 into github:main Oct 4, 2023
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants