Commit Graph

2609 Commits

Author SHA1 Message Date
Ted Kremenek
6eb16f6550 Revert "Clang importer: Global vars imported as static member properties are final." (#2155) 2016-04-12 08:24:29 -07:00
Joe Groff
08a4267f66 Clang importer: Global vars imported as static member properties are final. 2016-04-11 18:02:41 -07:00
Doug Gregor
9e2c68866c [Clang importer] Be robust against invalid Objective-C categories.
The Clang importer was crashing when encountering an Objective-C
category for an unknown class. Fixes rdar://problem/24244116.
2016-04-05 13:55:24 -07:00
Doug Gregor
398d216eca [Clang importer] Always pass an effective context to importDeclContextOf.
Some of the callers to importDeclContextOf could and should have
passed an effective context, but didn't, so (e.g.) an enum defined in
C couldn't be mapped to a nested type in Swift. Eliminate the
single-argument importDeclContextOf honeypot so we remember to pass
down the effective Clang context. Fixes rdar://problem/25502497.
2016-04-04 15:18:37 -07:00
practicalswift
abfecfde17 [gardening] if ([space]…[space]) → if (…), for(…) → for (…), while(…) → while (…), [[space]x, y[space]] → [x, y] 2016-04-04 16:22:11 +02:00
Jordan Rose
50e3b33739 [ClangImporter] Implement importing of ObjC class properties.
For the most part this was just "check isInstanceProperty"; the one feature not yet implemented
is the emission of ObjC metadata for class properties.

rdar://problem/16830785
2016-03-31 14:27:56 -07:00
Michael Ilseman
4e4c511cf0 [Import as error] Error on non-prototyped function declarations 2016-03-28 15:41:48 -07:00
Jordan Rose
639e437ab5 Merge pull request #1820 from jrose-apple/specialization-crash
[ClangImporter] Correctly set up inherited protocol conformances
2016-03-28 13:49:33 -07:00
Joe Groff
f443fb105c Use isGenericContext instead of getGenericParamsOfContext where possible. 2016-03-28 09:50:30 -07:00
Chris Willmore
3bcb169f0b Import lightweight Objective-C generics as Swift generic type
parameters.
2016-03-28 09:50:30 -07:00
Michael Ilseman
b01caa01c6 Merge remote-tracking branch 'origin/master' into import-as-member 2016-03-25 15:47:47 -07:00
Chris Lattner
668d224b62 Fix <rdar://problem/25168818> Don't import None members in NS_OPTIONS types
When importing members of an NS_OPTIONS (aka an option set), mark imported
members that have a value of 0 with an unavailable error.  This produces an
experience like this:

  x = NSRuncingOptions.none // expected-error {{'none' is unavailable: use [] to construct an empty option set}}

This is important to do, because option set members with a value of zero
do not act like members of the option set.  For example, they always fail a
"contains" check.
2016-03-25 13:57:18 -07:00
Michael Ilseman
8759905351 Merge remote-tracking branch 'origin' into import-as-member 2016-03-24 11:37:36 -07:00
Jordan Rose
1c5dd6001e [ClangImporter] Correctly set up inherited protocol conformances.
Previously we just left them out, and then bits of the SIL optimizer
would just crash when they asked about them.

rdar://problem/24547884
2016-03-24 10:33:40 -07:00
Slava Pestov
98c9a9c4f4 ClangImporter: Mark generated union accessors as transparent
This ensures their bodies are fragile in SIL. While they can
be synthesized again, this change will avoid tripping up the
SIL verifier after some upcoming changes.

Part of https://bugs.swift.org/browse/SR-267.
2016-03-24 00:50:39 -07:00
Michael Ilseman
47e73ad4f1 Merge branch 'master' of github.com:apple/swift into import-as-member 2016-03-23 17:01:47 -07:00
Michael Ilseman
7867533f2c Merge commit 'b894798e461077b30a3aa4afe89639f312f44858' into import-as-member 2016-03-23 15:40:04 -07:00
Michael Ilseman
d7581d1b36 Merge commit 'a31edf53d0580efe47f4e9ef89dccc4429c056e8' into import-as-member 2016-03-23 13:05:57 -07:00
Doug Gregor
593932741c Remove historical flags -enable-omit-needless-words/-enable-infer-default-arguments/-enable-swift-name-lookup-tables.
NFC; all of these options are always-on now and we no longer have a
way to turn them off.
2016-03-22 17:04:19 -07:00
Michael Ilseman
a1dabba674 [Clang importer] Note for where import errors are failing 2016-03-21 13:17:02 -07:00
Joe Groff
f42e579040 Change SILGen to use ImportAsMemberStatus populated by ClangImporter. 2016-03-17 17:09:41 -07:00
Michael Ilseman
bbde50e2a2 [Import as member] Protocols: generic signature and interface type
Computes the generic signature correctly for protocol extensions. Sets
the correct function and interface type when forming the imported
protocol member. This makes import-as-protocol-member work and fixes
the disappearing return value issue in protocols.
2016-03-17 13:32:06 -07:00
Michael Ilseman
875920b540 [Import as member] Also encode when imported as a static member in the AST 2016-03-17 11:16:20 -07:00
Slava Pestov
552a6ad1b7 Sema: Remove some dead code for "delayed members", NFC
This was added at some point to make 'import Foundation' faster in the REPL.
What we really care about though is not delaying synthesis of the rawValue
accessors (those are synthesized on demand anyway), but delaying the
conformance check to RawRepresentable.
2016-03-16 18:35:31 -07:00
Michael Ilseman
09c98f7be8 [Import as member] Permit instance members on protocols
When the identified decl context gets imported as a protocol, reject
init and statics with an error. Support instance members.
2016-03-16 14:33:45 -07:00
Michael Ilseman
332959df8e [Import as member] Store selfIndex in the AST 2016-03-15 13:18:59 -07:00
Michael Ilseman
c8e2422838 [Clang importer] Extract CFPointeeInfo into separate file
Moves CFPointeeInfo into CFTypeInfo.h/cpp, so that other parts of the
importer can re-use the logic for reasoning about CF types. This will
be needed by the import as member inference system to reason about
effective Clang contexts.
2016-03-10 17:30:29 -08:00
Michael Ilseman
919b973edc [Import as member] Import as implicit final.
Mark the inferred final attribute as implicit, as we care about
bringing in the right semantics, but don't need to print back that
fact.
2016-03-10 12:55:50 -08:00
Michael Ilseman
3c690d422d [Import as method] Create an empty tuple first parameter
For function that we are importing as init, if there's dangling words
after the "Create" or "Make", we move them onto the first argument
label. This introduces the creation of an empty tuple parameter when
that init has no arguments.
2016-03-09 15:20:04 -08:00
Max Moiseev
1fae0d1325 Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-03-08 12:48:48 -08:00
Chris Lattner
fe9fe47b7e Implement support for generic typealiases. 2016-03-07 22:20:16 -08:00
Doug Gregor
09a0e6cc05 [Clang importer] Test minimal SILGen for global variables imported as static properties. 2016-03-07 20:57:18 -08:00
Michael Ilseman
73f7fd2eb6 [Clang importer] Infer get-only properties and static properties.
Expands support for inference of computed properties, whether instance
or static, to include get-only. Adds test cases for both inference and
manual annotation for static computed properties.
2016-03-07 16:51:34 -08:00
Michael Ilseman
23c818ed57 [Clang importer] Support static methods in swift_name 2016-03-07 15:58:01 -08:00
Doug Gregor
c40b45eb8c [Clang importer] Factor out and tidy up global-as-initializer import. 2016-03-06 21:57:37 -08:00
Doug Gregor
47b2be3138 [Clang importer] Import a getter or getter/setter pair as a property.
When a global function is determined to be a lone getter or a
getter/setter pair, import it as a property. Handle global, instance,
and static properties.

As part of this, generalize importAsMethod to also handle static
methods and map pointer-to-non-const arguments to 'mutating' methods.
2016-03-06 21:25:43 -08:00
Doug Gregor
d88f546f0a [Clang importer / Interface printing] Print extensions in the appropriate submodule.
When printing the interface for a (sub)module, make sure that we only
print those extensions that were created to hold that submodule's
globals that were imported as members.
2016-03-04 17:21:13 -08:00
Michael Ilseman
e452b38119 [Clang Importer] Import as methods
Print module functionality hooked up to import global functions a
methods, if dictated by the swift_name attribute. Test case included.

No SILGen support yet.
2016-03-03 21:58:57 -08:00
Michael Ilseman
98e1d2d1ae [Clang Importer] cleanup import-as-init code
NFC
2016-03-03 18:13:53 -08:00
Doug Gregor
08c8155d6c [Clang importer] Eliminate importGlobalsAsMembers. NFC 2016-03-03 17:25:58 -08:00
Doug Gregor
42f0356aec [Clang importer] Wire up extensions for globals-as-members.
Wire up the extensions created when importing globals-as-members via
the same mechanisms we use for Objective-C categories, e.g.,
implementing loadAllExtensions() to find the extensions and lazily
loading their members via the member loader. Addresses most of my
comments on the way extensions were wired in.

Extend our testing for importing globals as members to two different
submodules, so we can see the separation of extensions.

As part of this, fold getOrCreateExtension into importDeclContextOf.
2016-03-03 17:22:47 -08:00
Michael Ilseman
6815d3593b [Clang Importer] import as initializer
This adds initial functionality to import as initializer declarations
that have been swift_name declared to be inits.

SILGen support is still lacking for these inits.
2016-03-03 16:25:32 -08:00
Max Moiseev
cf4bafe9e3 Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-03-03 13:22:03 -08:00
Michael Ilseman
e32353ec03 [Clang Importer] getOrCreateExtensionPoint for import as member
When importing as a member, we want a single unique extension
declaration per type per Clang submodule. This adds the mapping,
switches import-as-member VarDecl importing to use it, and forces the
created extensions to show up.
2016-03-02 23:30:17 -08:00
Michael Ilseman
c247bbf5b6 [Clang Importer] Import as member: bare bones variables.
Adds tentative and very basic functionality for importing global
variables as members of structs and classes. Test case added
2016-03-02 22:19:37 -08:00
Doug Gregor
3ffbe020d7 [Clang importer] Handle name mapping for "getter:" and "setter:" in swift_name.
The swift_name string format now supports "getter:" and "setter:"
prefixes to indicate that a function is the getter or setter of a
Swift-synthesized property. Start parsing these DeclNames and make
sure they're reflected in the Swift name lookup tables.

[Clang update required]
2016-03-01 15:33:21 -08:00
Doug Gregor
7265328e07 [Clang importer] Generalize name lookup tables for globals-as-members.
A swift_name attribute on a global declaration can specify a dotted
name (e.g., SomeStruct.member) to map that global into a member of the
(Swift-)named type. Handle this mapping in DeclName parsing, plumb it
through importFullName, and cope with it in the Swift name lookup
tables (tested via the dump) and importing into a Swift DeclContext
(as-yet-untested). Part of SE-0033.
2016-03-01 15:33:20 -08:00
Max Moiseev
859db53d87 Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-03-01 12:56:26 -08:00
Doug Gregor
940a65a994 [Clang importer] Make the "effective context" a core part of ImportedName.
Previously, the "effective context" parameter to importFullName was
used only during the construction of Swift name lookup tables, so we
can associate each declaration with a context. Expand the role of
"effective context" so it is always a part of ImportedName and is also
used by importDecl when actually importing the enum declaration.

This is partially a cleanup, and partially staging for SE-0033, which
will require this functionality more broadly.
2016-02-29 15:32:34 -08:00
Max Moiseev
a49dab6bf8 Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-02-29 12:08:52 -08:00