Commit Graph

1165 Commits

Author SHA1 Message Date
Slava Pestov
a1d0870e6c Serialization: Remove uses of AbstractFunctionDecl::getParameterLists() 2018-07-21 01:25:06 -07:00
swift-ci
9eb4e3a0a4 Merge remote-tracking branch 'origin/master' into master-next 2018-07-16 18:48:54 -07:00
Slava Pestov
fc80f75273 AST: Create new 'invalid' state for ProtocolConformanceRef 2018-07-16 16:44:27 -07:00
swift-ci
decf2b1130 Merge remote-tracking branch 'origin/master' into master-next 2018-07-05 11:49:26 -07:00
John McCall
34b0cbc11d Merge pull request #16237 from davezarzycki/metaprogram_ref_storage_types
[AST] NFC: Enable reference storage type meta-programming
2018-07-05 14:45:38 -04:00
swift-ci
ad947ba176 Merge remote-tracking branch 'origin/master' into master-next 2018-07-02 19:28:56 -07:00
Jordan Rose
f230abfde6 [Serialization] Remove unused "force non-cross-reference" feature (#17686)
This was originally added to support "derived" top-level declarations,
which in practice was just '==' implementations for enums. Now that
those are members, we don't have the notion of derived top-level
declarations anymore, and neither is there anything that would
normally be a cross-reference that we want to force to be serialized
directly.

No functionality change (because this was unused).
2018-07-02 19:19:10 -07:00
swift-ci
f3b8a3cbaf Merge remote-tracking branch 'origin/master' into master-next 2018-06-30 10:09:20 -07:00
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
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
swift-ci
f02fc2468f Merge remote-tracking branch 'origin/master' into master-next 2018-06-25 19:29:45 -07:00
Jordan Rose
7f33f47ab3 [Serialization] Drop extensions whose requirements are missing types (#17488)
If, for whatever reason, a type used in an extension's generic
requirements is missing, just drop the whole extension. This isn't
wonderful recovery, but in practice nothing should be able to use the
extension anyway, since the relevant type in question is missing.

...Okay, that's not quite true; there could, for example, be inlinable
code that references one of these methods. However, that (1) isn't
worse than the behavior for any other inlinable code (which doesn't
yet attempt to recover from missing declarations), and (2) is still a
strict improvement over the current situation, where we will eagerly
abort the compiler trying to load the extension in the first place.

rdar://problem/40956460
2018-06-25 19:17:11 -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
Jordan Rose
e5cec5fdd9 Merge pull request #17186 from jrose-apple/bridge-over-troubled-imports
[Serialization] Always list the bridging header before any imports

rdar://problem/40471329
2018-06-18 10:42:09 -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
swift-ci
bfe796b93e Merge remote-tracking branch 'origin/master' into master-next 2018-06-16 01:32:31 -07:00
Doug Gregor
18569e5f77 Merge pull request #16963 from DougGregor/evaluator-type-checker
[Type checker] Use the request-evaluator in the type checker.
2018-06-15 22:41:31 -07:00
Bob Wilson
d933b5d60c Merge remote-tracking branch 'origin/master' into master-next 2018-06-15 20:20:25 -07:00
Jordan Rose
570ed72ea5 Add assertions to prevent truncation when using llvm::endian::Writer (#17266)
Also, stop serializing a few constant values, saving a tiny bit of
space in swiftmodule files.
2018-06-15 19:26:35 -07:00
Bob Wilson
5df3d1f100 Merge remote-tracking branch 'origin/master' into master-next 2018-06-14 20:51:48 -07:00
Doug Gregor
ef337bb8ba [Evaluator] Use the request-evaluator for the superclass of a class.
Wire up the request-evaluator with an instance in ASTContext, and
introduce two request kinds: one to retrieve the superclass of a class
declaration, and one to compute the type of an entry in the
inheritance clause.

Teach ClassDecl::getSuperclass() to go through the request-evaluator,
centralizing the logic to compute and extract the superclass
type.

Fixes the crasher from rdar://problem/26498438.
2018-06-14 15:28:36 -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
Jordan Rose
6dcda937f0 [Serialization] Always list the bridging header before any imports
This mirrors how a bridging header is processed when compiling source
files: before any of the imports. This is important for LLDB to
recreate the source environment as closely as possible to how the
compiler does it; in the test case being added involving a non-modular
header file, failure to do so resulted in a deserialization
cross-reference crash.

Note that Serialization still sorts imports, which normal resolution
of imports in source does not do. So we're still not consistent. But
this is less important than handling textual includes (bridging
headers) before modular imports.

rdar://problem/40471329
2018-06-13 16:20:31 -07:00
swift-ci
1156f84f37 Merge remote-tracking branch 'origin/master' into master-next 2018-05-23 00:49:11 -07:00
Pavel Yaskevich
7ed3d754b5 [Serialization] Allow unbound generic types to cross-reference typealias decls
Ideally `UnboundGenericType` should never be serialized but it is
currently allowed to make generic `typealias` declarations without
specifying generic parameters, so it should be allowed to cross
reference typealias decls in such types as well because `NameAliasType`
can't be used until generic parameters are resolved.

This is only a temporary fix and more comprehensive solution is still
pending here, most likely such declarations should not produce
`UnboundGenericType` but instead should copy generic parameters from
underlying type and produce proper `NameAliasType`.

Resolves: rdar://problem/37384120
2018-05-22 18:17:21 -07:00
Bob Wilson
1fc7f1391e [master-next] Update endian stream interface to match Clang r332757 2018-05-19 22:19:35 -07:00
swift-ci
dd7589a85c Merge remote-tracking branch 'origin/master' into master-next 2018-05-11 01:49:13 -07:00
Rintaro Ishizaki
6496175653 [Serialization] Omit local discrimiator from LocalDeclTableInfo
Local discriminators are emitted as a part of decl.
2018-05-11 15:37:40 +09:00
swift-ci
289829000b Merge remote-tracking branch 'origin/master' into master-next 2018-05-04 13:09:41 -07:00
Jordan Rose
4714fcd50c Revert "Merge pull request #16211 from slavapestov/fix-inlinable-vs-autolinking"
This reverts commit bb16ee049d,
reversing changes made to a8d831f5f5.
It's not sufficient to solve the problem, and the choices were to do
something more complicated, or just take a simple brute force
approach. We're going with the latter.
2018-05-03 22:40:31 -06:00
swift-ci
604f5930fe Merge remote-tracking branch 'origin/master' into master-next 2018-05-03 19:29:42 -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
swift-ci
2ea33a93e9 Merge remote-tracking branch 'origin/master' into master-next 2018-05-03 00:09:35 -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
swift-ci
9d46968584 Merge remote-tracking branch 'origin/master' into master-next 2018-05-01 20:48:51 -07:00
Slava Pestov
db440121b7 Serialization: Support '@_usableFromInline import'
Progress on <rdar://problem/39338239>; we still need to infer this
attribute though.
2018-05-01 17:56:15 -07:00
swift-ci
d3dacc306b Merge remote-tracking branch 'origin/master' into master-next 2018-04-30 20:49:19 -07:00
Doug Gregor
6bdd24d1ac Merge pull request #16268 from DougGregor/substitution-map-ast-adoption
[AST] Adopt SubstitutionMap as the storage mechanism for substitutions
2018-04-30 20:36:02 -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