1627 Commits

Author SHA1 Message Date
David Zarzycki
b61c111f12 [Serialization] NFC: Adopt reference storage type meta-programming macros 2018-06-30 06:44:34 -04:00
John McCall
9bee3cac5a Generalize storage implementations to support generalized accessors.
The storage kind has been replaced with three separate "impl kinds",
one for each of the basic access kinds (read, write, and read/write).
This makes it far easier to mix-and-match implementations of different
accessors, as well as subtleties like implementing both a setter
and an independent read/write operation.

AccessStrategy has become a bit more explicit about how exactly the
access should be implemented.  For example, the accessor-based kinds
now carry the exact accessor intended to be used.  Also, I've shifted
responsibilities slightly between AccessStrategy and AccessSemantics
so that AccessSemantics::Ordinary can be used except in the sorts of
semantic-bypasses that accessor synthesis wants.  This requires
knowing the correct DC of the access when computing the access strategy;
the upshot is that SILGenFunction now needs a DC.

Accessor synthesis has been reworked so that only the declarations are
built immediately; body synthesis can be safely delayed out of the main
decl-checking path.  This caused a large number of ramifications,
especially for lazy properties, and greatly inflated the size of this
patch.  That is... really regrettable.  The impetus for changing this
was necessity: I needed to rework accessor synthesis to end its reliance
on distinctions like Stored vs. StoredWithTrivialAccessors, and those
fixes were exposing serious re-entrancy problems, and fixing that... well.
Breaking the fixes apart at this point would be a serious endeavor.
2018-06-30 05:19:03 -04:00
Slava Pestov
94feb373c8 AST: Remove 'checked inheritance clause' bit from TypeDecl and ExtensionDecl 2018-06-30 00:20:36 -07:00
swift-ci
0305938623 Merge remote-tracking branch 'origin/master' into master-next 2018-06-29 01:29:16 -07:00
Bob Wilson
b254041121 Merge remote-tracking branch 'origin/master' into master-next 2018-06-28 23:23:29 -07:00
Doug Gregor
a9d2e4cb69 [Serialization] Consistently (de-)serialize “isObjC” bit of declarations.
We sometimes serialized the “isObjC” state, and sometimes not. When we did serialize it,
we rarely used the bit for anything. Serialize it for all declarations where it makes
sense, and consistently call setIsObjC() with the deserialized value.
2018-06-28 20:23:08 -07:00
Slava Pestov
5f4f55caf8 AST: Add superclass field to ProtocolDecl 2018-06-28 15:19:20 -07:00
Jordan Rose
2a89d5cd51 Start recovering from missing types in SIL deserialization
Now that @inlinable is a supported feature, we need to handle cases
where a function is inlinable but it references some type that imports
differently in different Swift versions. To start, handle the case
where a SIL function's type is now invalid and therefore the entire
function can't be imported. This doesn't open up anything interesting
yet, but it's a start.

