Commit Graph

514 Commits

Author SHA1 Message Date
Slava Pestov
52fbe642ed Fix REQUIRES lines on class stubs tests
We use the just-built clang without any -target or -sdk flags. Keep things
simple and limit the test to macOS for now.

Fixes <rdar://problem/50586614>.
2019-05-08 22:22:27 -04:00
Nathan Hawes
af3fbc52b3 Revert "Add tests for weak-linked class stubs" 2019-05-08 10:55:00 -07:00
Slava Pestov
1b4f171fd4 PrintAsObjC: Add support for @_weakLinked attribute
Clang already takes availability into account when checking if a
declaration is weak imported, so this is only needed for testing.
2019-05-07 16:32:01 -04:00
Slava Pestov
2ad15fec3d PrintAsObjC: Add support for classes with resilient ancestry
Without -enable-resilient-objc-class-stubs, don't print classes with
resilient ancestry at all, since they're not actually visible to
Clang and referencing one will not actually work.

When the flag is specified, such classes do appear in the generated
header with the new objc_class_stub Clang attribute.
2019-03-26 18:58:13 -04:00
Michael Gottesman
f854547c55 [ownership] Enable ownership verification by default.
I also removed the -verify-sil-ownership flag in favor of a disable flag
-disable-sil-ownership-verifier. I used this on only two tests that still need
work to get them to pass with ownership, but whose problems are well understood,
small corner cases. I am going to fix them in follow on commits. I detail them
below:

1. SILOptimizer/definite_init_inout_super_init.swift. This is a test case where
DI is supposed to error. The only problem is that we crash before we error since
the code emitting by SILGen to trigger this error does not pass ownership
invariants. I have spoken with JoeG about this and he suggested that I fix this
earlier in the compiler. Since we do not run the ownership verifier without
asserts enabled, this should not affect compiler users. Given that it has
triggered DI errors previously I think it is safe to disable ownership here.

2. PrintAsObjC/extensions.swift. In this case, the signature generated by type
lowering for one of the thunks here uses an unsafe +0 return value instead of
doing an autorelease return. The ownership checker rightly flags this leak. This
is going to require either an AST level change or a change to TypeLowering. I
think it is safe to turn this off since it is such a corner case that it was
found by a test that has nothing to do with it.

