-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Swiftify] Adjust _SwiftifyImport invocation to align with the signature #81855
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
base: main
Are you sure you want to change the base?
Conversation
of the macro in the currently laoded macro module Stdlib macros are shipped with the SDK, so we need to make sure that the way we invoke the macro matches the version of the macro in the SDK. This patch skips the `spanAvailability` parameter if it isn't present. There's no good way to test this, because we will always pick up the current macro in our llvm-lit test suite, but I've tested it manually. rdar://152278292
@swift-ci please smoke test |
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.
Couple questions inline, otherwise looks good to me.
assert(SwiftifyImportDecl); | ||
if (!SwiftifyImportDecl) | ||
return false; | ||
for (auto *Param : *SwiftifyImportDecl->parameterList) |
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 this be replaced with llvm::find_if
or something similar?
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.
It could be replaced with any_of
, but it wouldn't really be any easier to read imo (nor more concise), and is a bit more annoying to debug with the jumping between stack frames
bool hasMacroParameter(StringRef ParamName) { | ||
ValueDecl *D = getDecl("_SwiftifyImport"); | ||
auto *SwiftifyImportDecl = dyn_cast_or_null<MacroDecl>(D); | ||
assert(SwiftifyImportDecl); |
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 the compiler ever be used with on old enough SDK that does not have this macro? Or could the compiler be used without the SDK at all? If yes, maybe we don't want to assert here.
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 that's the case I think we have bigger issues: the macro will still be attached. This only handles whether to use the new or old signature. But it's a good point. @DougGregor what's our stance on using this with an SDK that doesn't contain the macro at all?
of the macro in the currently laoded macro module
Stdlib macros are shipped with the SDK, so we need to make sure that the way we invoke the macro matches the version of the macro in the SDK. This patch skips the
spanAvailability
parameter if it isn't present. There's no good way to test this, because we will always pick up the current macro in our llvm-lit test suite, but I've tested it manually.rdar://152278292