Commit Graph

1019 Commits

Author SHA1 Message Date
Victoria Mitchell
ec6c3fb3d7 Revert "Merge pull request #40877 from apple/revert-40810-QuietMisdreavus/sourcefile-export"
This reverts commit caf2f087e3, reversing
changes made to 5a9abb2119.
2022-01-18 08:51:10 -07:00
Mishal Shah
caf2f087e3 Merge pull request #40877 from apple/revert-40810-QuietMisdreavus/sourcefile-export
Revert "[AST] scan `@_exported import` modules of source files for display decls"
2022-01-16 21:45:20 -08:00
nate-chandler
05a4c57149 Revert "[AST] scan @_exported import modules of source files for display decls" 2022-01-14 09:10:34 -08:00
Holly Borla
f368b77ad5 [Sema] Account for ExistentialType in lookupExistentialConformance. 2022-01-13 19:30:44 -08:00
Victoria Mitchell
e04092d87e don't crawl exported imports more than once 2022-01-13 09:01:52 -07:00
Victoria Mitchell
1f7fe0220a SourceFile::getDisplayDecls also walks @_exported imports 2022-01-13 09:01:52 -07:00
Victoria Mitchell
b5dc995d3e add module/file debug dumpers 2022-01-13 09:01:52 -07:00
Doug Gregor
5023a934fc Tolerate missing Sendable conformances on superclasses.
Fixes the crash in rdar://86653457
2022-01-11 11:11:21 -08:00
Doug Gregor
2832aedfe2 Make the @_predatesConcurrency diagnostic a once-per-file-per-module remark
Rather than tacking the "add `@_predatesConcurrecy` to import"
diagnostic on to the prior diagnostic as a note, make it its own
remark. Then, ensure that we only emit this remark once per source
file per imported module, so we're not overwhelming the user.
2021-12-21 12:16:06 -08:00
Alex Hoppen
669e3f34a6 Merge pull request #40155 from ahoppen/pr/improve-module-search-path-lookup
[Serialization] Improve module loading performance
2021-12-20 18:09:17 +01:00
Erik Eckstein
408cf02bc8 rework cross-module-optimization
* rename the CrossModuleSerializationSetup pass to simply CrossModuleOptimization
* remove the CMO specific serializer pass. Instead run the CrossModuleSerializationSetup pass directly before the standard serializer pass.
* correctly handle shared functions (e.g. specializations)
* refactoring
2021-12-20 11:33:02 +01:00
Alex Hoppen
fe7878ecce [Serialization] Improve module loading performance
When looking for a Swift module on disk, we were scanning all module search paths if they contain the module we are searching for. In a setup where each module is contained in its own framework search path, this scaled quadratically with the number of modules being imported. E.g. a setup with 100 modules being imported form 100 module search paths could cause on the order of 10,000 checks of `FileSystem::exists`. While these checks are fairly fast (~10µs), they add up to ~100ms.

To improve this, perform a first scan of all module search paths and list the files they contain. From this, create a lookup map that maps filenames to the search paths they can be found in. E.g. for
```
searchPath1/
  Module1.framework

searchPath2/
  Module1.framework
  Module2.swiftmodule
```
we create the following lookup table
```
Module1.framework -> [searchPath1, searchPath2]
Module2.swiftmodule -> [searchPath2]
```
2021-12-14 12:44:13 +01:00
Ellie Shin
d95d0a0a7d Merge pull request #40450 from apple/es-index
[Indexing] If module aliasing is used, store module real names to index unit/record files
Resolves rdar://82896373
2021-12-07 23:49:01 -08:00
Ellie Shin
0ff713d44c [Indexing] Use module real name in case module aliasing is used
Resolves rdar://82896373
2021-12-07 02:22:36 -08:00
Xi Ge
6377c3a742 Revert "Revert "serialization: obfuscate the serialized search paths"" 2021-12-02 13:21:04 -08:00
Saleem Abdulrasool
11d5d6d4ca Revert "serialization: obfuscate the serialized search paths" 2021-12-02 08:18:23 -08:00
Xi Ge
0047d81f9a serialization: obfuscate the serialized search paths
We noticed some Swift clients rely on the serialized search paths in the module to
find dependencies and droping these paths altogether can lead to build failures like
rdar://85840921.

