[Sema] Restrict reexported SPIs to modules with an export_as relationship

@_exported exports SPIs only when the exported module defines export_as
pointing to the exporter module. Other reexports do not reexport SPIs.
This is to prevent SPI reexporting to get out of hands with the wide
reexports of the Objective-C world.

rdar://102335473
This commit is contained in:
Alexis Laferrière
2022-11-14 12:30:37 -08:00
parent e52fbb89c1
commit 552d3a4984
3 changed files with 43 additions and 5 deletions

View File

@@ -1494,7 +1494,8 @@ void SerializedASTFile::lookupImportedSPIGroups(
continue;
if (dep.Import->importedModule == importedModule ||
imports.isImportedBy(importedModule, dep.Import->importedModule)) {
(imports.isImportedBy(importedModule, dep.Import->importedModule) &&
importedModule->isExportedAs(dep.Import->importedModule))) {
spiGroups.insert(dep.spiGroups.begin(), dep.spiGroups.end());
}
}