Commit Graph

26 Commits

Author SHA1 Message Date
Saleem Abdulrasool
6e62444840 test: use the swift_only_stable_abi feature instead of adhoc checks
Use the proper `swift_only_stable_abi` check to ensure that the tests do
not run on targets that do not support the pre-stable ABI.

Thanks to @slavapestov for pointing out that there was a better way!
2020-08-07 09:49:11 -07:00
Kuba Mracek
1bd425da67 [arm64e] Test changes to support arm64e 2020-02-27 16:10:48 -08:00
Slava Pestov
6363961e90 Split up a couple more tests into stable and pre-stable ABI deployment target versions 2019-05-21 17:30:13 -04:00
Slava Pestov
5d66bb810a Run stable ABI tests on all Apple platforms
A number of tests exercise features only available in Apple OSes that
shipped with Swift 5.0 in the OS; this includes the following versions:

- macOS 10.14.4
- iOS 12.2
- tvOS 12.2
- watchOS 5.2

Previously these tests were restricted to running on macOS only, with
an explicit -target x86_64-apple-macosx10.14.4. To get better test
coverage, add a new %target-stable-abi-triple substitution which
expands to a triple with the correct OS version on all Apple platforms.

On non-Apple platforms, this is the same as %target-variant-triple,
but for now any test that uses this exercises Apple platform features
anyway.

One caveat is that since iOS 12.2 does not have a 32-bit slice, we
have to skip any tests that use -target %target-stable-abi-triple
on this platform. A new swift_stable_abi feature flag can be tested
with 'REQUIRES: swift_stable_abi'. To get maximum test coverage,
I split off a 'stable_abi' version of a few tests that build with both
an old and new deployment target. This allows the old deployment
target case to still be tested on 32-bit iOS.
2019-05-16 17:02:06 -04:00
Slava Pestov
c954dfa6a9 Sema: Tweak test/decl/protocol/conforms/nscoding.swift a bit
Make sure we test on both an "old" and "new" deployment target.
2019-05-03 18:56:46 -04:00
kitasuke
543ddbceee Remove NSKeyedArchiver family support for decl attributes 2019-04-15 17:33:51 +09:00
Vinicius Vendramini
39d3963131 Fix broken tests
- Many tests got broken because of two things:
  - AST dump now outputs to stdout, but many tests expected stderr. This was a straightforward fix.
  - Many tests call swift with specific parameters; specifically, many call `swift frontend` directly. This makes them go through the compiler in unexpected ways, and specifically it makes them not have primary files, which breaks the new AST dump implementation. This commit adds the old implementation as a fallback for those cases, except it dumps to `stdout` to maintain some consistence.

Finally, the `/test/Driver/filelists.swift` failed for unknown reasons. It seems its output now had some lines out of order, and fixing the order made the test pass. However, as the reasons why it failed are unknown, this fix might not have been a good idea. Corrections are welcome.
2018-11-14 13:38:01 -02:00
Mark Rowe
62eb12b652 Include source ranges for decls in the AST dump. 2018-05-17 10:50:19 -07:00
Ben Langmuir
f20586b3d8 Revert "Include source ranges for statements, declarations, and parameter lists in the AST dump" 2018-05-17 09:53:05 -07:00
Mark Rowe
28af6959b8 Include source ranges for decls in the AST dump. 2018-05-09 11:15:35 -07:00
Erik Eckstein
2a7c9587ad NSArchive support: don't eagerly create class metadata for nested classes.
This is not required anymore to be able to unarchive such classes (before the first object of the class is instantiated).

rdar://problem/37568342
2018-02-16 15:36:52 -08:00
Jordan Rose
5c1967397b Update and re-enable the diagnostics for unstable runtime names.
This time, the warnings only fire when the class in question directly
conforms to NSCoding. This avoids warning on cases where the user has
subclassed something like, oh, UIViewController, and has no intention
of writing it to a persistent file.

This also removes the warning for generic classes that conform to
NSCoding, for simplicity's sake. That means
'@NSKeyedArchiverEncodeNonGenericSubclassesOnly' is also being
removed.

Actually archiving a class with an unstable mangled name is still
considered problematic, but the compiler shouldn't emit diagnostics
unless it can be sure they are relevant.

rdar://problem/32314195
2017-06-05 17:32:26 -07:00
Jordan Rose
f0aca936c7 Allow '@objc(RuntimeName)' on classes with generic ancestry.
This is accomplished by recognizing this specific situation and
replacing the 'objc' attribute with a hidden '_objcRuntimeName'
attribute. This /only/ applies to classes that are themselves
non-generic (including any enclosing generic context) but that have
generic ancestry, and thus cannot be exposed directly to Objective-C.

