Commit Graph

1921 Commits

Author SHA1 Message Date
Becca Royal-Gordon
07b2b9a01f [NFC] Add @objc to imported ObjC categories
This contains the category name, if there is one.
2024-05-01 12:18:19 -07:00
Becca Royal-Gordon
c3225b066e [NFC] Merge two category name accessors 2024-05-01 12:18:19 -07:00
swift-ci
09ef2055c3 Merge remote-tracking branch 'origin/main' into rebranch 2024-04-23 16:53:38 -07:00
Egor Zhdan
70c3e432f6 Merge pull request #73055 from apple/egorzhdan/ncg-unsafepointer
[cxx-interop] Import `NonCopyable*` as `OpaquePointer` if noncopyable generics are disabled
2024-04-24 00:45:25 +01:00
Egor Zhdan
6140ba1079 [cxx-interop] Do not try to use UnsafePointer<T> for non-copyable T when adding base member accessors 2024-04-23 18:47:55 +01:00
Nate Chandler
c43f87101f Merge branch 'main' into rebranch
Conflicts:
      lib/Basic/Platform.cpp

```
diff --git a/lib/Basic/Platform.cpp b/lib/Basic/Platform.cpp
index 240edfa144a..1797c87635f 100644
--- a/lib/Basic/Platform.cpp
+++ b/lib/Basic/Platform.cpp
@@ -200,10 +200,7 @@ StringRef swift::getPlatformNameForTriple(const llvm::Triple &triple) {
   case llvm::Triple::CUDA:
   case llvm::Triple::DragonFly:
   case llvm::Triple::DriverKit:
-<<<<<<< HEAD
   case llvm::Triple::ELFIAMCU:
-=======
->>>>>>> main
   case llvm::Triple::Emscripten:
   case llvm::Triple::Fuchsia:
   case llvm::Triple::HermitCore:
```
2024-04-17 13:32:48 -07:00
Steven Wu
e654e371de [BridgingHeader] Implicit import bridging header from CAS module
The binary module built from a CAS build will have the embeded bridging
header info with 0 modTime. Allow a regular build to import such a
module with the same behavior as if the module is built from a regular
build.

rdar://126221616
2024-04-15 14:47:56 -07:00
Steven Wu
7a68d364f4 [Caching] Embed bridging header in binary module correctly when caching
When caching is enabled with include-tree, the bridging header PCH is
created from the include tree directly. Setup the rewriter correctly
when embedding the bridging header into swift binary module.

rdar://125719747
2024-04-15 14:46:38 -07:00
swift-ci
5b6eadf416 Merge remote-tracking branch 'origin/main' into rebranch 2024-04-12 13:37:42 -07:00
Artem Chikin
1f14158a1d Introduce VisionOS Platform
This change introduces a new compilation target platform to the Swift compiler - visionOS.

- Changes to the compiler build infrastrucuture to support building compiler-adjacent artifacts and test suites for the new target.
- Addition of the new platform kind definition.
- Support for the new platform in language constructs such as compile-time availability annotations or runtime OS version queries.
- Utilities to read out Darwin platform SDK info containing platform mapping data.
- Utilities to support re-mapping availability annotations from iOS to visionOS (e.g. 'updateIntroducedPlatformForFallback', 'updateDeprecatedPlatformForFallback', 'updateObsoletedPlatformForFallback').
- Additional tests exercising platform-specific availability handling and availability re-mapping fallback code-path.
- Changes to existing test suite to accomodate the new platform.
2024-04-10 09:38:02 -07:00
Ben Barham
0c0c4ea7c3 [ClangImporter] Use new CXXThisExpr::Create function
The constructor takes a new arg which `Create` now handles. Use it
instead.
2024-04-08 08:58:58 -07:00
Ben Barham
a9077d7129 FileEntry to FileEntryRef updates 2024-04-08 08:58:58 -07:00
Artem Chikin
78852338de Revert "On 'canImport' of Clang submodules of modules with an umbrella header, attempt to infer the submodule" 2024-04-05 11:25:47 -07:00
Saleem Abdulrasool
fc5da5342c Merge pull request #72603 from compnerd/target-cpu
ClangImporter: handle `-target-cpu` for x86 targets
2024-04-04 07:00:34 +09:00
Egor Zhdan
a0c1027b6d Merge pull request #72766 from apple/egorzhdan/bump-std-default
[cxx-interop] Use C++17 standard by default
2024-04-03 19:13:03 +01:00
Egor Zhdan
1be7230876 [cxx-interop] Use C++17 standard by default
Clang is using C++17 standard version by default since Clang 16.

Swift’s ClangImporter should do the same, to make sure that clients who run clang and then swiftc without explicit std version see consistent behavior.

