-
Notifications
You must be signed in to change notification settings - Fork 10.6k
[MacrosOnImports][Swiftify] Copy module imports from clang node's module to its Swift macro SourceFile #81859
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
Conversation
5539cec to
7d2431e
Compare
|
@swift-ci please smoke test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DougGregor I don't fully get why only the module's imports that themselves are top-level modules show up in the dump. It seems to work regardless, but it seems a bit off. Do you know if this is intended?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
7d2431e to
e5c5c6e
Compare
|
@swift-ci please smoke test |
e5c5c6e to
229280f
Compare
|
@swift-ci please smoke test |
|
@swift-ci please smoke test windows |
|
@swift-ci please smoke test |
1b8ba84 to
7c794aa
Compare
|
@swift-ci please smoke test macos |
7c794aa to
726d7b3
Compare
|
@swift-ci please smoke test macos |
|
@swift-ci please smoke test |
2 similar comments
|
@swift-ci please smoke test |
|
@swift-ci please smoke test |
This flag dumps all imports for each SourceFile after it's gone through import resolution. It is only intended for testing purposes. There are other ways to print imports, but they don't correspond 1:1 to the imports actually resolved, which is a bit problematic when testing implicit clang module imports.
This prints all imports instead of just exported imports, for testing purposes.
The imported top-level module inherits the imports of all its (transitive) submodules. Since multiple submodules can import the same modules these need to be deduplicated to avoid redundant work.
Since only top-level Swift modules ever contain code, setting imports for submodule wrappers has no effect.
Non-explicit submodules don't need to be explicitly added to the list of imports to be visible, since their decls are implicitly exported. Skip these modules even when present in the list of imports. Explicit submodules are imported *regardless* of whether another module imports them however.
Importing clang submodules results in an implicit import of the top-level module as well. This can result in the same TLM being imported many different times, if multiple submodules are imported from the same module. This deduplicates these imports. Other imports are not expected to be duplicated, so care is taken to only deduplicate clang TLM imports.
Import resolution now adds the Swift module to the list of imports, so we no longer need to add it manually.
There's only one caller to performImportResolutionForClangMacroBuffer, which always passes a newly allocated SourceFile. This removes a redundant check for whether its imports have been resolved, and instead asserts that they haven't.
This fixes a few tests that were failing because scoped imports were counted as having imported the module already, leading to later imports of the same module being skipped. Since the scoped imports don't import the full module, this would result in syntactically imported symbols not being found by the compiler.
Contents in namespaces are imported to the bridging header module `__ObjC`. When macros attached to a decl imported from a namespace are expanded, they also end up in `__ObjC`. This prevents them from inheriting imports from the module they originated in. This patch implements a workaround by adding an alternative constructor to `ImportResolver` that takes an explicit origin module as input, overriding which module counts as the "parent" module.
A previous commit resulted in the swift interface for CxxStdlib containing an `import CxxStdlib` for each submodule. This restores the submodule names to `CxxStdlib.vector` etc.
libc++ v17-19 was split into multiple top-level modules, while versions earlier and later had one TLM with submodules.
c72dae7 to
0276feb
Compare
|
@swift-ci please smoke test |
|
@swift-ci please smoke test linux |
|
@swift-ci please smoke test linux macos |
|
@swift-ci please smoke test |
1 similar comment
|
@swift-ci please smoke test |
An assert checking the invariant of the module passed to alreadyImportedTLM being a top-level module would dereference a null pointer in the case where the clang module contained syntax errors, since findUnderlyingClangModule would return null. Instead call the bespoke isSubmodule function that already performs this null check. This fixes the lldb test lldb/test/API/lang/swift/clangimporter/expr_import/TestSwiftExprImport.py.
|
@swift-ci please smoke test |
|
This seems to have broken rebranch: https://ci.swift.org/view/Swift%20rebranch/job/oss-swift-rebranch-incremental-RA-macos/7016. Confirming in #81190. |
|
Confirmed reverting this PR makes the tests pass. |
[Interop] Fix tests relying on transitive module imports (NFC) This fixes test failures introduced by #81859 rdar://160994365
Since the _SwiftifyImport peer macro expansion reuses the function signature of the original imported function, it needs to import the same modules as the module where the original clang node resides, to ensure visibility of any symbols that may appear in the signature.
rdar://151611573