Commit Graph

6196 Commits

Author SHA1 Message Date
Ted Kremenek
2440796aeb Add logic to treat 'performSelector*' as unavailable, but disable it for now.
Turns out 'performSelector' is used in the SDK overlay; that needs
to be resolved first.

Swift SVN r16403
2014-04-16 06:52:12 +00:00
Ted Kremenek
fd864384df Imported '_attribute__((deprecated)' as 'unavailable'.
Swift SVN r16402
2014-04-16 06:52:10 +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
Doug Gregor
db439c1a4a Start introducing declaration names for more function declarations.
Swift SVN r16396
2014-04-16 04:52:07 +00:00
Doug Gregor
f384cbfe63 Add a flag -ignore-overlays to ignore overlays, and use it when building the standard library.
Fixes <rdar://problem/16603168>. This was way too much engineering
effort to ban fork() and vfork().

Swift SVN r16383
2014-04-16 00:02:38 +00:00
Doug Gregor
918c488e04 Whitelist all of the documented designated initializers in UIKit.
There are a few cases where the same class occurs in AppKit and UIKit,
with different designated initializers in each. Comment these out
because we can't handle this now.



Swift SVN r16363
2014-04-15 06:53:08 +00:00
Doug Gregor
22d11c52f0 Whitelist all of the documented designated initializers for AppKit.
Swift SVN r16361
2014-04-15 06:23:43 +00:00
Argyrios Kyrtzidis
f9775c3c82 [ClangImporter] When providing the display decls, make sure to include extensions
of the module that extend classes from other modules.

rdar://16608340

Swift SVN r16360
2014-04-15 05:20:38 +00:00
Doug Gregor
54e12fb13b Clang importer: use the selector-based lookup table to avoid importing
methods with conflicting selectors.

We were doing this in a very ad hoc manner before; centralizing the
lookup table should make this significantly more robust. There's also
some scaffolding here to handle initializers better.

Fixes <rdar://problem/16516638>.

Swift SVN r16349
2014-04-15 00:35:41 +00:00
Doug Gregor
b09fbf73b8 Centralize our addition of @objc attributes in the Clang importer.
Swift SVN r16348
2014-04-15 00:35:40 +00:00
Doug Gregor
2dfed7538d Switch the Clang importer over to using ObjCSelector more often.
Swift SVN r16347
2014-04-15 00:35:40 +00:00
Joe Groff
3e8b1eb0b8 ClangImporter: Import block parameters as `@unchecked (T -> U)?`.
Enable the importing of block parameters as @unchecked optionals, allowing 'nil' to be passed. Fixes <rdar://problem/16193003>.

Swift SVN r16331
2014-04-14 21:09:07 +00:00
Doug Gregor
18bf604360 Distinguish betweeen simple names ("foo") and zero-argument compound names ("foo()").
This isn't actually used yet, but it's an important distinction.

Swift SVN r16326
2014-04-14 20:05:34 +00:00
Doug Gregor
9520460449 Clean up the import of Objective-C init methods as Swift initializers.
Previously, we would import the init method as a FuncDecl, which
wasn't actually supposed to be used by anything, and then created a
separate ConstructorDecl via importSpecialMember(). That's insane:
just have VisitObjCMethodDecl() produce a ConstructorDecl directly
when given an init method. Should be NFC.

Swift SVN r16313
2014-04-14 14:30:08 +00:00
Ted Kremenek
35c2b6e469 PrintAsObjC: use protocol remapping in the importer to remap to the original protocol name.
Along the way, don't print out the same module import more than once.

Fixes <rdar://problem/16602327>.

Swift SVN r16308
2014-04-14 08:27:11 +00:00
Doug Gregor
6e5ca8a91f Clean up a number of Cocoa selector -> method name mappings.
Swift SVN r16302
2014-04-14 05:15:10 +00:00
Doug Gregor
9d7f0b6211 Rework the selector-splitting heuristics.
This makes a number of changes to the selector-splitting
heuristics. Specifically:

  - Eliminate last-word splitting, and with it the notion of
    multi-words. We only split at prepositions now.
  - Introduce the notion of "linking verbs" such as "will" or
    "should"; when these show up, we refuse to split a selector, which
    helps with delegates.
  - Eliminate the special case for "get" and "set". It wasn't
    helping.
  




