Commit Graph

2523 Commits

Author SHA1 Message Date
Doug Gregor
7c0c092004 Eagerly update a protocol's "has missing required members" flag.
Rather than plumbing a "has missing required members" flag all the way
through the LazyResolver's loadAllMembers and its implementations,
just eagerly update the "has missing required members" flag in the
Clang importer when it happens. More NFC cleanup.
2015-12-23 13:38:35 -08:00
Max Moiseev
200be71583 Merge remote-tracking branch 'origin' into swift-3-api-guidelines 2015-12-23 10:28:04 -08:00
Doug Gregor
a320b6cdc4 Clang importer: centralize the "suppress declaration import" logic.
The Swift name lookup tables and the complete Objective-C "container"
to Swift DeclContext mapping code used similar-but-different logic to
determine when to suppress a declaration (e.g., when suppressing the
accessors for a property). Centralize the logic so we get the same
behavior in both places.
2015-12-22 21:47:01 -08:00
Doug Gregor
d28cc60479 Clang importer: Handle inference of protocol member availability directly.
We were inferring protocol member availability as part of filling in
the complete imported protocol. Do it eagerly when we import a member
of a protocol.
2015-12-22 17:32:44 -08:00
Doug Gregor
c47c669e03 Clang importer: handle factory-method-as-initializer as an alternate declaration.
Alternate declarations now capture all of the ways in which a single
Objective-C method can be reflected into two Swift methods (for
subscripts, factory-methods-as-initializers, and
instance-methods-as-class-methods).
2015-12-22 17:32:44 -08:00
Doug Gregor
6ddce0b042 Clang importer: centralize the logic for importing instance methods as class methods.
Objective-C instance methods of root classes can also be used as class
methods, which we handle by performing a redundant import, the code
for which was scattered. Centralize this import as part of importing
the original (instance) method, and record it as an alternate
declaration to the original instance method. This eliminates a number
of special cases in the Clang importer.
2015-12-22 17:32:44 -08:00
practicalswift
6e3b700b44 Fix typos. 2015-12-23 00:31:13 +01:00
Doug Gregor
48fb38f82a Clang importer: eliminate importSpecialMethod. NFC
This method was only used for importing subscripts. Instead,
import a subscript when the imported name says we should (so we
eliminate the redundant check for "might this be a subscript
accessor?") and use the subscript "alternate declaration" to eliminate
the only other caller to importSpecialMethod.
2015-12-22 14:01:16 -08:00
Doug Gregor
192b16f7fe Clang importer: use "alternate declarations" when enumerating imported members.
When we are creating the complete list of imported members for an
Objective-C class or protocol, start relying on the "alternate
declarations" mapping to get the extra members. Do this only for
subscripts at the moment (now that they record alternate declarations
properly and are idempotent), but eventually we should expand this
out.
2015-12-22 13:38:10 -08:00
Doug Gregor
0c0a0fab4b Clang importer: clean up importing of subscripts.
There was a lot of dodgy code in here that made subscript imports not
necessarily idempotent. Try to clean up the flow a bit, eliminating
the DeclContext parameter (which caused some "interesting" effects if
misused), be more methodical about handling the redeclaration case,
eliminate some unnecessary recursion due to performing name lookup in
the wrong place for override checking, etc.
2015-12-22 13:26:44 -08:00
Max Moiseev
a7339e67ac Merge remote-tracking branch 'origin' into swift-3-api-guidelines 2015-12-22 11:36:07 -08:00
practicalswift
36d7072013 Remove immediately adjacent repeated words ("the the", "for for", "an an", etc.). 2015-12-21 22:16:04 +01:00
Doug Gregor
cd1c106e35 Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2015-12-18 15:45:48 -08:00
Doug Gregor
8fc9bb56de Clang importer: do selector matches to more carefully wire up overrides.
We were depending on the (nearly) 1-1 mapping from Objective-C
selectors into Swift names when wiring up overrides of Objective-C
methods, but this mapping falls apart under
-enable-omit-needless-words. Use the Objective-C selector, which
represents the truth of overriding in Objective-C, to wire up
overrides properly.
2015-12-18 15:09:29 -08:00
Max Moiseev
3fe0c60d7f Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2015-12-17 11:00:02 -08:00
Doug Gregor
e423ad03a3 Clang importer: clean up "alternate declaration" handling for subscripts. 2015-12-16 11:21:38 -08:00
Doug Gregor
2bd31a0e10 Clang importer: introduce "alternate declarations" for redundant imported decls.
There are some Clang declarations that end up being imported as
multiple declarations in Swift, e.g., CF types get imported both with
and without the "Ref" suffix, subscript getters get imported both as a
method and as a subscript, etc. Track this explicitly so it's easy to
query the alternate declaration of a given declaration for name
lookup.

In many of these cases, the alternate declarations should simply go
away, because they're bloating the API. But that's a Swift 3 change
that requires review. For now, we want parity between the behavior
without and with Swift name lookup tables.
2015-12-16 11:21:38 -08:00
Max Moiseev
2021dd5a4d Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2015-12-15 12:49:22 -08:00
Doug Gregor
d421a4fc0a Clang importer: use Swift name lookup tables for AnyObject member lookup.
When we're building Swift name lookup tables, use them for AnyObject
member lookup rather than falling back to the Objective-C selector
table.
2015-12-14 22:05:04 -08:00
Doug Gregor
563bdb9156 Clang importer: remove support for implicit properties.
We decided not to support "implicit" properties, where we import
getter/setter pairs as properties. Rather, we only import a property
when there is an explicit "@property" in Objective-C. Remove the flag
and supporting code for implicit properties.
2015-12-14 14:33:07 -08:00
Max Moiseev
806be29941 Merge remote-tracking branch 'origin' into swift-3-api-guidelines 2015-12-14 12:05:35 -08:00
practicalswift
c6e8459187 Fix typos. 2015-12-14 11:13:30 +01:00
practicalswift
8912c8b5d5 Fix typo: containining → containing 2015-12-14 00:11:27 +01:00
Maxim Moiseev
0e0191380a OptionSetType => OptionSet 2015-12-10 14:58:24 -08:00
Doug Gregor
8b82a674ec Clang importer: decouple importFullName from a specific Clang ASTContext. 2015-12-08 17:34:04 -08:00
Doug Gregor
6b3807401a Clang importer: When dropping a variadic parameter, update the selector as well
Fixes breakage on iOS.
2015-12-04 10:20:06 -08:00
Doug Gregor
d9ce07fa41 Clang importer: when dropping the variadic parameter, drop the variadic parameter.
Fixes iOS build.
2015-12-03 11:50:43 -08:00
Doug Gregor
2ea58f93b0 Clang importer: handle CF type renaming in importFullName.
Ensures that the Swift lookup tables get transformed name for imported
CF types, including original name (which is still
available). Otherwise, this is an NFC refactoring that gets the last
of the naming tricks into importFullName.
2015-12-03 11:50:43 -08:00
Doug Gregor
2d7044c024 Clang importer: move name translation for throwing methods into importFullName.
The translation from the Objective-C NSError** convention into Swift
throwing methods alters the names of methods. Move that computation
into importFullName. This should be NFC refactoring for everything
except the Swift name lookup tables, which will now correctly reflect
this name translation.
2015-12-03 11:50:42 -08:00
Doug Gregor
4c50598916 Clang importer: switch method name import to importFullName().
This lets us kill the redundant Objective-C selector to DeclName
mapping used only for methods.
2015-12-03 11:50:42 -08:00
Doug Gregor
3102e2314c Clang importer: switch init method importing over to importFullName.
Yet more name-importing refactoring toward eliminating some redundant
code. As a drive-by, happens to fix swift_private imports for
no-parameter init methods.
2015-12-03 11:50:42 -08:00
Doug Gregor
91d1c3b21a Clang importer: use importFullName for factory methods as initializers.
Eliminates one of the redundant places where we map Objective-C
selectors over to Swift names.
2015-12-03 11:50:42 -08:00
Doug Gregor
fedb6a8b8a Clang importer: give importFullName a richer result type.
Capture the imported name, as well as some information about it, in
the result of importFullName. Some of the clients need this
information.
2015-12-03 11:50:41 -08:00
Doug Gregor
eedf0fc1db Clang importer: teach importFullName to map init methods to initializers.
We're only using this in the Swift lookup tables at the moment.
2015-12-03 11:50:41 -08:00
Doug Gregor
5776fa59c6 Clang importer: migrate "Protocol" suffix computation into importFullName.
Refactoring that lets the Swift lookup tables get the names right for
Objective-C protocols that would conflict with another entity in the
same module (or within the bridging header). It's an NFC cleanup
everywhere else.
2015-12-03 11:50:41 -08:00
Doug Gregor
fa865c7165 Clang importer: handle enumerator prefix stripping in importFullName().
Centralize the mapping of C names to Swift names further by including
enumerator prefix stripping, rather than having that as a separate
path. The actual logic and code for computing the prefix is unchanged
(despite moving from one file to another). This corrects the name
computed for the Swift lookup tables, but is an NFC refactoring for
everything else.

With this, kill off importName(), because it's been entirely
superseded by importFullName().
2015-12-03 11:50:40 -08:00
Doug Gregor
c41535a7fb Clang importer: start computing the effective lookup context with the name.
This places enumerators that will become either cases of a Swift enum
or options in a Swift option into the context of the C enum type for
the name lookup table.
2015-12-03 11:50:40 -08:00
Doug Gregor
f798d53f92 Clang importer: convert more importName callers over to importFullName. NFC
The sole remaining caller to importName is for enumerators, which may
have prefixes that need stripping. That refactor will come in a
subsequent commit.
2015-12-03 11:50:40 -08:00
Doug Gregor
3caf703d47 Narrow the Clang importer's importDeclName to just importIdentifier. NFC
We never used it for non-identifier names, and the former is somewhat
ambiguous with the new importFullName.
2015-12-03 11:50:39 -08:00
Doug Gregor
a861a7345e Clang importer: introduce "importFullName" to centralize name-mapping logic.
The Swift lookup tables are the primary client and test vehicle right
now. This change adds the capability to use the swift_name attribute
to rename C functions when they are imported into Swift, as well as
handling the swift_private attribute more uniformly.

There are a few obvious places where I've applied this API to
eliminate redundancy. Expect it to broaden as the API fills out more.
2015-12-03 11:50:39 -08:00
Johan K. Jensen
fa76656c82 Remove instances of duplicated words 2015-12-03 20:00:29 +01:00
Dmitri Gribenko
4324e7c903 Remove conditional compilation of tvOS 2015-12-01 14:43:45 -07:00
Slava Pestov
2e796aeb9f Remove MappedLanguages enum, NFC
@jrose-apple says this is useless.
2015-11-04 13:53:06 -08:00
Xi Ge
9586337981 [Parser] Allow FuncDecl to record the locations of accessor keywords, e.g. set, get, etc. 2015-11-03 18:13:32 -08:00
Jordan Rose
070ccba166 Verify that a function's DeclName, TuplePattern, and ParamDecls are in sync.
This required a few changes in places where we synthesize functions to
make sure these properties hold. That's good because we don't know where
we might already be depending on them. (On the other hand, we could also
decide not to care about TuplePattern labels, in which case I wonder if
we could eventually discard them altogether in functions.)

Still untested: that the function type is also in sync.
2015-11-02 18:16:19 -08:00
Xi Ge
1604c4ba9e [ClangImporter] Import variadic C functions as unavailable functions instead of ignoring them. rdar://16677468
Also, this helps us fix rdar://20092567.

Swift SVN r32903
2015-10-27 00:29:44 +00:00
Doug Gregor
fa3bb96f85 Clang importer: allow the swift_name attribute to map any name.
This is functional for arbitrary Objective-C properties and methods
(the subject of rdar://problem/22214302), as well as for changing the
argument labels of C functions. However, it does not work when the
name of a global is changed because name lookup initiated from
Swift goes through the Swift lookup table. Fixes
rdar://problem/22214302 but is only a step toward
rdar://problem/17184411.

Swift SVN r32670
2015-10-13 21:12:28 +00:00
Doug Gregor
2feed84c91 Sketch out the interface to an iterative, lazy type checker.
This is all effectively NFC, but lays out the shape of the iterative
type checker: requests are packaged up in TypeCheckRequest, we can
check whether the request has been satisfied already (isSatisfied),
enumerate its dependencies (enumerateDependenciesOf) in terms of other
TypeCheckRequests, and satisfy a request (satisfy).

Lazily-computed semantic information is captured directly in the
AST, but has been set aside in its own structure to allow us to
experiment with moving it into a lookaside table.

The only request that exists now is to type-check the superclass of
the given class. It currently performs unhealthy recursion into the
existing type checker. As we detangle dependencies, this recursion
between the IterativeTypeChecker and the TypeChecker can go away.

Swift SVN r32558
2015-10-09 17:18:36 +00:00
Erik Eckstein
1a6a98b201 ClangImporter: import LLVM's const and pure function attributes to SIL function effects.
<rdar://problem/19558813>



Swift SVN r32371
2015-10-01 18:04:07 +00:00
Jordan Rose
59176785fa [ClangImporter] Typedefs of CFTypeRef should not be imported as AnyObject.
...or rather, typealiases of AnyObject. They should be typealiases of
CFTypeRef. (The problem is that everywhere else CFFooRef becomes a typealias
for CFFoo, but we don't do the same with 'CFType'.)

Fixes a PrintAsObjC problem where we'd try to mark such typealiases as
'strong' if they show up in the generated ObjC header.

rdar://problem/22827172

Swift SVN r32230
2015-09-25 17:53:45 +00:00