Commit Graph

717 Commits

Author SHA1 Message Date
Joe Pamer
a17cec6cb2 Some test and diagnostic cleanup:
- Mine conjunction constraints for constraint failure data. (rdar://problem/16833763)
- Rather than crash, add a diagnostic to signify a missing user constraint. (rdar://problem/16747055) I don't have a deterministic repro for this to include as a test, but users hit it from time to time, I'd like to address this issue holistically, and we're hoping that the new diagnostic will help us collect isolated repros.
- As promised, remove the temporary "compiler_submit_version" build configuration predicate in time for WWDC. (rdar://problem/16380797)

Swift SVN r17705
2014-05-08 18:46:08 +00:00
Joe Groff
05c80a8fe9 AST: Avoid instantiating all members when implicit destructors are inserted into classes.
We were accidentally forcing all members of a class to be instantiated in two places:

- by trying to look up an existing destructor decl in the class, and
- by adding the implicit destructor to the class, because addMember needlessly called loadAllMembers.

Fix the former problem by adding a 'has destructor' bit to ClassDecl so we can track whether the implicit destructor needs to be added without querying its members. Fix the latter by making IterableDeclContext::addMember not call loadAllMembers, and making loadAllMembers not barf when it sees existing members in the context.

Together with Jordan and JoeP's changes, this makes many interpreter tests now compile 3-20x faster.

Swift SVN r17562
2014-05-06 20:30:08 +00:00
Chris Lattner
ad0e63b15e fix <rdar://problem/16189360> [DF] Assert on subscript with variadic parameter
When rebuilding accesser parameter lists, make sure not to drop varargs
information.


Swift SVN r17448
2014-05-05 15:34:04 +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
Chris Lattner
d83289cb49 the 'destructor' keyword got renamed to 'deinit' a long time ago, remove
parsing and fixit support for 'destructor'.


Swift SVN r17361
2014-05-04 04:28:25 +00:00
Chris Lattner
bf666142b8 Finish <rdar://problem/16688592> Change "-> Self" syntax, and introduce a new "convenience" context sensitive keyword
This rejects the "-> Self" syntax and provides a fixit for the new syntax.


Swift SVN r17358
2014-05-04 04:09:42 +00:00
Chris Lattner
2427e36ff8 Introduce a new "convenience" context sensitive keyword, which can only be
used on init decls, with the same semantics as "-> Self".  Switch the ast
printer, and fixits to use it.

As driveby's, simplify verification of contextual keywords in declparsing,
and rename parseConstructor/Destructor to parseInit/Deinit.


Swift SVN r17356
2014-05-04 04:02:32 +00:00
Chris Lattner
1a422e0c6e Make the parser reject (with a fixit) use of the @weak/@unowned attributes,
pointing people to use the context sensitive keywords instead. 

This completes:
<rdar://problem/16782966> make weak and unowned be context sensitive keywords



Swift SVN r17300
2014-05-03 01:18:22 +00:00
Chris Lattner
b3133da827 Parse weak/unowned/unowned(safe)/unowned(unsafe) as context sensitive keywords.
This is part of <rdar://problem/16782966> make weak and unowned be context sensitive keywords

The part still missing is where we ban the attribute with a fixit to use the
non-attribute syntax.



Swift SVN r17235
2014-05-02 06:21:44 +00:00
Argyrios Kyrtzidis
2442d063ef [IDE] Fix syntax annotation crash with #if blocks that are missing an #endif.
rdar://16785562

Swift SVN r17231
2014-05-02 06:12:05 +00:00
Chris Lattner
029fe4f3af fix <rdar://problem/16792027> compiler infinite loops on a really really mutating function
by restructuring context sensitive keywords a bit.


Swift SVN r17228
2014-05-02 05:43:37 +00:00
Chris Lattner
0f6c01a6e8 factor a test for decl contextual keywords out into a helper function. NFC.
Swift SVN r17227
2014-05-02 04:33:35 +00:00
Doug Gregor
f3977e3f03 Introduce @NSManaged attribute with basic semantic analysis.
We're still missing a number of checks here, as well as the
functionality to turn @NSManaged properties into computed properties.

Swift SVN r17166
2014-05-01 18:55:32 +00:00
Doug Gregor
72e32c93af Make argument names default to keyword arguments in the cases where Objective-C has names.
Introduce a model where an argument name is a keyword argument if: 

  - It is an argument to an initializer, or
  - It is an argument to a method after the first argument, or
  - It is preceded by a back-tick (`), or
  - Both a keyword argument name and an internal parameter name are
    specified. 

Provide diagnostics Fix-Its to clean up cases where the user is
probably confused, i.e.,

  - "_ x: Int" -> "x: Int" where "x" would not have been a keyword
  argument anyway
  - "x x: Int" -> "`x: Int"

This covers the compiler side of <rdar://problem/16741975> and
<rdar://problem/16742001>.

Update the AST printer to print in this form, never printing just 
a type for a parameter name because we're also going to adopt
<rdar://problem/16737312> and it was easier to move the tests once
rather than twice.

Standard library and test updates coming separately.




Swift SVN r17056
2014-04-30 00:04:04 +00:00
Ted Kremenek
ccc5d6a8d2 Remove support for vestigial commas between type attributes.
Swift SVN r16948
2014-04-27 22:08:10 +00:00
Chris Lattner
4e218287f6 remove the weak and unowned keywords, which are not used. I'll bring up for
discussion on tuesday whether it makes sense to use keywords instead of 
attributes for these.


Swift SVN r16940
2014-04-27 20:50:21 +00:00
Chris Lattner
0c390777ba Implement <rdar://problem/16204675> Need #elseif
This restructures IfConfigDecl/Stmt to be a list of clauses controlled
by a condition.  This makes it straight-forward to drop in #elseif support.

While I'm in here, this patch moves checking for extraneous stuff at the
end of the #if line from the lexer to the parser.  This means that you can
now put a comment on the same line as a #if/#else/#elseif/#endif.



Swift SVN r16912
2014-04-27 04:51:36 +00:00
Chris Lattner
7ab94b7251 parse mutating and nonmutating in protocol requirement specifiers for properties/subscripts too.
Swift SVN r16894
2014-04-26 21:20:42 +00:00
Chris Lattner
371a9316f4 - Introduce a new 'nonmutating' context sensitive keyword, and use it instead of @!mutating.
- Change the parser to unconditionally reject @mutating and @!mutating with a fixit and 
  specific diagnostic to rewrite them into the [non]mutating keyword.
- Update tests.

This resolves <rdar://problem/16735619> introduce nonmutating CS keyword and remove the attribute form of mutating all together



Swift SVN r16892
2014-04-26 21:00:06 +00:00
Dmitri Hrybenko
e36baf4123 Code completion: add basic support for completing overriding decls
rdar://16539292


Swift SVN r16755
2014-04-24 15:59:05 +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
Dmitri Hrybenko
f82c7cd092 Comment parsing: move the virtual comment attribute to DeclAttribute
infrastructure


Swift SVN r16653
2014-04-22 14:58:23 +00:00
Joe Groff
c73acc67f2 SIL: Add an "UnownedInnerPointer" result convention.
This will represent the return convention of imported __attribute__((objc_returns_inner_pointer)) methods. Leave it unimplemented for now until we can autorelease things sanely.

Swift SVN r16628
2014-04-21 21:57:13 +00:00
Doug Gregor
89ef0af226 Switch subscript index parsing over to a parameter-clause.
Swift SVN r16586
2014-04-20 06:37:47 +00:00
Doug Gregor
40b2c9f7a4 Create ParamDecls for function parameters in more places.
Swift SVN r16584
2014-04-20 05:57:34 +00:00
Doug Gregor
22c4f01e9a Build the implicit "self" declaration as a ParamDecl.
Swift SVN r16582
2014-04-20 05:25:44 +00:00
Doug Gregor
6b3ef547ec Replace "Members" arrays with an intrusive linked list.
The use of ASTContext-allocated arrays to store the members of nominal
type declarations and the extensions thereof is an
abomination. Instead, introduce the notion of an "iterable"
declaration context, which keeps track of the declarations within that
context (stored as a singly-linked list) and allows iteration over
them. When a member is added, it will also make sure that the member
goes into the lookup table for its context immediately.

This eliminates a ton of wasted memory when we have to reallocate the
members arrays for types and extensions, and moves us toward a much
more sane model. The only functionality change here is that the Clang
importer no longer puts subscript declarations into the wrong class,
nor does it nested a C struct within another C struct.



Swift SVN r16572
2014-04-19 23:37:06 +00:00
Dmitri Hrybenko
e2e8db5f38 Migrate IB attributes to new decl attribute representation and fix a few bugs
along the way


Swift SVN r16542
2014-04-18 20:00:09 +00:00
Doug Gregor
8bc2ea4ea1 Use designated/convenience initializer terminology throughout. NFC
Introduce CtorInitializerKind to describe the kind of an enum, rather
than a bool, to make way for more initializer kinds in the future.

Swift SVN r16525
2014-04-18 15:10:13 +00:00
Chris Lattner
17e44086f0 fix <rdar://problem/16608609> Assert (and incorrect error message) when defining a constant stored property with observers
a crash-on-invalid, and QoI issue.



Swift SVN r16494
2014-04-18 05:03:12 +00:00
Doug Gregor
ea647624e3 Eliminate the notion of "selector-style" declarations in the AST.
We still parse them, but the distinction is no longer meaningful
beyond the parsing stage.



Swift SVN r16445
2014-04-17 05:42:58 +00:00
Doug Gregor
8e597cc695 Eliminate argument parameter patterns.
Swift SVN r16444
2014-04-17 05:20:14 +00:00
Doug Gregor
2d70fbad63 Give initializers compound names.
Swift SVN r16404
2014-04-16 07:44:31 +00:00
Chris Lattner
adff5375fe Initial support for the @NSCopying attribute on properties. This is enough to
wire it up, do basic semantic analysis and code gen a simple case of it.  There is
more type checking work to come, so it isn't complete yet.

This is the first step to:
<rdar://problem/15864836> Need a @NSCopying attribute for Cocoa types that aren't manually bridged



Swift SVN r16345
2014-04-15 00:31:59 +00:00
Dmitri Hrybenko
e325118714 Move @assignment to the new decl attribute infrastructure
Swift SVN r16216
2014-04-11 15:19:59 +00:00
Doug Gregor
5cf354337f Fix grammar in comment. NFC
Swift SVN r16187
2014-04-10 23:48:56 +00:00
Ted Kremenek
492dcb0c37 Reject @asmname on a function in a local scope.
Implements <rdar://problem/16115706>.

Swift SVN r16170
2014-04-10 21:37:43 +00:00
Dmitri Hrybenko
110f85bc16 Move @exported to use new attribute infrastructure
Swift SVN r16158
2014-04-10 13:35:35 +00:00
Ted Kremenek
2d4342b87a Give an error if “@obj” is used without importing ObjectiveC.
The standard library is exemptmpt (-parse-stdlib) from this checking.

Implements <rdar://problem/16559137>.

Swift SVN r16155
2014-04-10 09:08:09 +00:00
Dmitri Hrybenko
f90e0c153b Make 'override' a keyword
rdar://16462192

Swift SVN r16115
2014-04-09 14:19:50 +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
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
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
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
be3ec6359a Make DeclAttributes visitable via an AST visitor.
Swift SVN r15900
2014-04-03 22:57:15 +00:00
Doug Gregor
fe6160f455 Include SimpleDeclAttr to provide subclasses for simple declaration attributes.
The new "final" attribute didn't have a DeclAttribute subclass. While
that sounds like a nice simplification, it makes visitors awkward to
use.

Swift SVN r15899
2014-04-03 22:57:13 +00:00
Chris Lattner
d491f5121e Add parsing and SILGen support for @final methods and properties.
This is missing almost all semantic analysis and is missing various
optimization opportunities (e.g. final methods that are not overrides
don't need vtable entries), but this is enough to devirtualize class
stuff, which is important for our performance efforts.  I'll add this
to release notes when it is more fully fleshed out.



Swift SVN r15885
2014-04-03 17:53:52 +00:00
Chris Lattner
f9936b09e3 don't indent cases under a switch, NFC.
Swift SVN r15876
2014-04-03 16:51:48 +00:00
Doug Gregor
527b147ba7 Revert "Allow the first name of a selector-style function declaration to be separated."
This reverts r15140.

Conflicts:
	include/swift/Serialization/ModuleFormat.h
	lib/Parse/ParsePattern.cpp

Swift SVN r15846
2014-04-02 23:27:52 +00:00
Joe Pamer
cbc69bc8ee Restrict use of default arguments on protocol method signatures.
We were never handling this correctly, and default arguments are checked along with the method body.
In some cases where no further validation was necessary (such as when the default argument was a literal value),
the compiler would let this slip through but in others this would cause a crash.  (rdar://problem/16476405)

Swift SVN r15736
2014-04-01 16:53:21 +00:00