[Macros] Improve visitation of auxiliary decls

Use the same pattern as 'getAllMembers()'. This supports nested macro
expansion:
```
std::function<void(Decl *)> visit;
visit = [&](Decl *d) {
  doIt(d);
  d->visitAuxiliaryDecls(visit);
};
for (auto *d : decls)
  visit(d);
```

Don't visit auxiliary decls in `PrintAST::visit(Decl *)` this function
is only intended for single decl printing. The caller should visit them
separately. For that, add
`ModuleDecl::getTopLevelDeclsWithAuxiliaryDecls()`
This commit is contained in:
Rintaro Ishizaki
2023-10-23 12:54:13 -07:00
parent 6f5283ebfc
commit 03bf349778
5 changed files with 33 additions and 21 deletions

View File

@@ -833,7 +833,7 @@ bool swift::emitSwiftInterface(raw_ostream &out,
InheritedProtocolCollector::PerTypeMap inheritedProtocolMap;
SmallVector<Decl *, 16> topLevelDecls;
M->getTopLevelDecls(topLevelDecls);
M->getTopLevelDeclsWithAuxiliaryDecls(topLevelDecls);
for (const Decl *D : topLevelDecls) {
InheritedProtocolCollector::collectProtocols(inheritedProtocolMap, D);