Skip to content

Commit 24d39f6

Browse files
authored
Merge pull request swiftlang#63257 from hborla/attached-macro-names
2 parents be00ae8 + 32a0705 commit 24d39f6

20 files changed

+35
-36
lines changed

include/swift/AST/MacroDeclaration.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ enum class MacroRole: uint32_t {
4848
MemberAttribute = 0x08,
4949
/// An attached macro that generates synthesized members
5050
/// inside the declaration.
51-
SynthesizedMembers = 0x10,
51+
Member = 0x10,
5252
};
5353

5454
/// The contexts in which a particular macro declaration can be used.

include/swift/Basic/SourceManager.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ class GeneratedSourceInfo {
4444
/// The expansion of a member attribute attached macro.
4545
MemberAttributeMacroExpansion,
4646

47-
/// The expansion of a synthesized member macro.
48-
SynthesizedMemberMacroExpansion,
47+
/// The expansion of an attached member macro.
48+
MemberMacroExpansion,
4949

5050
/// A new function body that is replacing an existing function body.
5151
ReplacedFunctionBody,

lib/AST/ASTMangler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3738,7 +3738,7 @@ void ASTMangler::appendMacroExpansionContext(
37383738

37393739
case GeneratedSourceInfo::AccessorMacroExpansion:
37403740
case GeneratedSourceInfo::MemberAttributeMacroExpansion:
3741-
case GeneratedSourceInfo::SynthesizedMemberMacroExpansion:
3741+
case GeneratedSourceInfo::MemberMacroExpansion:
37423742
case GeneratedSourceInfo::PrettyPrinted:
37433743
case GeneratedSourceInfo::ReplacedFunctionBody:
37443744
return appendContext(origDC, StringRef());

lib/AST/ASTScopeCreation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ ASTSourceFileScope::ASTSourceFileScope(SourceFile *SF,
260260
case MacroRole::MemberAttribute:
261261
parentLoc = expansion.getStartLoc();
262262
break;
263-
case MacroRole::SynthesizedMembers: {
263+
case MacroRole::Member: {
264264
// For synthesized member macros, take the end loc of the
265265
// enclosing declaration (before the closing brace), because
266266
// the macro expansion is inside this scope.

lib/AST/Decl.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9722,10 +9722,10 @@ StringRef swift::getMacroRoleString(MacroRole role) {
97229722
return "accessor";
97239723

97249724
case MacroRole::MemberAttribute:
9725-
return "memberAttributes";
9725+
return "memberAttribute";
97269726

9727-
case MacroRole::SynthesizedMembers:
9728-
return "synthesizedMembers";
9727+
case MacroRole::Member:
9728+
return "member";
97299729
}
97309730
}
97319731

@@ -9771,7 +9771,7 @@ static MacroRoles freestandingMacroRoles =
97719771
static MacroRoles attachedMacroRoles = (MacroRoles() |
97729772
MacroRole::Accessor |
97739773
MacroRole::MemberAttribute |
9774-
MacroRole::SynthesizedMembers);
9774+
MacroRole::Member);
97759775

97769776
bool swift::isFreestandingMacro(MacroRoles contexts) {
97779777
return bool(contexts & freestandingMacroRoles);
@@ -9924,7 +9924,7 @@ MacroDiscriminatorContext MacroDiscriminatorContext::getParentOf(
99249924

99259925
case GeneratedSourceInfo::AccessorMacroExpansion:
99269926
case GeneratedSourceInfo::MemberAttributeMacroExpansion:
9927-
case GeneratedSourceInfo::SynthesizedMemberMacroExpansion:
9927+
case GeneratedSourceInfo::MemberMacroExpansion:
99289928
case GeneratedSourceInfo::PrettyPrinted:
99299929
case GeneratedSourceInfo::ReplacedFunctionBody:
99309930
return origDC;

lib/AST/DeclContext.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -986,7 +986,7 @@ void IterableDeclContext::addMemberSilently(Decl *member, Decl *hint,
986986

987987
// Synthesized member macros can add new members in a macro expansion buffer.
988988
auto *memberSourceFile = member->getInnermostDeclContext()->getParentSourceFile();
989-
if (memberSourceFile->getFulfilledMacroRole() == MacroRole::SynthesizedMembers)
989+
if (memberSourceFile->getFulfilledMacroRole() == MacroRole::Member)
990990
return;
991991

992992
llvm::errs() << "Source ranges out of order in addMember():\n";

lib/AST/DiagnosticEngine.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1315,7 +1315,7 @@ std::vector<Diagnostic> DiagnosticEngine::getGeneratedSourceBufferNotes(
13151315
case GeneratedSourceInfo::FreestandingDeclMacroExpansion:
13161316
case GeneratedSourceInfo::AccessorMacroExpansion:
13171317
case GeneratedSourceInfo::MemberAttributeMacroExpansion:
1318-
case GeneratedSourceInfo::SynthesizedMemberMacroExpansion: {
1318+
case GeneratedSourceInfo::MemberMacroExpansion: {
13191319
SourceRange origRange = expansionNode.getSourceRange();
13201320
DeclName macroName;
13211321
if (auto customAttr = generatedInfo->attachedMacroCustomAttr) {

lib/AST/Module.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -915,8 +915,8 @@ Optional<MacroRole> SourceFile::getFulfilledMacroRole() const {
915915
case GeneratedSourceInfo::MemberAttributeMacroExpansion:
916916
return MacroRole::MemberAttribute;
917917

918-
case GeneratedSourceInfo::SynthesizedMemberMacroExpansion:
919-
return MacroRole::SynthesizedMembers;
918+
case GeneratedSourceInfo::MemberMacroExpansion:
919+
return MacroRole::Member;
920920

921921
case GeneratedSourceInfo::ReplacedFunctionBody:
922922
case GeneratedSourceInfo::PrettyPrinted:

lib/ASTGen/Sources/ASTGen/Macros.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ enum MacroRole: UInt8 {
3636
case FreestandingDeclaration = 0x02
3737
case Accessor = 0x04
3838
case MemberAttribute = 0x08
39-
case SynthesizedMembers = 0x10
39+
case Member = 0x10
4040
}
4141

4242
/// Resolve a reference to type metadata into a macro, if posible.
@@ -383,7 +383,7 @@ func expandAttachedMacro(
383383
$0.trimmedDescription
384384
}.joined(separator: " ")
385385

386-
case (let attachedMacro as MemberMacro.Type, .SynthesizedMembers):
386+
case (let attachedMacro as MemberMacro.Type, .Member):
387387
let members = try attachedMacro.expansion(
388388
of: customAttrNode,
389389
attachedTo: declarationNode,

lib/Basic/SourceLoc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ void SourceManager::setGeneratedSourceInfo(
321321
case GeneratedSourceInfo::FreestandingDeclMacroExpansion:
322322
case GeneratedSourceInfo::AccessorMacroExpansion:
323323
case GeneratedSourceInfo::MemberAttributeMacroExpansion:
324-
case GeneratedSourceInfo::SynthesizedMemberMacroExpansion:
324+
case GeneratedSourceInfo::MemberMacroExpansion:
325325
case GeneratedSourceInfo::PrettyPrinted:
326326
break;
327327

0 commit comments

Comments
 (0)