-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Macros] Type check user-defined macro plugins #61861
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
Conversation
swiftlang/swift-syntax#1042 |
3fbb42d
to
dc35c4b
Compare
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.
LGTM, I think there's some follow-up I'd like to do, but this is ready to land.
if (builtinMacro) { | ||
const char *evaluatedSourcePtr; | ||
ptrdiff_t evaluatedSourceLength; | ||
swift_ASTGen_getMacroTypeSignature(builtinMacro, &evaluatedSourcePtr, |
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's interesting how we have similar code on both sides of the C++ divide. I want to think about this more.
lib/Sema/TypeCheckMacros.cpp
Outdated
nullptr); | ||
parser.consumeTokenWithoutFeedingReceiver(); | ||
SmallVector<Decl *, 1> decls; | ||
parser.parseTopLevel(decls); |
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.
Hmm. I'd like to move toward using the new parser here, because we can.
@@ -7,5 +7,8 @@ | |||
// FIXME: Swift parser is not enabled on Linux CI yet. | |||
// REQUIRES: OS=macosx | |||
|
|||
let (result, code) = #customStringify(3 + 2 - 1) | |||
print(result, code) | |||
print(#customStringify(3 + 2 - 1)) |
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.
Should we FileCheck the output 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.
Will do
Do we know what this entails? Is it because |
swiftlang/swift-syntax#1042 |
On Windows we should call
... but it's not in public headers. I think the right thing to do is to copy |
swiftlang/swift-syntax#1042 |
swiftlang/swift-syntax#1042 |
I think that we should just directly use |
Ok. We won't be able to test it in a meaningful way though, because |
swiftlang/swift-syntax#1042 |
Hmm, while we cannot use the swift-parser for official builds, we should be able to try to enable that for the CI tests ... |
Type check user-defined macros plugins with user-provided type signatures. Also, load plugin libraries with `RTLD_LOCAL` instead of `RTLD_GLOBAL` to prevent symbol collision between plugins. `llvm::sys::DynamicLibrary` only supports `RTLD_GLOBAL` so we use plain the `dlopen` instead. This does not work on Windows and needs to be fixed.
dc35c4b
to
c41ca94
Compare
swiftlang/swift-syntax#1042 |
swiftlang/swift-syntax#1042 |
Implement `_genericSignature` and `_typeSignature` requirements in `_CompilerPlugin`. This enables type checking for macro plugins. Friend PR: swiftlang/swift#61861
Type check user-defined macros plugins with user-provided type signatures. Also, load plugin libraries with `RTLD_LOCAL` instead of `RTLD_GLOBAL` to prevent symbol collision between plugins. `llvm::sys::DynamicLibrary` only supports `RTLD_GLOBAL` so we use the plain `dlopen` instead. This does not work on Windows and needs to be fixed. Friend PR: swiftlang/swift-syntax#1042
Type check user-defined macros plugins with user-provided type signatures.
Also, load plugin libraries with
RTLD_LOCAL
instead ofRTLD_GLOBAL
to prevent symbol collision between plugins.llvm::sys::DynamicLibrary
only supportsRTLD_GLOBAL
so we use the plaindlopen
instead. This does not work on Windows and needs to be fixed.Friend PR: swiftlang/swift-syntax#1042