Skip to content

Commit bbbc346

Browse files
committed
[Macros] Treat MacroDecl as a local context, like functions are.
1 parent d9f5aa0 commit bbbc346

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

include/swift/AST/DeclContext.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,14 @@ enum class DeclContextKind : unsigned {
9494
EnumElementDecl,
9595
AbstractFunctionDecl,
9696
SerializedLocal,
97-
Last_LocalDeclContextKind = SerializedLocal,
97+
MacroDecl,
98+
Last_LocalDeclContextKind = MacroDecl,
9899

99100
Module,
100101
FileUnit,
101102
GenericTypeDecl,
102103
ExtensionDecl,
103-
MacroDecl,
104-
Last_DeclContextKind = MacroDecl
104+
Last_DeclContextKind = ExtensionDecl
105105
};
106106

107107
/// Kinds of DeclContexts after deserialization.

lib/AST/ASTMangler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2381,7 +2381,7 @@ void ASTMangler::appendContext(const DeclContext *ctx, StringRef useModuleName)
23812381
return appendContext(ctx->getParent(), useModuleName);
23822382

23832383
case DeclContextKind::MacroDecl:
2384-
llvm_unreachable("macro declarations are never mangled");
2384+
return appendContext(ctx->getParent(), useModuleName);
23852385
}
23862386

23872387
llvm_unreachable("bad decl context");

lib/Serialization/Serialization.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,8 @@ static ModuleDecl *getModule(ModuleOrSourceFile DC) {
485485

486486
static bool shouldSerializeAsLocalContext(const DeclContext *DC) {
487487
return DC->isLocalContext() && !isa<AbstractFunctionDecl>(DC) &&
488-
!isa<SubscriptDecl>(DC) && !isa<EnumElementDecl>(DC);
488+
!isa<SubscriptDecl>(DC) && !isa<EnumElementDecl>(DC) &&
489+
!isa<MacroDecl>(DC);
489490
}
490491

491492
namespace {

0 commit comments

Comments
 (0)