Commit Graph

25 Commits

Author SHA1 Message Date
Pavel Yaskevich
74a8ee177e [Diagnostics] Diagnose missing members via fixes
Try to fix constraint system in a way where member
reference is going to be defined in terms of its use,
which makes it seem like parameters match arguments
exactly. Such helps to produce solutions and diagnose
failures related to missing members precisely.

These changes would be further extended to diagnose use
of unavailable members and other structural member failures.

Resolves: rdar://problem/34583132
Resolves: rdar://problem/36989788
Resolved: rdar://problem/39586166
Resolves: rdar://problem/40537782
Resolves: rdar://problem/46211109
2019-01-09 17:29:49 -08:00
Michael Gottesman
40a09c9c21 Fixup tests for -assume-parsing-unqualified-ownership-sil => [ossa] transition. 2018-12-18 00:49:32 -08:00
Erik Eckstein
39bb14b094 change mangling prefix from $S to $s
This is the final ABI mangling prefix

rdar://problem/38471478
2018-09-19 13:55:11 -07:00
Jordan Rose
abaf05f1b4 [test] Update APINotes tests for Swift 3 removal
For the most part, this moves 3/4 tests to 4/5 tests. There are
some interesting changes here because API notes for 4 also apply
to 3 unless otherwise specified, and 4.2 is the next version after
4 rather than 5, but everything should still be correct and testing
useful stuff.
2018-07-12 15:44:10 -07:00
Mark Lacey
9385dbb3fb Fix exponential type checking of tuple literals.
This fixes two easy cases where we would go exponential in type
checking tuple literals.

Instead of generating a conversion to a single type variable (which
results in one large constraint system), we generate a conversion ot
the same type that appears in the initializer expression (which for
tuples is a tuple type, which naturally splits the constraint system).

I experimented with trying to generalize this further, but ran into
problems getting it working, so for now this will have to do.

Fixes rdar://problem/20233198.
2018-03-26 14:46:03 -07:00
Jordan Rose
38e2cfe1e2 Mangle imported declarations using their C names.
This makes them consistent no matter what shenanigans are pulled by
the importer, particularly NS_ENUM vs. NS_OPTIONS and NS_SWIFT_NAME.

The 'NSErrorDomain' API note /nearly/ works with this, but the
synthesized error struct is still mangled as a Swift declaration,
which means it's not rename-stable. See follow-up commits.

The main place where this still falls down is NS_STRING_ENUM: when
this is applied, a typedef is imported as a unique struct, but without
it it's just a typealias for the underlying type. There's also still a
problem with synthesized conformances, which have a module mangled
into the witness table symbol even though that symbol is linkonce_odr.

