mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[Macros] Top-level freestanding macros (#63553)
Allow freestanding macros to be used at top-level. - Parse top-level `#…` as `MacroExpansionDecl` when we are not in scripting mode. - Add macro expansion decls to the source lookup cache with name-driven lazy expansion. Not supporting arbitrary name yet. - Experimental support for script mode and brace-level declaration macro expansions: When type-checking a `MacroExpansionExpr`, assign it a substitute `MacroExpansionDecl` if the macro reference resolves to a declaration macro. This doesn’t work quite fully yet and will be enabled in a future fix.
This commit is contained in:
@@ -2246,7 +2246,7 @@ static uint8_t getRawStableMacroRole(swift::MacroRole context) {
|
||||
}
|
||||
#undef CASE
|
||||
llvm_unreachable("bad result declaration macro kind");
|
||||
}
|
||||
}
|
||||
|
||||
static uint8_t getRawStableMacroIntroducedDeclNameKind(
|
||||
swift::MacroIntroducedDeclNameKind kind) {
|
||||
@@ -6133,7 +6133,7 @@ void Serializer::writeAST(ModuleOrSourceFile DC) {
|
||||
|
||||
// FIXME: Switch to a visitor interface?
|
||||
SmallVector<Decl *, 32> fileDecls;
|
||||
nextFile->getTopLevelDecls(fileDecls);
|
||||
nextFile->getTopLevelDeclsWithAuxiliaryDecls(fileDecls);
|
||||
|
||||
for (auto D : fileDecls) {
|
||||
if (isa<ImportDecl>(D) || isa<IfConfigDecl>(D) ||
|
||||
|
||||
Reference in New Issue
Block a user