Commit Graph

6196 Commits

Author SHA1 Message Date
fahadnayyar
bd9095e69f Merge pull request #76733 from fahadnayyar/cxx-interop-frt-retain-release-diagnostics-patch-2
[cxx-interop] Add diagnostic notes when retain/release are not import…
2024-09-27 22:37:07 -07:00
fahadnayyar
d1b380ffd6 [cxx-interop] Add diagnostic notes when retain/release are not imported into swift for SWIFT_SHARED_REFERENCE types 2024-09-27 18:57:31 -07:00
swift-ci
71dc8562b0 Merge remote-tracking branch 'origin/main' into rebranch 2024-09-27 10:14:45 -07:00
Daniel Rodríguez Troitiño
fe796b419a [cxx-interop] Use macosx paths when searching modulemaps for macCatalyst (#76735)
The existing code will use paths for "iphoneos" because the triples for
macCatalyst are in the form "<arch>-apple-iosXX.yy-macabi", which the
code interprets as an iPhone triple. This seems to work in Xcode because
the "iphoneos" folder is always there. When building in open source,
this seems to work because it is also normal to have the iPhone SDK
configured. This is not the case if you want to build the macOS SDK in
isolation.

The code changes detect the macCatalyst environment from the triple and
use the "macosx" paths instead, otherwise it follows the same code path
as before. This matches many places in the CMakeLists.txt files in which
macCatalyst support pieces are only enabled when the SDK is macOS.

The modified function is also used for the libc modulemap of non-Darwin
platforms, but for those triples, the macCatalyst environment should not
be detected, so the libc modulemap should not be affected by this
change.

This is a followup to #76260 and #74994.
2024-09-27 10:08:16 -07:00
swift-ci
59a7eb4710 Merge remote-tracking branch 'origin/main' into rebranch 2024-09-27 06:15:16 -07:00
Gábor Horváth
89708dd15a Merge pull request #76673 from swiftlang/gaborh/structural-escapability
[cxx-interop] Add rules to recognize escapability of aggregates
2024-09-27 13:58:33 +01:00
Egor Zhdan
fcb590690e [cxx-interop] Support char8_t C++20 type
https://en.cppreference.com/w/cpp/keyword/char8_t

This is based on a patch from Varun Gandhi: https://github.com/swiftlang/swift/pull/26153

rdar://39988329 / resolves https://github.com/swiftlang/swift/issues/68726
2024-09-27 13:56:03 +01:00
Ben Barham
c15bc19946 Merge remote-tracking branch 'origin/main' into main-to-rebranch
Conflicts:
  - `lib/Serialization/ModuleFileSharedCore.cpp` new headers on main
2024-09-26 16:01:56 -07:00
Steven Wu
5a6f6e1d4d [NFC][ScanDependency] Remove some ununsed code
Clean up some code that no longer used.
2024-09-24 16:29:21 -07:00
Gabor Horvath
cbd8cdfe95 [cxx-interop] Add rules to recognize escapability of aggregates
For now, this logic is used for importing fewer unannotated types as
unsafe. In the future, this logic will be used by escapability inference
for other (non-aggregate) types.
2024-09-24 16:41:00 +01:00
swift-ci
2bd533ccda Merge remote-tracking branch 'origin/main' into rebranch 2024-09-24 07:55:58 -07:00
Gábor Horváth
40529912a9 Merge pull request #76668 from swiftlang/gaborh/lifetimebound-off-by-one
[cxx-interop] Fix off-by-one error when importing lifetimebound attrs
2024-09-24 15:49:19 +01:00
Gabor Horvath
72ce39ce07 [cxx-interop] Fix off-by-one error when importing lifetimebound attrs 2024-09-24 12:01:26 +01:00
Gabor Horvath
e8aea32c95 [cxx-interop] Import SWIFT_UNSAFE_REFERENCE types as @unsafe 2024-09-23 16:51:01 +01:00
Konrad `ktoso` Malawski
d89347bed0 Merge branch 'main' into wip-experimental-isolated-deinit 2024-09-20 18:34:45 +09:00
swift-ci
df338c19a8 Merge remote-tracking branch 'origin/main' into rebranch 2024-09-19 09:34:45 -07:00
Gabor Horvath
929c0ca7d8 [cxx-interop] Introduce a safe C++ interop mode
In this mode all C++ types are imported as unsafe by default. Users
explicitly marking types are escapable or not escapable can make them
imported as safe. In the future, we also want to import unannotated
functions as unsafe and add more logic to infer types that are actually
safe, like agregates of escapable types.
2024-09-19 12:34:07 +01:00
swift-ci
6964118e7e Merge remote-tracking branch 'origin/main' into rebranch 2024-09-18 13:17:04 -07:00
Doug Gregor
3a570e060c Merge pull request #76551 from DougGregor/one-loc-to-file-lookup
Reimplement ModuleDecl::getSourceFileContainingLocation() using SourceManager
2024-09-18 12:55:08 -07:00
swift-ci
5039a2d86c Merge remote-tracking branch 'origin/main' into rebranch 2024-09-18 10:55:29 -07:00
Doug Gregor
da0c70f301 Merge pull request #76512 from DougGregor/sourcefile-nonopt-buffer
Ensure that SourceFiles always have a backing buffer in the SourceManager
2024-09-18 10:54:52 -07:00
Doug Gregor
8febd3fb32 Reimplement ModuleDecl::getSourceFileContainingLocation() using SourceManager
ModuleDecl kept track of all of the source files in the module so that it
could find the source file containing a given location, which relied on
a sorted array all of these source files. SourceManager has its own
similar data structure for a similar query mapping the locations to
buffer IDs.

Replace ModuleDecl's dats structure with a use of the SourceManager's version
with the mapping from buffer IDs to source files.
2024-09-18 07:45:50 -07:00
swift-ci
72a4f929b0 Merge remote-tracking branch 'origin/main' into rebranch 2024-09-18 07:33:29 -07:00
Gábor Horváth
ffa1014c30 Merge pull request #76311 from swiftlang/gaborh/import-lifetimebound
[cxx-interop] Teach importer to interpret lifetimebound annotations
2024-09-18 15:24:32 +01:00
Alastair Houghton
6e48b1d781 [ClangImporter][ModuleWrap] Turn off libc warnings.
`swift-modulewrap` uses the `ClangImporter` to obtain a module loader,
but it doesn't take an SDK argument (nor does anything bother to pass
one), which means that when cross-compiling you get warnings about not
being able to find the C library.

