[Macros] Add mangling for attached macro expansion.

Extend the name mangling scheme for macro expansions to cover attached
macros, and use that scheme for the names of macro expansions buffers.

Finishes rdar://104038303, stabilizing file/buffer names for macro
expansion buffers.
This commit is contained in:
Doug Gregor
2023-02-03 13:30:16 -08:00
parent 168027b6bd
commit b63fa566ec
13 changed files with 238 additions and 45 deletions

View File

@@ -340,6 +340,7 @@ private:
case Node::Kind::PackExpansion:
case Node::Kind::ProtocolListWithClass:
case Node::Kind::AccessorAttachedMacroExpansion:
case Node::Kind::AccessorFunctionReference:
case Node::Kind::Allocator:
case Node::Kind::ArgumentTuple:
@@ -442,6 +443,8 @@ private:
case Node::Kind::Macro:
case Node::Kind::MacroExpansionUniqueName:
case Node::Kind::MaterializeForSet:
case Node::Kind::MemberAttributeAttachedMacroExpansion:
case Node::Kind::MemberAttachedMacroExpansion:
case Node::Kind::MergedFunction:
case Node::Kind::Metaclass:
case Node::Kind::MethodDescriptor:
@@ -1338,10 +1341,22 @@ NodePointer NodePrinter::print(NodePointer Node, unsigned depth,
Node->getNumChildren() == 3? TypePrinting::WithColon
: TypePrinting::FunctionStyle,
/*hasName*/ true);
case Node::Kind::AccessorAttachedMacroExpansion:
return printEntity(Node, depth, asPrefixContext, TypePrinting::NoType,
/*hasName*/true, "accessor macro expansion #",
(int)Node->getChild(2)->getIndex() + 1);
case Node::Kind::FreestandingMacroExpansion:
return printEntity(Node, depth, asPrefixContext, TypePrinting::NoType,
/*hasName*/true, "freestanding macro expansion #",
(int)Node->getChild(2)->getIndex() + 1);
case Node::Kind::MemberAttributeAttachedMacroExpansion:
return printEntity(Node, depth, asPrefixContext, TypePrinting::NoType,
/*hasName*/true, "member attribute macro expansion #",
(int)Node->getChild(2)->getIndex() + 1);
case Node::Kind::MemberAttachedMacroExpansion:
return printEntity(Node, depth, asPrefixContext, TypePrinting::NoType,
/*hasName*/true, "member macro expansion #",
(int)Node->getChild(2)->getIndex() + 1);
case Node::Kind::MacroExpansionUniqueName:
return printEntity(Node, depth, asPrefixContext, TypePrinting::NoType,
/*hasName*/true, "unique name #",