rdar://125777068
2024-04-02 16:23:32 +01:00
Saleem Abdulrasool
e89bfcf63f ClangImporter: handle -target-cpu for x86 targets
`-mcpu` is a deprecated "alias" (unsupported) on x86 targets for
`-mtune`. Unlike `-mcpu`, `-mtune` simply tunes the code for the CPU but
does not prevent execution on other targets. In order to match the
behaviour of `-mcpu` on ARM, we must use both `-march=` and `-mtune=`.
Adjust this behaviour to allow tuning of code for non-Darwin targets.
2024-04-01 14:31:52 -07:00
Ben Barham
1fdda023b3 Rename StringRef::endswith references to StringRef::ends_with
Missed this when doing the `startswith` renaming. `endswith` has also
been deprecated upstream (and presumably soon to be removed).
2024-04-01 10:59:16 -07:00
Alex Lorenz
bdc3717834 Merge pull request #72643 from hyp/eng/cxx-interop/xrefcts
[cxx-interop] serialize x-refs for class template specializations
2024-04-01 08:08:25 -07:00
Becca Royal-Gordon
3990e17ae3 Merge pull request #71938 from beccadax/objcimpl-redundant-conformance-class-ext
Fix class extension visibility bug
2024-03-29 20:15:46 -07:00
Becca Royal-Gordon
f9a1c4d2bf Fix class extension visibility bug
New code introduced for objcImp class extension support failed to check whether a class extension would be visible to Swift before importing it. This caused Swift to import extensions declared in private headers that ought not to be visible. Add the needed visibility check to the loop.

