-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[ASTGen] Generate MacroDecl #77412
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
[ASTGen] Generate MacroDecl #77412
Conversation
64e5af9
to
bc64ff2
Compare
5cf4eb6
to
f8f3651
Compare
@swift-ci Please smoke test |
b01701b
to
643570b
Compare
@swift-ci Please smoke test |
643570b
to
210470e
Compare
@swift-ci Please smoke test |
210470e
to
f78ced2
Compare
@swift-ci Please smoke test |
include/swift/AST/ASTBridgingImpl.h
Outdated
case BridgedMacroRoleNone: | ||
break; | ||
} | ||
assert(false && "invalid macro role"); | ||
} |
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.
Will this compile in a no-asserts build? Should this be llvm_unreachable
instead?
let type = self.generate(type: node.attributeName) | ||
|
||
let argList: BridgedArgumentList? | ||
if let args = node.arguments { |
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.
if let args = node.arguments { | |
if let args = node.arguments { |
if !self.declContext.isLocalContext && initContext == nil { | ||
initContext = BridgedPatternBindingInitializer.create(declContext: self.declContext) | ||
} |
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.
This reminds me, currently we create these even when attached to non-PatternBindingDecls :( This crashes (rdar://100585434):
@attached(member)
macro M<T>(_ x: T) = #externalMacro(module: "", type: "")
@M({})
struct S {}
Not to be solved in this PR though 😄
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.
Huh. Do we only need it for PBD? If so, I think we should just pre-create PatternBindingInitializer
when generating PatternBindingDecl
if it has any attributes or initializers, and generate the attributes and the initializers with withDeclContext
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 believe we need some local context to contextualize closures for the non-PatternBindingDecl cases, but it can't be PatternBindingInitializer, we probably need a new kind of context (or maybe we could rework PatternBindingInitializer such that it doesn't assume it's on a PBD).
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 see let me leave this as is for now :)
f78ced2
to
f47c2b3
Compare
@swift-ci Please smoke test |
Also basic macro role attributes.