Commit Graph

1616 Commits

Author SHA1 Message Date
David Ungar
27aaa549ad separate out addMemberAndAlternatesToExtension 2017-08-24 20:09:18 -07:00
David Ungar
bd6a9c0432 factor out loadAllMembersIntoExtension 2017-08-24 20:09:17 -07:00
David Ungar
7d06a9af71 reindent the rest 2017-08-24 20:09:17 -07:00
David Ungar
9bc7afc652 reindent as much as diff will handle 2017-08-24 20:09:17 -07:00
David Ungar
d25b59a045 flip order of test in loadAllMembers 2017-08-24 20:09:17 -07:00
David Ungar
672e46c9ad factor out loadMembersOfBaseImportedFromClang 2017-08-24 20:09:17 -07:00
David Ungar
6a4005ca69 factor out figureOutTheDeclarationContextToImportInto 2017-08-24 20:09:16 -07:00
David Ungar
cdfd3c561f demorgan for-loop condition 2017-08-24 20:09:16 -07:00
David Ungar
f8b524342d factor out for-loop body into insertMembersAndAlternates 2017-08-24 20:09:16 -07:00
David Ungar
0f57a83229 factor out collectMembersToAdd 2017-08-24 20:09:16 -07:00
David Ungar
a2e7ea1237 separate out loadAllMembersOfObjcContainer 2017-08-24 20:09:16 -07:00
Robert Widmann
76a4935d16 Staging for __consuming
Pushes __consuming through the frontend and extends existing
attribute-based diagnsotics to cover it.  Unlike `nonmutating`,
__consuming is allowed in class methods, though it makes little
sense to put it there.
2017-08-23 12:19:00 -07:00
Slava Pestov
bf2ca1ab94 Sema/AST: Don't crash when stdlib declarations are missing
I don't have reduced test cases. The original test cases
were a series of frontend invocations in -parse-stdlib
mode.

While the original bugs seem to have been fixed, while
verifying I found a few places where we weren't checking
for null decls property in the ASTContext.

Probably not too useful to check this in, but I don't see it
causing any harm, either.
2017-08-06 00:43:23 -07:00
swift-ci
ac4efebac6 Merge remote-tracking branch 'origin/master' into master-next 2017-07-25 22:28:55 -07:00
Doug Gregor
e82e7d5fbd [Clang importer] Map swift_objc_members attribute found on superclasses.
Fixes rdar://problem/33514802.
2017-07-25 16:18:31 -07:00
swift-ci
d9f0e3cedb Merge remote-tracking branch 'origin/master' into master-next 2017-07-19 13:28:52 -07:00
Robert Widmann
8cdddef2f8 Refactor Params to use flags
Also, begin to pass around base types instead of raw InOutType types.  Ideally, only Sema needs to deal with them, but this means that a bunch of callers need to unwrap any inouts that might still be lying around before forming these types.

Multiple parts of the compiler were slicing, dicing, or just dropping these flags.  Because I intend to use them for the new function type representation, I need them to be preserved all across the compiler.  As a first pass, this stubs in what will eventually be structural rules as asserts and tracks down all callers of consequence to conform to the new invariants.

This is temporary.
2017-07-19 09:49:32 -07:00
swift-ci
54f218676d Merge remote-tracking branch 'origin/master' into master-next 2017-07-13 15:48:48 -07:00
Jordan Rose
663c4f9524 [ClangImporter] Don't import compatibility methods named 'print'. (#10928)
...because they make things harder for people trying to use
Swift.print. Before:

  error: 'print' has been renamed to 'printDocument(_:)'

After:

  error: use of 'print' nearly matches global function
    'print(_:separator:terminator:)' in module 'Swift'
    rather than instance method 'print(_:extra:)'

(This actually occurs with AppKit's NSDocument, so it's not just a
hypothetical concern.)

