swift-api-digester: avoid synthesizing nominal types from the same module.

Synthesizing types from the same module may bring back types that are
not part the ABI/API, leading to false positives.

Resolves: SR-9372
This commit is contained in:
Xi Ge
2018-11-29 14:25:05 -08:00
parent 6fac47e7e6
commit 588391eb7e
2 changed files with 10 additions and 1 deletions

View File

@@ -1,3 +1,4 @@
#include "llvm/ADT/STLExtras.h"
#include <ModuleAnalyzerNodes.h>
#include <algorithm>
@@ -1522,7 +1523,11 @@ void SwiftDeclCollector::lookupVisibleDecls(ArrayRef<ModuleDecl *> Modules) {
for (auto *D: KnownDecls) {
if (auto *Ext = dyn_cast<ExtensionDecl>(D)) {
if (HandledExtensions.find(Ext) == HandledExtensions.end()) {
ExtensionMap[Ext->getExtendedNominal()].push_back(Ext);
auto *NTD = Ext->getExtendedNominal();
// Check if the extension is from other modules.
if (!llvm::is_contained(Modules, NTD->getModuleContext())) {
ExtensionMap[NTD].push_back(Ext);
}
}
}
}