Commit Graph

1697 Commits

Author SHA1 Message Date
Mark Lacey
21134efd22 Revert "IRGen: Deserialize SIL witness tables and shared-linkage definitions by need." 2018-03-30 22:14:13 -07:00
Andrew Trick
4ed120e46c Merge branch 'master' into add-access-tracking-flag 2018-03-30 19:25:46 -07:00
swift-ci
9121164d82 Merge remote-tracking branch 'origin/master' into master-next 2018-03-30 17:09:01 -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
Andrew Trick
ed8a604c27 Merge branch 'master' into add-access-tracking-flag 2018-03-29 18:26:22 -07:00
swift-ci
00ecedd1b3 Merge remote-tracking branch 'origin/master' into master-next 2018-03-28 11:08:57 -07:00
Robert Widmann
187f6c132f Serialize the resilience expansion of EnumElementDecl's default arguments 2018-03-28 12:13:25 -04:00
swift-ci
e6d70f352e Merge remote-tracking branch 'origin/master' into master-next 2018-03-27 22:08:57 -07: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
Andrew Trick
70ee3df099 Serialization support for begin_access [no_nested_conflict].
Add serialization layouts for rare instructions that take extra attributes. We
can continue adding bits to these layout without affecting the layout of the
vast majority of instructions.
2018-03-27 12:04:20 -07:00
swift-ci
29011402dd Merge remote-tracking branch 'origin/master' into master-next 2018-03-26 09:11:11 -07: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
c43f96a855 [AST] Remove now-unused NameAliasType. 2018-03-25 21:35:16 -07:00
swift-ci
18f27a5300 Merge remote-tracking branch 'origin/master' into master-next 2018-03-24 19:09:15 -07:00
swift-ci
29788f6245 Merge pull request #14963 from kitasuke/replace-of-builtin-string-with-constant 2018-03-24 18:56:17 -07:00
swift-ci
4c1d212192 Merge remote-tracking branch 'origin/master' into master-next 2018-03-22 13:29:26 -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
swift-ci
ccc93e88ee Merge remote-tracking branch 'origin/master' into master-next 2018-03-20 14:14:09 -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
swift-ci
d80ce649ed Merge remote-tracking branch 'origin/master' into master-next 2018-03-16 03:09:03 -07:00
Slava Pestov
30dae65226 AST: Add DeclBaseName::Kind::Constructor
Not used yet.
2018-03-16 00:25:54 -07:00
swift-ci
c1ea75c505 Merge remote-tracking branch 'origin/master' into master-next 2018-03-10 17:48:57 -08:00
Jordan Rose
c26f40b45b Fix some more misuses of LLVM's YAML parser. (#15119)
https://reviews.llvm.org/D44317 should prevent this from happening
again.
2018-03-10 17:47:14 -08:00
swift-ci
97b732d8cc Merge remote-tracking branch 'origin/master' into master-next 2018-03-07 18:29:16 -08:00
Huon Wilson
e307e54098 [AST] Explicitly track things marked __owned. 2018-03-08 12:36:24 +11:00
swift-ci
dcee1f4d47 Merge remote-tracking branch 'origin/master' into master-next 2018-03-02 14:31:02 -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
Adrian Prantl
0747d9a339 Force the DJB hash seed to 0 for compatibility with HashString.
The obsolete llvm::HashString() was equivalent to
llvm::djbHash(seed=0) and was removed from llvm. This patch replaces
all occurences of llvm::HashString() with llvm::djbHash(seed=0), no
functional change.

The default seed of llvm::djbHash() is supposed to yield a higher
quality result that using seed=0, but changing it looks like it
affects the ordering of SIL serialization.
2018-02-28 14:10:25 -08:00
Saleem Abdulrasool
a0c6a70c31 upstream-update: adjust for SVN r326091 2018-02-27 12:36:15 -08:00
Joe Groff
d365c153d4 SIL: Introduce sil_property declarations for property descriptors.
This provides SILGen a place to generate the key path component information for an exported property so that it can be linked to from other modules.
2018-02-23 14:57:45 -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
Mark Lacey
fdd86fe069 Remove ImplicitlyUnwrappedOptionalType.
We haven't been creating these since
https://github.com/apple/swift/pull/14299 but there was more
groundwork before we could actually remove the type definition.
2018-02-05 23:59:01 -08:00
Harlan
5e02d2a877 Implement #warning and #error (#14048)
* Implement #warning and #error

* Fix #warning/#error in switch statements

* Fix AST printing for #warning/#error

* Add to test case

* Add extra handling to ParseDeclPoundDiagnostic

* fix dumping

* Consume the right paren even in the failure case

* Diagnose extra tokens on the same line after a diagnostic directive
2018-02-03 18:07:05 -05:00
Mark Lacey
2008674495 Make ImplicitlyUnwrappedOptional<T> an unavailable typealias.
Also remove the decl from the known decls and remove a
bunch of code referencing that decl as well as a bunch of other
random things including deserialization support.

This includes removing some specialized diagnostics code that
matched the identifier ImplicitlyUnwrappedOptional, and tweaking
diagnostics for various modes and various issues.

