-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Implicit import fixes #84642
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
base: main
Are you sure you want to change the base?
Implicit import fixes #84642
Conversation
@swift-ci please smoke test |
1 similar comment
@swift-ci please smoke test |
ImportPath::Builder builder; | ||
while (M) { | ||
if (!M->isSubModule() && isCxxStdModule(M)) | ||
if (!M->isSubModule() && M->Name == "std") |
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.
Should this still accept std_core
, which acts as a top-level module in recent libc++?
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.
This is specifically done to exclude top-level libc++ modules other than std
. The issue is that while you could specify submodules to CxxStdlib
, there was no way to inherit imports to other libc++ submodules. E.g. a clang module importing std_core.math.abs
would become an import of CxxStdlib.math.abs
on the Swift side, which would then be translated back to std.math.abs
(which doesn't exist) when looking up the module.
77e67bf
to
25b189d
Compare
@swift-ci please smoke test |
@swift-ci please smoke test |
25b189d
to
52a3df3
Compare
@swift-ci please smoke test |
52a3df3
to
851d5cc
Compare
9c1a8a9
to
58ca618
Compare
@swift-ci please smoke test |
1 similar comment
@swift-ci please smoke test |
This is finally ready for review now |
Inheriting a clang import marked `requires: !swift` will always result in an error. This skips such imports, which *may* result in name lookup errors instead, but also may not, depending on the module. rdar://161795145
When expanding a Swift macro in a clang module where the original clang module imported a submodule in a C++ standard library module other than `std`, e.g. a submodule to `std_core`, this would result in an error. This is because `std_core.math.abs` would be imported as `CxxStdlib.math.abs`, which would later be translated back as `std.math.abs` which doesn’t exist. This changes the mapping to only map `std` to `CxxStdlib`. To prevent errors when importing modules starting with `std_`, this error is moved from the late-stage module import to the earlier processing of `ImportDecl`s. This results in these module names still being forbidden in explicit imports (i.e. naming them in source code), while still being allowed in implicit imports inherited from clang modules. This also fixes a fix-it bug where only the first 3 characters would be selected for replacing with `CxxStdlib` when importing `std_core`. This also fixes a diagnostic bug where aliased modules would refer to the module name in the source code rather than the real module name, and adds a note clarifying the situation. rdar://161795429 rdar://161795673 rdar://161795793
The _SwiftifyImport macro is emitted into an unnamed buffer and then parsed, pretending it was in the header all along. This makes it hard to add `expected-note` comments for `diag::in_macro_expansion` when they point here. That's okay, because the macro expansion has already been pointed out by `expected-expansion` directives. But -verify-ignore-unrelated is too blunt of a tool, so this adds -verify-ignore-macro-note to ignore these specific diagnostics.
7656009
to
6ebb5e4
Compare
@swift-ci please smoke test |
This fixes some bugs related to implicitly inherited imports that block enabling safe interop wrappers by default.
rdar://161795145
rdar://161795429
rdar://161795673
rdar://161795793