Part of rdar://problem/40899824
2018-06-27 11:38:27 -07:00
swift-ci
8bb9dd9911 Merge remote-tracking branch 'origin/master' into master-next 2018-06-21 13:29:19 -07:00
Jordan Rose
1beed09570 [Serialization] Remove bogus limitation on fast path (#17336)
The meaning of this bit changed way back in 3639343c53, but I forgot
to update this fast path. Thanks to this code falling back to the slow
path if things didn't work out, there wasn't a correctness issue here,
but it might have been doing more work than necessary.
2018-06-21 13:10:03 -07:00
swift-ci
cb0520c595 Merge remote-tracking branch 'origin/master' into master-next 2018-06-20 15:10:55 -07:00
Jordan Rose
6b894154d3 [Serialization] Track whether a cross-reference came from Clang (#17333)
Cross-references are identified by their containing module, with the
assumption that two modules will never have the same name. However, an
overlay has the same name as its underlying Clang module, which means
that there can be two declarations with the same name, the same type,
and the same module name. This is the underlying cause of the
'UIEdgeInsetsZero' problem, but it also affects the CloudKit overlay.

By tracking a bit that just says "this came from Clang", we're able
to resolve otherwise ambiguous cross-references.

(Why didn't we do it this way all along? Because if a declaration
moves from Clang to Swift or vice versa, that would break the
cross-reference. But that's only interesting if the swiftmodule format
is meant to be persistent across changing dependencies, and it looks
like we're moving away from that anyway. It's also a little weird for
SerializedModuleLoader to have special cases for Clang, but this isn't
the first.)

Note that I'm not reverting the UIEdgeInsetsZero workaround here; the
end state will have that coming just from UIKit as originally
described.

rdar://problem/40839486
2018-06-20 14:51:17 -07:00
swift-ci
2a0e83dc0d Merge remote-tracking branch 'origin/master' into master-next 2018-06-18 11:00:19 -07:00
Jordan Rose
05d0a2dfef [Serialization] Mark decls that can never be cross-referenced (#17223)
This allows us to filter them out in cases that would otherwise be
ambiguous. The particular prompting situation looks a lot like the
test case: a protocol, plus a forward-declared class with the same
name. (Normally we ignore forward-declared classes, but SourceKit's
module interface generation feature makes dummy ClassDecls for them
instead.)

https://bugs.swift.org/browse/SR-4851
2018-06-18 10:50:35 -07:00
swift-ci
4538ce9818 Merge remote-tracking branch 'origin/master' into master-next 2018-06-17 15:38:24 -07:00
John McCall
69f4dd1ec9 Generalize accessor storage to preserve the original accessor list.
Only not NFC because it's detectable by source tools.
2018-06-16 18:16:31 -04:00
Bob Wilson
5df3d1f100 Merge remote-tracking branch 'origin/master' into master-next 2018-06-14 20:51:48 -07:00
John McCall
9022b5152f Rename accessor kinds from IsGetter -> IsGet, etc.
Introduce some metaprogramming of accessors and generally prepare
for storing less-structured accessor lists.

NFC except for a change to the serialization format.
2018-06-14 17:08:55 -04:00
Bob Wilson
83f6d9649f Merge pull request #17160 from bob-wilson/llvm-r334399
[master-next] Adjust for VersionTuple moving from clang to llvm.
2018-06-12 16:47:25 -07:00
Bob Wilson
c3e02955bb [master-next] Adjust for VersionTuple moving from clang to llvm.
LLVM r334399 (and related Clang changes) moved clang::VersionTuple to
llvm::VersionTuple. Update Swift to match.

Patch by Jason Molenda.
rdar://problem/41025046
2018-06-12 16:44:11 -07:00
Jordan Rose
bcc1ed29e3 [Serialization] Slightly improve cross-reference failure crash traces (#17148)
Trade a tiny bit of speed in the happy path for a more sensible
result, and make sure to preserve the information about what was being
looked up when a cross-reference turns out to be ambiguous. No
intended functionality change.
2018-06-12 16:25:40 -07:00
Jordan Rose
ec90545ff2 [Serialization] Follow compatibility typealiases for non-generic types (#16618)
Now that we use the C names of imported types in mangled names, it's
safe to resolve a compatibility alias when a type gets an
NS_SWIFT_NAME for the first time, rather than requiring the developer
to recompile the imported library.

This doesn't include generic types, which only applies for Objective-C
generics. There shouldn't be additional complications here but I want
to be extra careful.

rdar://problem/39661212
2018-05-15 10:04:40 -07:00
Jordan Rose
a45928ca8a [Serialization] Handle XREFs to generic subscripts (#16554)
Found while compiling another project.
2018-05-11 15:06:48 -07:00
Doug Gregor
ba391b6b47 [Serialization] Remove (de-)serialization of Substitution.
We are no longer serializing Substitution (or SubstitutionList) anywhere, so
remove the code associated with it.
2018-05-03 13:40:52 -07:00
Doug Gregor
bc5bbe8b64 [AST] Use SubstitutionMap, not SubstitutionList, in SILBoxType.
Eliminate the last place in the AST proper that stores
SubstitutionLists rather than SubstitutionMaps. Randomly fixes a
crasher, too.
2018-05-02 13:39:21 -07:00
Doug Gregor
3e2bed119b [AST] Switch SpecializedProtocolConformance over to SubstitutionMap.
Eliminate another common use of SubstitutionList from the AST.
2018-05-02 13:38:15 -07:00
Doug Gregor
192234415d [AST] Store SubstitutionMaps in ConcreteDeclRef and Witness data structures.
Replace two prominent uses of SubstitutionList, in ConcreteDeclRef and
Witness, with SubstitutionMap. Deal with the myriad places where we
now have substitution maps and need substitution lists (or vice versa)
caused by this change.

Overall, removes ~50 explicit uses of SubstitutionList (of ~400).
2018-05-02 13:38:14 -07:00
Doug Gregor
df97e44eb9 [AST] Replace SubstitutionList in NameAliasType with a SubstitutionMap.
Convert NameAliasType’s internal representation from tail-allocating an
array of Substitutions (to be treated as a SubstitutionList) to store a
single SubstitutionMap. Serialize using that SubstitutionMap.
2018-04-30 16:23:14 -07:00
Doug Gregor
ab56fa3e9c [Serialization] Support (de-)serialization of SubstitutionMaps.
Allow substitution maps to be serialized directly (via an ID), writing out
the replacement types and conformances as appropriate. This is a more
efficient form of serialization than the current SubstitutionList approach,
because it maintains uniqueness of substitution maps within a module file,
and is a step toward eliminating SubstitutionList entirely.
2018-04-30 16:21:58 -07:00
Pavel Yaskevich
f5db1df5dc [AST] Unify witness construction logic
Avoid storing more information than necessary in witnesses
and establishing the invariant that we only use out-of-line
storage when we require substitutions.
2018-04-19 18:00:04 -07:00
Pavel Yaskevich
e1fab0559c [Serialization] Always serialize requirement substitutions
Absence of synthetic generic environment should not affect
serialization of the required substitutions because they can
come from outer requirement context for static members.

Resolves: rdar://problem/36497404
2018-04-19 17:58:13 -07:00
Joe Groff
9e1a417b56 Serialization: Never serialize conformances from Clang modules.
We should always go through the Clang importer to reinstantiate them. Serializing them leads to the possibility of us ending up with multiple conformances with different identities that ought to be equivalent.
2018-04-03 14:40:26 -07:00
Mark Lacey
21134efd22 Revert "IRGen: Deserialize SIL witness tables and shared-linkage definitions by need." 2018-03-30 22:14:13 -07:00
Joe Groff
73895a3f22 Serialization: Never serialize conformances from Clang modules.
We should always go through the Clang importer to reinstantiate them. Serializing them leads to the possibility of us ending up with multiple conformances with different identities that ought to be equivalent.
2018-03-30 11:12:58 -07:00
Robert Widmann
187f6c132f Serialize the resilience expansion of EnumElementDecl's default arguments 2018-03-28 12:13:25 -04:00
Robert Widmann
03580d2fe5 Add a parameter list to EnumElementDecl
This models, but does not plumb through, default arguments.
2018-03-28 00:05:56 -04:00
Doug Gregor
b2b69e8abf Rename BoundNameAliasType to NameAliasType.
NameAliasType is dead! Long live NameAliasType!
2018-03-25 21:35:17 -07:00
Doug Gregor
0524741f6c [Serialization] Rename "alias name type" to "builtin alias type".
We still use the old layout for NameAliasType for builtin types, so
rename the Layout struct and corresponding code to describe its new
(more restricted) purpose.
2018-03-25 21:35:16 -07:00
Doug Gregor
e82e7ee908 [Type checker] Use BoundNameAliasType for all typealiases.
Rather than relying on the NameAliasType we get by default for references
to non-generic typealiases, use BoundNameAliasType consistently to handle
references to typealiases that are formed by the type checker.
2018-03-25 21:35:16 -07:00
Doug Gregor
bde6401f5b Support BoundNameAliasType everywhere we support NameAliasType.
This doesn't have a specific effect now, because all of these places
are likely to only see NameAliasType, but it is refactoring with the
intent of eliminating NameAliasType entirely.
2018-03-25 20:46:07 -07:00
Doug Gregor
80eae200b6 [AST] Preserve type sugar for generic typealiases
Introduce a new Type node, BoundNameAliasType, which describes a
reference to a typealias that requires substitutions to produce the
underlying type. This new type node is used both for references to
generic typealiases and for references to (non-generic) typealiases
that occur within generic contexts, e.g., Array<Int>.Element.

At present, the new type node is mainly useful in preserving type
sugar for diagnostics purposes, as well as being reflected in other
tools (indexing, code completion, etc.). The intent is to completely
replace NameAliasType in the future.
2018-03-21 23:49:17 -07:00
Jordan Rose
8a66d998fa Decide if a class inherits convenience inits alongside implicit inits
We have a predicate in ClassDecl, 'inheritsSuperclassInitializers',
that is used in a few places to decide if we need to do lookups into a
superclass to find all relevant initializers. That's useful, but the
actual work being computed in that function is almost identical to the
work done in figuring out whether the class has provided all its
superclass's /required/ initializers, which is part of the type
checker operation 'resolveImplicitConstructors'. Furthermore,
'inheritsSuperclassInitializers' is /already/ calling
'resolveImplicitConstructors' because those implicit constructors
might affect the result.

Simplify this whole mess and prevent further inconsistencies like the
previous commit by just making 'resolveImplicitConstructors' decide
whether superclass convenience initializers are inherited. It does
make that function more complicated, but with the benefit of not
having duplication anymore.

No intended user-visible change, except that this bit is now
serialized instead of being recomputed, which means the module format
changed.
2018-03-19 18:28:41 -07:00
Slava Pestov
34fd4ae512 AST: Use DeclBaseName::Kind::Constructor
Fixes <rdar://problem/35852727>, <https://bugs.swift.org/browse/SR-1660>,
<https://bugs.swift.org/browse/SR-6557>.
2018-03-16 00:25:56 -07:00
Slava Pestov
30dae65226 AST: Add DeclBaseName::Kind::Constructor
Not used yet.
2018-03-16 00:25:54 -07:00
Huon Wilson
e307e54098 [AST] Explicitly track things marked __owned. 2018-03-08 12:36:24 +11:00
Huon Wilson
3feb91b9a3 [Serialization] Explicitly convert to VarDecl::Specifier when deserializing.
Previously this just relied on serialization::VarDeclSpecifier being
identical to swift::VarDecl::Specifier, which is presumably true, but
also fragile.
2018-03-02 11:42:16 -08:00
Huon Wilson
12871d75bc [AST] Introduce "ValueOwnership" collecting __shared, inout, etc.
This is designed to stop having to n bits to track each of the
mutually exclusive 'shared', 'inout' and eventually 'owned'.
2018-03-02 11:40:20 -08:00
Huon Wilson
b94c5364f5 [NFC] Rename 'Ownership' to 'ReferenceOwnership'.
There's really two forms of ownership: references and values. Renaming
to make way for better distinguishing of the two.
2018-03-02 11:38:28 -08:00
Doug Gregor
ba8e86d2fb [Deserialization] Weakened DeclContext asssertion in maybeReadGenericParams.
An over-eager assertion in ModuleFile::maybeReadGenericParams() rejected
deserialization into the context of a generic subscript for a generic
parameter within one of its accessors. Weaken the assertion; the
DeclContext of the generic parameter will be overwritten with the
correct context later.

Fixes rdar://problem/37408205.
2018-02-12 12:01:48 -08:00
Jordan Rose
af67204b51 [Serialization] Handle XREFs to private types (#14352)
We can encounter these when the compiler modifies an inlinable
function to break apart a struct and the struct uses a private
type for one of its fields. It's questionable whether we /should/
handle this, but meanwhile this /is/ a non-intrusive fix that
preserves the performance of non-resilient libraries.

(That is, it appears this worked in Swift 4.0, though perhaps
not all of the same optimizations kicked in.)

https://bugs.swift.org/browse/SR-6874
2018-02-07 16:42:16 -08:00