Commit Graph

32 Commits

Author SHA1 Message Date
Allan Shortlidge
4f61908b4c AST: Fix a typo in missingImportsForDefiningModule(). 2025-04-24 22:56:43 -07:00
Allan Shortlidge
43fd131762 Sema: Improve MemberImportVisibility diagnostics for cross import overlays.
When `MemberImportVisibility` is enabled and a declaration from a cross import
overlay is diagnosed because it has not been imported, suggest imports of the
declaring and bystanding modules instead of the cross import overlay module
(which is an implementation detail).

Resolves rdar://149307959.
2025-04-22 10:09:24 -07:00
Alexis Laferrière
e2215321dd Sema: track use in API of declaring and bystanders for cross-import overlay
Cross-import overlays are imported automatically if the declaring
module and the bystanders modules are also imported. In theory,
one could import the declaring module and bystanders without using
them and use only the overlay in API. Let’s make sure we track these
indirect uses to avoid superfluous warning.

rdar://129779460
2024-06-13 10:55:11 -07:00
Alexis Laferrière
17b8e86a6d Sema: Support newer import restrictions with cross-import overlays
Add support for access-level on imports and `@_spiOnly imports` to cross
import overlays. The overlay inherits the most restrictive import
access-level of the declaring module and the bystander module.

rdar://129606112
2024-06-12 11:08:49 -07:00
Alexis Laferrière
f53be71874 ModuleInterface: Print imports shadowed by a cross-import overlay
In some cases this import may be superfluous as it's also
`@_exported` imported by the overlay. However, when the overlay
is hidden and the import not printed, the import can go entierly
missing.
2024-06-12 10:06:05 -07:00
Steven Wu
cf8187a4fe [ScanDependency] Pass crossimport overlay file to swift-frontend
Teach dependency scanner to pass cross import overlay file to
swift-frontend for main module compilation. This allows swift-frontend
not to repeat the file system search for overlay files when loading
modules.

This also fixes the issue when caching is enabled, the cross import
doesn't work when the first module is a clang module because the module
built with caching using clang include tree does not preserve
DefinitionLoc which is used to inferred the modulemap location for cross
import overlay search.

