Make SourceFile::collectLinkLibraries() visit all visible modules; use it.

Centralize the logic for collecting the link libraries of a source file
in SourceFile::collectLinkLibraries(), extending it to look at all visible
modules. Use it in the main place that counts for autolinking.
This commit is contained in:
Doug Gregor
2018-04-10 23:09:52 -07:00
parent 61e9cf8f1d
commit ee70e19c3c
2 changed files with 9 additions and 9 deletions

View File

@@ -1208,8 +1208,14 @@ void ModuleDecl::collectLinkLibraries(LinkLibraryCallback callback) {
void
SourceFile::collectLinkLibraries(ModuleDecl::LinkLibraryCallback callback) const {
for (auto importPair : Imports)
importPair.first.second->collectLinkLibraries(callback);
const_cast<SourceFile *>(this)->forAllVisibleModules([&](swift::ModuleDecl::ImportedModule import) {
swift::ModuleDecl *next = import.second;
if (next->getName() == getParentModule()->getName())
return;
next->collectLinkLibraries(callback);
});
}
bool ModuleDecl::walk(ASTWalker &Walker) {