Commit Graph

2080 Commits

Author SHA1 Message Date
John McCall
7ae26ffd05 Serialize the materializeForSet accessor of a subscript.
Swift SVN r22016
2014-09-17 08:08:10 +00:00
John McCall
75050f8166 Generate an implicit 'materializeForSet' accessor
along with getters and setters.

Just generate it for now.

Swift SVN r22011
2014-09-17 08:08:03 +00:00
Devin Coughlin
1b8ed882d3 Move AvailabilityAttr::PlatformKind into its own file
Swift SVN r21728
2014-09-04 23:34:19 +00:00
Jordan Rose
1b51b60e72 [Serialization] Preserve private discriminators through serialization.
Part of rdar://problem/17632175

Swift SVN r21611
2014-08-30 17:27:02 +00:00
Jordan Rose
c35312815a [PrintAsObjC] @import required explicit submodules.
...but prefer the base module for implicit submodules.

rdar://problem/18097120

Swift SVN r21555
2014-08-29 00:39:24 +00:00
Jordan Rose
422565100e [Serialization] Keep track of whether a module has an underlying Clang module.
Previously, we depended on whether or not a serialized module was located
within a framework bundle to consider whether or not it may have a "Clang
half". However, LLDB loads serialized modules from dSYM bundles. Rather
than try to figure out if such a module is "really" a framework, just track
whether the original module was built with -import-underlying-module. If so,
consider the underlying Clang module to be re-exported.

rdar://problem/18099523

Swift SVN r21544
2014-08-28 21:36:02 +00:00
Jordan Rose
c3660d5ad6 [Serialization] Ensure that a cached bridging header is null-terminated.
I'm not quite sure how to tickle this one, but the next commit adds more
data after the cached header, at which point existing tests break. This
could have already caused problems if no padding was needed in the bitstream.

Swift SVN r21543
2014-08-28 21:36:00 +00:00
Jordan Rose
90c76906bd [Serialization] Wrap up serialization options into a class.
No functionality change.

Swift SVN r21542
2014-08-28 21:35:57 +00:00
Andrew Trick
9ce5894db1 Fix raw_fd_ostream calls for ToT constructor changes
Swift SVN r21447
2014-08-25 23:29:36 +00:00
Doug Gregor
51c1433ddd Add magic "literal" __DSO_HANDLE__ to refer to the DSO handle.
__DSO_HANDLE__ can be used as a callee-side default
argument. Addresses rdar://problem/17878114.


Swift SVN r21440
2014-08-25 16:33:54 +00:00
Doug Gregor
17716524c5 Handle CF <-> Objective-C toll-free-bridged conversions in the type checker.
Introduce an attribute that describes when a given CF type is
toll-free-bridged to an Objective-C class, and which class that
is. Use that information in the type checker to provide the CF <->
Objective-C toll-free-bridged conversions directly, rather than using
the user-defined conversion machinery.

Swift SVN r21376
2014-08-21 21:36:05 +00:00
Doug Gregor
64bd844e0e Parse failable initializers.
Parsing, representation, (de-)serialization, printing, and dumping for
failable initializers.


Swift SVN r21290
2014-08-19 18:41:30 +00:00
Nadav Rotem
8dd52d63cd Add the @effects(readonly/readnone/readwrite) attribute.
Swift SVN r21070
2014-08-06 18:48:20 +00:00
Doug Gregor
6bf57e9010 Revert "Serialization: introduce a conformance cross-reference so we don’t serialize normal protocol conformances in modules that didn’t declare them."
This reverts commit r20792.

Conflicts:
	include/swift/Serialization/ModuleFormat.h

Swift SVN r20834
2014-07-31 17:30:08 +00:00
Doug Gregor
0184d9719b Partially revert “Maintain the DeclContext of a NormalProtocolConformance as the type declaration or extension.”
We now have this information during parsing and throw it away during deserialization. This half-baked state works because all non-generic-extension clients only care about the module context.

Swift SVN r20833
2014-07-31 17:30:08 +00:00
Doug Gregor
ae454c49d6 Revert "Don't emit protocol conformance cross-references for conformances owned by Clang modules."
This reverts commit r20828.