rdar://problem/31616162
2018-01-09 17:55:24 -08:00
Jordan Rose
18689fe223 [Mangling] Uniformly use "So" for imported decls.
...and repurpose "SC" for (C)lang-importer-synthesized decls, instead
of just decls that are C-like instead of ObjC-like. (See next commits.)
2018-01-09 17:55:23 -08:00
Erik Eckstein
cd3d50a5d9 ABI: Change the mangling prefix from _T0 to $S 2018-01-06 13:55:59 -08:00
Pavel Yaskevich
170ccbd36d [Mangling/ABI] NFC: Fix Frontend/APINotes/Index tests to reflect label mangling changes 2017-12-18 15:45:50 -08:00
Robert Widmann
71bf312a25 Migrate the rest of the tests to %empty-directory 2017-06-04 11:08:39 -07:00
Jordan Rose
4f26b0182e Update Swift-side tests for Clang providing an unversioned SwiftName. (#9414)
The behavior in versioned-objc.swift changes now that we've fixed
this, since we always prefer to use a type's Swift 4 name. A handful
of new tests have also been added to versioned.swift.
2017-05-15 10:19:16 -07:00
Jordan Rose
9a9d139320 [ClangImporter] Import Swift 3 and 4 names for enumerators. (#9523)
Also lays the groundwork for rdar://problem/16513537, which is about
being able to find an enum by its original top-level name so that we
can show a diagnostic for that. I'll file a public bug about that
later.

rdar://problem/31893305
2017-05-12 14:51:40 -07:00
Slava Pestov
d663ee94df ClangImporter: Fix bug where members of renamed types were dropped
When "Always import types under their Swift 4 name." was
introduced, we still import members under their Swift 3 names;
this means the member's DeclContext imports as a compatibility
alias.

However, we did not look through the compatibility alias when
mapping the member's Clang DeclContext to a Swift DeclContext,
and as a result, the member was dropped on the floor.

Fixes <rdar://problem/31911531>, <rdar://problem/32042522>,
and probably <rdar://problem/31976966>.
2017-05-11 01:37:57 -07:00
Doug Gregor
5934a86566 [Clang importer] Look through typealiases when importing members of swift_wrappers.
When a swift_wrapper'd type is renamed from Swift 3 -> 4, we create a
typealias for it. We need to look through that typealias when
deserializing members of that type, e.g., global variables of the
swift_wrapper'd type.
2017-05-04 16:41:01 -07:00
Jordan Rose
c8d3506e55 Revert "[Mangling] Uniformly use "So" for imported decls." (#9233)
This reverts commit 25985cb764. For now,
we're trying to avoid spurious non-structural changes to the mangling,
so that the /old/ mangling doesn't appear to change. That doesn't mean
no changes at all, but we can save this one for later.
2017-05-03 16:13:29 -07:00
Jordan Rose
dbc148bfb3 [ClangImporter] Tag compatibility aliases as such...
...so we can avoid showing an 'aka' for them...unless they are
themselves typealiases.
2017-04-26 13:07:03 -07:00
Jordan Rose
cb9b9ea734 [ClangImporter] Always import types under their Swift 4 name.
This means all cross-module references and all mangled names will
consistently use the Swift 4 name (the canonical type), no special
handling required.

The main thing we lose here is that the Swift 4 names of imported
types become usable in Swift 3 mode without any diagnostics, similar
to how most language features introduced in Swift 4 are available in
Swift 3 mode. It also implies that the Swift 4 name will show up in
demangled names.

rdar://problem/31616162
2017-04-26 13:07:03 -07:00
Jordan Rose
bd1920ba67 [ClangImporter] Fix versioned stubs for functions-as-members. (#8539)
That is, the stubs we generate when you rename a C global function
imported as a type member using the SwiftName API note. (See the
test case changes.) Previously we hit an assertion.

For good measure, also fix versioned stubs for types-as-members,
which were always added to their original context rather than the
new context.

rdar://problem/31435658
2017-04-04 15:20:30 -07:00
Jordan Rose
0328139a77 [ClangImporter] Don't crash on versioned import-as-member stubs. (#8269)
If a top-level declaration is imported as a member in Swift 4 but not
in Swift 3, it would still show up in the lookup table for the
containing type in Swift 3 mode. We would import it, and then try to
add the top-level declaration to the containing type.

I'm about to redo this anyway so that the versioned stub will show up
(the one for the Swift 4 name) but this is the narrow fix that avoids
the assertion failure we were seeing.

rdar://problem/31161489
2017-03-22 13:48:03 -07:00
Jordan Rose
c402030877 [ClangImporter] Give compatibility typealiases the correct version.
Unlike values, we can't import multiple copies of types under
different names and get good results. Instead, we make a typealias
that points back to the original type. Make sure this typealias is
flagged with whatever version is appropriate, rather than always using
"Swift 2".
2017-02-24 16:11:33 -08:00
Jordan Rose
79ed26f575 [ClangImporter] Use the correct name for replacement decls.
When a C declaration is marked unavailable with a replacement, we look
for the replacement to see how it would be imported into Swift. Make
sure we do that with respect to the active language version.
2017-02-24 16:11:33 -08:00
Jordan Rose
b9853c209e [ClangImporter] Fix marking of protocols with missing requirements.
This doesn't actually have any effect yet, but if we start importing
both Swift 3 and Swift 4 versions of protocol requirements and the
non-active one is unavailable, we might mistakenly mark the protocol
un-implementable even when the requirements that are needed are all
there. (Hopefully we would never make a protocol /less/ available in a
newer release, of course.) The test case is designed to catch that.
2017-02-24 16:11:33 -08:00
Jordan Rose
c9124d989d [ClangImporter] Import Swift 3 versions of top-level decls in Swift 4.
...and Swift 4 versions in Swift 3, and Swift 2 and "raw" versions in
both. This allows the compiler to produce sensible errors and fix-its
when someone uses the "wrong" name for an API. The diagnostics
certainly have room to improve, but at least the essentials are there.

Note that this commit only addresses /top-level/ decls, i.e. those
found by lookup into a module. We're still limited to producing all
members of a nominal type up front, so that'll require a slightly
different approach.

Part of rdar://problem/29170671
2017-02-24 14:01:10 -08:00
Michael Ilseman
12efcc9db6 [Version] Don't allow effective sub-versions, only major versions
Also offer a note when the major version is valid on its own.
2016-10-18 14:43:21 -07:00
Doug Gregor
c91064ba8e [Clang importer] Pass Swift major version to Clang's API notes.
Clang now accepts an option -fapinotes-swift-version=XX that describes
which Swift version to use when applying API notes to the Clang
AST. Pass this option down to Clang based on the Swift major version
number (e.g., 3 or 4), allowing API notes to introduce
Swift-version-specific behavior.

Fixes rdar://problem/28617631.
2016-10-04 14:23:03 -07:00