@@ -217,12 +217,13 @@ int swift_symbolgraph_extract_main(ArrayRef<const char *> Args, const char *Argv
217
217
}
218
218
219
219
auto M = CI.getASTContext ().getModuleByName (options::ModuleName);
220
- SmallVector<Identifier, 32 > VisibleModuleNames;
221
- CI.getASTContext ().getVisibleTopLevelModuleNames (VisibleModuleNames);
222
220
if (!M) {
223
221
llvm::errs ()
224
222
<< " Couldn't load module '" << options::ModuleName << ' \' '
225
223
<< " in the current SDK and search paths.\n " ;
224
+
225
+ SmallVector<Identifier, 32 > VisibleModuleNames;
226
+ CI.getASTContext ().getVisibleTopLevelModuleNames (VisibleModuleNames);
226
227
227
228
if (VisibleModuleNames.empty ()) {
228
229
llvm::errs () << " Could not find any modules.\n " ;
@@ -260,16 +261,16 @@ int swift_symbolgraph_extract_main(ArrayRef<const char *> Args, const char *Argv
260
261
// don't need to print these errors.
261
262
CI.removeDiagnosticConsumer (&DiagPrinter);
262
263
263
- for ( const auto &ModuleName : VisibleModuleNames) {
264
- if (ModuleName. str (). startswith ( " _ " )) {
265
- auto CIM = CI. getASTContext (). getModuleByName (ModuleName. str ());
266
- if ( CIM && CIM-> isCrossImportOverlayOf (M)) {
267
- const auto &CIMainFile = CIM-> getMainFile (FileUnitKind::SerializedAST);
268
- llvm::errs () << " Emitting symbol graph for cross-import overlay module file: "
269
- << CIMainFile. getModuleDefiningPath () << ' \n ' ;
270
-
271
- Success |= symbolgraphgen::emitSymbolGraphForModule (CIM, Options);
272
- }
264
+ SmallVector<ModuleDecl *> Overlays;
265
+ M-> findDeclaredCrossImportOverlaysTransitive (Overlays);
266
+ for ( const auto *OM : Overlays) {
267
+ auto CIM = CI. getASTContext (). getModuleByName (OM-> getNameStr ());
268
+ if (CIM) {
269
+ const auto &CIMainFile = CIM-> getMainFile (FileUnitKind::SerializedAST);
270
+ llvm::errs () << " Emitting symbol graph for cross-import overlay module file: "
271
+ << CIMainFile. getModuleDefiningPath () << ' \n ' ;
272
+
273
+ Success |= symbolgraphgen::emitSymbolGraphForModule (CIM, Options);
273
274
}
274
275
}
275
276
0 commit comments