Commit Graph

1180 Commits

Author SHA1 Message Date
Jordan Rose
0e10f89964 Preserve default argument text through serialization (#18579)
This allows us to dump it in the generated interface, though it's
still not syntax-highlighted. This is necessary for textual module
interfaces, but it's also just a longstanding request for Xcode's
"Generated Interface" / "Jump to Definition" feature.

rdar://problem/18675831
2018-08-09 11:06:22 -07:00
Jordan Rose
9ebbf2fbaf [Serialization] Remove PARAMETERLIST_ELT node (#18570)
Way back in 6afe77d597 Chris removed the 'Parameter' type that tracked
extra information about parameters, collapsing it into ParamDecl and
making ParameterList "an overblown array of ParamDecl*'s". Do the same
thing for Serialization: push the few fields tracked in
PARAMETERLIST_ELT records down into PARAM_DECL, and then simplify the
PARAMETERLIST record to directly reference its parameters.

No functionality change.
2018-08-08 14:15:47 -07:00
swift-ci
71f0248b0a Merge remote-tracking branch 'origin/master' into master-next 2018-08-06 11:07:55 -07:00
Doug Gregor
bd5f5d80e4 [AST] Add ExtensionDecl::getExtendedNominal().
Introduce ExtensionDecl::getExtendedNominal() to provide the nominal
type declaration that the extension declaration extends. Move most
of the existing callers of the callers to getExtendedType() over to
getExtendedNominal(), because they don’t need the full type information.

ExtensionDecl::getExtendedNominal() is itself not very interesting yet,
because it depends on getExtendedType().
2018-08-03 11:26:48 -07:00
swift-ci
df3895a653 Merge remote-tracking branch 'origin/master' into master-next 2018-08-02 12:29:14 -07:00
Michael Gottesman
7e70389b80 [upstream-update] Do not specify OpenFlags since it was removed upstream.
This was removed upstream in https://reviews.llvm.org/D47789 since the only
place this flag was used was in the windows implementation where the behavior
triggered by this could be hidden in the implementation instead of being an
argument. As such, this code doesn't compile on master-next.

Since this has an acceptable default argument given the current stable, we can
just fix this on master and everything will work.

rdar://42862352
2018-08-02 11:34:54 -07:00
swift-ci
19cb223a66 Merge remote-tracking branch 'origin/master' into master-next 2018-08-01 18:49:02 -07:00
Jordan Rose
1dd415ae68 Add a new helper, atomicallyWritingToFile, and use it
This replaces the use of a Clang utility function that was
inexplicably a non-static member function of CompilerInstance. It
would be nice to sink this all the way to LLVM and share the
implementation across both projects, but the Clang implementation does
a handful of things we don't need, and it's hard to justify including
them in an LLVM-level interface. (I stared at
llvm/Support/FileSystem.h for a long time before giving up.)

Anyway, Serialization and FrontendTool both get their atomic writes
now without depending on Clang, and without duplicating the
scaffolding around the Clang API. We should probably adopt this for
all our output files.

No functionality change.
2018-08-01 16:41:21 -07:00
swift-ci
5830e237ff Merge remote-tracking branch 'origin/master' into master-next 2018-07-31 13:29:50 -07:00
Jordan Rose
2dfa303975 [Serialization] Preserve source order in serialization (#18361)
We previously shied away from this in order to not /accidentally/
depend on it, but it becomes interesting again with textual
interfaces, which can certainly be read by humans. The cross-file
order is the order of input files, which is at least controllable by
users.
2018-07-31 13:15:07 -07:00
swift-ci
bebd1ecbc7 Merge remote-tracking branch 'origin/master' into master-next 2018-07-26 09:09:12 -07:00
Doug Gregor
9b888533d4 [Serialization] Serialize Objective-C method names for accessors.
Due to some short-circuiting in the serialization logic, we never
added @objc getters/setters to a module’s Objective-C method table.
2018-07-25 16:48:50 -07:00
swift-ci
685b007c3f Merge remote-tracking branch 'origin/master' into master-next 2018-07-23 20:39:45 -07:00
John McCall
7a4aeed570 Implement generalized accessors using yield-once coroutines.
For now, the accessors have been underscored as `_read` and `_modify`.
I'll prepare an evolution proposal for this feature which should allow
us to remove the underscores or, y'know, rename them to `purple` and
`lettuce`.

`_read` accessors do not make any effort yet to avoid copying the
value being yielded.  I'll work on it in follow-up patches.

Opaque accesses to properties and subscripts defined with `_modify`
accessors will use an inefficient `materializeForSet` pattern that
materializes the value to a temporary instead of accessing it in-place.
That will be fixed by migrating to `modify` over `materializeForSet`,
which is next up after the `read` optimizations.

SIL ownership verification doesn't pass yet for the test cases here
because of a general fault in SILGen where borrows can outlive their
borrowed value due to being cleaned up on the general cleanup stack
when the borrowed value is cleaned up on the formal-access stack.
Michael, Andy, and I discussed various ways to fix this, but it seems
clear to me that it's not in any way specific to coroutine accesses.

rdar://35399664
2018-07-23 18:59:58 -04:00
swift-ci
b4bae42909 Merge remote-tracking branch 'origin/master' into master-next 2018-07-21 13:49:33 -07:00
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