Skip to content

Commit 3c68c20

Browse files
committed
AST: Handle TopLevelCodeDecl in DeclExportabilityVisitor.
1 parent a038f7d commit 3c68c20

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

include/swift/AST/DeclExportabilityVisitor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@ class DeclExportabilityVisitor
149149
return true; \
150150
}
151151
UNREACHABLE(Module);
152-
UNREACHABLE(TopLevelCode);
153152
UNREACHABLE(Missing);
154153
UNREACHABLE(MissingMember);
155154
UNREACHABLE(GenericTypeParam);
@@ -165,6 +164,7 @@ class DeclExportabilityVisitor
165164
// context has already been checked.
166165
#define UNINTERESTING(KIND) \
167166
bool visit##KIND##Decl(const KIND##Decl *D) { return true; }
167+
UNINTERESTING(TopLevelCode);
168168
UNINTERESTING(IfConfig);
169169
UNINTERESTING(Import);
170170
UNINTERESTING(PoundDiagnostic);
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-swift-frontend -emit-silgen %s -module-name Test | %FileCheck %s --check-prefixes=CHECK,CHECK-NO-SKIP
3+
// RUN: %target-swift-frontend -emit-silgen %s -module-name Test -experimental-skip-non-exportable-decls | %FileCheck %s --check-prefixes=CHECK,CHECK-SKIP
4+
5+
// CHECK-NO-SKIP: sil_global hidden @$s4Test1xSivp : $Int
6+
// CHECK-SKIP: sil_global hidden_external @$s4Test1xSivp : $Int
7+
var x = foo()
8+
9+
// CHECK-NO-SKIP: sil hidden{{.*}} @$s4Test3fooSiyF : $@convention(thin) () -> Int {
10+
// CHECK-SKIP: sil hidden_external @$s4Test3fooSiyF : $@convention(thin) () -> Int
11+
func foo() -> Int { return 1 }

0 commit comments

Comments
 (0)