This commit also eliminates '@NSKeyedArchiverClassName'. It was
decided that the distinction between '@NSKeyedArchiverClassName' and
'@objc' was too subtle to be worth explaining to developers, and that
any case where you'd use '@NSKeyedArchiverClassName' was already a
place where the ObjC name wasn't visible at compile time.

This commit does not update diagnostics to reflect this change; we're
going to change them anyway.

rdar://problem/32414557
2017-06-05 17:32:25 -07:00
Jordan Rose
4a46d47a05 Disable diagnostics about problem NSCoding-conforming classes for now. (#9808)
Adoption so far shows that the criteria we set up here are too broad.
This is particularly problematic for subclasses of NS/UIView and the
like that might never be encoded at all.

rdar://problem/32306355
2017-05-20 14:26:30 -07:00
Doug Gregor
7955aa13e6 Rename @NSKeyedArchive* attributes.
@NSKeyedArchiveLegacy -> @NSKeyedArchiverClassName
@NSKeyedArchiveSubclassesOnly -> @NSKeyedArchiverEncodeNonGenericSubclassesOnly

Fixes rdar://problem/32178796.
2017-05-15 11:02:31 -07:00
Doug Gregor
23bc3223ce Ban the use of @_staticInitializeObjCMetadata; it's an implementation detail. 2017-05-10 14:58:42 -07:00
Doug Gregor
6ceb47bd6c [Type checker] Provide actual ObjC runtime name in @NSKeyedArchiveLegacy Fix-Its. 2017-05-10 14:47:11 -07:00
Doug Gregor
c805da7291 Improve/clarify the inference of @_staticInitializeObjCMetadata.
Infer @_staticInitializeObjCMetadata in those cases where we need a
static initializer to make an NSCoding-conforming class visible to the
Objective-C runtime. This does *not* include classes with one of the
@NSKeyedArchive attributes:

* @NSKeyedArchiveLegacy implies that we'll register the class
  directly, with the necessary side effect of initialize Objective-C
  metadata.
* @NSKeyedArchiveSubclassesOnly promises not to archive the class
  directly anyway.
2017-05-02 23:30:28 -07:00
Doug Gregor
bf7a8612e6 Add @NSKeyedArchiveSubclassesOnly to suppress NSCoding unstable name diags.
Introduce the @NSKeyedArchiveSubclassesOnly attribute, which can be
placed on a class that conforms to NSCoding to suppress the
unstable-name diagnostics by promising to only archive
subclasses---not this class directly.
2017-05-02 23:30:28 -07:00
Doug Gregor
9b65c85b44 Make diagnostics for NSCoding classes with unstable names more discouraging.
The diagnostic regarding NSCoding classes with unstable names can be
suppressed by adding @objc (the preferred solution for new code) or
@NSKeyedArchiveLegacy (for existing archives). Provide those as
Fix-Its, in that order.

(Thanks, Jordan!)
2017-05-02 23:30:28 -07:00
Doug Gregor
e6c6470f1e Properly warn about local classes that conform to NSCoding. 2017-05-02 23:30:28 -07:00
Doug Gregor
bafa99cd6e Add the @_staticInitializeObjCMetadata attribute.
Currently inactive, this attribute indicates that a static initializer should be emitted to register the Objective-C metadata when the image is loaded, rather than on first use of the Objective-C metadata. Infer this attribute for NSCoding classes that won’t have static Objective-C metadata or have an @NSKeyedArchiveLegacy attributed.
2017-05-02 23:30:27 -07:00
Doug Gregor
b912c7f7e1 Diagnose attempts to apply @NSKeyedArchiveLegacy to a generic class.
Generic classes don't have a single name to register, so disallow
@NSKeyedArchiveLegacy.
2017-05-02 22:38:32 -07:00
Doug Gregor
60f5a6529e Add Fix-Its suggesting @NSKeyedArchiveLegacy when it can be used. 2017-05-02 22:38:32 -07:00
Doug Gregor
aaf7933a6d Add the @NSKeyedArchiveLegacy attribute.
This attribute allows one to provide the "legacy" name of a class for
the purposes of archival (via NSCoding). At the moment, it is only
useful for suppressing the warnings/errors about classes with unstable
archiving names.
2017-05-02 22:38:32 -07:00
Doug Gregor
28560ec005 [Type checker] Warn about NSCoding-conforming classes with unstable mangled names.
The name mangling changed from Swift 3 to Swift 4, and may get slight
tweaks as we lock down ABI stability. Identify and warn about (in
Swift 3) or error about (in Swift 4) the cases where we don't have
obviously-stable name mangling, e.g.,

* private/fileprivate classes (whose mangled names involve the file name)
* nested classes (whose mangled names depend on their enclosing type)
* generic classes (whose mangled names involve the type arguments)
2017-05-02 21:45:18 -07:00