Fixes most of rdar://problem/37121121, among other things.
2018-02-02 08:35:53 -08:00
Jordan Rose
3f4cba25d4 Use a semantic ClangImporterSynthesizedTypeAttr for error structs
...rather than the ad hoc CustomTypeNameManglingAttr I was using
before. As John pointed out, the AST should be semantic wherever
possible.

We may someday want to get out of this being an attribute altogether,
or duplicating information that's available in the original Clang
node, by actually storing a reference to that node somewhere. This is
tricky and mixed up with deciding what hasClangNode() or
getClangDecl() would mean, though, so for now the attribute just
carries the information we need.
2018-01-24 10:57:52 -08:00
Jordan Rose
9c1a22ad0f Mangle synthesized error structs as a variant of the imported enum
When importing a C enum with the ns_error_domain attribute, we
synthesize a struct containing an NSError object to represent errors
in that domain. That synthesized struct should have a mangled name
that ties it to the original C enum, if we want it to be stable, and
now it does.

Before: $SSC7MyErrorV (a normal struct, which is a lie)
After: $SSC11MyErrorCode13ns_error_enumLLV
  kind=Global
    kind=Structure
      kind=Module, text="__C_Synthesized"
      kind=PrivateDeclName
        kind=Identifier, text="ns_error_enum"
        kind=Identifier, text="MyErrorCode"

Using the "private discriminator" feature allows us to pack in extra
information about the declaration without changing the mangling
grammar, and without stepping on anything the importer is using.

More rdar://problem/24688918
2018-01-23 17:05:43 -08:00
John McCall
7f0f8830cd Split AccessorDecl out from FuncDecl. NFC.
This has three principal advantages:

- It gives some additional type-safety when working
  with known accessors.

- It makes it significantly easier to test whether a declaration
  is an accessor and encourages the use of a common idiom.

- It saves a small amount of memory in both FuncDecl and its
  serialized form.
2018-01-12 14:20:27 -05:00
Doug Gregor
3042e1f5ed [Serialization] Deserialize type witnesses before value witnesses.
The deserialization of the type witnesses for a normal protocol conformance
is crucial to the usability of said conformance. Deserializing the
value witnesses first can fail if they somehow rely on the type
witnesses (e.g., through a recursive conformance).

As a stop-gap, deserialize and record type witnesses *first*, then
deserialize value witnesses afterward. A longer-term solution would
make deserialization of the normal protocol conformance far more
lazy.

Fixes SR-6522 / rdar://problem/35830641, a merge-modules crasher in a
nontrivial project.
2017-12-14 22:07:23 -08:00
Jordan Rose
9cac094f89 [Serialization] Recover if an enum's generic requirements are broken
Follow-up to ac6fd7214 that adds a similar feature for enums. This
probably doesn't come up much, but the infrastructure's already there.
(The previous commit showed that the other places we do recovery
already handle this from their normal collection of "dependency
types".)
2017-11-27 13:21:12 -08:00
Jordan Rose
3d6e9cc629 [Serialization] Use a helper to get dependencies from requirements
Refactoring suggested by Slava on ac6fd7214. In cases where multiple
requirements mention the same nominal type, this will also result in
doing slightly less work because we'll only record it once. Other than
that, no user-visible change expected.
2017-11-27 13:21:12 -08:00
Slava Pestov
be1512c89f Serialization: Don't serialize the 'self' parameter 2017-11-18 20:02:50 -05:00
Jordan Rose
ac6fd7214e [Serialization] Recover if a typealias's underlying type is broken (#12979)
We could handle a typealias itself disappearing, but not if the
typealias was okay but the underlying type wasn't. This came up in
real Swift 3/4 mix-and-match code.

rdar://problem/34940079
2017-11-16 19:31:13 -08:00
Slava Pestov
510c4124c7 Serialization: Fix a warning 2017-11-15 22:52:28 -08:00
Slava Pestov
f07cde75e7 AST: Move mapTypeOutOfContext() from GenericEnvironment to TypeBase
It doesn't actually *use* the generic environment.
2017-11-15 22:52:13 -08:00
Erik Eckstein
8033476b64 Function-level optimization attributes.
For now these are underscored attributes, i.e. compiler internal attributes:
@_optimize(speed)
@_optimize(size)
@_optimize(none)

Those attributes override the command-line specified optimization mode for a specific function.
The @_optimize(none) attribute is equivalent to the already existing @_semantics("optimize.sil.never") attribute
2017-11-14 11:25:02 -08:00
John McCall
7743be30f6 Add a "token" type to SIL to allow dependencies to be expressed without
allowing abstraction.
2017-11-13 04:03:21 -05:00
Huon Wilson
99c4cddfca [SILGen] Store conditional conformances in SILWitnessTables. 2017-11-08 17:02:50 -08:00
Doug Gregor
82e1c98e46 [Serialize] Serialize uniqued generic signatures.
Rather than inlining generic signatures in a half dozen places throughout
the serialization format, serialize (uniqued) generic signatures with their
own GenericSignatureID. Update various layouts (generic function types,
SIL function types, generic environments, extension cross-references) to
use GenericSignatureID.

Shaves ~187k off the size of Swift.swiftmodule.
2017-11-07 13:36:22 -08:00