Suppress the warning by telling the `ClangImporter` that we don't care
about the C library here.

rdar://115918181
2024-09-18 13:56:53 +01:00
Gabor Horvath
16e012bb5e [cxx-interop] Teach importer to interpret lifetimebound annotations
The lifetimebound annotations are now imported as lifetime dependencies.
This works for basic cases but there are still some parts missing:
* Support lifeitmebound annotations on constructors
* A way to represent immortal/static lifetimes on the C++ side
2024-09-18 10:51:05 +01:00
swift-ci
24e41cb1b0 Merge remote-tracking branch 'origin/main' into rebranch 2024-09-17 09:35:17 -07:00
Egor Zhdan
5981833c17 [cxx-interop] NFC: Remove unused method
`importer::hasUnsafeAPIAttr` is being used instead of this method.
2024-09-17 13:48:53 +01:00
Konrad `ktoso` Malawski
7d1ce789ad Revert "Revert "Isolated synchronous deinit"" 2024-09-17 17:35:38 +09:00
Doug Gregor
4e7fb73b0c Provide the buffer ID for source files created for C swift_attr attributes
When rendering a swift_attr attribute for parsing, we were creating both
the backing buffer and a source file, but not providing the buffer's ID
to the source file, so we couldn't find the source code again. Fix that.

While here, also register the source file with the module, so we can
find the source file again based on location.
2024-09-16 21:45:34 -07:00
Ben Barham
a7b50f357f Merge remote-tracking branch 'origin/main' into manual-main-merge
Conflicts:
  - `lib/Driver/ToolChains.cpp` conflicting with the `addAllArgs` rename
    for multiple options