rdar://problem/32839733
2017-07-13 15:44:39 -07:00
swift-ci
e0782d0448 Merge remote-tracking branch 'origin/master' into master-next 2017-07-11 13:29:16 -07:00
swift-ci
e98182387b Merge remote-tracking branch 'origin/master' into master-next 2017-07-11 12:23:35 -07:00
Alex Hoppen
f8c2692f79 Introduce special decl names
Special DeclNames represent names that do not have an identifier in the
surface language. This implies serializing the information about whether
a name is special together with its identifier (if it is not special)
in both the module file and the swift lookup table.
2017-07-11 19:04:13 +02:00
Jordan Rose
85019e8d3d [ClangImporter] Structs lexically in an ObjC class are still top-level. (#10874)
Not every declaration that's syntactically in an Objective-C container
is a member of that container. Double-check the decl context before
adding it.

This is technically a breaking change in non-asserts builds, because
the struct really could be found via member lookup. But that should
be considered a bug, and I /suspect/ no one is relying on it.

rdar://problem/32451417
2017-07-11 08:25:19 -07:00
John McCall
0e89efa1c8 Bridge types during import only if we are in a fully-bridgeable context.
Somehow the logic had slipped so that we were basing this decision purely
on the ImportTypeKind and not on whether the broader context is bridgeable.
This was allowing us to use bridged types when e.g. importing the results
and parameters of C function pointer types, which is really bad.

Also, when importing a reference to a typedef of block type, do not use
the typedef in a non-bridgeable context.  We import typedefs of block type
as fully-bridged types, but this means that it is invalid to import a type
using the typedef in a context where the original C type must be used.
Similarly, make sure we use a properly-imported underlying type of the
typedef when the typedef itself is unavailable.

Also, extend the special behavior of block typedefs to abstract-function
typedefs, which seems to be consistent with the expected behavior of the
tests.

Finally, I changed importType to take a new Bridgeability enum instead of
a raw canFullyBridgeTypes bool.  At the time, I was doing that because I
was going to make it tri-valued; that turned out to be unnecessary, but I
think it's an improvement anyway.
2017-07-09 13:53:19 -04:00
swift-ci
058c33f8be Merge remote-tracking branch 'origin/master' into master-next 2017-07-05 16:08:51 -07:00
swift-ci
7763bade6f Merge pull request #10768 from CodaFi/lets-not-get-into-specifics 2017-07-05 16:03:56 -07:00
swift-ci
2dc84ee365 Merge remote-tracking branch 'origin/master' into master-next 2017-07-05 15:28:50 -07:00
Robert Widmann
b19bae4ac4 Import the value of a subscript setter as owned
The translation from a bit to the specifiers exposed this instance
in the Clang importer where we hooked up a parameter as mutable
but never reflected that in the interface type.

A future patch requires that this parameter be immutable.
2017-07-05 14:16:54 -07:00
Robert Widmann
4da853e7cb Rename Specifier::None to Specifier::Owned 2017-07-05 14:02:26 -07:00
Arnold Schwaighofer
a72b685927 Merge remote-tracking branch 'origin/master' into master-next 2017-06-30 12:21:33 -07:00
swift-ci
3e31e8c2cd Merge pull request #10721 from CodaFi/parampa-tha-rappa 2017-06-30 10:50:08 -07:00
Robert Widmann
4411223156 [NFC] Switch some more of the frontend to params 2017-06-30 10:24:52 -07:00
swift-ci
5707eaf699 Merge remote-tracking branch 'origin/master' into master-next 2017-06-29 20:09:34 -07:00
Robert Widmann
679584d8d8 Merge pull request #10695 from CodaFi/all-specd-out
[NFC] Use a meaningful representation of parameter specifiers
2017-06-29 20:00:14 -07:00
swift-ci
fe5e31012d Merge remote-tracking branch 'origin/master' into master-next 2017-06-29 18:08:56 -07:00
Robert Widmann
ac5594dabe Use a meaningful representation of parameter specifiers
In anticipation of future attributes, and perhaps the ability to
declare lvalues with specifiers other than 'let' and 'var', expand
the "isLet" bit into a more general "specifier" field.
2017-06-29 16:03:49 -07:00
Jordan Rose
a8bc132565 [ClangImporter] Make conformance loading lazier.
Previously, the importer queued up conformances to complete once it
was done importing the current batch of declarations. However, if
there was a serialized Swift module that extended an imported type to
add a conformance in exactly the wrong way, the importer could end up
asking for that conformance later---even before the reference to the
imported type was resolved. This led to a crash in the deserializer
"while reading conformance for type X".

Instead of this "pending actions" queue, we can just use the
mechanisms already in place for lazily loading conformances. That way
they'll get filled out on demand, which is better all around anyway.
This does mean putting the requirement signature into the "lazy" part
of the conformance, though.

This does as a side effect mean that /all/ of the witnesses for the
imported conformance may be opaque---that is, they will never be
devirtualized to a particular implementation. However, they previously
would have referred to methods implemented in Objective-C anyway,
which are always dispatched with objc_msgSend. So this should have no
practical effect.

rdar://problem/32346184
2017-06-29 15:50:09 -07:00
swift-ci
b28a1093da Merge remote-tracking branch 'origin/master' into master-next 2017-06-29 15:09:18 -07:00
Doug Gregor
623d72db3c [AST] Make the "requirement signature" of a protocol a flat array.
Rather than pretend that the requirement signature of a protocol is a
full, well-formed generic signature that one can meaningfully query,
treat it as a flat set of requirements. Nearly all clients already did
this, but make it official. NFC
2017-06-29 14:01:49 -07:00
Doug Gregor
75f3c99382 [Clang importer] Compute requirement signature before setting environment.
Match what the type checker is doing.
2017-06-29 14:01:49 -07:00
Greg Parker
7b009eccde Merge remote-tracking branch 'origin/master' into master-next 2017-06-28 15:25:17 -07:00
Doug Gregor
6a26f5f044 [Clang importer/module printing] Correctly print NS_ERROR_ENUMs.
Ever since we stopped associating the top-level struct of an imported
NS_ERROR_ENUM with the Clang enum declaration, we've been unable to
print imported NS_ERROR_ENUMs. The module-printing infrastructure
would drop them thinking they aren't imported declarations.

This also affected NS_ERROR_ENUMs that were imported as members of
another type, as well as other types imported as members.

Fixes rdar://problem/32497693.
2017-06-27 17:01:29 -07:00
Jordan Rose
701a70d257 [ClangImporter] Filter import-as-member decls by preferred submodule. (#10612)
That is, if a member is redeclarable, use the module of the definition
if possible, and the canonical declaration otherwise. This is
consistent with what we do when we actually import the declaration.
Without this, we can end up dropping declarations.

rdar://problem/32816381
2017-06-27 09:00:47 -07:00
Doug Gregor
f855d2f87e [Clang importer] Infer @_downgrade_exhaustivity_check for new-to-2017 enum elements in Swift 3.
In Swift 3 mode, infer @_downgrade_exhaustivity_check for any enum
elements that were introduced in the 2017 SDKs (macOS 10.13, iOS 11.0,
tvOS 11.0, watchOS 4.0). This is a stop-gap until we get "open" enums,
but serves an important source-compatibility use case.

Fixes rdar://problem/32824207.
2017-06-26 13:13:50 -07:00
Michael Ilseman
db70b76a88 Merge pull request #10254 from milseman/new_type_old_abi
[ClangImporter] Fix indirection mismatch surrounding swift_newtype
2017-06-23 06:15:30 -07:00
Pavel Yaskevich
42246cae8a [ClangImporter] Fix importType to return interface types for generic parameters
`ClangImporter`'s `importType` should always return interface types
for everything it imports, which helps to avoid tracking of declaration
contexts and remapping returned types in/out of them.

Resolves: rdar://problem/32298667
2017-06-22 16:38:09 -07:00
Michael Ilseman
c7d9404e4a [Clang Importer] Account for indirection when importing swift_newtypes
Previously, we did not properly handle levels of indirection for
swift_newtype-ed typedefs of pointer types. We imported them in a way
that tried to present the value semantics of the pointee rather than
of the pointer. We then tried (sometimes incorrectly) to detect and
fix this up during SILGen.

Instead, model with the value semantics of the pointer itself. SILGen
can then be simplified to just pass swift_newtypes the same as any
other struct: directly for non-mutating and indirectly for mutating
(i.e. inout self). Tests added.
2017-06-22 13:14:55 -07:00
swift-ci
08a536f2d4 Merge remote-tracking branch 'origin/master' into master-next 2017-06-13 18:48:41 -07:00
Huon Wilson
b60aef8536 [ClangImporter] Correct curried method types for SE-110.
Method types are now required to be `(Self) -> (Args...) -> Return`, not
`Self -> (Args...) -> Return`.

See also https://github.com/apple/swift/pull/9454 .

Fixes rdar://problem/32588152 .
2017-06-13 17:53:21 -07:00
swift-ci
40337d7d98 Merge remote-tracking branch 'origin/master' into master-next 2017-05-31 09:28:34 -07:00