4040#include "swift/Basic/SourceManager.h"
4141#include "swift/Basic/StringExtras.h"
4242#include "swift/Bridging/ASTGen.h"
43+ #include "swift/Bridging/Macros.h"
4344#include "swift/Demangling/Demangler.h"
4445#include "swift/Demangling/ManglingMacros.h"
4546#include "swift/Parse/Lexer.h"
@@ -121,7 +122,7 @@ MacroDefinition MacroDefinitionRequest::evaluate(
121122 ptrdiff_t *genericReplacements = nullptr;
122123 ptrdiff_t numGenericReplacements = 0;
123124
124- // Parse 'macro' decl in swift_ASTGen_checkMacroDefinition .
125+ // Parse 'macro' decl in swift_Macros_checkMacroDefinition .
125126 // NOTE: We don't use source->getExportedSourceFile() because it parses the
126127 // entire source buffer, which we don't want. Usually 'macro' decl is not in
127128 // the same file as the expansion, so we only want to parse only the decl.
@@ -133,16 +134,16 @@ MacroDefinition MacroDefinitionRequest::evaluate(
133134 SM.extractText(Lexer::getCharSourceRangeFromSourceRange(
134135 SM, macro->getSourceRangeIncludingAttrs()));
135136
136- auto checkResult = swift_ASTGen_checkMacroDefinition (
137+ auto checkResult = swift_Macros_checkMacroDefinition (
137138 &ctx.Diags, sourceFileText, macroDeclText, &externalMacroName,
138139 &replacements, &numReplacements, &genericReplacements,
139140 &numGenericReplacements);
140141
141142 // Clean up after the call.
142143 SWIFT_DEFER {
143144 swift_ASTGen_freeBridgedString(externalMacroName);
144- swift_ASTGen_freeExpansionReplacements (replacements, numReplacements);
145- // swift_ASTGen_freeExpansionGenericReplacements (genericReplacements, numGenericReplacements); // FIXME: !!!!!!
145+ swift_Macros_freeExpansionReplacements (replacements, numReplacements);
146+ // swift_Macros_freeExpansionGenericReplacements (genericReplacements, numGenericReplacements); // FIXME: !!!!!!
146147 };
147148
148149 if (checkResult < 0 && ctx.CompletionCallback) {
@@ -247,20 +248,20 @@ initializePlugin(ASTContext &ctx, CompilerPlugin *plugin, StringRef libraryPath,
247248 // But plugin loading is in libAST and it can't link ASTGen symbols.
248249 if (!plugin->isInitialized()) {
249250#if SWIFT_BUILD_SWIFT_SYNTAX
250- if (!swift_ASTGen_initializePlugin (plugin, &ctx.Diags)) {
251+ if (!swift_Macros_initializePlugin (plugin, &ctx.Diags)) {
251252 return llvm::createStringError(llvm::inconvertibleErrorCode(),
252253 "'%s' produced malformed response",
253254 plugin->getPath().data());
254255 }
255256
256257 // Resend the compiler capability on reconnect.
257258 auto *callback = new std::function<void(void)>([plugin]() {
258- (void)swift_ASTGen_initializePlugin (plugin, /*diags=*/nullptr);
259+ (void)swift_Macros_initializePlugin (plugin, /*diags=*/nullptr);
259260 });
260261 plugin->addOnReconnect(callback);
261262
262263 plugin->setCleanup([plugin, callback] {
263- swift_ASTGen_deinitializePlugin (plugin);
264+ swift_Macros_deinitializePlugin (plugin);
264265 delete callback;
265266 });
266267#endif
@@ -281,7 +282,7 @@ initializePlugin(ASTContext &ctx, CompilerPlugin *plugin, StringRef libraryPath,
281282 std::string moduleNameStr(moduleName.str());
282283
283284 BridgedStringRef bridgedErrorOut{nullptr, 0};
284- bool loaded = swift_ASTGen_pluginServerLoadLibraryPlugin (
285+ bool loaded = swift_Macros_pluginServerLoadLibraryPlugin (
285286 plugin, resolvedLibraryPathStr.c_str(), moduleNameStr.c_str(),
286287 &bridgedErrorOut);
287288
@@ -300,7 +301,7 @@ initializePlugin(ASTContext &ctx, CompilerPlugin *plugin, StringRef libraryPath,
300301 // Set a callback to load the library again on reconnections.
301302 auto *callback = new std::function<void(void)>(
302303 [plugin, resolvedLibraryPathStr, moduleNameStr]() {
303- (void)swift_ASTGen_pluginServerLoadLibraryPlugin (
304+ (void)swift_Macros_pluginServerLoadLibraryPlugin (
304305 plugin, resolvedLibraryPathStr.c_str(), moduleNameStr.c_str(),
305306 /*errorOut=*/nullptr);
306307 });
@@ -385,10 +386,10 @@ static ExternalMacroDefinition resolveExternalMacro(ASTContext &ctx,
385386 Identifier moduleName,
386387 Identifier typeName) {
387388#if SWIFT_BUILD_SWIFT_SYNTAX
388- if (auto *macro = swift_ASTGen_resolveExternalMacro (moduleName.get(),
389+ if (auto *macro = swift_Macros_resolveExternalMacro (moduleName.get(),
389390 typeName.get(), plugin)) {
390391 // Make sure we clean up after the macro.
391- ctx.addCleanup([macro]() { swift_ASTGen_destroyExternalMacro (macro); });
392+ ctx.addCleanup([macro]() { swift_Macros_destroyExternalMacro (macro); });
392393 return ExternalMacroDefinition::success(macro);
393394 }
394395 // NOTE: this is not reachable because executable macro resolution always
@@ -1163,7 +1164,7 @@ evaluateFreestandingMacro(FreestandingMacroExpansion *expansion,
11631164
11641165 BridgedStringRef evaluatedSourceOut{nullptr, 0};
11651166 assert(!externalDef.isError());
1166- swift_ASTGen_expandFreestandingMacro (
1167+ swift_Macros_expandFreestandingMacro (
11671168 &ctx.Diags, externalDef.get(), discriminator->c_str(),
11681169 getRawMacroRole(macroRole), astGenSourceFile,
11691170 expansion->getSourceRange().Start.getOpaquePointerValue(),
@@ -1487,7 +1488,7 @@ static SourceFile *evaluateAttachedMacro(MacroDecl *macro, Decl *attachedTo,
14871488
14881489 BridgedStringRef evaluatedSourceOut{nullptr, 0};
14891490 assert(!externalDef.isError());
1490- swift_ASTGen_expandAttachedMacro (
1491+ swift_Macros_expandAttachedMacro (
14911492 &ctx.Diags, externalDef.get(), discriminator->c_str(),
14921493 extendedType.c_str(), conformanceList.c_str(), getRawMacroRole(role),
14931494 astGenAttrSourceFile, attr->AtLoc.getOpaquePointerValue(),
0 commit comments