Commit Graph

3461 Commits

Author SHA1 Message Date
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
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
Argyrios Kyrtzidis
2c88bb3f59 [AST] Modify mangleObjCRuntimeName to allow getting the ObjC runtime name of a class or protocol
without needing a fully typechecked AST.

Part of rdar://16521245

Swift SVN r16503
2014-04-18 07:07:11 +00:00
Argyrios Kyrtzidis
26114ca4a1 [AST] Add some const goodness, NFC.
Swift SVN r16492
2014-04-18 04:14:41 +00:00
Doug Gregor
8e597cc695 Eliminate argument parameter patterns.
Swift SVN r16444
2014-04-17 05:20:14 +00:00
Joe Pamer
7107aee3ca If a semantic error occurs while resolving an associated type during archetype construction, we should propagate the error rather than crash. (rdar://problem/16427613)
Swift SVN r16427
2014-04-17 00:24:05 +00:00
Doug Gregor
6493231b77 Switch Objective-C selector computation for initializers over to the method name.
Swift SVN r16405
2014-04-16 07:50:44 +00:00
Doug Gregor
2d70fbad63 Give initializers compound names.
Swift SVN r16404
2014-04-16 07:44:31 +00:00
Doug Gregor
cb252d76d7 Switch Objective-C selector creation for methods from argument patterns to arguments in the name.
Swift SVN r16399
2014-04-16 06:20:49 +00:00
Doug Gregor
e12afa2e1d Start naming functions more uniformly.
For any function that has a name, ensure that the name is a compound
name with argument names for each of the parameters. 


Swift SVN r16398
2014-04-16 06:05:45 +00:00
Joe Groff
69a1f91ded AST: Fix a typo that caused all generic struct property accesses to be computed.
Two little characters cause array complexity to jump from O(n) to O(n^2)! Fixes <rdar://problem/16629598>.

Swift SVN r16392
2014-04-16 03:31:01 +00:00
Doug Gregor
7c961a501f Migrate off a few more ArgParamPatterns
Swift SVN r16391
2014-04-16 03:22:47 +00:00
Chris Lattner
ca7ed40cf0 change Sema to synthesize getters and setters for properties in classes,
even if they are @final.  To get good performance for them, just always
perform direct access to the underlying storage, instead of going through
the accessors.

This allows them to properly fulfill protocol witnesses without overhead,
allows the objc runtime to find them properly, and is just a cleaner way
to go.


Swift SVN r16357
2014-04-15 04:43:36 +00:00
John McCall
f70879c4d9 Fix a weirdly complicated issue with the order of
type-checking and applying attributes.

We should really move to a model where variables are
type-checked in a single pass, including their attributes.
However, given that we don't, attributes which affect the
type must be applied in multiple places and hence multiple
times to the same declaration.

Swift SVN r16339
2014-04-14 22:54:30 +00:00
Doug Gregor
53b84c121e Switch ValueDecl::getObjCSelector() and friends over to ObjCSelector.
Formatting names into strings repeatedly, and using those for semantic
analysis, is generally considered poor form. Additionally, use the
camelCase utilities to perform the string manipulation we need, and
cache results on the ObjCAttr so we don't repeatedly do string
manipulation.

Swift SVN r16334
2014-04-14 22:02:51 +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
Chris Lattner
6e90d343be At long last, land the implementation of <rdar://problem/16397000> Should be able to override stored properties
This means that we now synthesize getters and setters a lot more than we used to, so the
implementation work on this shook out a ton of bugs with them.

There is still one failure that I don't understand at all (test/stdlib/NewArray.swift.gyb), 
nor do I understand how to diagnose the problem, so I XFAILed it and filed rdar://16604980 to
track fixing it.



Swift SVN r16299
2014-04-14 04:48:54 +00:00
Argyrios Kyrtzidis
31a620f1ee [IDE/ModuleInterface] Fix erroneously printed newline between a regular comment and the declaration it is 'attached' to.
Swift SVN r16293
2014-04-14 03:28:05 +00:00
Doug Gregor
2d28d70bf8 Remove the language/driver/frontend options to enable/disable mangled names for the ObjC runtime.
Burn the bridges!


Swift SVN r16277
2014-04-13 05:36:08 +00:00
Joe Groff
42a942925b Enable block bridging.
Swift SVN r16248
2014-04-12 05:13:45 +00:00
Joe Groff
ef4afbcffa Allow function-type properties to use ObjC dispatch.
Now they can bridge to blocks.

Swift SVN r16246
2014-04-12 05:13:37 +00:00
John McCall
8a85750c4c Plumb a lot of querying for different kinds of existential
type.

Swift SVN r16232
2014-04-11 22:30:14 +00:00
Doug Gregor
825e5be3d2 Default-initialize optional variables/properties to 'nil'.
Addresses <rdar://problem/16342813>.


Swift SVN r16222
2014-04-11 17:59:14 +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
Doug Gregor
fa6ae94e0e Re-organize the checking of @IBOutlet to better handle implicit optionalification.
Swift SVN r16201
2014-04-11 06:09:03 +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
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
Doug Gregor
e160f9049c Don't poke at Objective-C ASTs for designated initializers: the importer handles this.
Swift SVN r16011
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
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
a272ac75aa Add a change I forgot to add in the previous commit
Swift SVN r15939
2014-04-04 15:26:17 +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
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
Doug Gregor
4bcc4daa3d Selector splitting: the first parameter name is always relevant.
Swift SVN r15923
2014-04-04 04:14:34 +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
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
Jordan Rose
107eeefd77 Allow AbstractFunctionDecls to have their bodies "synthesized" on demand.
...then use this functionality for derived conformances for RawRepresentable.

No functionality change because these bodies are always forced right now.

Swift SVN r15828
2014-04-02 21:00:42 +00:00
Argyrios Kyrtzidis
41dbe5384b [AST] Add ClangNode::getLocation(), that returns the clang SourceLocation.
Swift SVN r15808
2014-04-02 17:39:08 +00:00
John McCall
f1180f5e6d in order to work correctly for non-@objc protocols.
Language features like erasing concrete metatype
values are also left for the future.  Still, baby steps.

The singleton ordinary metatype for existential types
is still potentially useful; we allow it to be written
as P.Protocol.

I've been somewhat cavalier in making code accept
AnyMetatypeType instead of a more specific type, and
it's likely that a number of these places can and
should be more restrictive.
When T is an existential type, parse T.Type as an
ExistentialMetatypeType instead of a MetatypeType.

An existential metatype is the formal type
 \exists t:P . (t.Type)
whereas the ordinary metatype is the formal type
 (\exists t:P . t).Type
which is singleton.  Our inability to express that
difference was leading to an ever-increasing cascade
of hacks where information is shadily passed behind
the scenes in order to make various operations with
static members of protocols work correctly.

This patch takes the first step towards fixing that
by splitting out existential metatypes and giving
them a pointer representation.  Eventually, we will
need them to be able to carry protocol witness tables

Swift SVN r15716
2014-04-01 00:38:28 +00:00
Doug Gregor
4f9f945d62 Teach the Clang importer to add @objc(selector) attributes for imported methods and initializers.
With this in place, remove the hacks that peeked at the imported Clang
node to determine the selector for a method. We're all
attribute-driven now. Part of <rdar://problem/16019773>.


Swift SVN r15663
2014-03-31 04:26:32 +00:00
Doug Gregor
f2578cb605 Use a named @objc to provide the name for methods, initializers, getters, and setters.
This is all of the functionality of <rdar://problem/16019773>, but
some cleanup remains.


Swift SVN r15641
2014-03-30 03:59:01 +00:00
Doug Gregor
d51744e396 Clang importer: add @objc(name) attributes to imported classes and protocols.
Now that we represent the Objective-C runtime names of classes and
protocols in a uniform way, stop peeking into the Clang AST nodes to
get this information for imported classes and protocols. This is
better layering and helps test that new code path.


Swift SVN r15632
2014-03-29 21:15:29 +00:00
Doug Gregor
a0e384f517 A named 'objc' attribute on a class or attribute provides the Objective-C runtime name.
Replace the use of 'asmname' for the runtime name of a class or
protocol with 'objc'. Use it for SwiftObject to eliminate a hack.


Swift SVN r15631
2014-03-29 20:53:17 +00:00
Doug Gregor
1e33daddf9 Allow @asmname on classes and protocols,
This will allow a Swift-defined class to put itself in the global
namespace, for example, to replace a previously Objective-C-defined
class. Part of <rdar://problem/15506580>.



Swift SVN r15590
2014-03-28 23:39:10 +00:00
Doug Gregor
9400e890d3 Emit @objc classes using namespaced names under a new flag -enable-objc-mangling.
Centralize the logic for figuring out what name to use for a class or
protocol in the Objective-C runtime. When the flag is enabled (it's
still disabled by default), use mangled names for all Swift-defined
classes, including those that are @objc. Note that the naming is
determined in the AST, because we're also going to use this logic when
printing an Objective-C header for Clang's consumption. The mangled
names will always start with _Tt, so they're easy to recognize and
demangle in various tools or, eventually, in the Objective-C runtime.

The new test (test/IRGen/objc_mangling.sil) is the only test of this
behavior at the moment. The other test changes are due to the
centralized logic tweaking the names of internal constants (_DATA_*,
_CATEGORY_*, etc.).

This is the majority of <rdar://problem/15506580>.



Swift SVN r15588
2014-03-28 23:00: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
Chris Lattner
0ea5a37fc1 rework PatternBindingDecl::hasStorage() to be a dynamic query of the vardecls it
contains, instead of being a stored bit set up by the parser.  Observed properties
have storage... unless they are overriding, and this avoids having to maintain
this bit.

This fixes:
<rdar://problem/16382967> Overriding observing properties have no storage, so shouldn't prevent initializer synth



Swift SVN r15301
2014-03-20 22:43:16 +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
Doug Gregor
7e7489936e Ignore stub definitions when checking whether a class overrides parent designated initializers.
Thanks, Dmitri!


Swift SVN r15107
2014-03-15 21:37:33 +00:00