Commit Graph

2328 Commits

Author SHA1 Message Date
Jordan Rose
6296a0e21a [Serialization] Make sure we handle all decl kinds
...well, at least a little more than before. This /still/ isn't as
strong as the switch that used to be here because a subtype of an
existing Decl or Type won't show up, but that's probably still worth
the maintainability (and backtrace) tradeoff.
2019-05-23 21:09:48 -07:00
Jordan Rose
dc1653fe63 [Serialization] Factor out a helper for types that wrap other types
...and carry no other information (besides their record code).
No functionality change.
2019-05-23 21:06:14 -07:00
Jordan Rose
f932eafa01 [Serialization] Simplify metatype and function type serialization
No functionality change.
2019-05-23 21:06:14 -07:00
Jordan Rose
f89358fc5c [Serialization] Factor TypeSerializer out of writeType
Like the recent change for DeclSerializer. No functionality change,
just making it easier to read.
2019-05-23 21:06:14 -07:00
Jordan Rose
0a34fe5487 [Serialization] Move a bunch of helpers to DeclSerializer
...and off of the main Serializer class. No functionality change.
2019-05-22 18:58:53 -07:00
Jordan Rose
94712186a8 [Serialization] Move attribute serialization into DeclSerializer 2019-05-22 18:58:52 -07:00
Jordan Rose
eb4b4ecd0d [Serialization] Push more of writeDecl into DeclSerializer
No functionality change.
2019-05-22 18:58:52 -07:00
Jordan Rose
96fcfbf016 [Serialization] Factor out common code for {Pre,Post}fixOperatorDecl 2019-05-22 18:58:52 -07:00
Jordan Rose
21b3766aa3 [Serialization] Finish factoring the switch out to DeclSerializer 2019-05-22 18:58:49 -07:00
Jordan Rose
6ea9cd7165 [Serialization] Start splitting up Decl serialization using a visitor
There's a big switch now; separate functions will make this a little
easier to read. The writing side of f637c754.
2019-05-22 18:56:36 -07:00
Slava Pestov
5b2211dde7 Serialization: Recover from failure to deserialize inheritance clause entries
... by dropping them.

Fixes <rdar://problem/50473619>.
2019-05-20 17:38:30 -04:00
Jordan Rose
96e8d56878 [Serialization] Add recovery for structs with non-loadable constraints
That is, if a struct's generic requirements can't be deserialized,
drop the struct. This is the same logic that's already in play for
enums and (as of the previous commit) classes, so it should be pretty
well tested by now. (Hence the sole test I'm adding here, snuck into
superclass.swift because it's a superclass /constraint/ being tested.)

I don't know of any outstanding issues caused by this, but it was
weird to have it for enums and classes but not structs, so here we
are.
2019-05-17 10:25:01 -07:00
Jordan Rose
ff7c6f6702 [Serialization] Drop a class if the superclass can't be found
...instead of crashing. Also drop the class if its generic
requirements depend on a type that can't be loaded (instead of
crashing).

