Commit Graph

601 Commits

Author SHA1 Message Date
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
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
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
5b49d59c57 Remove the @ from @final and @lazy, the last major piece of
rdar://17168115.

Also, reinstate the ARM driver change and testcase that I removed
in my last patch.


Swift SVN r19790
2014-07-10 06:23:27 +00:00
Chris Lattner
fe95f81397 introduce a new 'DeclModifier' flag on attributes, which mark that the
attribute is a "modifier" of a decl, not an "attribute" and thus shouldn't
be spelt with an @ sign.  Teach the parser to parse "@foo" but reject it with
a nice diagnostic and a fixit if "foo" is a decl modifier.

Move 'dynamic' over to this (since it simplifies some code), and switch the
@optional and @required attributes to be declmodifiers (eliminating their @'s).



Swift SVN r19787
2014-07-10 05:49:10 +00:00
Joe Groff
9ddad1d718 Sema: Basic parsing and checking for 'dynamic'.
Parse 'dynamic' as a contextual keyword, and check that it's applied only to ObjC-compatible members of classes. We don't handle inheritance of the attribute yet.

Swift SVN r19781
2014-07-10 05:05:29 +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
Chris Lattner
02999cac51 Reinstate the @ on the @objc attribute. This is largely a revert of r19555 with a few tweaks.
Swift SVN r19706
2014-07-08 21:50:34 +00:00
Jordan Rose
3f59d6b9ee Drop the '@' from access control modifiers.
Test and stdlib changes to follow.

Swift SVN r19671
2014-07-08 02:16:59 +00:00
Chris Lattner
7a56499d61 Start making @objc not start with an @ sign:
- Change the parser to accept "objc" without an @ sign as a contextual
   keyword, including the dance to handle the general parenthesized case.
 - Update all comments to refer to "objc" instead of "@objc".
 - Update all diagnostics accordingly.
 - Update all tests that fail due to the diagnostics change.
 - Switch the stdlib to use the new syntax.

This does not switch all tests to use the new syntax, nor does it warn about
the old syntax yet.  That will be forthcoming.  Also, this needs a bit of 
refactoring, which will be coming up.



Swift SVN r19555
2014-07-04 05:57:57 +00:00
Jordan Rose
b3addba09e Split "private(set)" attributes out into a separate class.
No functionality change, i.e. these still don't do anything.

Swift SVN r19547
2014-07-04 01:53:47 +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
b5a78c04ce [attribute] remove InlineKind::Always.
Swift SVN r19450
2014-07-02 05:57:20 +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
Nadav Rotem
ab811bdc35 Fix the indentation of two lines.
Swift SVN r19401
2014-07-01 16:49:33 +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
Ted Kremenek
1e51a9fda8 Add printer support for @noinline.
Swift SVN r19205
2014-06-26 00:50:59 +00:00
Ted Kremenek
a3b704ec42 Mark all imported APIs deprecated in iOS 7 (or earlier) or OS 10.9 (or earlier) as unavailable.
This patch takes care that synthesized initializers are created
when overriding unavailable initializers (thanks Doug).

Swift SVN r19202
2014-06-26 00:50:46 +00:00
Jordan Rose
deaa0a1497 Parse @private, @internal, @public, and the (set) variants of each.
This does no validation of the access control modifiers.

As part of this commit, note that "virtual" attributes may actually be
written in the source under another spelling. Update a few other parts of
the source to account for that.

Swift SVN r19140
2014-06-24 21:32:03 +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
Joe Groff
ac903bf943 IRGen: Make our use of spare bits in heap objects tagged-pointer-safe.
Don't use spare bits on platforms that use ObjC tagged pointers when an enum payload involves a class-constrained existential, archetype, or ObjC-defined class type. If a payload is of a Swift-defined class type, we can still assume it's a real pointer and use its spare bits. Add an @unsafe_no_objc_tagged_pointer attribute that can be applied to protocols to denote that existentials bounded by that protocol can use spare bits; this is necessary to preserve the layout of bridged Array and Dictionary types, which should not be bound to tagged pointer types in practice (fingers crossed). Fixes <rdar://problem/16270219>.

Swift SVN r18781
2014-06-10 17:07:47 +00:00
Dmitri Hrybenko
11b23bbf1a Code completion for overrides: complete @optional members
First half of rdar://15695863


Swift SVN r18741
2014-06-09 11:40:53 +00:00
Joe Groff
9b4c9cc181 Print @UIApplicationMain.
Swift SVN r18062
2014-05-14 04:48:20 +00:00
Jim Ingham
14a6697ba5 Add an attribute marking the "Debugger function" lldb uses for emulating
local contexts.  Get the parser in consultation with the DebuggerClient
to handle moving persistent declarations from the debugger function to the
source file.

<rdar://problem/15302321> [ER] Define Swift classes in expressions


Swift SVN r17948
2014-05-12 19:03:31 +00:00
Chris Lattner
d79646e962 parse and start type checking of @lazy attribute.
Swift SVN r17877
2014-05-11 18:37:29 +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
Argyrios Kyrtzidis
7f2fa7f97e [IDE] Filter out attributes like @objc and @availability when code-completing overrides.
rdar://16766431

Swift SVN r17366
2014-05-04 05:19:11 +00:00
Argyrios Kyrtzidis
bb66d6dd1a [IDE] Don't show '@transparent' in the module interface.
rdar://16804855

Swift SVN r17350
2014-05-04 01:24:55 +00:00
Argyrios Kyrtzidis
c0e69b8d4a [Printer] In PrintOptions, add a general 'exclude attributes' list for the attribute kinds we don't want to print.
Swift SVN r17349
2014-05-04 01:24:52 +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
3d3ff6811a Add a pile of missing #includes exposed by pruning includes in top-of-tree LLVM.
Swift SVN r17157
2014-05-01 14:26:34 +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
f82c7cd092 Comment parsing: move the virtual comment attribute to DeclAttribute
infrastructure


Swift SVN r16653
2014-04-22 14:58:23 +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
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
Doug Gregor
fa8a10e36e Unbreak ObjCSelector and the new ObjCAttr.
Swift SVN r16329
2014-04-14 20:22:10 +00:00
Doug Gregor
cd4ca76b6a Introduce the ObjCSelector class to store an Objective-C selector.
We have to work with selectors quite often, so provide an efficient
representation for them. Switch ObjCAttr over to this representation,
which has the nice property that it efficiently represents implicit
@objc attributes with names and allows us to overwrite the Objective-C
name without losing all source information. Addresses
<rdar://problem/16478678>, and sets us up for dealing with selectors
better.

Swift SVN r16327
2014-04-14 20:05:35 +00:00
Dmitri Hrybenko
e325118714 Move @assignment to the new decl attribute infrastructure
Swift SVN r16216
2014-04-11 15:19:59 +00:00
Dmitri Hrybenko
6a24e5475e Remove a separate bit for @objc inference, and use normal implicit attributes
This allows us to get rid of /* @objc(inferred) */ completely.


Swift SVN r16215
2014-04-11 14:34:28 +00:00
Dmitri Hrybenko
0fc4f3949c AST printer: add an option to hide @exported
Swift SVN r16168
2014-04-10 19:39:25 +00:00
Dmitri Hrybenko
110f85bc16 Move @exported to use new attribute infrastructure
Swift SVN r16158
2014-04-10 13:35:35 +00:00
Dmitri Hrybenko
f90e0c153b Make 'override' a keyword
rdar://16462192

Swift SVN r16115
2014-04-09 14:19:50 +00:00
Dmitri Hrybenko
4315fdbbf8 @availability: implement serialization and AST printing
Swift SVN r16010
2014-04-07 14:07:28 +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