Commit Graph

384 Commits

Author SHA1 Message Date
Doug Gregor
091f987e28 Revert "[PrintAsObjC] Test that we don't leak extended implementationOnly types"
This reverts commit 4e8867e021.
2020-04-13 13:58:07 -07:00
Doug Gregor
bf99f31d75 Revert "PrintAsObjc: expand module @imports to header #imports if modules are not supported"
This reverts commit a2534fa234.
2020-03-27 21:02:44 -07:00
Doug Gregor
ab97d50b0f Revert "PrintAsObjC: use header path relative to usr/include when importing non-framework headers"
This reverts commit ebe0a45583.
2020-03-27 21:00:51 -07:00
Xi Ge
ebe0a45583 PrintAsObjC: use header path relative to usr/include when importing non-framework headers
We could assume usr/include belongs to header search paths. If a header
is located in a deeper location inside this directory, we need to print
the additional path components.

rdar://60857172
2020-03-25 23:30:28 -07:00
Xi Ge
df0493c288 PrintAsObjC: allow users to specify bridging header relative path for printing
Compatibility header may #import bridging header if specified with -import-underlying-module.
How these two headers are relative to each other is subject to project setting. To accommodate
this, we should allow users to specify bridging header directory for header generating purposes.

rdar://59110975
2020-03-11 17:09:53 -07:00
Alexis Laferrière
4e8867e021 [PrintAsObjC] Test that we don't leak extended implementationOnly types 2020-03-09 14:11:06 -07:00
Xi Ge
a2534fa234 PrintAsObjc: expand module @imports to header #imports if modules are not supported
rdar://58284119
2020-03-03 11:54:14 -08:00
Xi Ge
fa659ede76 [PrintAsObjc] add macro guard against potential recursive definitions 2020-02-05 12:37:01 -08:00
Slava Pestov
eef1428a2b PrintAsObjC: Support for blocks with __owned parameters 2019-12-02 18:41:27 -05:00
Jordan Rose
bb83722113 Merge pull request #5252 from JGiola/SR-2405
SR-2405 Print IB_DESIGNABLE and IBInspectable in the generated ObjC header
2019-10-21 09:44:09 -07:00
Jacopo Andrea Giola
5902a477d4 Print IB_DESIGNABLE and IBInspectable in the generated ObjC header
Add support for @IBDesignable and @IBInspectable attribute to the
generated ObjC headers
2019-10-16 20:18:50 +02:00
Brent Royal-Gordon
f1e8ad9348 Reenable PrintAsObjC/extensions.swift
This test was disabled to work around a bug in the ObjC generics implementation in clang. That bug was corrected by https://reviews.llvm.org/D66696, so we should now be able to turn the Swift test back on.
2019-10-16 10:10:01 -07:00
Varun Gandhi
04ce7bf779 Merge pull request #27557 from varungandhi-apple/vg-fix-selector-names
Use the accessor names as written in Objective-C.
2019-10-08 10:08:13 -07:00
Varun Gandhi
3b9dbd57c4 [AST] Get the ObjC accessor name, not the one parsed from Swift.
Fixes rdar://problem/55519276.
2019-10-06 06:57:50 -07:00
Varun Gandhi
d4bafdf9fa Add minimal test case for rdar://problem/55519276.
We are dropping the getter and setter names we get from Objective-C.
This leads to a runtime crash. Oops.
2019-10-06 06:57:50 -07:00
Brent Royal-Gordon
f696ebdae5 XFAIL PrintAsObjC/extensions.swift
rdar://problem/54414986
2019-08-16 17:41:00 -07:00
Jordan Rose
406a9d9cf1 Add the notion of @_implementationOnly overrides
When an @_implementationOnly import includes Objective-C categories
for existing types, it's useful to be able to override the members
provided in those categories without exposing them to clients of the
framework being built. Allow this as long as the overriding
declaration is marked as @_implementationOnly itself, with an
additional check that the type of the declaration does not change.
(Normally overrides are allowed to change in covariant ways.)

Part of rdar://50827914
2019-06-17 17:48:40 -07:00
mishal_shah
1e38fc3030 Update master to build with Xcode 11 beta, macOS 10.15, iOS 13, tvOS 13, and watchOS 6 SDKs 2019-06-03 22:50:02 -07:00
Ben Cohen
e9d4687e31 De-underscore @frozen, apply it to structs (#24185)
* De-underscore @frozen for enums

* Add @frozen for structs, deprecate @_fixed_layout for them

* Switch usage from _fixed_layout to frozen
2019-05-30 17:55:37 -07: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
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