Fixes rdar://123543707.
2024-03-29 14:21:15 -07:00
Alex Lorenz
0c7b1cee13 [cxx-interop] serialize x-refs for class template specializations
Fixes https://github.com/apple/swift/issues/70253
2024-03-29 10:08:18 -07:00
Michael Gottesman
363c5634f1 [transferring] Implement swift_attr support for transferring results and parameters.
rdar://125211624
2024-03-23 17:59:01 -07:00
John McCall
40d9ea598e Merge pull request #72514 from rjmccall/isolated-any-optional-conversion
Correctly apply `@isolated(any)` even when converting to an optional type
2024-03-23 05:04:18 -04:00
Dave Lee
e6a34e89ac [ClangImporter] Honor ClangTarget in getNormalInvocationArguments (#72375)
In `getNormalInvocationArguments`, use a triple that corresponds to `ClangTarget`. This 
matches the behavior of `addCommonInvocationArguments`.

rdar://124539816
2024-03-21 16:31:40 -07:00
John McCall
44d7d06dd2 Don't lie about the intermediate result type when synthesizing a call to a
function that returns UnsafeMutablePointer.
2024-03-21 12:47:56 -04:00
Artem Chikin
32bad62e34 Merge pull request #72129 from artemcm/canImportSubmoduleInfer
On 'canImport' of Clang submodules of modules with an umbrella header, attempt to infer the submodule
2024-03-15 14:29:21 -07:00
Artem Chikin
0808a1d822 On 'canImport' of Clang submodules of modules with an umbrella header, attempt to infer the submodule
Resolves rdar://124163264
2024-03-14 15:12:00 -07:00
Ben Barham
9779c18da3 Rename startswith to starts_with
LLVM is presumably moving towards `std::string_view` -
`StringRef::startswith` is deprecated on tip. `SmallString::startswith`
was just renamed there (maybe with some small deprecation inbetween, but
if so, we've missed it).

The `SmallString::startswith` references were moved to
`.str().starts_with()`, rather than adding the `starts_with` on
`stable/20230725` as we only had a few of them. Open to switching that
over if anyone feels strongly though.
2024-03-13 22:25:47 -07:00
Steven Wu
fb3c268abc [Caching] Support index while building when caching on
Model indexing output as an optional output from the swift compiler
as the build system has no knowledge about them and they can be
regenerated by indexer. Make sure the indexing store output is produced
when cache hit so the compilation is done for the module. If cache hit,
no indexing data is produced since no compilation is done.

rdar://123331335
2024-03-07 14:40:00 -08:00
Steven Wu
cdeef58e0f [Caching] Create clang importer from cc1 args directly
When caching build is enabled, teach dependency scanner to report
command-lines with `-direct-clang-cc1-module-build` so the later
compilation can instantiate clang importer with cc1 args directly. This
avoids running clang driver code, which might involve file system
lookups, which are the file deps that are not captured and might result
in different compilation mode.

rdar://119275464
2024-03-07 14:40:00 -08:00
Becca Royal-Gordon
fd9ae4c8ac Merge pull request #72023 from beccadax/lazy-objc-workaround
Add workaround flag for lazy import-as-member
2024-03-05 16:12:32 -08:00
Egor Zhdan
638abd991f [cxx-interop] Refactor: move synthesis logic elsewhere 2024-03-01 15:57:33 +00:00
Becca Royal-Gordon
1a97803c8c Add flag for dumping ClangImporter lookup tables
ClangImporter’s SwiftLookupTables map Swift names to their corresponding Clang declarations. These tables are built into a module’s clang .pcm file and missing or inaccurate entries can cause name lookup to fail to find an imported declaration.

Swift has always included a helper function that would dump these tables, and swift-ide-test has a command-line switch that would invoke it, but these tools are clumsy to use in many debugging scenarios. Add a frontend flag that dumps the tables at the end of the frontend job, making it a lot easier to get at this information in the context of a specific compilation.
2024-02-29 17:51:00 -08:00
Egor Zhdan
3e75fd207d Revert "[cxx-interop] Enable virtual function calling from Swift to C++"
This partially reverts commit 128064f3
2024-02-29 22:33:27 +00:00
Egor Zhdan
98fc9fd9c5 Merge pull request #71813 from apple/egorzhdan/std-not-found
[cxx-interop] Correctly generate the list of transitive dependencies for CxxStdlib overlay
2024-02-26 12:35:25 +00:00
Ben Barham
f292ec9784 Use the new template deduction guides rather than makeArrayRef
LLVM has removed `make*ArrayRef`, migrate all references to their
constructor equivalent.
2024-02-23 20:04:51 -08:00
Egor Zhdan
9147522506 [cxx-interop] Correctly generate the list of transitive dependencies for CxxStdlib overlay
This fixes a compiler error that occurred while building `CxxStdlib.swiftmodule` and other projects that use C++ interop: `error: cannot find type 'std' in scope`.

The compiler was creating two distinct `swift::ModuleDecl` instances for the CxxStdlib module while building the CxxStdlib overlay: one as a main module (the module that is currently being compiled), one as a dependency of the main module. This confused the Swift name lookup logic down the road.

This only happened with recent libc++.

See the inline comment for more details.

rdar://122815523
2024-02-22 16:43:51 +00:00
Ben Barham
5637284e48 Merge pull request #71368 from bnbarham/std-optional-all-the-things
Migrate llvm::Optional to std::optional
2024-02-21 16:54:00 -08:00
Ben Barham
ef8825bfe6 Migrate llvm::Optional to std::optional
LLVM has removed llvm::Optional, move over to std::optional. Also
clang-format to fix up all the renamed #includes.
2024-02-21 11:20:06 -08:00
Pavel Yaskevich
c533d4298e [ClangImporter] Produce ErrorType for invalid variables
If type couldn't be imported, produce error type instead
of `Type()` to align with other checks.

Resolves: rdar://123244479
2024-02-21 09:32:25 -08:00
Becca Royal-Gordon
7aa5b7fd88 Merge pull request #71445 from beccadax/category-error 2024-02-13 11:13:48 -08:00
Steven Wu
9607e9dec1 Merge pull request #71497 from cachemeifyoucan/eng/PR-122423965
[Caching] Use subInvocation to verify interface
2024-02-13 09:18:40 -08:00
Steven Wu
3986937e03 [Caching][NFC] Restructure CASOption in swift. NFC
Clean up how CASOptions are kept and passed inside swift to make the
code more readable. Also avoid a copy of CAS configuration in
ClangImporter.
2024-02-11 14:08:09 -08:00
Becca Royal-Gordon
9bcd818fb1 [NFC] Make objcImpl request one-to-many
An @_objcImpl extension with no category name *should* implement not only the class’s main @interface, but also any class extension @interfaces. Start making this true by making ObjCInterfaceAndImplementationRequest return all of these decls as the interfaces for such an implementation.

This commit doesn’t actually change Sema or IRGen to process the extra interfaces, so it’s NFC.
2024-02-09 21:32:06 -08:00
Jan Svoboda
757c50cd4b [ClangImporter] Align callback with Clang change (#71475) 2024-02-08 20:17:14 -08:00
Becca Royal-Gordon
8621508098 Merge pull request #71320 from beccadax/globally-lazy-maximum
[ClangImporter] Support lazy member loading for import-as-member globals in extensions
2024-02-08 12:13:32 -08:00
Kuba Mracek
dba8d5d3a0 Revert "Merge pull request #71278 from kubamracek/embedded-no-mach-defines"
This reverts commit 21eddf0b1a, reversing
changes made to e2d516f3c9.
2024-02-05 09:05:22 -08:00
Kuba (Brecka) Mracek
21eddf0b1a Merge pull request #71278 from kubamracek/embedded-no-mach-defines
[embedded] Implicitly define __APPLE__ and __MACH__ when on -apple-none triples
2024-02-02 19:30:56 -08:00
Kuba Mracek
4776e993ad [embedded] Use defined(__wasm__) instead of defined(__wasi__) in Visibility.h 2024-02-02 12:41:54 -08:00