2024-09-16 13:53:18 -07:00
Allan Shortlidge
02dbb96b94 AST: Rename AvailabilityContext to AvailabilityRange.
The generality of the `AvailabilityContext` name made it seem like it
encapsulates more than it does. Really it just augments `VersionRange` with
additional set algebra operations that are useful for availability
computations. The `AvailabilityContext` name should be reserved for something
pulls together more than just a single version.
2024-09-13 16:25:18 -07:00
fahadnayyar
7753ad0885 Merge pull request #76131 from fahadnayyar/cxx-interop-frt-retain-release-diagnostics
Fixed diagnostics for incorrect parameters of retain/release function…
2024-09-11 10:24:20 -07:00
fahadnayyar
f3f4e1913b Fixed diagnostics for incorrect signature of retain/release functions of SWIFT_SHARED_REFERENCE C++ types. 2024-09-10 16:15:07 -07:00
Alexis Laferrière
839f99ec40 Sema: Register clang's export_as in ModuleDecl::getExportAsModule
This service on ModuleDecl wasn't actually used before this PR. The main
client in ASTPrinter calls direclty the underlying logic in FileUnit.
Let's update it for our needs.
2024-09-09 16:57:46 -07:00
swift-ci
f3fac46bbc Merge remote-tracking branch 'origin/main' into rebranch 2024-09-09 08:35:46 -07:00
Alex Lorenz
8ea7569b14 Merge pull request #76286 from hyp/eng/bodyParamsimport
[cxx-interop] do not rely on bodyParams being always non-null when im…
2024-09-09 08:24:30 -07:00
Steven Wu
b6ec5e5860 Merge pull request #76301 from cachemeifyoucan/eng/PR-135319536
[ScanDependency] Use `-fsyntax-only` to scan clang module dependencies
2024-09-06 10:10:28 -07:00
swift-ci
9717c082ca Merge remote-tracking branch 'origin/main' into rebranch 2024-09-06 09:16:29 -07:00
fahadnayyar
e3ea4e1b54 Merge pull request #75897 from fahadnayyar/f-dev-frt-return-ownership-annotations-pr
[cxx-interop] Add SWIFT_RETURNS_RETAINED and SWIFT_RETURNS_UNRETAINED…
2024-09-06 09:16:08 -07:00
Steven Wu
b2ea889721 [ScanDependency] Use -fsyntax-only to scan clang module dependencies
Use `-fsyntax-only` action to scan clang module dependencies instead of
`-c` option. This fixes a non-deterministic output on windows from
scan-dependency output because `-c` implies it needs a temporary object
file in the cc1 arguments that makes the pcm compilation command
different every run. This can also make the `-Xcc` commands for PCM
compilation simpler and more likely to be deduplicated by build system.

rdar://135319536
2024-09-05 16:22:28 -07:00
swift-ci
da55e84c74 Merge remote-tracking branch 'origin/main' into rebranch 2024-09-05 15:35:33 -07:00
Alejandro Alonso
45d7ea39a5 Merge pull request #75518 from Azoy/integer-generics
Implement Value generics
2024-09-05 15:33:46 -07:00
swift-ci
189d9fd1e3 Merge remote-tracking branch 'origin/main' into rebranch 2024-09-05 14:54:27 -07:00
Saleem Abdulrasool
c8a24e5aeb Merge pull request #75635 from compnerd/sdk-notes
ClangImporter: support SDK for APINotes
2024-09-05 14:51:59 -07:00
fahadnayyar
ea4328384d [cxx-interop] Add SWIFT_RETURNS_RETAINED and SWIFT_RETURNS_UNRETAINED annotations to specify ownership of FRT returned by a C++ method or function
rdar://135306908
2024-09-05 11:44:31 -07:00
Alex Lorenz
86886d96c9 [cxx-interop] do not rely on bodyParams being always non-null when importing function's name
This change fixes a swift-ide-test crash that occured in the Interop\Cxx\stdlib\msvcprt-module-interface.swift testcase with a newer MSVC, as one of its operator() had a parameter with a type that couldn't have been imported. The change ensures that body params are not used if they're null.
2024-09-05 10:54:52 -07:00
swift-ci
db2417963d Merge remote-tracking branch 'origin/main' into rebranch 2024-09-05 04:56:41 -07:00
Egor Zhdan
9ac56f2f05 Merge pull request #76249 from swiftlang/egorzhdan/simd-template-param
[cxx-interop] Disambiguate template instantiations with SIMD parameters
2024-09-05 12:46:50 +01:00
Saleem Abdulrasool
a8f47b3ef5 ClangImporter: support SDK for APINotes
Honour the SDK for APINotes to augment the system libraries. This allows
us to distribute APINotes with the Swift SDK and impact the system
without having to map the APINotes into the filesystem.
2024-09-04 15:59:57 -07:00