Swift SVN r20831
2014-07-31 17:30:05 +00:00
Doug Gregor
2b59a39ccf Don't emit protocol conformance cross-references for conformances owned by Clang modules.
Swift SVN r20828
2014-07-31 15:59:01 +00:00
Doug Gregor
ba040d9f21 Maintain the DeclContext of a NormalProtocolConformance as the type declaration or extension.
Previously, we only retained the module in which a normal protocol
conformance occurred, which meant we either had to go searching for
the appropriate extension (yuck) or do without that information. This
is part of the separating-extension-archetypes work.

Swift SVN r20793
2014-07-31 01:00:30 +00:00
Doug Gregor
e098ce84fb Serialization: introduce a conformance cross-reference so we don’t serialize normal protocol conformances in modules that didn’t declare them.
Swift SVN r20792
2014-07-31 01:00:17 +00:00
Jordan Rose
5c1e9d7d36 [Accessibility] Store setter accessibility explicitly.
Previously, we were just storing setter accessibility via the accessibility
level on the setter function. However, some Stored properties never actually
have a setter synthesized, which led to the compiler dropping the setter
accessibility at serialization time. Rather than try to hack up something
clever, just store the setter accessibility explicitly in every
AbstractStorageDecl. (We still only serialize it for VarDecls, because
settable SubscriptDecls always have setter functions.)

<rdar://problem/17816530>

Swift SVN r20598
2014-07-26 22:43:54 +00:00
Chris Lattner
6d0934d33d Introduce a new 'renamed' modifier on unavailable attributes. This allows Xcode
to emit fixit's when we rename something, e.g.:

t.swift:6:9: error: 'float' has been renamed to Float
var y : float
        ^~~~~
        Float

Adopt this in the stdlib.



Swift SVN r20549
2014-07-25 18:00:37 +00:00
Joe Groff
623aba1786 Encapsulate Substitution's state.
Expose Substitution's archetype, replacement, and conformances only through getters so we can actually assert invariants about them. To start, require  replacement types to be materializable in order to catch cases where the type-checker tries to bind type variables to lvalue or inout types, and require the conformance array to match the number of protocol conformances required by the archetype. This exposes some latent bugs in the test suite I've marked as failures for now:

- test/Constraints/overload.swift was quietly suffering from <rdar://problem/17507421>, but we didn't notice because we never tried to codegen it.
- test/SIL/Parser/array_roundtrip.swift doesn't correctly roundtrip substitutions, which I filed as <rdar://problem/17781140>.

Swift SVN r20418
2014-07-23 18:00:38 +00:00
Joe Groff
7feeecfd21 Sema: Bring back 'assignment' as an infix operator modifier.
We need it to decide whether to admit infix operators into an optional chain, such as 'x? = 0' or 'x?.y += 2'.

Swift SVN r20295
2014-07-22 05:16:01 +00:00
Jordan Rose
6ee53ff75f [Serialization] Preserve submodule import paths through serialization.
This is a bit of a hack, but Clang submodules are the only case we have to
support.

Part of <rdar://problem/13140302>

Swift SVN r20287
2014-07-22 01:31:15 +00:00
Jordan Rose
fce31decdc Serialize bridging headers into the merged module file.
We do this so that the swiftmodule file contains all info necessary to
reconstruct the AST for debugging purposes. If the swiftmodule file is copied
into a dSYM bundle, it can (in theory) be used to debug a built app months
later. The header is processed with -frewrite-includes so that it includes
any non-modular content; the user will not have to recreate their project
structure and header maps to reload the AST.

There is some extra complexity here: a target with a bridging header
(such as a unit test target) may depend on another target with a bridging
header (such as an app target). This is a rare case, but one we'd like to
still keep working. However, if both bridging headers import some common.h,
we have a problem, because -frewrite-includes will lose the once-ness
of #import. Therefore, we /also/ store the path, size, and mtime of a
bridging header in the swiftmodule, and prefer to use a regular parse from
the original file if it can be located and hasn't been changed.

<rdar://problem/17688408>

Swift SVN r20128
2014-07-18 00:22:53 +00:00
Chris Lattner
2f1c9c290b spell the attribute correctly. It helps to save before committing.
Swift SVN r20077
2014-07-17 05:32:44 +00:00
Chris Lattner
887ff4cefd eliminate VIRTUAL_DECL_ATTR, switching accessibility (the last holdout) over to
using a combination of attribute aliases and "NotSerialized" to provide the
equivalent functionality.