rdar://problem/50125674
2019-05-17 10:25:01 -07:00
Jordan Rose
c506747a9c [Serialization] Drop inherited conformances on classes (#23347)
These can be recreated if needed in a client library. To do this, I've
added a new ConformanceLookupKind::NonInherited, which can also be
used elsewhere in the project where we're already filtering out
inherited conformances some other way.

Note that this doesn't drop inherited conformances from the entire
serialized interface, just from the list that a class explicitly
declares. They still get referenced sometimes.

rdar://problem/50541451 and possibly others
2019-05-13 13:41:10 -07:00
eeckstein
cfc2dda69a Merge pull request #24705 from eeckstein/fix-vtable-serialization
Serialization: use the mangled class name for serializing vtables.
2019-05-13 12:47:03 -07:00
Jordan Rose
6cca050fd9 [Serialization] Retire "shadowed module" in favor of "underlying" (#24711)
Similar to 517f5d6b6a, the "shadowed" terminology didn't end up
describing the most common use of the feature; there is pretty much no
intended case where a Swift module shadows a Clang module without also
re-exporting it. Switch to "underlying", which was already in use in a
few places, and which better parallels "overlay".

No intended functionality change.
2019-05-13 10:20:03 -07:00
Erik Eckstein
c957c50e28 Serialization: use the mangled class name for serializing vtables.
To distinguish between classes which have the same name (but are in different contexts).
Fixes a miscompile if classes with the same name are used from a different module.

SR-10634
rdar://problem/50538534
2019-05-11 08:30:15 -07:00
Alexis Laferrière
9c4c30413b Merge pull request #24591 from xymus/req-sig-request
GSB: Lazy requirement signature
2019-05-10 08:47:27 -07:00
Rintaro Ishizaki
d3d30ee246 [Serialization] Support Swift only system module
Previously 'isSystemModule()' returns true only if the module is:
- Standard library
- Clang module and that is `IsSystem`
- Swift overlay for clang `IsSystem` module

Now:
- Clang module and that is `IsSystem`; or
- Swift overlay for clang `IsSystem` module
- Swift module found in either of these directories:
  - Runtime library directoris (including stdlib)
  - Frameworks in `-Fsystem` directories
  - Frameworks in `$SDKROOT/System/Library/Frameworks/` (Darwin)
  - Frameworks in `$SDKROOT/Library/Frameworks/` (Darwin)

rdar://problem/50516314
2019-05-08 17:03:06 -07:00
Alexis Laferrière
862432fd1b Explicitly request to createGenericParamsIfMissing as it will be lazy
Computing the requirement signature created the generic params as
a side effect. Making getRequirementSignature lazy means that users
of the generic params must make sure they are created before use.
2019-05-08 13:54:03 -07:00
Rintaro Ishizaki
0d43e5ad67 [Serialization] Avoid to call getTargetSpecificModuleTriple() twice
Maintain an invariant that forEachTargetModuleBasename() iterates names
from most to least desiable.
2019-05-08 12:41:10 -07:00
Rintaro Ishizaki
acd4cb1a9d [ASTContext] Remove unused function and includes 2019-05-08 10:12:29 -07:00
Rintaro Ishizaki
8773fe303c [Serialize] Consolidate duplicated logics
- forEachTargetModuleBasename(): Iterate through target names to search
- forEachModuleSearchPath(): Iterate through search paths
2019-05-08 10:11:52 -07:00
Rintaro Ishizaki
6956089b0b [CodeCompletion] Complete Swift only module name after 'import'
rdar://problem/39392446
2019-05-08 10:11:52 -07:00
Ben Langmuir
a861e760e7 Merge pull request #24520 from benlangmuir/cc-crash-keypath
[code-completion] Avoid invalid member substitution for keypath dynamic lookup
2019-05-06 15:28:50 -07:00
Ben Langmuir
34da079aa6 Pass DynamicLookupInfo through VisibleDeclConsumers NFC
This commit adds a new type DynamicLookupInfo that provides information
about how a dynamic member lookup found a particular Decl. This is
needed to correctly handle KeyPath dynamic member lookups, but for now
just plumb it through everywhere.
2019-05-06 10:02:39 -07:00
Jordan Rose
6720a7cb74 Merge branch 'master' into artiodactyla 2019-05-06 09:32:56 -07:00
swift-ci
b16ee94d1a Merge pull request #24512 from DougGregor/property-delegates-serialization 2019-05-05 23:17:43 -07:00
Doug Gregor
7092be6a28 [Property delegates] (De-)serialize property delegates attached to properties
Serialize the relationship between a property that has an attached delegate
and its backing variable, so deserialization can reestablish that link.

Fixes rdar://problem/50447022.
2019-05-05 21:44:54 -07:00
Jordan Rose
b3c5a68acf [Serialization] Reduce file size by splitting dep dirnames from basenames
Dependency tracking for cached compiled modules (compiled from
swiftinterfaces) can lead to a high percentage of the module being
SDK-relative paths when -track-system-dependencies is on. Cut down on
this by storing directory names in a separate record that gets
referenced from each file dependency. (Since a lot of per-file
dependencies are header files in a common directory, this is a win.)

We can do something more clever in the future, but this is a
reasonable start for, say, the overlays.

rdar://problem/50449802
2019-05-04 10:47:46 -07:00
Jordan Rose
f76d2c3976 [ModuleInterface] Short-circuit module loading for frameworks too (#24459)
Follow-up to 7969705 that handles frameworks as well. Oops.

rdar://problem/50070463
2019-05-03 11:11:07 -07:00
Slava Pestov
fa12d85739 AST: Clean up associated type default representation a bit 2019-04-26 21:47:02 -04:00
swift-ci
d24bc38797 Merge pull request #23701 from DougGregor/property-delegates-as-custom-attributes 2019-04-24 22:51:18 -07:00
Nathan Hawes
1a2680a52f Merge pull request #24212 from nathawes/overriding-convenience-init-module-interface
[Deserialization] Don't add an OverrideAttr if the 'overridden' decl is a convenience init when deserializing
2019-04-24 13:58:16 -07:00
Erik Eckstein
2e01b0edeb SIL: add assign_by_delegate instruction
Used for property delegates.
2019-04-23 11:32:28 -07:00
Doug Gregor
a97a51956f Merge pull request #24209 from DougGregor/opaque-result-types-mangling-fixes
[Opaque result types] Fix mangling issues with opaque result types.
2019-04-23 06:26:39 -07:00
Nathan Hawes
2ae7315adf [Serialization] Don't add an OverrideAttr if the 'overridden' decl is a convenience init when deserializing 2019-04-22 18:08:03 -07:00
Doug Gregor
e29469b9c0 [Opaque result types] Fix mangling issues with opaque result types.
Fix a trio of issues involving mangling for opaque result types:
* Symbolic references to opaque type descriptors are not substitutions
* Mangle protocol extension contexts correctly
* Mangle generic arguments for opaque result types of generic functions

The (de-)serialization of generic parameter lists for opaque type
declarations is important for the last bullet, to ensure that the
mangling of generic arguments of opaque result types works across
module boundaries.

Fixes the rest of rdar://problem/50038754.
2019-04-22 17:10:45 -07:00
adrian-prantl
ecebf70745 Merge pull request #24173 from adrian-prantl/memorybufferloader
Factor out the pre-registered MemoryBuffer functionality
2019-04-22 11:32:06 -07:00
Adrian Prantl
b244b0928e Factor out the pre-registered MemoryBuffer functionality
form SerializedModuleLoader into its own ModuleLoader class. (NFC-ish)

This gives better control over the order in which the various module
load mechanisms are applied.
2019-04-22 09:17:08 -07:00
adrian-prantl
f75dea49df Merge pull request #23910 from adrian-prantl/49751363
Record parseable interface imports in the debug info.
2019-04-19 14:23:57 -07:00
Alexis Laferrière
007fbb6ebd Merge pull request #23932 from xymus/IsFinalRequest
Sema: implement `isFinal` using a request evaluator
2019-04-19 13:02:07 -07:00
Joe Groff
5215290f25 Serialization: Cross-reference opaque return types by mangled name. rdar://problem/50005972 2019-04-18 14:41:26 -07:00
Joe Groff
b57f35220e Serialize opaque return type of var/subscript decls. 2019-04-17 14:46:22 -07:00
Joe Groff
f96ca720d3 Serialization: Handle reentrance while deserializing OpaqueTypeDecl. rdar://problem/49829836 2019-04-17 14:46:22 -07:00
Joe Groff
60aa49d69c merge fixup 2019-04-17 14:46:22 -07:00
Joe Groff
399332b75b Parsable interface and type reconstruction support for opaque types.
When printing a swiftinterface, represent opaque result types using an attribute that refers to
the mangled name of the defining decl for the opaque type. To turn this back into a reference
to the right decl's implicit OpaqueTypeDecl, use type reconstruction. Since type reconstruction
doesn't normally concern itself with non-type decls, set up a lookup table in SourceFiles and
ModuleFiles to let us handle the mapping from mangled name to opaque type decl in type
reconstruction.

(Since we're invoking type reconstruction during type checking, when the module hasn't yet been
fully validated, we need to plumb a LazyResolver into the ASTBuilder in an unsightly way. Maybe
there's a better way to do this... Longer term, at least, this surface design gives space for
doing things more the right way--a more request-ified decl validator ought to be able to naturally
lazily service this request without the LazyResolver reference, and if type reconstruction in
the future learns how to reconstruct non-type decls, then the lookup tables can go away.)
2019-04-17 14:46:22 -07:00
Joe Groff
2d19110e38 Serialization: Serialize opaque types and their decls. 2019-04-17 14:43:32 -07:00
Joe Groff
a419754fe9 Support nested types on opaque archetypes (and maybe opened ones). 2019-04-17 14:43:32 -07:00
Joe Groff
dd2b51d6dc Add an OpaqueTypeArchetypeType subclass. 2019-04-17 14:43:32 -07:00