rdar://43398898
2019-03-25 00:11:52 -07:00
Michael Gottesman
0dfaa19f9f [ownership] Rename enable-sil-ownership => verify-sil-ownership.
I have been meaning to do this change for a minute, but kept on putting it off.
This describes what is actually happening and is a better name for the option.
2019-03-18 01:31:44 -07:00
Slava Pestov
1159af50d9 Rename -enable-resilience to -enable-library-evolution and make it a driver flag
Fixes <rdar://problem/47679085>.
2019-03-14 22:24:26 -04:00
Michael Gottesman
15c03b7b0a Fix potential use-after-free in emitFuncToBlock exposed by enabling ownership verification on PrintAsObjC/blocks.swift.
If the block is guaranteed, we need to be sure to copy here. This can happen for
instance with arguments (where this was caught). I added a SILGen test that
exposes this failure since this is not an actual bug in PrintAsObjC.
2019-03-11 14:23:44 -07:00
Suyash Srijan
c3e074700b [test] add a dynamic self test file 2019-01-23 10:57:56 +00:00
Suyash Srijan
34c46d916a [test] add a dynamic self test file 2019-01-22 23:44:36 +00:00
Pitiphong Phongpattranont
08204efd5b Losen the test for the initizlier in the Subclass since it’s unavailable on some platforms and won’t be printed 2018-12-18 23:56:10 +07:00
Pitiphong Phongpattranont
7a9bca939e Added: Overloaded initializer test cases 2018-12-14 15:00:22 +07:00
Pitiphong Phongpattranont
25d74fefe3 Remove duplicated test case 2018-12-13 12:16:58 +07:00
Pitiphong Phongpattranont
7b76115788 Remove the parent/sub type lookup logic 2018-12-13 12:16:58 +07:00
Pitiphong Phongpattranont
4f88e31d63 Add more test case for the case of renamed methods have a parameter which is a superclass of itself 2018-12-13 12:16:57 +07:00
Pitiphong Phongpattranont
c23230c1e7 Revert part of the Follow the base type to follow only in its own superclasses 2018-12-13 12:16:57 +07:00
Pitiphong Phongpattranont
293d3d1033 Find the renamed overloading method by looking at the type of method parameters 2018-12-13 12:16:57 +07:00
Pitiphong Phongpattranont
a505202e6d Follow the base type if the renamed attribute is point to another type 2018-12-13 12:16:57 +07:00
Brent Royal-Gordon
746fb2864e [PrintAsObjC] Disable -Watimport-in-framework-header warning in generated headers (#20086)
This is a new warning in clang when you use @import in a framework header. That’s often a mistake, but it isn’t in our generated -Swift.h headers. If we’re building with a clang that supports this warning, we’ll now emit a pragma to disable it.
2018-11-02 19:02:17 -07:00
Jordan Rose
e34a6a1105 [PrintAsObjC] Look through "compatibility" typealiases (#20027)
These handle imported types that have been renamed in a /later/ Swift
version than the one being used; for consistency when deserializing
from a swiftmodule, the latest name is always used. This is important
because it might mean we can avoid importing the framework that a name
comes from; a forward declaration might be sufficient if it's an ObjC
class or protocol.

rdar://problem/45491607
2018-10-25 08:26:17 -07:00
Harlan
665db876ea [InterfaceGen] Print bodies of inlinable functions in textual interfaces (#19224)
* Introduce stored inlinable function bodies

* Remove serialization changes

* [InterfaceGen] Print inlinable function bodies

* Clean up a little bit and add test

* Undo changes to InlinableText

* Add serialization and deserialization for inlinable body text

* Allow parser to parse accessor bodies in interfaces

* Fix some tests

* Fix remaining tests

* Add tests for usableFromInline decls

* Add comments

* Clean up function body printing throughout

* Add tests for subscripts

* Remove comment about subscript inlinable text

* Address some comments

* Handle lack of @objc on Linux
2018-09-14 10:23:15 -07:00
Jordan Rose
0bcf355bc8 [PrintAsObjC] Use 'unsafe_unretained' to print 'unowned', not 'assign'
The ObjC generator previously preserved a subtle difference between
'unowned' and 'unowned(unsafe)' / Unmanaged by printing the former as
'assign' and the latter as 'unsafe_unretained'. Upstream Clang,
however, has gotten a new warning to discourage the use of 'assign'
with reference-countable types at all. Since it was always a subtle
distinction, just go with the new convention and print
'unsafe_unretained' for 'unowned' properties as well.

rdar://problem/44290715
2018-09-10 14:32:32 -07:00
Jordan Rose
ad7bbdfbd6 [PrintAsObjC] Handle generic typealiases (#18941)
(either explicitly generic ones, or those embedded in generic contexts)

Previously we tried to look at the typealias decl's underlying type,
but that might have generic parameters in it. Oops. Use the
NameAliasType's desugared type instead.

Also, drop half-baked support for `@objc typealias`, which isn't
supported. (It's not an unreasonable feature, but the bits that were
there weren't implemented correctly.)

rdar://problem/43347303
2018-08-24 08:57:22 -07:00
Jordan Rose
a3942059bf Make sure to allow '@objc' on enum elements
Previously they were ignored by the checking of '@objc', but in the
refactoring to a request the attribute started getting marked as
invalid without a diagnostic.

rdar://problem/43401047
2018-08-22 15:29:27 -07:00
Arnold Schwaighofer
b077abb43e Codesign test/PrintAsObjC 2018-08-10 06:58:40 -07:00
Doug Gregor
f39fe1a755 [Tests] Put NSObject Equatable/Hashable back in the ObjectiveC module.
Technically, these operations belong in the ObjectiveC module, where NSObject
is defined. Keep them there. However, we need to build the mock ObjectiveC
overlay with `-disable-objc-attr-requires-foundation-module` now.
2018-08-01 09:25:28 -07:00
Pitiphong Phongpattranont
0a29962d51 Added: Test cases for the platform deprecation, unavailable and platform unavailable PrintAsObjC 2018-07-27 00:13:37 +07:00
Pitiphong Phongpattranont
b3a0a5ecb9 Add the deprecation messages in the renamed-to Objective-C name test cases 2018-07-25 23:12:56 +07:00
Pitiphong Phongpattranont
65dc151954 Added: New test file for the renaming to the Objective-C functions 2018-07-25 22:59:38 +07:00
Pitiphong Phongpattranont
1cdbe33892 Added: renaming to a method that does not have a custom Objective-C name test case 2018-07-24 14:14:36 +07:00
Pitiphong Phongpattranont
c71a34019f Added: Test case for the renamed to one of the overload methods which have a differnce ObjC names case 2018-07-24 14:03:11 +07:00
Pitiphong Phongpattranont
f99027db3b Added: Renames of deprecated methods to properties or properties to methods and vice versa 2018-07-24 10:58:29 +07:00
Pitiphong Phongpattranont
18d71d5424 Added: renaming to a method that is not exposed to Objective-C 2018-07-24 10:50:03 +07:00
Pitiphong Phongpattranont
2067935b00 Use the CHECK-SAME where appropriate and update some ObjC names 2018-07-24 08:56:29 +07:00
Pitiphong Phongpattranont
db0eafe93f Added: Test case for the case where the renamed method is class method not instance method and vice versa 2018-07-22 00:08:56 +07:00
Pitiphong Phongpattranont
59b39bce02 Added: Test case for the case where the renamed method is class method not instance method 2018-07-21 22:48:50 +07:00
Pitiphong Phongpattranont
8837ca0dd2 Added: Test case for the renamed to one of the initializer case 2018-07-21 22:40:48 +07:00
Pitiphong Phongpattranont
b6cd6bf24e Added: Test case for the renamed to one of the overload methods case 2018-07-21 22:14:21 +07:00
Pitiphong Phongpattranont
dc3b7804bb Added: Test for the class and protocol cases for the PrintAsObjC availability 2018-07-21 17:40:41 +07:00
Pitiphong Phongpattranont
12d0024188 Reserve the white spaces 2018-07-21 17:40:41 +07:00
Pitiphong Phongpattranont
5b247c78b3 Added: More test cases for the PrintAsObjC availability 2018-07-21 17:40:41 +07:00
Pitiphong Phongpattranont
d0801890ec Use the custom @objc name in the Availablity attributes when generates the ObjC header 2018-07-21 17:40:41 +07:00
Jordan Rose
6ecfe7a34d Merge pull request #17917 from jrose-apple/t3sts
[test] Update APINotes, Serialization, and PrintAsObjC tests for Swift 3 removal
2018-07-13 10:24:42 -07:00
Jordan Rose
480e02b0cf [test] Update PrintAsObjC test (just one) for Swift 3 removal
Use Swift 4 as the "old" version instead of Swift 3.
2018-07-12 15:44:10 -07:00
Jordan Rose
c8b61f990b Merge pull request #17615 from maniramezan/master
[SR-2250] Include Foundation framework instead of minimal NSObject.h
2018-07-11 19:14:49 -07:00
Mani Ramezan
bee45aecb0 Use relative path to point to frameworks folder 2018-07-11 19:15:17 -04:00
Mani Ramezan
9df5adb150 Move mock Foundation framework into clang shared folder 2018-07-11 02:32:59 -04:00
Mani Ramezan
3c824ddaa5 Include Foundation framework instead of minimal NSObject.h
This change is for preventing scenarios like https://bugs.swift.org/projects/SR/issues/SR-2250
2018-06-28 19:27:24 -04:00
Slava Pestov
5964c00091 Migrate PrintAsObjC tests to Swift 4
I didn't migrate test/PrintAsObjC/versioned.swift, because it
explicitly checks the Swift 3 projection of some APIs.
2018-06-26 16:57:04 -07:00
Slava Pestov
5d2752f7d2 Run tests with -swift-version 4 by default
Some test now fail, so add an explicit -swift-version 3.
2018-06-19 23:24:19 -07:00