-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Macro declarations #62204
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
Macro declarations #62204
Conversation
07b4018
to
5b3c24f
Compare
@swift-ci please smoke test |
@swift-ci please test |
@swift-ci please smoke test |
@swift-ci please smoke test |
@swift-ci please smoke test |
1 similar comment
@swift-ci please smoke test |
#include "swift/Demangling/Demangle.h" | ||
#include "swift/Demangling/Demangler.h" |
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.
These are probably no longer needed.
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'll do this in a follow-up PR, thanks.
free(const_cast<void *>((const void *)returnedName.data())); | ||
kind = invokeKind(); | ||
} | ||
if ((&swift_conformsToProtocol == nullptr) || !protocolDescriptor) |
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.
Isn't &swift_conformsToProtocol
never null since it's either a local variable or an extern declaration? swift_conformsToProtocol
could be null.
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.
Ah... yeah, I got sloppy here. I'll fix it in a follow-up.
123490e
to
fa2ff3a
Compare
AARRGGGGHHHH silly conflict |
@swift-ci please smoke test |
Enable type checking support for explicitly specifying generic arguments to a macro, e.g., `#stringify<Double>(1 + 2)`. To do so, introduce a new kind of constraint that performs explicit argument matching against the generic parameters of a macro only after the overload is chosen.
…ion. A macro declaration contains the external module and type name of the macro's implementation. Use that information to find the macro type (via its type metadata accessor) in a loaded plugin, so we no longer require the "allMacros" array. Instead, each macro implementation type must be a public struct. Since we are now fully dependent on the macro declaration for everything about a macro except its kind, remove most of the query infrastructure for compiler plugins. Replace the macro registration scheme based on the allMacros array with
Don't look up the macro name again when doing expansion; that's already been done when we found the macro definition.
This approach works for both macros built into the compiler (e.g., the builtin macros) as well as those that are loaded via plugin but don't conform to the _CompilerPluginSupport protocol. This eliminates all uses of the `MacroSystem` itself in ASTGen, and pushes more of the implementation through ASTGen.
Although macro declarations never produce any symbols in the compiled binary, they can be referenced via USR, so introduce a mangling for them.
fa2ff3a
to
64f2c8e
Compare
@swift-ci please smoke test |
Introduce macro declarations and use them for the... declaration... of macros... with a way to specify the externally-provided definition of the macro. Macro declarations look like this:
With these macro declarations, we no longer need to query the macro implementation for the type signature, because it's all available in the source. Nor do we need
allMacros
to help us find macros, because the macro module and type name is specified in the definition.Macro declarations also make most of the other features one expects work easily, so wire up access control, code completion, and indexing in the process.