rdar://127844120
2024-05-14 15:24:35 -07:00
Anthony Latsis
d820fcf731 Gardening: Migrate test suite to GH issues: CrossImport 2022-08-21 02:57:40 +03:00
Josh Soref
9c6b703063 spelling: declaring (#58596) 2022-05-27 22:08:27 -07:00
Allan Shortlidge
747f286b8d ModuleInterface: Adopt new swiftinterface verification lit substitutions pervasively in tests where they can be adopted by simply updating or adding a few RUN: lines. 2022-04-15 20:13:00 -07:00
Daniel Duan
3dfc40898c [NFC] Remove Python 2 imports from __future__ (#42086)
The `__future__` we relied on is now,  where the 3 specific things are
all included [since Python 3.0](https://docs.python.org/3/library/__future__.html):

* absolute_import
* print_function
* unicode_literals
* division

These import statements are no-ops and are no longer necessary.
2022-04-13 14:01:30 -07:00
Saleem Abdulrasool
849d5f0aaf Serialization: normalize the path before use
This normalizes the path so that we always have the mapping in normal
form.  This fixes a bug in the cross-module import tracing, allowing us
to finally enable the test on Windows.
2021-12-22 08:41:17 -08:00
Brent Royal-Gordon
e843a16649 Merge pull request #33935 from brentdax/these-imports-are-testing-my-patience
Add -testable-import-module frontend flag (+ refactoring)
2020-10-11 12:49:09 -07:00
Daniel Rodríguez Troitiño
2a7a3eb436 [windows] Use extended length paths for os.walk invocation.
In the Windows VS 2017 CI machines, the path for certain tests end up
being very long. rewrite-module-triples.py was aware and was using
extended length paths for the copy and remove operations in Windows
but it was not using it for the os.walk invocation, so when a folder
that was longer than MAX_PATH was encountered, the walk stopped
drilling into it, missing some module-triple-here substitutions and
making some test fail.

The changes remove the special treatment of the copy and remove
operations and move it into os.walk, which carries the prefix to
every path.

This should fix the problems seen in the SourceKit test in the
Windows VS 2017 machine:

- SourceKit/InterfaceGen/gen_swift_module_cross_import_common.swift
- SourceKit/DocSupport/doc_cross_import_common.swift
- SourceKit/CursorInfo/cursor_info_cross_import_common_case.swift

PD: Misc/stats_dir_profiler.swift is something else. It seems as if
an glob was not being expanded by lit for some reason.
2020-10-10 13:34:24 -07:00
Brent Royal-Gordon
bf074b093e Run some implicit imports through import resolution
Unloaded implicit imports (e.g. the `-import-module` flag) will now be processed by import resolution, and will be fully validated and cross-imported. Preloaded imports, like the standard library import, are still not run through full import resolution, but this is a definite improvement over the status quo.

This also folds `-import-underlying-module` and `@_exported import <ParentModule>` into a single code path, slightly changing the diagnostic for a failed overlay-style underlying module import.
2020-10-09 18:59:19 -07:00
Varun Gandhi
a1716fe2a6 [Diagnostics] Update compiler diagnostics to use less jargon. (#31315)
Fixes rdar://problem/62375243.
2020-04-28 14:11:39 -07:00
Nathan Hawes
e311480a17 [test] Support long paths on windows in more places in rewrite-module-triples.py 2020-04-23 15:55:36 -07:00
Brent Royal-Gordon
f38474896d Fix layering of cross-import and clang overlays
If a clang module declares a cross-import overlay, but it also has a traditional overlay, we want the cross-import overlay to be registered with the SourceFile as sitting atop the traditional overlay. Otherwise module-qualified name lookups will bypass the cross-import overlay.

Fixes rdar://62139656.
2020-04-21 23:43:53 -07:00
Saleem Abdulrasool
f46492f7a4 test: support long paths in rewrite-module-triples
The path that the tests are using here are extremely long, and can
easily exceed the 261 character limit on Windows.  Apply some
workarounds to support long paths.
2020-04-08 21:15:34 -07:00
Saleem Abdulrasool
5309f27cb4 Fix #30819
The commit added a broken header into the test which happened to pass
due to ObjC behaviours accidentally leaking.  Fix the header.
2020-04-08 19:43:16 -07:00
Brent Royal-Gordon
4de19e1c3c Merge pull request #30819 from brentdax/a-less-ambitious-crossover-event
Ignore transitive ObjC imports when cross-importing
2020-04-08 11:40:35 -07:00
Brent Royal-Gordon
121fa9a058 Ignore transitive ObjC imports when cross-importing
This behavior change reduces the chance of unexpected and unwanted cross-imports being performed.

Fixes rdar://problem/60554019.
2020-04-05 19:06:59 -07:00
Artem Chikin
b679fd8738 Add -Rcross-import option
It is an optional, user-accessible mechanism to have the compiler tell you what it’s cross-importing.

Resolves rdar://problem/60381893
2020-04-02 19:45:39 -07:00
Brent Royal-Gordon
b5430607a2 Provide a more useful cross-import submodule test
Removes an unreliable performance-based submodule skipping test and replaces it with a test that checks for a related functional trait instead.
2020-03-03 22:06:59 -08:00
Varun Gandhi
3626f19e76 [NFC] Mark CrossImport test unsupported without assertions. 2020-02-26 13:22:46 -08:00
Varun Gandhi
fa2ab3b8f6 [NFC] Mark cross-import overlay + module trace test unsupported on Windows. (#29977) 2020-02-20 22:32:21 -08:00
abdulras
bbbdf146c9 test: fix for Windows 2020-02-20 18:55:50 +00:00
Brent Royal-Gordon
014bb1cd83 Don’t count submodules when cross-importing
It turns out that, if you pull in any nontrivial module, there are thousands of submodules and none of them could possibly have a  cross-import overlay. Avoid evaluating them.
2020-02-18 11:08:36 -08:00
Brent Royal-Gordon
12286197c9 [NFC] Improvements suggested in code review
Thank you, @hamishknight and @varungandhi-apple.
2020-02-18 11:08:36 -08:00
Brent Royal-Gordon
747c50725c Add a warning about redundant cross-import declarations
These are mostly harmless, except that they make the two module names synonymous in qualified lookup. A hard error seems too aggressive for something that could easily be caused by uncoordinated changes to two modules, so warn instead.
2020-02-18 11:08:36 -08:00
Brent Royal-Gordon
17087cbb4e Correct for difference between BSD and GNU cp 2020-02-18 11:08:36 -08:00
Brent Royal-Gordon
0ab823801c Test cross-import overlays 2020-02-18 11:08:36 -08:00
Brent Royal-Gordon
e248f82773 Add support for loading cross-import files 2020-02-18 11:06:12 -08:00