Commit Graph

1132 Commits

Author SHA1 Message Date
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
2d19110e38 Serialization: Serialize opaque types and their decls. 2019-04-17 14:43:32 -07:00
Slava Pestov
39a22f3d6a AST: Remove ParameterTypeFlags::Escaping
Escapingness is a property of the type of a value, not a property of a function
parameter. Having it as a separate parameter flag just meant one more piece of
state that could get out of sync and cause weird problems.

Instead, always look at the noescape bit in a function type as the canonical
source of truth.

This does mean that '@escaping' is now printed in a few diagnostics where it was
not printed before; we can investigate these as separate issues, but it is
correct to print it there because the function types in question are, in fact,
escaping.

Fixes <https://bugs.swift.org/browse/SR-10256>, <rdar://problem/49522774>.
2019-04-15 00:25:03 -04:00
Slava Pestov
8292cbe3b3 AST: Remove 'default argument resilience expansion'
This was a Swift 3 mode holdover.
2019-04-02 20:37:01 -04:00
Brent Royal-Gordon
972eda2316 [NFC] AST-level support for static subscripts
* Moves the IsStatic flag from VarDecl to AbstractStorageDecl.
* Adds a StaticSubscriptKind to SubscriptDecl.
* Updates serialization for these changes.
* Updates SubscriptDecl constructor call sites for these changes.
2019-04-01 18:04:00 -07:00
Doug Gregor
a848d12665 Parse unknown attributes as "custom" attributes.
Parse custom attributes with the grammar:

```
'@' type-identifier expr-paren?
```
2019-03-29 23:10:36 -07:00
Argyrios Kyrtzidis
dd40c70496 Merge pull request #23627 from akyrtzi/fix-bad-deserial-49336277
[Serialization] Fix bad tagging of deserialized decls that can result in failed member lookups
2019-03-28 15:36:42 -07:00
Argyrios Kyrtzidis
1b2cb9c723 [Serialization] Fix bad tagging of deserialized decls that can result in failed member lookups
The issue was introduced in ec95e68ab9 which changed the behavior of `ModuleFile::getDeclChecked()` slightly.

rdar://49336277
2019-03-28 12:18:25 -07:00
Ted Kremenek
fe215edb9b Merge pull request #19743 from Azoy/smarter-struct-init
[Sema] Synthesize default values for memberwise init
2019-03-25 17:31:01 -07:00
Jordan Rose
61d3b0d4ec [ClangImporter] Avoid unneeded copy for getExportedModuleName
std::string -> StringRef of long-lived backing storage.

No functionality change.
2019-03-21 15:16:21 -07:00
Jordan Rose
1bec714519 [Serialization] Recover when a typealias can't be deserialized (#23419)
We already detected when a typealias /changed/ incompatibly; being
unable to deserialize it at all is just a very dramatic version of
that, right?

https://bugs.swift.org/browse/SR-9811
2019-03-19 16:45:57 -07:00
Azoy
6f7d20b99e Synthesize default values for memberwise init
Introduce stored property default argument kind

Fix indent

Assign nil to optionals with no initializers

Don't emit generator for stored property default arg

Fix problem with rebase

Indentation

Serialize stored property default arg text

Fix some tests

Add missing constructor in test

Print stored property's initializer expression

cleanups

preserve switch

complete_constructor

formatting