This change teaches the serialization to obfuscate the search paths and the deserialization
to recover them. This allows clients to keep accessing these paths without exposing
them when shipping the module to other users.
2021-12-01 11:47:41 -08:00
Kuba (Brecka) Mracek
c89eca6c34 Enforce consistent usage of -experimental-hermetic-seat-at-link flag (#39986)
We've recently added the -experimental-hermetic-seal-at-link compiler flag,
which turns on aggressive dead-stripping optimizations and assumes that library
code can be optimized against client code because all users of the library
code/types are present at link/LTO time. This means that any module that's
built with -experimental-hermetic-seal-at-link requires all clients of this
module to also use -experimental-hermetic-seal-at-link. This PR enforces that
by storing a bit in the serialized module, and checking the bit when importing
modules.
2021-11-30 10:44:58 -08:00
Becca Royal-Gordon
1880118e70 Restructure getDisplayDecl() Sendable forcing
Move this into a helper function that lives in Sema, avoiding libswiftAST calling into libswiftSema.
2021-11-19 17:51:27 -08:00
Becca Royal-Gordon
8007d70659 Print Sendable conformances for clang types 2021-11-19 11:34:01 -08:00
Becca Royal-Gordon
21f58ec78f [NFC] Attach SynthesizedFile to any FileUnit
Gives us a place to stuff synthesized declarations for, among other things, imported Clang decls.
2021-11-19 11:34:01 -08:00
Saleem Abdulrasool
4d44953691 Revert "Support __available__((swift_attr("@Sendable")))" 2021-11-19 07:40:24 -08:00
Becca Royal-Gordon
36bae62b19 Print Sendable conformances for clang types 2021-11-12 23:13:29 -08:00
Becca Royal-Gordon
e130826686 [NFC] Attach SynthesizedFile to any FileUnit
Gives us a place to stuff synthesized declarations for, among other things, imported Clang decls.
2021-11-12 23:13:29 -08:00
Robert Widmann
22405cefea Plumb the "Is Type Sequence" Bit Through the Surface AST 2021-11-08 13:48:30 -08:00
Ellie Shin
6f34844b49 Merge pull request #39705 from apple/es-module-alias-serialize
[Module aliasing] Serialize SIL and binaries with module real names for referenced or imported modules. Resolves rdar://83632529
2021-10-18 21:55:45 -07:00
Becca Royal-Gordon
fa8436bdf6 [NFC] Allow extensions in SynthesizedFileUnits 2021-10-14 12:14:46 -07:00
elsh
adf33e0bb9 Add doc comments
Rename test
2021-10-12 15:03:30 -07:00
elsh
96fb3d6112 [Module aliasing] Serialize binary with module real name
Resolves rdar://83632529
2021-10-12 13:59:34 -07:00
Alexis Laferrière
9cf45faefd [Sema] Objective-C SPI are always imported
rdar://83186214
2021-10-05 10:12:49 -07:00
elsh
6b4951e31e Rename lookupModuleAlias to getRealModuleName 2021-09-30 13:29:02 -07:00
elsh
b5f8c7901c move the lookup to the getRealName() 2021-09-30 12:43:41 -07:00
elsh
fc420d04e2 Modify setModuleAliases and lookup
Add examples to documentation comment
2021-09-29 16:40:22 -07:00
elsh
0e05d10308 Add module alias map and lookup func to ASTContext
Set module underlying name in ModuleDecl if a module alias exists
rdar://83682112
2021-09-29 16:40:22 -07:00
Alexis Laferrière
c8104aab38 [Sema] Generate TRC for unparsed functions right before type-checking
Fix an issue where `if #available(...)` conditions were ignored in
emit-module-separately builds or when skipping non-inlinable function
bodies.

To handle functions for which parsing is delayed but type-checking is
not delayed, move up building the delayed TRC to the
TypeCheckFunctionBodyRequest service.

rdar://83166742
2021-09-16 08:16:21 -07:00
eeckstein
deb02c188c Merge pull request #38951 from eeckstein/fix-cmo-crash
cross-module-optimization: Don't serialize functions which reference implementationOnly-imported functions
2021-08-23 18:22:29 +02:00
Becca Royal-Gordon
c517b45bb4 Merge pull request #38948 from beccadax/the-copypasta-is-stale
[NFC] Factor out ASTContext `operator new`s
2021-08-20 11:04:56 -07:00
Erik Eckstein
c1e1bf2bd6 cross-module-optimization: Don't serialize functions which reference implementationOnly-imported functions
The check for implementationOnly imports was already done for types, but it was missing for functions.
Fixes a crash when implementationOnly-importing a C module.

https://bugs.swift.org/browse/SR-15048
rdar://81701218
2021-08-19 20:27:56 +02:00
Becca Royal-Gordon
59bb325e4b [NFC] Factor out ASTContext operator news
Many, many, many types in the Swift compiler are intended to only be allocated in the ASTContext. We have previously implemented this by writing several `operator new` and `operator delete` implementations into these types. Factor those out into a new base class instead.
2021-08-19 11:19:52 -07:00
Doug Gregor
d54abea922 Implement customizable Sendable conformance diagnostics.
Rework Sendable checking to be completely based on "missing"
conformances, so that we can individually diagnose missing Sendable
conformances based on both the module in which the conformance check
happened as well as where the type was declared. The basic rules here
are to only diagnose if either the module where the non-Sendable type
was declared or the module where it was checked was compiled with a
mode that consistently diagnoses `Sendable`, either by virtue of
being Swift 6 or because `-warn-concurrency` was provided on the
command line. And have that diagnostic be an error in Swift 6 or
warning in Swift 5.x.

There is much tuning to be done here.
2021-08-14 08:13:10 -07:00
Alexis Laferrière
6fd9102b45 [AST] Accept SynthesizedFileUnit in populateMemberCache
The differentiation and actor logics insert SynthesizedFileUnit in
SourceFile modules. Accepting these file units in populateMemberCache
allow to cache all the top-level decls of source file modules.
2021-08-13 16:53:42 -07:00
Robert Widmann
d75b34be22 Merge pull request #38753 from CodaFi/modulo-modules
[NFC] Remove Unused Module Parameter to Conformance Lookup
2021-08-11 10:36:39 -07:00
Robert Widmann
808220510e [NFC] Remove Unused Module Parameter to Conformance Lookup
It's been quite a long time since this unused parameter was introduced.
The intent is to produce the module as a root for the search - that is,
computing the set of conformances visible from that module, not the set
of conformances inside of that module. Callers have since been providing
all manner of module-scoped contexts to it.

Let's just get rid of it. When we want to teach protocol conformance
lookup to do this, we can revert this commit as a starting point and try
again.
2021-08-04 14:43:31 -07:00
Doug Gregor
f9c34756ef Parameterize conformance lookup on whether "missing" conformances are allowed.
Many clients of the conformance lookup operations would prefer to get
an invalid conformance (== there is no conformance) rather than a
missing conformance. Parameterize the conformance lookup operations so
that most callers won't see missing conformances, by filtering them
out at the end. Opt-in those callers that do want to see missing
conformances so they can be diagnosed.
2021-08-03 00:10:45 -07:00
Doug Gregor
de44396bd2 Always enable "missing" conformances to Sendable.
Always build the conformances, and produce warnings/errors when they are
needed during type checking.
2021-08-02 16:17:00 -07:00
Doug Gregor
c79fa23339 Implicitly build "missing" conformances to Sendable.
When looking up a conformance to Sendable fails, implicitly create a
"missing" builtin conformance. Such conformances allow type checking
to continue even in the presence of Sendable-related problems.

Diagnose these missing conformances when they are used in an actual
program, as part of availability checking for conformances and when we
are determining Sendability. This allows us to decide between an
error, a warning, and suppressing the diagnostic entirely without
affecting how the program is compiled. This is a step toward enabling
selective enforcement of Sendable.

Part of rdar://78269348.
2021-08-02 16:16:59 -07:00
Doug Gregor
3253a4fc1c [SE-0302] Implement structural conformances to Sendable.
Add implement conformance of structural types to Sendable as appropriate:
* A tuple type is Sendable when its element types are Sendable
* A metatype type is Sendable
* A function type is Sendable if it is @Sendable, thin, or C
* A builtin type is always Sendable

Implements rdar://76836578.
2021-07-28 07:38:55 -07:00
Ben Barham
f1c45de2a9 [NFC] Refactor getRenameDecl to use the request evaluator
Move `getRenameDecl` from `PrintAsObjC` into its own request so that
other components can re-use this functionality.
2021-07-24 10:00:02 +10:00
Robert Widmann
cc246db38f Fix Potential Use-After-Free of Temporary Twine
Twine is non-owning and the lifetime of the result ends at the semicolon
here unless it is consumed into an owning abstraction. Convert to
a std::string first then insert that into the buffer here.

Not a big deal since this is along a catastrophic error path.
2021-07-21 14:58:12 -07:00
Doug Gregor
9c8615d663 Revert "Disable standard substitutions when building with "older" _Concurrency module" 2021-06-16 23:07:08 -07:00