[SourceKit][PrintObjcHeader] Avoid printing the same Swift decl twice.

Clang and Swift decls likely have many-to-one mappings; for instance,
a RecordDecl and a TypedefDecl in Clang are both imported as the same Swift
NominalTypeDecl. This commit reduces duplication when we print Clang decls in
Swift. rdar://23275959
This commit is contained in:
Xi Ge
2015-12-07 16:14:48 -08:00
parent 3aec2c993f
commit bef5b4301d
4 changed files with 221 additions and 1 deletions

View File

@@ -493,8 +493,12 @@ void swift::ide::printHeaderInterface(
};
SmallVector<Decl *, 32> ClangDecls;
llvm::SmallPtrSet<Decl *, 32> SeenDecls;
auto headerReceiver = [&](Decl *D) {
ClangDecls.push_back(D);
if (SeenDecls.count(D) == 0) {
SeenDecls.insert(D);
ClangDecls.push_back(D);
}
};
Importer.lookupDeclsFromHeader(Filename, headerFilter, headerReceiver);