fix conflict
2019-03-13 18:57:36 -05:00
Jordan Rose
4db46b07b6 [Serialization] Make the input/output of a helper lambda clearer
It still has side effects, and it's still a lambda rather than a
helper function because it's not used anywhere else, but `[&]`
captures in helper lambdas make me nervous (as opposed to callback
lambdas).
2019-02-22 09:01:42 -08:00
Jordan Rose
fff69c9df6 [Serialization] Unify ExistentialMetatype and Metatype deserialization 2019-02-22 09:01:42 -08:00
Jordan Rose
da9fa9eb64 [Serialization] Move the rest of the type layouts into TypeDeserializer 2019-02-22 09:01:40 -08:00
Jordan Rose
0297d8fc3d [Serialization] Move one type's deserialization into a method
...to prove it can be done.
2019-02-22 08:59:36 -08:00
Jordan Rose
cdadaad9b5 [Serialization] Push caching of deserialized types out of helper class
Decls need to do this to avoid re-entrancy issues, but it turns out
types are simpler. I left a dummy "result" variable in the minimize
churn, since I'm going to move all the cases into their own functions
anyway.
2019-02-22 08:59:36 -08:00
Jordan Rose
23fdccc373 [Serialization] Start getTypeChecked() -> TypeDeserializer
Like I just did for DeclDeserializer. This one adds the new class and
moves most of getTypeChecked() into it, but doesn't yet split anything
up.
2019-02-22 08:59:33 -08:00
Joe Groff
64488b19f9 Serialization: Rework serialization of nested archetypes.
Explicitly serialize the parent archetype so that it can be any kind of root archetype.
2019-02-20 12:53:18 -08:00
Jordan Rose
b577838fa9 [Serialization] Collapse prefix/postfix operator deserialization
...using a template.
2019-02-13 20:23:39 -08:00
Jordan Rose
ec95e68ab9 [Serialization] Collapse one level of helper function I didn't need
No functionality change.
2019-02-13 20:23:39 -08:00
Jordan Rose
855ad2ca87 [Serialization] Move all the decl layouts into DeclDeserializer
Now we have a separate function for each serialized declaration kind!
Much cleaner, still NFC.
2019-02-13 20:23:39 -08:00
Jordan Rose
83586c74f0 [Serialization] Move helper lambda into DeclDeserializer
And cache the ASTContext pointer for convenience.
2019-02-13 20:23:39 -08:00
Jordan Rose
9f80d71bfb [Serialization] Move various RAII-based setup into DeclDeserializer
No functionality change.
2019-02-13 20:23:39 -08:00
Jordan Rose
8c062232c5 [Serialization] Make ASTDeserializer stateful, and use that state
...for decl attributes. Also, rename to DeclDeserializer.
2019-02-13 20:23:39 -08:00
Jordan Rose
e5408748cd [Serialization] Move one case in getDeclCheckedImpl out of line
...as a proof of concept. The next commit will move them /all/ out of
line.

(The intent here is to produce better backtraces when not recovering
from errors.)
2019-02-13 20:23:39 -08:00
Jordan Rose
b5a86cf3af [Serialization] Move decl attribute deserialization into new helper
No functionality change.
2019-02-13 20:23:39 -08:00
Jordan Rose
3273f06879 [Serialization] Pull decl deserialization out to a helper class
In preparation for splitting up one big switch into many small
methods. Well, medium-sized methods.

