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.
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.
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.
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.
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.
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.
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().
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.
The sole remaining caller to importName is for enumerators, which may
have prefixes that need stripping. That refactor will come in a
subsequent commit.
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.
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.
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
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
...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
Instead, when mapping a Clang type to its name for omission purposes,
map CF types to their appropriate names. This more directly mirrors
what will happen on the Swift side, but is otherwise NFC.
Swift SVN r32140
This covers this case:
struct foo {
struct {
int x;
int y;
} bar;
union {
void *ptr;
float num;
} baz;
};
Based on the original patch by Graham Batty.
Progress on <rdar://problem/21683348> -- anonymous unnamed unions
are still not supported (struct foo { union { int x, y }; };).
Swift SVN r31924
Bitfields are imported as computed properties with Clang-generated
accessors.
While we cannot represent them directly in SIL, we can still
synthesize a memberwise initializer, so also decouple that notion
from "has unreferenceable storage".
Fixes <rdar://problem/21702107>.
Swift SVN r31779
- Extract makeFieldGetterDecl() and makeFieldSetterDecl()
- Remove makeUnionConstructorDecl(), the ordinary struct constructor logic
works just fine
Swift SVN r31709
Some GCD APIs rely on the pointer identity of blocks, so avoid bridging
when possible. The easiest way to do this was to use our existing rules
for special-casing typedefs.
The summary text for dispatch_block_t comes from the actual GCD headers.
rdar://problem/22432170
Swift SVN r31634
We were memcopying a std::function into the the AST context memory,
which leaks memory incidentally used by the std::function
implementation. Fix by using a std::unique_ptr and registering a
destructor cleanup. Incidentally, I turned the array of functions into
a single function, since we never have more than one anyway.
rdar://problem/22387897
Swift SVN r31600
marker isn't actually setting the implicit bit, it was setting the "trailing
closure" bit, for something that isn't of function type. The effect of this
was to cause sema to eat the rawValue: parameter without requiring the label.
Instead of generating this code that happened to work out most of the time,
build the proper TupleExpr with the right parameter label. NFC.
Swift SVN r31597
This provides the == operator as well as ~=, which allows for
less encumbered pattern matching for these imported types.
rdar://problem/17287720
Swift SVN r31469
Create getters and setters for, and initializers taking, fields in
C unions. This doesn't yet fold anonymous unions' fields nested into
a struct, but it does open up APIs that were previously unavailable.
rdar://problem/19660119
Swift SVN r31396
Now that we have the inheritance lists hanging around, use them: it
makes the conformance lookup table use the same code whether we're
deserializing the conformances or parsing them.
Swift SVN r31383