Commit Graph

514 Commits

Author SHA1 Message Date
Allan Shortlidge
e5c6bb649c Remove support for Swift 3 @objc inference.
Obsolete the `-enable-swift3-objc-inference` option and related options by
removing support for inferring `@objc` attributes using Swift 3 rules.
Automated migration from Swift 3 has not been supported by the compiler for
many years.
2024-01-11 15:40:04 -08:00
Becca Royal-Gordon
8651af4325 Make @objcImpl work with @_cdecl
No real diagnostics yet, but we’re emitting mostly correct code.
2023-12-13 11:09:49 -08:00
Max Ovtsin
b0105e112d Introduce -application-extension-library (#63769)
The current implementation of `-application-extension` has a problem that affects the generation of ObjC headers for regular Swift modules.

The primary purpose of `-application-extension` is to prevent the use of unavailable APIs in app extensions. However, it has an impact on the generation of -Swift.h headers and exposes Swift's internal declarations to ObjC. This behavior is appropriate for mixed modules that are not consumed externally, such as app extensions, but it fails to address the situation when a module is not an extension itself but is consumed by the extension (c90cd11).

To resolve this issue while maintaining the desired behavior, we can introduce a new flag for this particular use-case.
2023-11-03 08:24:19 -07:00
Karl Wagner
ab4f80ed95 [SE-0404] Allow protocols to be nested in non-generic contexts 2023-10-06 21:04:03 +02:00
Michael Spencer
b2640e15e4 [test] Rename all module.map files to module.modulemap
`module.map` as a module map name has been discouraged since 2014, and
Clang will soon warn on its usage. This patch renames all instances of
`module.map` in the Swift tests to `module.modulemap` in preparation
for this change to Clang.

rdar://106123303
2023-08-21 15:58:59 -07:00
Daniel Rodríguez Troitiño
8f0382c109 [test] Replace swift_obj_root for alternates that work in LLVM unified builds (#66167)
In LLVM unified builds `%swift_obj_root` points to `<LLVM build dir>/tools/swift`,
and folders like `bin`, `lib` and `share` are not under `swift_obj_root`, which
makes some tests fail.

For the cases in which `%swift_obj_root/lib` was used, replace it by
using `%swift-lib-dir` instead. Replicate `%swift-lib-dir` to create
`%swift-bin-dir` and `%swift-share-dir`, and use those instead of
`%swift_obj_root/bin` and `%swift_obj_root/share`.

This alternates work both in Swift build-script builds and also in LLVM
unified builds.
2023-05-26 08:39:31 -07:00
Ethan Smith
d9dcf06b64 Desugar ElabroatedType in isNSUInteger if present.
Re-enable PrintAsObjC/availability-real-sdk and PrintAsObjC/override, they are now passing.
2023-05-18 15:53:47 -07:00
Steven Wu
16e4cfae76 [ObjcHeader] Fix objc header generation when pch is explicited passed
When swift-frontend is explicitly passed the pch file as bridging header
on command-line through `-import-objc-header`, it needs to print the
original source file name if needed to the generated objc header.

rdar://109411245
2023-05-17 14:15:55 -07:00
Alex Lorenz
f4f6f7a408 [interop][SwiftToCxx] avoid importing C++ stdlib in C++ section of generated header inside of 'pragma clang attribute' block 2023-05-04 17:01:39 -07:00
QuietMisdreavus
c63d899b0f add test to ensure consistent compatibility macro definitions (#64086)
rdar://106087804
2023-04-26 10:26:02 -06:00
QuietMisdreavus
8981535283 add missing symbols to compatibility-symbols (#64510)
rdar://104389344
2023-04-03 11:50:33 -06:00
Ben Barham
59afba5bf9 Manually merge branch 'main' into rebranch 2023-03-01 14:13:50 -08:00
Becca Royal-Gordon
1629521b12 Exclude @objcImpl member impls from PrintAsObjC
PrintAsClang was not aware of @objcImplementation. Teach it to skip over both member implementations (which are declared in handwritten headers, so printing them would be a redeclaration) and overrides (which may not be valid in a category, if e.g. they are declaring a designated initializer).

Fixes rdar://106035578.
2023-02-28 21:34:25 -08:00
swift-ci
8cbb3b42ce Merge remote-tracking branch 'origin/main' into rebranch 2022-12-06 11:54:57 -08:00
Nuri Amari
cd4b9a6416 Add support for textual imports to -emit-objc-header
Currently headers produced with `-emit-objc-header` /
`-emit-objc-header-path` produce headers that include modular imports.
If the consumer wishes to operate without modules enabled, these headers
cannot be used. This patch introduces a new flag
(`-emit-clang-header-nonmodular-includes`) that when enabled
attempts to argument each modular import included in such a header with
a set of equivalent textual imports.
2022-12-03 13:07:39 -08:00
swift-ci
11ef9e2935 Merge remote-tracking branch 'origin/main' into rebranch 2022-12-03 11:54:00 -08:00
Evan Wilde
7c0c89546f Revert "Add support for textual imports to -emit-objc-header" 2022-12-02 15:02:19 -08:00
Erik Eckstein
286295023a tests: temporarily disable PrintAsObjC tests which are failing in rebranch
rdar://102629628
2022-12-01 15:28:14 +01:00
Nuri Amari
89a01dddfb Add support for textual imports to -emit-objc-header
Currently headers produced with `-emit-objc-header` /
`-emit-objc-header-path` produce headers that include modular imports.
If the consumer wishes to operate without modules enabled, these headers
cannot be used. This patch introduces a new flag
(`-emit-clang-header-nonmodular-includes`) that when enabled
attempts to argument each modular import included in such a header with
a set of equivalent textual imports.
2022-11-19 12:05:09 -08:00
Josh Soref
b2c6da3acb spelling: replaceable
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>
2022-11-07 07:52:30 -05:00
Josh Soref
31b4c9b14c spelling: difference
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>
2022-11-07 07:52:30 -05:00
Allan Shortlidge
b7e8f00046 Test: Adjust bridged known types tests for the macOS 13 SDK.
In the macOS 13 SDK the definition of `CGFloat` moved from the CoreGraphics Swift overlay to the CoreFoundation overlay. This test should therefore no longer check that a `@import CoreGraphics` directive is emitted since this check fails for compiler developers using newer SDKs.
2022-10-24 08:20:03 -07:00
Alex Lorenz
de1e67d054 [interop][SwiftToCxx] include the swiftToCxx shim header only when actually needed for reverse interop 2022-10-17 13:12:20 -07:00
Alex Lorenz
21adff9feb Merge pull request #61047 from hyp/eng/cxx-types-to-cxx
[interop] pass and return C++ value types to/from Swift in C++
2022-09-12 12:39:45 -07:00
Alex Lorenz
b4d7a0c208 [interop][SwiftToCxx] bridge returned C++ record types back to C++ from Swift 2022-09-11 18:42:41 -07:00
Anthony Latsis
9b924684d3 Gardening: Migrate test suite to GH issues: PrintAsObjC 2022-09-02 01:44:24 +03:00
swift-ci
089c1d0d61 Merge remote-tracking branch 'origin/main' into rebranch 2022-07-28 04:14:23 -07:00
Alex Lorenz
8da01aa0f1 Merge pull request #60087 from WANGJIEKE/cxx-interop-extract-enum-payload
[Interop][SwiftToCxx] Initial support for getting associated values from enum
2022-07-28 12:06:44 +01:00
Tongjie Wang
22d686b933 update test cases 2022-07-26 11:25:30 -07:00
swift-ci
4917d26524 Merge remote-tracking branch 'origin/main' into rebranch 2022-07-22 14:13:43 -07:00
Holly Borla
dd40e14385 Merge pull request #60181 from hborla/restated-coregraphics-conformance
[Sema] Downgrade the redundant conformance error to a warning for conformances originally stated in CoreGraphics.
2022-07-22 14:04:56 -07:00
Holly Borla
25f10b9164 [Sema] Downgrade the redundant conformance error to a warning for conformances
originally stated in CoreGraphics.
2022-07-21 19:48:48 -07:00
Victoria Mitchell
76fe621c1f markup: add support for swift-cmark inline attributes
rdar://96830173
2022-07-21 08:13:07 -06:00
swift-ci
e383c70659 Merge remote-tracking branch 'origin/main' into rebranch 2022-06-30 13:33:55 -07:00
Allan Shortlidge
f63800b169 NFC: Test that @_spi decls are emitted in ObjC compatibility headers.
Some projects depend on `@_spi` decls being emitted this way so we should have a test that asserts this is expected behavior.
2022-06-30 09:13:20 -07:00
swift-ci
3d1da9d5a2 Merge remote-tracking branch 'origin/main' into rebranch 2022-06-23 17:33:23 -07:00
Becca Royal-Gordon
8a8e71ea09 Ignore Sendable conformances in PrintAsClang
PrintAsClang previously tried to print Sendable conformances, which tripped an assertion and failed. Skip them instead.

Fixes rdar://95241184.
2022-06-23 13:16:41 -07:00
swift-ci
55000f53be Merge remote-tracking branch 'origin/main' into rebranch 2022-06-17 10:15:14 -07:00
Becca Royal-Gordon
5459737239 Don’t declare async methods with alternatives in headers
If Swift sees this pattern of methods in an @objc protocol:

```
    func hello() async -> Int

    @available(*, renamed: “hello()”)
    func hello(completion: @escaping (Int) -> Void)
```

Then PrintAsClang will print only the completion-handler-based method, not the async one, into a generated header, on the assumption that the completion-handler method may have greater availability.

Fixes rdar://94175167.
2022-06-16 18:27:12 -07:00
Ben Barham
6094e9f22f [next] Add missing void for function taking no arguments 2022-05-11 17:06:29 -07:00
Robert Widmann
88ec6cbd60 Update Two Tests Relying on Explicit NSObjectProtocol Conformances
These conformances are banned when using NSObjectProtocl in the real
SDK. Adding the `self` member has exposed these few places and started
diagnosing them as invalid again.
2022-05-06 09:10:18 -07:00
Anton Korobeynikov
581b13fe31 Ignore "noescape" bit for all @convention(c) function pointers 2022-04-20 10:34:45 +02:00
Saleem Abdulrasool
36c951d31e Revert "[DebugInfo] Ignore noescape bit for all @convention(c) pointers" 2022-04-19 18:09:23 -07:00
Anton Korobeynikov
07396c5de6 Ignore "noescape" bit for all @convention(c) function pointers 2022-04-18 22:43:57 +02:00
Alex Lorenz
6a6e9b0ff6 Merge pull request #42090 from hyp/i/cxxfuncprim
[cxx-interop] Emit C++ inline function thunks that with correct primitive types
2022-03-29 21:57:55 -07:00
Alex Lorenz
71d95b88cc [interop] fix the test/PrintAsObjC/empty.swift for C++ interop 2022-03-29 16:58:38 -07:00
Doug Gregor
d6d21892f3 Handle output file maps that use the key "objc-header".
This anachronously-named key is nonetheless still important to accept,
or else we'll fail to emit the generated header.

Fixes rdar://90900115.
2022-03-28 10:06:59 -07:00
Alex Lorenz
2e3aa87737 Revert "Revert "Merge pull request #41831 from hyp/unify-header""
This reverts commit 4c9582c295.
2022-03-19 13:36:28 -07:00
Alex Lorenz
4c9582c295 Revert "Merge pull request #41831 from hyp/unify-header"
This reverts commit cd93d23bac, reversing
changes made to f9f5476e9a.
2022-03-18 10:03:07 -07:00
Alex Lorenz
9d52099d5b [cxx-interop] start to emitting a unified header file for a Swift module
This change removes the -emit-cxx-header option, and adds a new -emit-clang-header-path option instead. It's aliased to -emit-objc-header-path for now, but in the future, -emit-objc-header-path will alias to it. After this change Swift can start emitting a single header file that can be expose declarations to C, Objective-C, or C++. For now C++ interface is generated (for all public decls) only when -enable-cxx-interop flag is passed, but that behavior will change once  attribute is supported.
2022-03-17 10:34:47 -07:00