Skip to content

[SymbolGraphGen] Correctly handle exported imports in swift-symbolgraph-extract #73080

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

daniel-grumberg
Copy link
Contributor

This sets up the necessary stuff to include symbols from exported imported modules in symbol graphs generated using the swift-symbolgraph-extract tool

Changes include:

  • Add option to provide an allow list of reexported modules for swift-symbolgraph-extract
  • Recursively collect exported imports to allow fetching all visible Decls for symbol graph generation
  • Enable collection of exported imports that originate from non SourceFile file units for the purpose of ModuleDecl::getDisplayDecl

Resolves #59920
rdar://89687175

@daniel-grumberg daniel-grumberg changed the title Export import sgf extract [SymbolGraphGen] Correctly handle exported imports in swift-symbolgraph-extract Apr 17, 2024
@daniel-grumberg
Copy link
Contributor Author

@swift-ci please test

@daniel-grumberg
Copy link
Contributor Author

@swift-ci please smoke test

@ahoppen ahoppen removed their request for review April 17, 2024 21:21
@daniel-grumberg daniel-grumberg force-pushed the export-import-sgf-extract branch from 0246506 to 1d749b1 Compare April 18, 2024 15:22
@daniel-grumberg
Copy link
Contributor Author

@swift-ci please smoke test

@daniel-grumberg
Copy link
Contributor Author

@swift-ci please test

1 similar comment
@daniel-grumberg
Copy link
Contributor Author

@swift-ci please test

if (Recursive) {
ImportCollector importCollector;
this->getDisplayDeclsRecursivelyAndImports(Results, importCollector);
}
// FIXME: Should this do extra access control filtering?
FORWARD(getDisplayDecls, (Results));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make this an else branch

Copy link
Contributor

@QuietMisdreavus QuietMisdreavus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than the comment we spotted while walking through the code, could you add a test that verifies that the recursive export-import functionality still works? There's a similar test in SymbolGraph/Module/ThirdOrder.swift that you can copy to make something similar. We just need to make sure that the innermost module's symbols appear in the outer symbol graph.

…cls for symbol graph generation

This change is two fold. Firstly it enables collection of exported
imports from non source file units. Additionally this recurses through
the exported imports to ensure the transitive set is collected.

Fixes swiftlang#59920
rdar://89687175
Ensure recursive calls to `ModuleDecl::getDisplayDecls` does not result in double collection of display decls.
@daniel-grumberg daniel-grumberg force-pushed the export-import-sgf-extract branch from 1d749b1 to f152885 Compare April 25, 2024 10:36
@daniel-grumberg
Copy link
Contributor Author

@swift-ci please smoke test

@daniel-grumberg
Copy link
Contributor Author

@swift-ci please test

@daniel-grumberg
Copy link
Contributor Author

Other than the comment we spotted while walking through the code, could you add a test that verifies that the recursive export-import functionality still works? There's a similar test in SymbolGraph/Module/ThirdOrder.swift that you can copy to make something similar. We just need to make sure that the innermost module's symbols appear in the outer symbol graph.

Test is in test/SymbolGraph/Module/NestedExportedImport.swift

Copy link
Contributor

@QuietMisdreavus QuietMisdreavus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New test looks great, thanks!

@daniel-grumberg daniel-grumberg merged commit cffb637 into swiftlang:main May 2, 2024
daniel-grumberg added a commit to daniel-grumberg/swift that referenced this pull request May 2, 2024
…-sgf-extract

[SymbolGraphGen] Correctly handle exported imports in swift-symbolgraph-extract
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[SymbolGraphGen] swift-symbolgraph-extract support for emitting symbols from @_export imports
2 participants