Use a SetVector when looking up the SPI attributes on imports

Using a SetVector fixes an issue where many source files imported the
same SPI group from the same module, the emitted private textual
interfaces superfluously repeated the `@_spi` attribute on the import.

rdar://problem/63681845
This commit is contained in:
Alexis Laferrière
2020-05-21 20:27:18 -07:00
parent 9c08c2456a
commit 8fefdece2c
11 changed files with 35 additions and 30 deletions

View File

@@ -2664,13 +2664,14 @@ void ModuleFile::lookupObjCMethods(
}
}
void ModuleFile::lookupImportedSPIGroups(const ModuleDecl *importedModule,
SmallVectorImpl<Identifier> &spiGroups) const {
void ModuleFile::lookupImportedSPIGroups(
const ModuleDecl *importedModule,
llvm::SmallSetVector<Identifier, 4> &spiGroups) const {
for (auto &dep : Dependencies) {
auto depSpis = dep.spiGroups;
if (dep.Import.hasValue() && dep.Import->importedModule == importedModule &&
!depSpis.empty()) {
spiGroups.append(depSpis.begin(), depSpis.end());
spiGroups.insert(depSpis.begin(), depSpis.end());
}
}
}