Skip to content

Commit a8e3283

Browse files
authored
Merge pull request #64134 from DougGregor/visit-aux-decls-sil-symbol-visitor
2 parents 75995f0 + 17f5686 commit a8e3283

File tree

2 files changed

+26
-6
lines changed

2 files changed

+26
-6
lines changed

lib/SIL/IR/SILSymbolVisitor.cpp

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,13 @@ class SILSymbolVisitorImpl : public ASTVisitor<SILSymbolVisitorImpl> {
395395
addMainIfNecessary(file);
396396

397397
for (auto D : decls) {
398+
D->visitAuxiliaryDecls([&](Decl *decl) {
399+
if (Ctx.getOpts().LinkerDirectivesOnly && !requiresLinkerDirective(decl))
400+
return;
401+
402+
visit(decl);
403+
});
404+
398405
if (Ctx.getOpts().LinkerDirectivesOnly && !requiresLinkerDirective(D))
399406
continue;
400407

@@ -573,6 +580,20 @@ class SILSymbolVisitorImpl : public ASTVisitor<SILSymbolVisitorImpl> {
573580
visitAbstractStorageDecl(SD);
574581
}
575582

583+
template<typename NominalOrExtension>
584+
void visitMembers(NominalOrExtension *D) {
585+
if (!Ctx.getOpts().VisitMembers)
586+
return;
587+
588+
for (auto member : D->getMembers()) {
589+
member->visitAuxiliaryDecls([&](Decl *decl) {
590+
visit(decl);
591+
});
592+
593+
visit(member);
594+
}
595+
}
596+
576597
void visitNominalTypeDecl(NominalTypeDecl *NTD) {
577598
auto declaredType = NTD->getDeclaredType()->getCanonicalType();
578599

@@ -591,9 +612,7 @@ class SILSymbolVisitorImpl : public ASTVisitor<SILSymbolVisitorImpl> {
591612

592613
addRuntimeDiscoverableAttrGenerators(NTD);
593614

594-
if (Ctx.getOpts().VisitMembers)
595-
for (auto member : NTD->getMembers())
596-
visit(member);
615+
visitMembers(NTD);
597616
}
598617

599618
void visitClassDecl(ClassDecl *CD) {
@@ -682,9 +701,7 @@ class SILSymbolVisitorImpl : public ASTVisitor<SILSymbolVisitorImpl> {
682701
addConformances(ED);
683702
}
684703

685-
if (Ctx.getOpts().VisitMembers)
686-
for (auto member : ED->getMembers())
687-
visit(member);
704+
visitMembers(ED);
688705
}
689706

690707
#ifndef NDEBUG

test/Macros/macro_expand_peers.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
// RUN: %target-build-swift -swift-version 5 -Xfrontend -disable-availability-checking -load-plugin-library %t/%target-library-name(MacroDefinition) -parse-as-library -I %swift-host-lib-dir -L %swift-host-lib-dir %s -o %t/main -module-name MacroUser
88
// RUN: %target-run %t/main | %FileCheck %s -check-prefix=CHECK-EXEC
99

10+
// Emit module while skipping function bodies
11+
// RUN: %target-swift-frontend -swift-version 5 -emit-module -load-plugin-library %t/%target-library-name(MacroDefinition) -parse-as-library -I %swift-host-lib-dir %s -disable-availability-checking -o %t/macro_expand_peers.swiftmodule -experimental-skip-non-inlinable-function-bodies-without-types
12+
1013
// FIXME: Swift parser is not enabled on Linux CI yet.
1114
// REQUIRES: OS=macosx
1215

0 commit comments

Comments
 (0)