Swift SVN r16265
2014-04-12 20:32:16 +00:00
Argyrios Kyrtzidis
2da311cf1f [IDE] For the module interface, don't print submodule imports, unless they are submodules
of the module we are printing.

rdar://16530804

Swift SVN r16262
2014-04-12 19:20:08 +00:00
Argyrios Kyrtzidis
e0209fd540 [ClangImporter] Don't update the clang node of the swift decl if one already exists.
If it already has a node it should be the node we want the swift decl to point to,
e.g. the @interface definition. Otherwise we may replace it with a @class forward declaration.

rdar://16560290

Swift SVN r16254
2014-04-12 16:33:40 +00:00
Joe Groff
42a942925b Enable block bridging.
Swift SVN r16248
2014-04-12 05:13:45 +00:00
Joe Groff
2fea7bcaf1 ClangImporter: Import block types as native function types when they can be bridged.
Swift SVN r16247
2014-04-12 05:13:39 +00:00
Dmitri Hrybenko
110f85bc16 Move @exported to use new attribute infrastructure
Swift SVN r16158
2014-04-10 13:35:35 +00:00
Argyrios Kyrtzidis
3a60b89d95 [ClangImporter] Don't import include guard macros.
This depends on clang r205917.
rdar://16555519

Swift SVN r16126
2014-04-09 19:53:31 +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
Jordan Rose
8582cc10d8 [ClangImporter] Fix the interface type of imported protocol initializers.
We should be returning the declared type of the implicit 'Self' parameter,
not the archetype.

<rdar://problem/16520667>

Swift SVN r16081
2014-04-08 23:17:10 +00:00
Doug Gregor
a57253120c Selector splitting: add more multi-words.
Swift SVN r16075
2014-04-08 22:33:06 +00:00
Ted Kremenek
450effff23 Refactor check for animator proxy into helper method. NFC.
Swift SVN r16068
2014-04-08 19:43:39 +00:00
Ted Kremenek
656fd1a2ee Add blacklist for imported macros, which can be extended over time.
Implements:

<rdar://problem/16454306> NS_BLOCKS_AVAILABLE probably should not be imported since by default it's true

Swift SVN r16067
2014-04-08 19:26:17 +00:00
Doug Gregor
e56c2dee3f Split first selector piece after "get" or "set" if there is no preposition.
Addresses <rdar://problem/16548821>.

Swift SVN r16057
2014-04-08 16:34:45 +00:00
Ted Kremenek
79bddbc66f Import -animator (from NSAnimatablePropertyContainer) as returning 'id' instead of 'instancetype'.
Fixes <rdar://problem/16020273>.

Swift SVN r16050
2014-04-08 08:27:51 +00:00
Jordan Rose
1e14e28461 [ClangImporter] Don't look in protocols when seeing if a method is an accessor.
clang::ObjCMethodDecl::findPropertyDecl does a very general lookup to see if
a particular method /could/ be interpreted as a property accessor, but in
other places we were just using isPropertyAccessor() to decide whether a
method was /actually/ a property accessor. We should use the more conservative
of the two; I'm not sure if the former can /change/ if new protocols are
added (via categories).

This does cause one problem: the setter is now not available in any way on
the adopting class. We should still be exposing it as a method, even though
it's not available as a property.

Swift SVN r16035
2014-04-08 01:23:23 +00:00
Jordan Rose
835bfb15a9 [ClangImporter] Add an option (off by default) to infer "implicit properties".
In Objective-C, any method with no arguments can be used with dot syntax, as
can any method that takes one argument whose name starts with "set". This
commit adds a frontend-only flag -enable-objc-implicit-properties to look for
"setter-like" methods that match up with "getter-like" methods to import them
as Swift properties. By default, such methods are just considered unrelated
methods.

Part of <rdar://problem/16215476>

Swift SVN r16025
2014-04-07 21:49:37 +00:00
Jordan Rose
7810edea97 [ClangImporter] "NSPost" is not a prefix of "NSPostingStyle"
A small error in last week's enum changes.

<rdar://problem/16540910>