Swift SVN r20076
2014-07-17 05:29:17 +00:00
Ben Langmuir
073d3a441c Print precedence and associativity of infix operator decls
To answer "did the user specify this, or is it implicit", stick a couple
of is-implicit bits in InfixOperatorDecl, and thread them through
serializaton/deserialization.

Swift SVN r20067
2014-07-17 03:20:01 +00:00
Chris Lattner
6592366f23 switch weak/unowned/unowned(unsafe) to the new declattributes machinery.
Swift SVN r20032
2014-07-16 19:46:00 +00:00
Chris Lattner
d75c9570ec switch raw doc comments off of VIRTUAL_DECL_ATTR, they can just use NotSerialized now.
Swift SVN r20025
2014-07-16 17:12:37 +00:00
Chris Lattner
2825b9f5f8 move @transparent and @requires_stored_property_inits to the new attribute model.
All that is left is unowned(unsafe) & weak.



Swift SVN r20012
2014-07-16 06:14:19 +00:00
Chris Lattner
1907ad9c91 Move 'mutating' and 'nonmutating' onto the new attribute processing machinery.
Also:
 - merge the test/decl/func/functions_new.swift testcase into test/Sema/immutability.swift,
   where the bulk of similar tests are.
 - Move the type checking logic for 'dynamic' out of ValidateAttrs into TypeCheckAttrs
 - Change the encoding for 'override' to 49 so that stuff vbr's so much more densely :-)




Swift SVN r20006
2014-07-16 05:32:17 +00:00
Chris Lattner
fe30b66a93 move "override" onto the new fangle decl modifier code, instead of being a virtual
attribute.  As part of this, introduce a new "NotSerialized" flag in Attr.def.
This eliminates a bunch of special case code in the parser and elsewhere for handling
this modifier.



Swift SVN r19997
2014-07-16 01:23:58 +00:00
Chris Lattner
ea8b7a471a Extend the attributes machinery to enforce the "OnFoo" flags in Attr.def at sema time, and extend
them to cover all declaration types.

This ensures that we reject attributes on declkinds where they don't make sense.  I went so far
as to make the QoI decent when an attribute can only be applied to a single kind of declaration
to make sure the error message says "@IBAction is only valid on 'func' declarations" as well.

This resolves <rdar://problem/17681151> 'dynamic' accepted by the compiler where it shouldn't be




Swift SVN r19982
2014-07-15 20:30:21 +00:00
Joe Groff
45eec9a2e9 Remove 'interface' from the method names of SILFunctionType.
SILFunctionTypes are always interface types now. NFC.

