Commit Graph

4327 Commits

Author SHA1 Message Date
Dmitri Hrybenko
d72a13b1c7 ReST parsing: add information about current and expected support level of
various section of ReST specification


Swift SVN r16121
2014-04-09 16:48:50 +00:00
Dmitri Hrybenko
f90e0c153b Make 'override' a keyword
rdar://16462192

Swift SVN r16115
2014-04-09 14:19:50 +00:00
Dmitri Hrybenko
68b609d7af Remove a kludge from deserialization that does not seem to be needed anymore
Swift SVN r16113
2014-04-09 13:42:17 +00:00
Michael Gottesman
2c191278d8 Fix header of SILDeclRef to be 80 columns.
Swift SVN r16097
2014-04-09 04:40:20 +00:00
Joe Groff
d149851607 SILGen: Copy blocks received as function arguments.
We want to generally treat blocks as heap objects until proven stack-able by escape analysis, like we do generally with other heap entities. The only place we should be exposed to stack blocks is when they're passed as arguments, so handle this by copy_block'ing any block arguments we get in the function prolog. Optimization can eliminate them when analysis shows the block doesn't escape or is already on the heap.

Swift SVN r16096
2014-04-09 04:35:17 +00:00
Joe Groff
8adaab0233 Fold ExtInfo::isThin and ::isBlock into a "Representation" enum.
These bits are orthogonal to each other, so combine them into one, and diagnose attempts to produce a type that's both. Spot-fix a bunch of places this revealed by inspection that we would have crashed in SILGen or IRGen if blocks were be handled.

Swift SVN r16088
2014-04-09 00:37:26 +00:00
Nadav Rotem
15233517ca Indent the line.
Swift SVN r16073
2014-04-08 20:31:57 +00:00
Nadav Rotem
5db3af6d38 Improve the diagnostics of immutable field access.
1.swift:7:18: error: cannot assign to 'x' in 'self'
  func Mod() { x = 1 }
               ~ ^



Swift SVN r16072
2014-04-08 20:27:32 +00:00
Doug Gregor
9e75a46c8c swift-ide-test: Add a -skip-unavailable option to skip unavailable declarations
Swift SVN r16056
2014-04-08 16:34:44 +00:00
Doug Gregor
5d20720e87 Some more camelCase string utilities.
Swift SVN r16053
2014-04-08 15:13:18 +00:00
Michael Gottesman
90f7864293 Implement John's suggestion of using "using SILCloner<ImplClass>::asImpl" to make calling Base::asImpl everywhere unnecessary.
Swift SVN r16048
2014-04-08 05:48:21 +00:00
Michael Gottesman
01b05fdc96 [specialization] SILCloner should always reference its builder SILBuilder via getBuilder().
Also fixed some 80+ issues.

This is in preparation for generic mandatory inlining.

Swift SVN r16046
2014-04-08 03:33:13 +00:00
Michael Gottesman
3525fac72d [specialization] Refactor SILCloner/SILVisitor to use an asImpl() method instead of directly calling static_cast.
NFC.

Swift SVN r16045
2014-04-08 03:25:29 +00:00
Joe Groff
4e789a09f7 Add an -enable-block-bridging frontend option we can hide disruptive changes to block bridging behind.
Swift SVN r16043
2014-04-08 02:43:19 +00:00
Joe Groff
fd9a9b5881 SIL: Add a CopyBlockInst instruction.
This maps down to a _Block_copy call that gives us the result, which may be different from the original object, back.

Swift SVN r16042
2014-04-08 02:43:17 +00:00
Joe Pamer
00427c0dfd Canonicalize new SIL generation error message.
Swift SVN r16026
2014-04-07 22:00:40 +00:00
Jordan Rose
835bfb15a9 [ClangImporter] Add an option (off by default) to infer "implicit properties".
In Objective-C, any method with no arguments can be used with dot syntax, as
can any method that takes one argument whose name starts with "set". This
commit adds a frontend-only flag -enable-objc-implicit-properties to look for
"setter-like" methods that match up with "getter-like" methods to import them
as Swift properties. By default, such methods are just considered unrelated
methods.

Part of <rdar://problem/16215476>