Swift SVN r16019
2014-04-07 20:49:54 +00:00
Doug Gregor
0a8d792b2f Add some more multiwords.
Swift SVN r16017
2014-04-07 20:03:36 +00:00
Doug Gregor
49387beb25 Selector splitting: don't split selectors in the middle of whitelisted "multi-words".
Swift SVN r16016
2014-04-07 19:17:23 +00:00
Doug Gregor
f6a196f700 Clang importer: when preposition splitting fails, split at the last word.
Swift SVN r16015
2014-04-07 19:17:22 +00:00
Doug Gregor
4130bb15ff Add a whitelist of designated initializers and use it in the Clang importer.
Seed the whitelist with the designated initializers for NSObject,
NSDocument, and UIDocument. We'll grow this list over time.
Fixes <rdar://problem/16521299>.


Swift SVN r16013
2014-04-07 15:06:59 +00:00
Doug Gregor
7e8d5f7cfe Use a different selector encoding in the .def file that allows nullary selectors. NFC.
Swift SVN r16012
2014-04-07 14:17:43 +00:00
Doug Gregor
0364e0b977 Assert that the # of selector pieces matches the # of method arguments.
Swift SVN r15985
2014-04-05 06:54:14 +00:00
Doug Gregor
57d54cacee Clang importer: add a hardwired table mapping selectors to method names.
Regardless of the heuristic we choose when importing Objective-C
selectors into Swift method names, there will be poor cases. Allow us
to bake specific mappings into the compiler so we can address those
cases without having to modify the Objective-C headers.

Part of <rdar://problem/16341485>.


Swift SVN r15984
2014-04-05 06:52:38 +00:00
Doug Gregor
c78a3ecd48 Clang importer: cache the result of the selector -> method mapping.
Swift SVN r15983
2014-04-05 06:04:01 +00:00
Doug Gregor
6baa7eb35c PrintAsObjC: Emit objc_runtime_name attributes for Swift classes.
This makes sure that Clang uses the mangled class names for
Swift-defined classes. Should be last compiler-side piece of
<rdar://problem/15506580>.


Swift SVN r15977
2014-04-05 04:45:21 +00:00
Jordan Rose
13e8d9d27d [ClangImporter] Import properties even if there is a similarly-named method.
...and teach the type-checker to prefer variables to functions.

This matters in Objective-C, where you may have these two members:

@property NSURL *URL;
- (void)URL:(NSURL *)url resourceDidFailLoadingWithReason:(NSString *)reason;

This doesn't happen often, but we should do the right thing when it does.

We still won't import a property named 'foo' if there is already a method
'-foo' that takes no arguments.

<rdar://problem/16383845>

Swift SVN r15963
2014-04-04 23:35:01 +00:00
Jordan Rose
531a3d794d [ClangImporter] Mark mirrored members from protocols as implicit.
Also class versions of instance methods on root classes.

No tests because nothing is actually using the implicit flag besides
SIL printing.

Swift SVN r15953
2014-04-04 20:57:28 +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
Jordan Rose
2c62cd4232 [ClangImporter] Maintain the invariant that new members come in last.
Enum elements were being added before the members already in the enum decl.
This was probably harmless, but just in case.

Swift SVN r15909
2014-04-04 01:17:51 +00:00
Joe Groff
bef2cdfac4 ClangImporter: Enable importing NSFoo** as ObjCMutablePointer<NSFoo?>.
And blast away a bunch of withUnsafePointer* noise this obviates in the stdlib.

Swift SVN r15896
2014-04-03 22:33:33 +00:00
Joe Groff
b61bfe5e61 ClangImporter: Fix logic order.
Test for true void pointers before giving up on opaque types when importing pointer parameter types.

Swift SVN r15893
2014-04-03 20:48:01 +00:00
Joe Groff
40f675641a ClangImporter: Don't bridge pointers to forward-declared types.
This backs off trying to bridge CF*Ref forward declarations to C*VoidPointer, which throws away all the typedef sugar. Continue importing these as COpaquePointer for now. This should fix the complete_from_cocoa tests.

Swift SVN r15890
2014-04-03 20:31:12 +00:00
Doug Gregor
7102f1bb0b Clang importer: add a statistic for trailing prepositions in the first selector piece.
Swift SVN r15887
2014-04-03 18:08:01 +00:00