Commit Graph

425 Commits

Author SHA1 Message Date
Jordan Rose
2b73716dd2 [ClangImporter] When a submodule is imported, so is the top-level module.
Background: if a Clang module /only/ imports submodules from another module,
we would lose all re-exports from that other module, because we're treating
all decls as part of the top-level module. This actually shows up with UIKit
and QuartzCore due to some weirdness in how the QuartzCore module is set up
(see <rdar://problem/17888079>), resulting in 'CALayer' not being visible
with just 'import UIKit'.

Workaround (this patch): treat Clang imports just like Swift imports: if the
submodule is referenced, so is the top-level module. This isn't great, but
it's not really any more awful than the rest of our Clang modules story.

<rdar://problem/17607060>

Swift SVN r20920
2014-08-01 21:44:41 +00:00
Anna Zaks
a8cb45a269 API Notes: add UIView + a couple of corrections to UIKit audit.
The corrections are:
 - Change the UIFont's API from '?' to '!'. These APIs are almost never get checked.
 - Change the "options" array parameter to being optional.

Swift SVN r20723
2014-07-29 23:47:11 +00:00
Jordan Rose
d0433fde33 [test] Update for Clang r214119 "Change __INTx_TYPE__ to be always signed."
This change should work fine with older Clang revisions as well.

Swift SVN r20662
2014-07-29 00:38:24 +00:00
Anna Zaks
071291003b APINotes: Use the property's notes to set the accessor's types.
Fixes the crashes due to the property and its setter and getter being out of sync.

Swift SVN r20570
2014-07-25 22:49:36 +00:00
Doug Gregor
ec6016040e Clang importer: try harder to mark initializers from protocols as required.
There is an egregious hack here that special-cases -initWithCoder:. We
need to completely revisit how we handle 'required' checking.

Swift SVN r20516
2014-07-24 21:29:05 +00:00
Jordan Rose
00b6a5cb08 Import Objective-C properties marked weak/copy as weak/@NSCopying.
...and 'assign' and 'unsafe_unretained' as 'unowned(unsafe)', if the
property is a class type.

This isn't important for the compiler, but it is documentation for users
when they look at the generated interface for an Objective-C module.

Note that this actually produces a decl users can't yet write:

  unowned(unsafe) var foo: UIView!

That's <rdar://problem/17277899> unowned pointers can't be optional.

<rdar://problem/17245555>

Swift SVN r20433
2014-07-23 22:29:01 +00:00
Jordan Rose
ce1e02c6c0 [ClangImporter] Remove hack for non-property 'description' and 'hash'.
...and 'debugDescription'. All SDKs now have the updated NSObject.h.

<rdar://problem/17719783>

Swift SVN r20291
2014-07-22 02:38:58 +00:00
Doug Gregor
97f894dd4a In the importer SDK, move NCWidgetController into the NotificationCenter module.
We’re about to require that API notes show up in the right place.

Swift SVN r20119
2014-07-17 23:16:41 +00:00
Anna Zaks
eab2792cd8 Disallow [NSArray makeObjectsPerformSelector:]
Addresses radar://17559678

Swift SVN r19958
2014-07-14 22:42:37 +00:00
Jordan Rose
c99b417a59 [ClangImporter] Handle underscore-punctuated enum names (used by CoreMedia).
<rdar://problem/17594425>

Swift SVN r19732
2014-07-09 18:44:43 +00:00
Anna Zaks
c1537fdcdd Reject explicit uses of CFRetain/CFRelease/CFAutorelease
Ban use of CFRetain, CFRelease, CFAutorelease used for manual memory management as well as a bunch of other similar APIs, such as CGColorRelease.
Addresses radar://16892185

Swift SVN r19552
2014-07-04 02:29:05 +00:00
Anna Zaks
8cb6d45efb Only remap NSUInteger to Int in system frameworks
Makes NSUInteger come in as Uint from user declarations (and as Int from system modules).
Addresses radar://17473606

Swift SVN r19536
2014-07-03 21:46:47 +00:00
Joe Groff
ce9802c5a5 ClangImporter: Allow unions and structs with bitfields to be imported.
We still don't import the fields of unions or bitfields, but we want to at least be able to represent the types so that APIs using the types can be used from Swift. IRGen should be able to produce the correct layout for these types even if all of their fields don't get reflected into Swift.

Swift SVN r19529
2014-07-03 21:15:29 +00:00
Ted Kremenek
5ecbad667a Instead of defining __swift__, rely on the 'annotate' attribute to define custom unavailability in Swift (v1).
Swift SVN r19482
2014-07-02 20:59:14 +00:00
Ted Kremenek
148756e39a Predefine macro "__swift__" when importing Clang modules.
Implements <rdar://problem/17502039>.

Swift SVN r19327
2014-06-30 05:44:08 +00:00
Ted Kremenek
9c3fc9e6b4 Add iOS availability to test input.
Swift SVN r19222
2014-06-26 05:36:31 +00:00
Ted Kremenek
0ec94df58e Add test for App Extension API restrictions.
Swift SVN r19204
2014-06-26 00:50:54 +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
Joe Groff
c9f24d1f2e ClangImporter: Keep importing pointers to unimportable types as COpaquePointer in -enable-pointer-conversions mode.
Don't crash.

Swift SVN r19182
2014-06-25 21:35:21 +00:00
Jordan Rose
ce4dcb7a5f [ClangImporter] Import C function types as CFunctionPointer<T>.
...where T is the equivalent Swift function type. This gives us proper type
safety (ish) for C function pointers while still not treating them the same
as Swift closures.

If the function type is not one we can represent in Swift, we fall back to
COpaquePointer. CFunctionPointer<T> and COpaquePointer can be explicitly
constructed from one another, but do not freely convert.

<rdar://problem/17215978>

Swift SVN r19154
2014-06-25 00:33:06 +00:00
Anna Zaks
a7fefdb561 Known ObjC types sidecar: add ability to annotate properties.
Add a simple option that allows to pass along information about properties.

Swift SVN r19110
2014-06-23 23:53:37 +00:00
Anna Zaks
9f122e56b7 Add initial support for importing with tighter Objective C pointer types.
Add the ability to store optionality of the ObjC method parameters and return
type in a sidecar. This hardcoded info is then used to import Objective C
object pointer types as either optional or none, instead of implicitly
unwrapped optionals.

The feature is enabled with -import-with-tighter-objc-types=true.

Swift SVN r19048
2014-06-20 19:19:43 +00:00
Doug Gregor
821d18718a Add a test ensuring that we prefer non-bridged methods to bridged ones.
Swift SVN r18921
2014-06-16 09:36:16 +00:00
Doug Gregor
1c06c309bc Automatically reflect non-Foundation categories of bridged Objective-C classes onto their bridged value types.
This makes categories of NSString, NSArray, and NSDictionary available
on String, Array, and Dictionary. Note that we only consider
categories not present in the Objective-C Foundation module, because
we want to manually map those APIs ourselves. Hence, no changes to the
NSStringAPI. Implements <rdar://problem/13653329>.


Swift SVN r18920
2014-06-16 09:07:00 +00:00
Jordan Rose
54c0baa9aa [ClangImporter] Don't recurse infinitely on "#define X X".
<rdar://problem/17182523>

Swift SVN r18772
2014-06-10 01:18:29 +00:00
Jordan Rose
171fc95d27 [ClangImporter] Suppress macros named TRUE and FALSE.
These are too close to "true" and "false" for comfort; they add confusion and
mess up code completion. If the names appear in other contexts, though (such
as enumerator names), we should still bring them through.

<rdar://problem/17080279>

Swift SVN r18670
2014-05-30 18:39:39 +00:00
Jordan Rose
3ba8808a6f [ClangImporter] When remapping an init method's name, change the selector too.
This is what we use to drop the variadic parameter on UIActionSheet and
UIAlertView's initializers, along with secretly adding a category to each
to provide the one-fewer-parameter init method implementation. However,
we haven't been using the Swift name for the method to generate Objective-C
calls for a while now--we use the @objc attribute. And that was still using
the original selector, and so we crashed.

Fixed by passing the new selector to the @objc attribute.

<rdar://problem/17012323>

Swift SVN r18582
2014-05-23 01:56:56 +00:00
Jordan Rose
f256d65669 [ClangImporter] NSProcessInfo.processInfo() is distinct from NSProcessInfo().
Thankfully, Doug already put in infrastructure for this, so it just required
adding one more entry to the table.

<rdar://problem/16995980>

Swift SVN r18537
2014-05-22 00:20:32 +00:00
Jordan Rose
e6db58a6ae [ClangImporter] Map u_int*_t [sic] to UInt*.
These types come from <sys/types.h> indirectly and show up in a few
interesting functions like arc4random_uniform.

This commit also introduces a new test file for mapping fixed-sized integers,
to eliminate boilerplate as we continue to rack up aliases for UInt*.

<rdar://problem/16978349>

Swift SVN r18505
2014-05-21 19:45:42 +00:00
Jordan Rose
8ef90ddf92 [test] Use __typeof__(__objc_yes) to get the right per-platform type for BOOL.
With this trick in place, re-enable test/IRGen/abitypes.swift.

<rdar://problem/16936814>

Swift SVN r18380
2014-05-19 01:14:29 +00:00
Doug Gregor
3b61830f81 Mark -[NSObject dealloc] as unavailable.
This is most of <rdar://problem/16486790>, solved trivially.

Swift SVN r18275
2014-05-17 21:43:34 +00:00
Doug Gregor
c0e218c982 Mark -[NSExtensionContext openURL:completion:] as unavailable <rdar://problem/16909180>
Swift SVN r18274
2014-05-17 21:37:14 +00:00
Doug Gregor
8b70f34ea8 Revert r18196: Clang importer: use T* type sugar when importing as UnsafePointer<T>.
Swift SVN r18254
2014-05-17 16:38:44 +00:00
Doug Gregor
2e499b8cdd Clang importer: use T* type sugar when importing as UnsafePointer<T>.
Swift SVN r18196
2014-05-16 15:44:25 +00:00
Joe Groff
8923d50f6a Revert "Define BOOL correctly for arm64 in the clang-importer-sdk."
This reverts commit r18159. There's a redundant definition in another header, and it's not worth messing with this now.

Swift SVN r18164
2014-05-16 02:43:35 +00:00
Joe Groff
45a6bbe831 Define BOOL correctly for arm64 in the clang-importer-sdk.
BOOL should also be _Bool on x86-64 simulator, but the clang importer preprocessor doesn't appear to have the necessary #defines to distinguish that currently.

Swift SVN r18159
2014-05-16 01:24:16 +00:00
Doug Gregor
d640eb4083 Introduce support for blacklisting factory-methods-as-inits.
Some fcactory methods shouldn't come in as initializers, per
<rdar://problem/16908950>.


Swift SVN r18101
2014-05-15 07:04:46 +00:00
Joe Groff
067f810be6 Parse and do basic checking for @UIApplicationMain.
Introduce the UIApplicationMain attribute, and check that it's only applied to nongeneric classes that conform to UIApplicationDelegate.

Swift SVN r18048
2014-05-14 01:06:52 +00:00
Jordan Rose
11947c4e86 [test] Change UTF-16 test to not mention the language name.
Just in case. I changed the emoji for "Swift" too, just for Joe.

Swift SVN r17985
2014-05-13 00:48:04 +00:00
Doug Gregor
2702c943aa When determining whether an imported initializer is a designated initializer, use the context it's being imported into.
Previously, we were using the context where the initializer was declared in Objective-C, rather than where it was being imported. This meant that we wouldn't treat an inherited designated initializer as a designated initializer if (for example) the designated-initializer marking came from our internal table of DIs. Fixes <rdar://problem/16838515>.

Swift SVN r17968
2014-05-12 22:47:38 +00:00
Ted Kremenek
4479eb85c0 Import +class and -class as unavailable, suggesting ".type" and ".dynamicType" instead.
Implements <rdar://problem/16871007>.

Swift SVN r17883
2014-05-11 20:22:53 +00:00
Doug Gregor
77ca640d42 Add -objc-bridge-array option to import NSArray* as (AnyObject[])!
This should be the last of the compiler-side functionality for
<rdar://problem/16535097>; we lack any real testing of this.


Swift SVN r17871
2014-05-11 06:29:13 +00:00
Doug Gregor
dc3ca1145d Loosen the constraints on bridging Dictionary<K, V>.
We now allow bridging so long as both K and V can be bridged to
Objective-C, as determined by _BridgedToObjectiveC conformance. Note
that Dictionary's implementation still needs to handle this, which is
tracked separately.

Swift SVN r17859
2014-05-11 00:08:41 +00:00
Doug Gregor
ef1c1a8892 Import NSDictionary* as Dictionary<NSObject, AnyObject>.
Note that this is still under -objc-bridge-dictionary, but otherwise
this should be all of the functionality needed for
<rdar://problem/16870626>.

Swift SVN r17848
2014-05-10 21:39:46 +00:00
Doug Gregor
4de43af267 PrintAsObjC: Print Dictionary<K, V> as "NSDictionary *"
Swift SVN r17839
2014-05-10 20:07:57 +00:00
John McCall
c03b705dd0 Recognize CF "subclasses" and require CFTypeRef to specifically
be 'const void *', not just any 'void*'.

Swift SVN r17659
2014-05-08 00:51:27 +00:00
Jordan Rose
f4f8e7c127 [ClangImporter] Add a special case for AVVideoCompositionInstruction.
...which, like NSObject, is a protocol that has the same name as a class.

Doing this more generally is tracked in <rdar://problem/16206627>.

Swift SVN r17583
2014-05-06 23:34:42 +00:00
Jordan Rose
9ba37a07a3 [PrintAsObjC] Print imported CF types using their typedefs.
Swift SVN r17577
2014-05-06 22:50:37 +00:00
Jordan Rose
829d3e6de9 [ClangImporter] Handle macros that use bitshifts, like "(1 << 0)".
<rdar://problem/16202229>

Swift SVN r17462
2014-05-05 17:37:03 +00:00
Jordan Rose
ac15f949d2 [ClangImporter] Import macros that use ~.
This and the previous commit cover <rdar://problem/16521124>.

Swift SVN r17461
2014-05-05 17:37:02 +00:00