Swift SVN r16025
2014-04-07 21:49:37 +00:00
Joe Pamer
28d4b2a98c Add more tests and harden nested archetype lookup.
Swift SVN r16024
2014-04-07 21:31:53 +00:00
Joe Pamer
18f3bf67b0 More progress towards getting same-type constraints working correctly.
Swift SVN r16023
2014-04-07 21:31:52 +00:00
Joe Pamer
b9fdfe3063 Begin softening some restrictions on self-recursive constraints on associated types. This will prevent cases of infinite recursion while building archetypes.
Swift SVN r16022
2014-04-07 21:31:50 +00:00
Joe Pamer
1b50ad2d83 Protect against lookup failures on Foundation bridge types during SIL generation. (rdar://problem/16330675)
Swift SVN r16021
2014-04-07 21:31:48 +00:00
Doug Gregor
49387beb25 Selector splitting: don't split selectors in the middle of whitelisted "multi-words".
Swift SVN r16016
2014-04-07 19:17:23 +00:00
Dmitri Hrybenko
4315fdbbf8 @availability: implement serialization and AST printing
Swift SVN r16010
2014-04-07 14:07:28 +00:00
Dmitri Hrybenko
9a15e6bddd Attributes: hasAttribute() / getAttribute() returns only valid attributes by
default


Swift SVN r16008
2014-04-07 12:06:09 +00:00
Dmitri Hrybenko
67354b227f Update number of bits after I added the 'Invalid' bit
Swift SVN r16007
2014-04-07 11:25:42 +00:00
Dmitri Hrybenko
865a96a1a1 @noreturn: move to the new serialization scheme and add override checking
Swift SVN r16006
2014-04-07 11:22:59 +00:00
Doug Gregor
a87d65d617 Bridge NSArray <-> AnyObject[].
Allows AnyObject[] to occur in @objc methods/properties/etc., then
bridges between the two in SILGen based on the new array
implementation. <rdar://problem/16535097>.

Note that this commit does not change the Clang module importer to
import NSArray* as AnyObject[] (yet).


Swift SVN r16004
2014-04-07 05:49:48 +00:00
Dmitri Hrybenko
fb2a6499cd Move @class_protocol to use the new attribute infrastructure
... and fix a few other bugs:

* always set the inherited protocols on the ProtocolDecl in the type checker,
  so that we can remove a hack in ProtocolDecl::requiresClassSlow();

* diagnose DeclAttributes that are inverted when this is not allowed.


Swift SVN r15992
2014-04-06 01:24:08 +00:00
Nadav Rotem
276201c8ec Error message should start with a lower case letter.
Swift SVN r15987
2014-04-05 07:03:44 +00:00
Nadav Rotem
0d8729a9f6 Forbid the any kind of inheritance from @final classes.
Emit the following diagnostics:

  Inheritance from a final class 'ClassName'



Swift SVN r15986
2014-04-05 06:58:41 +00:00
Nadav Rotem
4b0e7737e1 Add support for the @final attribute on classes.
Swift SVN r15981
2014-04-05 05:52:40 +00:00
Enrico Granata
34209113fb The REPL currently tries to "warm up" by running an harmless expression, Void(), before giving the user control
This works, except when you launch it in -parse-stdlib mode, where running that expression fails, because Swift.Void wasn't pulled in, and that failure causes the REPL to quit

This patch passes down the -parse-stdlib flag to the REPL initialization code, such that it does not try to run any warm up code in -parse-stdlib mode



Swift SVN r15968
2014-04-05 00:28:55 +00:00
Doug Gregor
6da952e798 Parse the new function syntax.
Parse the new function syntax, which allows both the argument (API)
and parameter (internal) name to be specified prior to the colon
within each parameter. Don't re-use the existing pattern-parsing
logic. Rather, implement a new (far simpler) parser for this purpose,
then map from its simple data structures to ArgParams and BodyParams
as we're used to.

There are a number of caveats here:
  - We no longer have the ability to use patterns for parameters in
  function declarations. The only place this really has an impact is
  that it makes the ~> hack in the standard library even uglier.
  - This exposed some issues with code completion with generic
  parameters that need to be investigated.
  - There's still some work to be done to improve recovery when things
  parse poorly within a parameter list; there are some XFAILs to deal
  with that.

I'll address the last two issues with follow-up commits.

Swift SVN r15967
2014-04-05 00:21:06 +00:00
Dmitri Hrybenko
f661691962 Don't serialize @final twice and add tests for printing @final
Swift SVN r15962
2014-04-04 23:20:55 +00:00
Joe Groff
18f6e950a6 Reflection: Look through existential containers.
When we reflect an existential container, reflect the contained value as its dynamic type. Implements <rdar://problem/16427022>.

Swift SVN r15952
2014-04-04 20:16:47 +00:00
Chris Lattner
d94d11ea6b reword a diagnostic to read more nicely.
Swift SVN r15941
2014-04-04 16:36:52 +00:00
Dmitri Hrybenko
f198c28d75 Serialize @required as a DeclAttribute
Also introduce an invalid bit on a DeclAttribute for use by semantic analysis.

This fixes AST printing for @required.


Swift SVN r15938
2014-04-04 15:24:47 +00:00
Dmitri Hrybenko
7a63906b15 Serialize @objc as a DeclAttribute
This allows us to consistently print the AST, no matter if it was just parsed
or deserialized.

Note that we still serialize the isObjC bit from Decl, because it can be set or
cleared by the typechecker.  It is possible to have isObjC=true when there is
not attribute (the ObjC'ness was inferred), and it is possible that
isObjC=false while there is an attribute (when the attribute does not pass the
semantic check).  While we can represent the former with an implicit attribute,
the latter is harder to represent (maybe with an invalid bit on the attribute?)


Swift SVN r15935
2014-04-04 12:42:52 +00:00
Ted Kremenek
ad2afaeb34 Start serializing out DeclAttribute objects using generalized serialization logic.
To generalize our serialization logic for more attributes, serialize
each DeclAttribute object in a separate bitcode record.

For simple declaration attributes (no arguments), all of this
serialization logic can be fully automatically generated, and is
done so in this patch.  This currently includes @final, but will
expand over time.

To illustrate the plumbing end-to-end, move the serialization logic
for asmnmame over to the new mechanism.

Swift SVN r15933
2014-04-04 08:52:32 +00:00
Doug Gregor
26c4620b35 Introduce a "descriptive declaration kind" for use in diagnostics, etc.
Provide a fine-grained classification of declarations that can be used
in diagnostics instead of ad hoc %select operations. For now, only cut
over the "overriding a final <whatever>" diagnostic.


Swift SVN r15932
2014-04-04 06:35:42 +00:00
Doug Gregor
d2f7f90586 Re-introduce the restriction I zapped in r15928. getters/setters can't separately be marked @final.
Swift SVN r15930
2014-04-04 05:43:06 +00:00
Doug Gregor
604ad33d06 Handle getter/setter overriding more cleanly.
Use recordOverride() for getter and setter overriding. This means that
@objc names get propagated correctly, so we can stop chasing overrides
to find @objc names.



Swift SVN r15928
2014-04-04 05:27:50 +00:00
Chris Lattner
25b8f01fef enforce that @final may only be applied to func/var/subscripts (@final classes someday),
and that it doesn't appear on accessors.


Swift SVN r15927
2014-04-04 05:19:28 +00:00
Chris Lattner
3830face44 Carve out a new TypeCheckAttr.cpp file, and sketch out a new structure for doing
attribute checking on a per attribute basis.  It makes a lot more sense for a 
given attribute to think about all of the decl kinds it may or may not apply to
rather than all decl kinds thinking about the cross products of attributes they 
may apply to.

Start by adding a new check to reject @final in structs and enums.


Swift SVN r15925
2014-04-04 05:08:23 +00:00
Jordan Rose
646952defd [serialization] Write substitution conformances as references when possible.
More importantly, when writing substitution conformances /within the same
module/, use an "incomplete" form of the NormalProtocolConformance layout
that doesn't include any of the substitutions or defaulted definitions.
This avoids a serialization cycle when the witness for a protocol itself
ends up conforming to the protocol.

I couldn't come up with a reduced test cases, but both cases filed by Dave
now work.

<rdar://problem/16468715>

Swift SVN r15912
2014-04-04 01:17:55 +00:00
Jordan Rose
aa6aa72ba1 Add lazy conformances to nominals and extensions.
...and deserialize conformances lazily.

No intended user-visible change.

Swift SVN r15911
2014-04-04 01:17:54 +00:00
Jordan Rose
22645d7f97 Add a wrapper type for the union of ArrayRef and LazyMemberLoader+context.
This requires some careful handling since the base of an ArrayRef and the
lazy loading "context data" both have no free bits, but it now works.
(It's essentially a TwoPointerUnion type, just specialized for a particular
pair of two-pointer types.)

No functionality change, except that NominalTypeDecl and ExtensionDecl
are two words smaller.

Swift SVN r15910
2014-04-04 01:17:54 +00:00
John McCall
a7a4f67f1b Bump the reference count of a function as long as it's sitting
around in the deserializer's .
1,2d
1i
Bump the reference count of a SILFunction as long as it's sitting
around in the deserializer's cache.

If we deserialize a function, then delete it, then deserialize
another reference to it, we'll end up pointing to a deleted
function.  This was causing the bug where IRGen would assert
with "no order number for SIL function definition?"; I can't
seem to find a radar for that, though.

Also, deserialization test cases are hard to write and probably
inherently unstable.

Swift SVN r15908
2014-04-04 00:53:55 +00:00
Doug Gregor
9ca6a394d4 Diagnose attempts to override a 'final' declaration.
Swift SVN r15905
2014-04-03 23:53:18 +00:00
Doug Gregor
6b71d48a97 When overriding a declaration, complain if the @objc names don't match.
Swift SVN r15901
2014-04-03 22:57:15 +00:00