-
Notifications
You must be signed in to change notification settings - Fork 10.6k
🍒 [6.2] [Swiftify] Do not swiftify non-Swift-like counted_by exprs #81397
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
🍒 [6.2] [Swiftify] Do not swiftify non-Swift-like counted_by exprs #81397
Conversation
|
@swift-ci please test |
__counted_by (and __sized_by) expressions can have arbitrary C syntax
in them, such as:
void foo(int * __counted_by(*len) p, int *len);
When @_SwififyImport tries to generate Swift code for this, the
expression `*len` leads to a syntax error, since it isn't valid Swift.
This patch adds a check to ensure we only attach the Swiftify macro to
__counted_by expressions that are also syntactically valid in Swift.
rdar://150956352
(cherry picked from commit e5b1f4a)
b290743 to
8be78da
Compare
|
@swift-ci please test |
DougGregor
left a comment
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.
The naming issue isn't a critical one, we can deal with it on main.
| }; | ||
| } // namespace | ||
|
|
||
| static bool SwiftifiableCAT(const clang::CountAttributedType *CAT) { |
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.
Could we get some more descriptive names here? I see what "CAT" is an acronym for here, but it isn't quite discoverable. CountedByExpressionValidator, perhaps?
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.
Yeah that's a fair point! I'll address that in my PR on main.
| } // namespace | ||
|
|
||
| namespace { | ||
| /// Look for any side effects within a Stmt. |
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.
Oops, I just realized that I forgot to remove this stray comment that got copied over when I was setting up the StmtVisitor boilerplate 😮💨
Explanation: This patch adds a check to ensure we only attach the Swiftify macro to
__counted_byand__sized_byexpressions that are also syntactically valid in Swift.Issue: rdar://150956352
Risk: low
Testing: added tests
Original PRs: #81395
Reviewer: @hnrklssn