Commit Graph

2062 Commits

Author SHA1 Message Date
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
Jordan Rose
727a7eb77a Attributes: Use class names in the DAK_* enum instead of attribute spellings.
This allows for single attributes that can be spelled multiple ways.
No functionality change.

Swift SVN r18993
2014-06-18 23:28:28 +00:00
Justin Bogner
a0c0dc25be Use std::error_code rather than llvm::error_code
std::error_code is no longer available via the llvm namespace as of
r210835.

Swift SVN r18851
2014-06-13 02:54:07 +00:00
Jordan Rose
e5c6de2224 [Serialization] Tighten up handling of generic param lists.
No functionality change. Does not fix the issue with extensions of generic
types.

Swift SVN r18828
2014-06-12 19:45:05 +00:00
Doug Gregor
5783d0b313 Revert r19185: Add T* syntactic sugar type for UnsafePointer<T>.
Swift SVN r18255
2014-05-17 16:43:46 +00:00
Doug Gregor
806daf3a87 Add T* syntactic sugar type for UnsafePointer<T>.
This is the basic plumbing for <rdar://problem/16912508>.


Swift SVN r18195
2014-05-16 15:30:26 +00:00
Andrew Trick
fa898f5562 Force generic parameter types declared in module context to belong to
the current SIL module, unless the AST sees them first.

This turns out to be important when we deserialize generic
reabstraction thunks, which have shared linkage so get serialized
again in the current SIL module.

There are some fundamental inconsistencies in the way parameter type
decls are handled, but we need a quick workaround to unblock progress
on the stdlib.

Fixes
<rdar://problem/16807985> Building Foundation overlay crashes in stdlib deserialization in r17377

Swift SVN r18173
2014-05-16 04:27:09 +00:00
Ted Kremenek
edd89bfcc7 Move definition of @availabilty platforms into Attr.def, and change AvailabilityAttr's representation of platform.
This hardcodes the list of platforms into unique identifiers, which
has tradeoffs to using strings.  The reality is that various
logic in the compiler needs to be present to identify a given
platform, so hardcoding this list for now is ok.  We can evaluate
in the future.

This change is motivated by some needed cleanup, supporting
App Extensions @availability, and unifying build configurations
with the platform names for @availability.

As part of this change, it introduces some slightly better
parser recovery for bad @availability attributes.

Moreover, the 'macosx' platform is renamed to 'osx'.  We will need
to handle this mapping in the Clang Importer, but this is the
right thing to do.

Swift SVN r17767
2014-05-09 07:43:38 +00:00
Jordan Rose
dde2a8b06b Serialize and honor whether a particular library should be force-loaded.
When a module built with -autolink-force-load is imported, add a reference
to a special symbol in the corresponding library so that ld is forced to
link it.

This means the library will be linked into the final binary even if no other
symbols are used (which happens for some of our overlays that just add
category methods to Objective-C classes).

Second part of <rdar://problem/16829587>

Swift SVN r17751
2014-05-09 01:20:32 +00:00
Manman Ren
a842fff29f [Serializer] serialize the parent module of NormalProtocolConformance.
We used to just use FileContext at deserialization time. That causes
multiple NormalProtocolConformances with the same protocol and type,
but from different modules. And we will have issues at IRGen.

With this commit, we serialize the parent module and deserialize the parent
module, and we are not going to have multiple NormalProtocolConformances with
the same protocol and type.

rdar://16809311


Swift SVN r17675
2014-05-08 03:40:47 +00:00
Jordan Rose
5ceecb4337 [serialization] Add a special encoding for the imported header module.
This allows a loaded swiftmodule to refer to decls that come from a header
imported by the module itself. There's an unfortunate sharing of the
namespace here with any /other/ headers loaded by /other/ modules (including
the module currently being compiled), but that shouldn't be too much of an
issue in practice -- the declarations would need to be compatible anyway if
you were doing the same thing in Objective-C.

More of <rdar://problem/16702101>. This is possibly the end of the compiler
work, but I'd like to add more tests to make sure everything is working.

Swift SVN r17639
2014-05-07 19:03:22 +00:00
Jordan Rose
465b083ba9 [serialization] Serialize the header path used by -import-objc-header.
This doesn't handle cross-references to decls /loaded/ from the header
just yet, so all that's testable right now is whether the header's imports
are visible from the secondary target (after being imported in response
to loading the serialized module).

More of <rdar://problem/16702101>

Swift SVN r17638
2014-05-07 19:03:21 +00:00
Jordan Rose
a0de0e411d [serialization] Drop swift::serializeToStream and swift::serializeModuleDoc.
All serialization should go through serialize(). We don't currently support
serializing docs without serializing a module.

Also, tidy up how Serializer is used within Serialization.cpp.

Swift SVN r17637
2014-05-07 19:03:19 +00:00
John McCall
2b969c41a2 Track whether a class is "foreign" in the AST.
This basically just means "it's a CF class" for now,
but you could imagine applying this to all sorts of
class-like types from peer runtimes that we can't
support all possible language features for.

There are quite a few language features that require
fairly deep object-model integration to implement,
like subclassing and adding polymorphic methods.
Some of those features, like final classes, are useful
to generally support as attributes, but most of
them aren't.  At least in the short term, it makes
sense to have a big hammer we can hit things with.

Swift SVN r17428
2014-05-05 06:45:40 +00:00
Doug Gregor
eb7a9144a8 Bring keyword arguments to subscripts.
Subscript declarations were still encoding the names of index
variables in the subscript type, which unintentionally made them
keyword arguments. Bring subscript declarations into the modern day,
using compound names to encode the subscript argument names, which
provides consistency for the keyword-argument world
<rdar://problem/14462349>. Note that arguments in subscripts default
to not being keyword arguments, which seems like the right default.

We now get keyword arguments for subscripts, so one can overload
subscripts on the names of the indices, and distinguish at the call
site. Under -strict-keyword-arguments, we require strictness here as well.

The IRGen/IDE/SILGen test updates are because the mangling of common
subscripts changed from accidentally having keyword arguments to not
having keyword arguments.

Swift SVN r17393
2014-05-04 19:31:09 +00:00
Ted Kremenek
050fd53af7 Rename UncheckedOptional to ImplicitlyUnwrappedOptional.
Swift SVN r17232
2014-05-02 06:13:57 +00:00
Chris Lattner
a7012f23ef Remove swift::ArrayType. It is dead and vestigial code for supporting fixed size
arrays, which never got baked.  Remove it until we have time to do things right.


Swift SVN r16995
2014-04-28 21:18:27 +00:00
John McCall
d9e4d6f2ad Add the Unmanaged library type.
Swift SVN r16796
2014-04-25 02:16:04 +00:00
John McCall
b38a63950d Implement @unowned(unsafe).
This was part of the original weak design that
there was never any particular reason to rush the
implementation for.  It's convenient to do this now
so that we can use it to implement Unmanaged<T> for
importing CF types.

Swift SVN r16693
2014-04-23 08:51:23 +00:00