Skip to content

Commit 88b76b2

Browse files
committed
Make sure we visit auxiliary declarations for all SIL symbol visitation
Addresses IRGen, TBD generation, and so on
1 parent 6a9e9d6 commit 88b76b2

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

lib/SIL/IR/SILSymbolVisitor.cpp

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,20 @@ class SILSymbolVisitorImpl : public ASTVisitor<SILSymbolVisitorImpl> {
573573
visitAbstractStorageDecl(SD);
574574
}
575575

576+
template<typename NominalOrExtension>
577+
void visitMembers(NominalOrExtension *D) {
578+
if (!Ctx.getOpts().VisitMembers)
579+
return;
580+
581+
for (auto member : D->getMembers()) {
582+
member->visitAuxiliaryDecls([&](Decl *decl) {
583+
visit(decl);
584+
});
585+
586+
visit(member);
587+
}
588+
}
589+
576590
void visitNominalTypeDecl(NominalTypeDecl *NTD) {
577591
auto declaredType = NTD->getDeclaredType()->getCanonicalType();
578592

@@ -591,9 +605,7 @@ class SILSymbolVisitorImpl : public ASTVisitor<SILSymbolVisitorImpl> {
591605

592606
addRuntimeDiscoverableAttrGenerators(NTD);
593607

594-
if (Ctx.getOpts().VisitMembers)
595-
for (auto member : NTD->getMembers())
596-
visit(member);
608+
visitMembers(NTD);
597609
}
598610

599611
void visitClassDecl(ClassDecl *CD) {
@@ -682,9 +694,7 @@ class SILSymbolVisitorImpl : public ASTVisitor<SILSymbolVisitorImpl> {
682694
addConformances(ED);
683695
}
684696

685-
if (Ctx.getOpts().VisitMembers)
686-
for (auto member : ED->getMembers())
687-
visit(member);
697+
visitMembers(ED);
688698
}
689699

690700
#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)