@@ -549,6 +549,42 @@ static void emitSymbolicInterfaceForClangModule(
549
549
}
550
550
}
551
551
552
+ static void emitTransitiveClangSymbolicInterfacesForSwiftModuleImports (
553
+ ArrayRef<ImportedModule> imports, StringRef indexStorePath,
554
+ const clang::CompilerInstance &clangCI, DiagnosticEngine &diags) {
555
+ auto &fileMgr = clangCI.getFileManager ();
556
+ for (auto &import : imports) {
557
+ ModuleDecl *mod = import .importedModule ;
558
+ if (mod->isOnoneSupportModule ())
559
+ continue ; // ignore the Onone support library.
560
+ if (mod->isSwiftShimsModule ())
561
+ continue ;
562
+
563
+ for (auto *FU : mod->getFiles ()) {
564
+ switch (FU->getKind ()) {
565
+ default :
566
+ break ;
567
+ case FileUnitKind::SerializedAST:
568
+ case FileUnitKind::DWARFModule:
569
+ case FileUnitKind::ClangModule: {
570
+ auto *LFU = cast<LoadedFile>(FU);
571
+ if (auto F = fileMgr.getFile (LFU->getFilename ())) {
572
+ if (FU->getKind () == FileUnitKind::ClangModule) {
573
+ auto clangModUnit = cast<ClangModuleUnit>(LFU);
574
+ if (auto clangMod = clangModUnit->getUnderlyingClangModule ()) {
575
+ // Emit the symbolic interface file in addition to index data.
576
+ emitSymbolicInterfaceForClangModule (
577
+ clangModUnit, mod, clangMod, indexStorePath, clangCI, diags);
578
+ }
579
+ }
580
+ // FIXME: We should keep recursing here into other Swift modules.
581
+ }
582
+ }
583
+ }
584
+ }
585
+ }
586
+ }
587
+
552
588
static void addModuleDependencies (ArrayRef<ImportedModule> imports,
553
589
StringRef indexStorePath,
554
590
bool indexClangModules,
@@ -630,6 +666,16 @@ static void addModuleDependencies(ArrayRef<ImportedModule> imports,
630
666
// the underlying module instead.
631
667
if (auto *declaring = mod->getDeclaringModuleIfCrossImportOverlay ())
632
668
moduleName = declaring->getNameStr ();
669
+
670
+ // Emit symbolic interface files for any re-exported Clang modules
671
+ // from this Swift module.
672
+ if (mod->getASTContext ().LangOpts .EnableCXXInterop ) {
673
+ SmallVector<ImportedModule, 4 > imports;
674
+ mod->getImportedModules (imports,
675
+ ModuleDecl::ImportFilterKind::Exported);
676
+ emitTransitiveClangSymbolicInterfacesForSwiftModuleImports (
677
+ imports, indexStorePath, clangCI, diags);
678
+ }
633
679
}
634
680
clang::index::writer::OpaqueModule opaqMod =
635
681
moduleNameScratch.createString (moduleName);
0 commit comments