Commit Graph

2357 Commits

Author SHA1 Message Date
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
Joe Pamer
7b771affd9 Add limited build configuration support for testing against compiler submit versions. (rdar://problem/16337966)
This is meant to be utilized for a narrow set of scenarios specific to dogfooding our pre-1.0 compiler, so please do not take any dependencies on this.  In fact, I'll be removing this in the next milestone.  (See rdar://problem/16380797.)

Also included - improve error recovery when parsing broken build configuration clauses.

Swift SVN r15694
2014-03-31 20:34:02 +00:00
Doug Gregor
b49978675e Parsing, representation, and printing for @objc(name)
The @objc attribute can now be provided with a name (in parentheses),
which names the corresponding entity in Objective-C. The name will
either be a selector (for anything that maps down to an Objective-C
method) or a single identifier (for classes and protocols).

The extra information is not used for anything yet.



Swift SVN r15626
2014-03-29 19:36:05 +00:00
Doug Gregor
055e0ef136 Add an "implicit" bit to DeclAttribute.
Swift SVN r15623
2014-03-29 17:24:15 +00:00
Jim Ingham
7f11e5b620 Get the parse phase to allow imports in contexts other than toplevel code
when DebuggerSupport is turned on.


Swift SVN r15563
2014-03-27 20:34:45 +00:00
Ted Kremenek
07a4449621 Remove vestigial comma-separated attribute list for declarations.
For example:

  @class_protocol, @objc

is now just:

  @class_protocol @objc

Once we removed attribute grouping in brackets this comma separation
became vestigial.  Doug and I discussed this and thought this
was a good simplification in the grammar.

This change still remains to be done for type attributes.

Swift SVN r15540
2014-03-27 00:11:40 +00:00
Doug Gregor
51672965f4 Remove the unused @fragile, @resilient, and @born_fragile attributes.
Swift SVN r15518
2014-03-26 19:47:08 +00:00
Doug Gregor
1cdd295182 Move the @objc attribute over to a DeclAttribute.
Swift SVN r15517
2014-03-26 19:33:07 +00:00
Ted Kremenek
3f0ff8fa05 Remove @unavailable, and move to introducing basic (sham) parsing for @availability.
The parsing here for @availability isn't real yet; but it provides
scaffolding.  Intended grammar:

  @availability(*, unavailable, message="...")
  @availability(*, unavailable)

  @availability(ios, unavailable)

  and so on.

Much of this doesn't work yet in a general way, but I wanted something
basic to work with to start with to wire up the functionality
for @availability end-to-end (at least for 'unavailable').

As part of this, extend DECL_ATTR to include whether or not an
attribute supports multiple declarations, and use this for
@availability.

Also hardwire darwin platforms, which we will need to have this
list come from somewhere.  The checking could be done at parsing
or elsewhere.

Swift SVN r15491
2014-03-26 06:51:15 +00:00
Ted Kremenek
9bb6eab78d [Decl Attributes] Change DECL_ATTR to specify serialization constraints for attributes.
Via preprocessor goop, Serialization.cpp generates a set of static
functions that can be used to verify if a set of attributes
can be serialized for a particular declaration.

This design forces the author of the attribute to specify up front
whether or not an attribute is supported on a given declaration
kind.  We can possibly hoist this into semantic analysis as well.

These N separate functions do conceptually replace a simple
variadic template implementation.  I'm fine with alternatives,
but the goal was to provide a way for the author of new 
attributes to describe the requirements in one place: Attr.def.

Swift SVN r15470
2014-03-25 22:59:55 +00:00
Chris Lattner
60063a866d fix <rdar://problem/16406886> Observing properties don't work with ownership types
Now that rvalues of ownership types are working, we just need to strip the ownership
type on the argument to setter and return value of getter.



Swift SVN r15460
2014-03-25 16:32:05 +00:00