-
Notifications
You must be signed in to change notification settings - Fork 333
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
Add support for availability-style features #9815
base: next
Are you sure you want to change the base?
Conversation
9c6c6b4
to
6b1eb91
Compare
db3f142
to
e959883
Compare
@swift-ci please smoke test |
e959883
to
ffd2237
Compare
clang/lib/AST/StmtPrinter.cpp
Outdated
@@ -630,6 +630,10 @@ void StmtPrinter::VisitObjCAvailabilityCheckExpr( | |||
OS << "@available(...)"; | |||
} | |||
|
|||
void StmtPrinter::VisitObjCFeatureCheckExpr(ObjCFeatureCheckExpr *Node) { | |||
OS << "@feature(...)"; |
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.
I think the body was elided on @available(...)
because the AST doesn't retain full fidelity of the availability check and instead it drops the other platforms. Do we have that same problem with @feature()
? If not, I think this should print the actual feature too, so you can write a test that checks it round-trips through serialization.
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.
I've changed this to use @available
instead of introducing a new keyword but haven't made any changes to StmtPrinter
yet.
@@ -3999,6 +4008,23 @@ std::optional<AvailabilitySpec> Parser::ParseAvailabilitySpec() { | |||
Actions.CodeCompletion().CodeCompleteAvailabilityPlatformName(); | |||
return std::nullopt; | |||
} | |||
|
|||
if (Tok.is(tok::identifier) && GetLookAheadToken(1).is(tok::equal)) { |
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.
Can you make it tok::colon
instead? I think it's too late to change the feat:
one, and it would be nice if they matched.
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.
Yes, domain:feature1
would be okay too.
rdar://137999979
ffd2237
to
cd0efbe
Compare
rdar://137999979