Commit Graph

2438 Commits

Author SHA1 Message Date
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
Argyrios Kyrtzidis
415a7036e2 [AST] In IfConfigDecl, keep track of its members per the block they belong to.
Swift SVN r15446
2014-03-25 03:55:31 +00:00
Argyrios Kyrtzidis
121bf14dd1 [AST] In IfConfigDecl/IfConfigStmt keep track of whether the IfBlock is active or not.
Swift SVN r15444
2014-03-25 03:55:29 +00:00
Argyrios Kyrtzidis
3064e04d47 [Parser] Add the IfConfigDecl/IfConfigStmt ahead of its active members, so we can see it before them, in source order.
Swift SVN r15443
2014-03-25 03:55:28 +00:00
Ted Kremenek
4712476353 Wire up basic parsing support for @unavailable. WIP.
Swift SVN r15434
2014-03-25 01:14:51 +00:00
Ted Kremenek
3afa48172d Refactor string literal processing from @asmname into helper method.
This seems generally useful for processing other attributes.

Swift SVN r15433
2014-03-25 01:14:49 +00:00
Ted Kremenek
3673fde994 Change attribute 'asmname' syntax from '@asmname="..."' to '@asmname("...")'.
This grammar change is motivated by consistency with richer
attributes we are going to add in the future, @availablity,
and seems a more scalable syntax amendable to parser recovery.
Conceptually, the values of the attribute look like a tuple of
arguments.

Swift SVN r15430
2014-03-25 00:20:13 +00:00
Ted Kremenek
f43842e160 Change processing of @asmname to use a new internal representation.
This representation is inspired by Clang's internal representation.
The current attribute representation, which is basically a union
of "stuff" in DeclAttributes, is not amendable to richer
attributes, such as @availability, that need to be implemented.
In Clang, attributes are modeled with actual objects that
encode both semantic and syntactic information (e.g., source ranges)
that facilitate richer checking, better diagnostics, and better tools.

This change is foundational for implementing @availability, but
also is a better long-term representation.  As a migratory path,
it creates some duplications, with AttrKind and DeclAttrKind, the
two which should eventually become the same thing.

As part of this patch, there is some additional parser recovery
(for the new attribute representation) for duplicate attributes.
The parser now parses the entire duplicate attribute, which could
be quite complex, and then issues a diagnostic that the attribute
is a duplicate (and discarding it).  This delayed diagnostic
also allows us to present ranges for the duplicate attribute, which
provides a better user experience.

Swift SVN r15365
2014-03-22 14:58:30 +00:00
Chris Lattner
1f275532a6 now that nothing uses the PatternBindingDecl::HasStorage bit, there is no
reason to compute it, store it, serialize it, etc.  Remove the associated
logic.



Swift SVN r15302
2014-03-20 22:49:43 +00:00
Doug Gregor
5e8e7279f8 Allow the first name of a selector-style function declaration to be separated.
Parse function declarations with the form

  func murder inRoom(room: Int) weapon(Int) {}

where the function name ("murder") is separated from the parameter
names. This is the same style used in initializers, i.e.,

  init withCString(cstr: CString) encoding(Encoding)



Swift SVN r15140
2014-03-17 16:04:21 +00:00
Joe Pamer
701ff469be Align declarations permissible within protocol bodies with the language reference.
Namely, nested structs, class, enum and other protocol declarations within protocols should raise a parse error, but not crash the type checker.
Also, protocol methods may not have bodies.

The fact that we weren't catching these issues resulted in a number of crasher bugs:
rdar://problem/15811382
rdar://problem/16290458
rdar://problem/16299208
rdar://problem/16316944

Swift SVN r15093
2014-03-14 23:24:12 +00:00
Doug Gregor
8cf018a1d2 Give Pattern::clone() an OptionSet rather than a bool; it's going to get more interesting.
Swift SVN r15061
2014-03-14 18:31:21 +00:00
Joe Groff
0b44a71741 Accept @asmname property accessors without bodies.
I want this so I can move the less magic bits of the Reflection implementation out of C++.

Swift SVN r15013
2014-03-13 23:51:13 +00:00
Chris Lattner
4d28ecd2b5 rename the default argument for "set" and "willSet" to "newValue" instead of
being "oldValue".


Swift SVN r14950
2014-03-12 05:11:14 +00:00
Joe Groff
b8d48dd7bb Change 'x.type' to 'x.dynamicType'.
It's not a common operation, so it doesn't need a terse name that occupies valuable identifier real estate.

Swift SVN r14932
2014-03-11 23:18:33 +00:00
Joe Groff
b08f06f191 Revert "Accept (and prefer) "import type" as a scoped import for any non-protocol type."
This reverts commit r14488, since we're demoting 'type' back to a plain old identifier.

We could consider reallowing 'type' as a contextual keyword here, but from talking to Jordan he was OK with just reverting this functionality.

Swift SVN r14931
2014-03-11 23:18:30 +00:00
John McCall
6471fc90ce Parse type attributes in generic argument lists in expressions.
Swift SVN r14913
2014-03-11 07:59:23 +00:00
John McCall
a9443d72f8 Parse attributes as part of <type> and simplify the grammar.
This means that we accept type attributes in a much broader
range of places where we previously required a <type>.  <type>
was already a production that demanded a grammatically
unconstrained context because of all the possible continuations;
reducing the number of independent productions makes it easier
to choose one and thus not accidentally limit the range of
possible types parsed.

In particular, we want to be able to parse @unchecked T? pretty
much anywhere you can write a type.

Swift SVN r14912
2014-03-11 07:59:22 +00:00
Dmitri Hrybenko
ab9dcd39c4 Source annotation: fix a crash on var decls with propagated types
rdar://16194527


Swift SVN r14868
2014-03-10 15:09:04 +00:00
Chris Lattner
2593a52b99 implement <rdar://problem/16191398> add an 'oldValue' to didSet so you can implement "didChange" properties
This names the implicit argument "oldValue".  Whether we keep implicit arguments or not
is a subject of debate, tracked by rdar://16268361.



Swift SVN r14819
2014-03-08 02:15:01 +00:00