mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user