No functionality change.
2019-02-13 20:23:38 -08:00
Jordan Rose
106c470a10 [Serialization] Handle re-export of error enums harder (#21880)
A refinement of Doug's e3207f753c from a year ago to account for
trying to reference an import-as-member error enum /through/ an
overlay when it's in a Clang module using 'export_as'. The problem is
that importing error enums synthesizes a corresponding struct, and
that struct doesn't have a Clang node and so when it isn't found in
the right module the compiler didn't know to allow it anyway.

I know, right?

(Looking at the source change might be simpler than trying to read
the above paragraph.)

I'm still not 100% sure on how this occurred in the original
(Apple-internal) projects hitting this, but I think it's just that we
handle all import-as-member types at once, and the clients were using
something else from a type that contained the error enum, and then
that resulted in the error struct's conformances getting written into
a serialized swiftmodule.

rdar://problem/47152185
2019-01-15 15:02:19 -08:00
Parker Schuh
f5859ff46e Rename NameAliasType to TypeAliasType. 2019-01-09 16:47:13 -08:00
Ankit Aggarwal
45290837b4 Merge pull request #21110 from aciidb0mb3r/swiftpm-manifest-version
Extend @available to support PackageDescription
2019-01-07 12:20:23 -08:00
Joe Groff
89979137fc Push ArchetypeType's API down to subclasses.
And clean up code that conditionally works only with certain kinds of archetype along the way.
2018-12-12 19:45:40 -08:00
Jordan Rose
4017416d5e [Serialization] Only allow loading modules during import resolution (#21218)
Very early groundwork for private imports. Should not affect anything
today.
2018-12-12 10:50:20 -08:00
Slava Pestov
544e0a02d5 AST: Don't link together GenericParamLists of nested generic types
GenericParamList::OuterParameters would mirror the nesting structure
of generic DeclContexts. This resulted in redundant code and caused
unnecessary complications for extensions and protocols, whose
GenericParamLists are constructed after parse time.

Instead, lets only use OuterParameters to link together the multiple
parameter lists of a single extension, or parameter lists in SIL
functions.
2018-12-11 23:55:41 -05:00
Slava Pestov
e0c1e819c8 Serialization: Redo generic param xrefs to use GenericSignature
This code used GenericParamList::getOuterParameters() and
DeclContext::getGenericParamsOfContext(). The meaning of the
former is about to change, and the latter is going away.
2018-12-11 23:22:18 -05:00
Ankit Aggarwal
92d09f4e19 Extend @available to support PackageDescription
<rdar://problem/46548531> Extend @available to support PackageDescription

This introduces a new private availability kind "_PackageDescription" to
allow availability testing by an arbitary version that can be passed
using a new command-line flag "-swiftpm-manifest-version". The semantics
are exactly same as Swift version specific availability. In longer term,
it maybe possible to remove this enhancement once there is
a language-level availability support for 3rd party libraries.

Motivation:

Swift packages are configured using a Package.swift manifest file. The
manifest file uses a library called PackageDescription, which contains
various settings that can be configured for a package. The new additions
in the PackageDescription APIs are gated behind a "tools version" that
every manifest must declare. This means, packages don't automatically
get access to the new APIs. They need to update their declared tools
version in order to use the new API. This is basically similar to the
minimum deployment target version we have for our OSes.

This gating is important for allowing packages to maintain backwards
compatibility. SwiftPM currently checks for API usages at runtime in
order to implement this gating. This works reasonably well but can lead
to a poor experience with features like code-completion and module
interface generation in IDEs and editors (that use sourcekit-lsp) as
SwiftPM has no control over these features.
2018-12-08 09:38:40 +05:30
Harlan Haskins
245109d909 Merge pull request #20250 from harlanhaskins/accessorizing
[ParseableInterface] Standardize printing for accessors
2018-11-27 10:31:17 -08:00
Harlan Haskins
a20c31abf1 [Serialization] Add @_hasStorage and private(set) while deserializing 2018-11-26 18:42:02 -08:00
Jordan Rose
1f25ea51d7 Fix two issues with typealiases in protocol extensions (#20654)
- The GenericSignatureBuilder assumed it didn't have to look in
  protocol extensions to resolve member types.

- Serialization was incorrectly filtering out such typealiases when
  trying to resolve a cross-module reference to one.

rdar://problem/46103190
2018-11-26 11:31:12 -08:00
John McCall
6ffeb4d839 [NFC] Add PrettyStackTraceConformance and use it
Also allow the printFooDescription functions to suppress
the trailing newline.
2018-11-15 18:39:35 -05:00
John McCall
5553224fd4 Support the explicit representation of self-conformances.
Big, but actually NFC because we're never actually creating them.
2018-11-15 16:42:03 -05:00
Jordan Rose
40cfc458e2 Fix synthesis of 'override' and 'required' on initializers (#20548)
This is actually two separate problems:
- 'override' wasn't getting added to initializers in deserialization
- 'override' was getting added when inheriting a 'required' initializer,
  even though it's normally an error to write that

Needed for parseable interfaces.
2018-11-13 16:54:53 -08:00
Pavel Yaskevich
bce1ba5f37 [AST] Remove @autoclosure flag from function type ExtInfo 2018-11-10 11:59:29 -08:00
Pavel Yaskevich
0857611fa0 [Serialization] Add @autoclosure to parameter decl serialization format 2018-11-10 11:59:28 -08:00
Slava Pestov
c7338d06ca AST: Remove owning addressors 2018-11-09 20:49:44 -05:00
Jordan Rose
4539dbfd06 [Serialization] Simplify the representation of GenericParamLists (#20446)
Now that we don't store requirements in the GenericParamList, there's
no reason to use trailing records to list out the
GenericTypeParamDecls.

No functionality change.
2018-11-09 14:17:30 -08:00
Jordan Rose
4270bddaeb Verify that a GenericTypeParamDecl's depth and index are correct (#20445)
Re-applied after fixing a bug in Serialization where the DeclContext
wasn't being set correctly for extensions with nested parameters. I
was unable to come up with a reduced test case, but the CoreStore
project in the source compatibility suite was failing without the
Serialization change, and now it isn't.
2018-11-09 08:58:55 -08:00