Swift SVN r19952
2014-07-14 22:03:46 +00:00
Chris Lattner
a3c17dc166 move the @infix/@postfix/@prefix attributes onto the modern attribute infrastructure, NFC.
Swift SVN r19927
2014-07-14 14:30:26 +00:00
Doug Gregor
a5c079af59 Replace the class_protocol attribute with a "class" requirement.
This only tackles the protocol case (<rdar://problem/17510790>); it
does not yet generalize to an arbitrary "class" requirement on either
existentials or generics.

Swift SVN r19896
2014-07-13 06:57:48 +00:00
Doug Gregor
cb8e12368b Remove user conversions (@conversion __conversion) as a user feature.
We still have type checker support for user-defined conversions,
because the importer still synthesizes __conversion functions for CF
<-> NS classes.

Swift SVN r19813
2014-07-10 16:58:44 +00:00
Chris Lattner
35dcc3aa10 Move the @optional attribute to being a SIMPLE_DECL_ATTR, which
simplifies a bunch of code, makes them more consistent with the
other attributes, and is generally the newfangled way to do things.



Swift SVN r19779
2014-07-10 04:34:00 +00:00
Jordan Rose
132a29eb67 Remove unnecessary wrapper type GenericParam.
This always wrapped a single GenericTypeParamDecl *, and provided no benefit
over just using the decl directly.

No (intended) functionality change.

Swift SVN r19628
2014-07-07 20:51:50 +00:00
Jordan Rose
f4296846b0 [Serialization] Allow witness conformances to be "incomplete" when writing.
This just means we haven't deserialized them properly yet. As soon as we
try to /do/ something with the conformance, we'd pull in what we need, but
for reserializing (i.e. module-merging) we can generally just keep going.

<rdar://problem/17251682>

Swift SVN r19540
2014-07-03 22:56:34 +00:00
Ted Kremenek
04095fb5aa *Start* importing more availability information from the SDK.
This is a WIP.  This patch includes:

- Adds version tuple information for 'introduced', 'deprecated',
  and 'obsoleted' to the 'availability' attribute.

- Add Clang importer support to import __attribute__((availability))
  version tuples into Swift as pieces of the 'availability'
  attribute.

- Add serialization support for the 'availability' attribute with
  this extra information.  This is not tested other than the
  tests currently passing.  This is not expected to be
  really exercised (with interesting versions) until
  parsing support is added for the version tuples.  However,
  existing @availability attributes in the test suite are being
  serialized, which should just include "empty" version information.

What's not in this patch:

- Parsing support in Swift for 'deprecated', 'introduced', or
  'obsoleted'.  All of this information is currently being pulled
  in from the Clang Importer.

- Warning support for using deprecated declarations based on the
  availability information and the minimum deployment target.

- Some harmony reconciling the 'IsUnavailable' field in
  AvailabilityAttr, which attempts to eagerly compute if something
  is unavailable so we don't have to replicate the checking logic
  elsewhere.  The idea is that when we either import availability
  information or lazily deserialize it we can compute whether or
  not something is conditionally unavailable or deprecated right
  there, and not have to have all clients within the frontend
  of the availability information need to pass the minimum
  deployment target.  Right now 'IsUnavailable' is also used
  to encode if the attribute represents unconditional unavailability,
  e.g. @availability(*, unavailable).

This patch, however, should contain enough information to start
looking at implementing weak linking support.

NOTE: the serialization of the attribute is a bit ugly.  I wasn't
certain if Jordan's serialization meta-programming supported
serializing values that decomposed into multiple values in a record,
so this ugly macro-based implementation is in place which compacts
all the version tuple information for an availability attribute
into a single record.

Swift SVN r19487
2014-07-02 23:13:14 +00:00
Manman Ren
2b2330bf5b [attribute] rename @noinline to @inline(never).
Add support for parsing inline(never), it can be easily expanded to
handle inline(always).

rdar://17527111


Swift SVN r19447
2014-07-02 01:27:05 +00:00
Doug Gregor
304361b015 Serialization: add initializer cross-references that also include the kind of initializer (designated, convenience, etc.).
When we import factory methods as initializers, we can end up with two initializers that have the same name and type but different kinds. This will differentiate them. Tripped over this while investigating <rdar://problem/17411843>

Swift SVN r19440
2014-07-01 23:42:17 +00:00
Nadav Rotem
92d8688983 Add the @semantics attribute.
The @semantics attribute allows the stdlib to mark some functions as
having a specific semantics. The optimizer can use this information
to optimize the code.



Swift SVN r19328
2014-06-30 05:52:46 +00:00
Doug Gregor
07a7059934 Preserve dictionary type sugar in the type system.
Another piece of <rdar://problem/17460972>.


Swift SVN r19253
2014-06-26 21:12:19 +00:00
Manman Ren
863138ead7 [noinline diagnostic] allow noinline on Func Decl only.
Also move noinline attribute to use the new infrastructure i.e SIMPLE_DECL_ATTR,
per feedback from Dmitri.

rdar://15882816


Swift SVN r19188
2014-06-25 23:17:43 +00:00
Manman Ren
17f7202aae [noinline attribute] make it allowed attribute for FuncDecl in Serializer.
rdar://15882816


Swift SVN r19173
2014-06-25 18:34:16 +00:00
Manman Ren
7667b829bb [noinline attribute] add noinline attribute.
Propagate it to SILFunction and use it in PerformanceInliner. We also serialize
and parse the attribute.

rdar://15882816


Swift SVN r19150
2014-06-24 23:07:45 +00:00
Jordan Rose
6cca3529eb Compute accessibility for all ValueDecls, and serialize it properly.
No validation is done yet on whether the user-specified access control makes
sense in context, but all ValueDecls should at least /have/ accessibility now.

/Still/ no tests yet. They will be much easier to write once we're actually
enforcing access control and/or printing access control.

Swift SVN r19143
2014-06-24 21:32:13 +00:00