Skip to content

Commit 1b17e33

Browse files
committed
AST: Handle MacroExpansionDecl in DeclExportabilityVisitor.
Instances of `MacroExpansionDecl` may be found in the AST when declarations are expanded from freestanding declaration macros and therefore exportability computations must be prepared to handle them. Resolves rdar://119449439
1 parent 32c2b43 commit 1b17e33

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

include/swift/AST/DeclExportabilityVisitor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ class DeclExportabilityVisitor
153153
UNREACHABLE(PoundDiagnostic);
154154
UNREACHABLE(Missing);
155155
UNREACHABLE(MissingMember);
156-
UNREACHABLE(MacroExpansion);
157156
UNREACHABLE(GenericTypeParam);
158157
UNREACHABLE(Param);
159158

@@ -172,6 +171,7 @@ class DeclExportabilityVisitor
172171
UNINTERESTING(PrecedenceGroup);
173172
UNINTERESTING(EnumCase);
174173
UNINTERESTING(Operator);
174+
UNINTERESTING(MacroExpansion);
175175

176176
#undef UNINTERESTING
177177
};
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// REQUIRES: swift_swift_parser, executable_test
2+
3+
// RUN: %empty-directory(%t)
4+
// RUN: %host-build-swift -swift-version 5 -emit-library -o %t/%target-library-name(MacroDefinition) -module-name=MacroDefinition %S/Inputs/syntax_macro_definitions.swift
5+
6+
// RUN: %target-swift-frontend -swift-version 5 -emit-module -o %t/freestanding_macro_library.swiftmodule %S/Inputs/freestanding_macro_library.swift -module-name freestanding_macro_library -load-plugin-library %t/%target-library-name(MacroDefinition)
7+
8+
// RUN: %target-swift-frontend -parse-as-library -emit-sil -load-plugin-library %t/%target-library-name(MacroDefinition) %s -module-name MacroUser -experimental-skip-non-exportable-decls | %FileCheck %s
9+
10+
@freestanding(declaration)
11+
macro anonymousTypes(public: Bool = false, causeErrors: Bool = false, _: () -> String) = #externalMacro(module: "MacroDefinition", type: "DefineAnonymousTypesMacro")
12+
13+
// CHECK: sil @$s9MacroUser03$s9A70User33_B2D49A1BE4DC7AF5CC327EB8EE2214BDLl14anonymousTypesfMf_4namefMu_C5helloSSyF : $@convention(method) (@guaranteed $s9MacroUser33_B2D49A1BE4DC7AF5CC327EB8EE2214BDLl14anonymousTypesfMf_4namefMu_) -> @owned String {
14+
#anonymousTypes(public: true) { "hello" }
15+
16+
// CHECK-NOT: s9MacroUser03$s9A71User33_B2D49A1BE4DC7AF5CC327EB8EE2214BDLl14anonymousTypesfMf_4namefMu0_O5helloSSyF
17+
#anonymousTypes(public: false) { "goodbye" }

0 commit comments

Comments
 (0)