Commit Graph

1896 Commits

Author SHA1 Message Date
Xi Ge
c5a715d4ed Revert "[cxx-interop] Fix two issues with extending nested types across modules."
This reverts commit 6ba7a1ec1e.
2021-12-08 20:00:41 -08:00
zoecarver
fc3b3a1d71 [cxx-interop] Implement foreign reference types.
This is an expiremental feature to allow an attribute, `import_as_ref`, to import a C++ record as a non-reference-counted reference type in Swift.
2021-12-08 15:35:18 +00:00
Argyrios Kyrtzidis
7ad553f981 Merge pull request #40273 from bnbarham/pch-allow-errors
[ClangImporter] Handle allowing PCM/PCH errors
2021-12-03 18:13:46 -08:00
Egor Zhdan
9010d89c5e Merge pull request #39999 from egorzhdan/cxx-mutating-attr
C++ Interop: support mutating attribute for C++ methods
2021-11-30 10:58:16 +03:00
Ben Barham
594fabafd9 [ClangImporter] Handle allowing PCM/PCH errors
Ignore errors when emitting/reading a PCM/PCH and Clang has
`-fallow-(pcm|pch)-with-compiler-errors` set.

Resolves rdar://85576570.
2021-11-30 15:46:51 +10:00
Egor Zhdan
06612934e8 C++ Interop: support mutating attribute for C++ methods
This change teaches ClangImporter to import C++ methods marked with `__attribute__((__swift_attr__("mutating")))` as mutating in Swift. This is useful, for example, when a method mutates `this` despite being `const` in C++ (e.g. via `const_cast`).
2021-11-29 21:13:16 +03:00
Becca Royal-Gordon
b9480f12d0 Allow imported types to add a Sendable conformance
...by using `__attribute__((swift_attr("@Sendable")))`. `@_nonSendable` will "beat" `@Sendable`, while `@_nonSendable(_assumed)` will not.

This commit also checks if `SwiftAttr` supports `#pragma clang attribute` and, if it does, defines `__SWIFT_ATTR_SUPPORTS_SENDABLE_DECLS` in imported headers so they know they can apply these attributes in an auditing style.
2021-11-19 11:34:01 -08:00
Saleem Abdulrasool
4d44953691 Revert "Support __available__((swift_attr("@Sendable")))" 2021-11-19 07:40:24 -08:00
Becca Royal-Gordon
3d2d4e1721 Merge pull request #40170 from beccadax/send-me-an-object
Support __available__((swift_attr("@Sendable")))
2021-11-19 01:26:10 -08:00
Robert Widmann
f97d0cc4c0 [NFC] Initialize Members in Order 2021-11-17 13:17:00 -08:00
Zoe Carver
8980b8b6ec Merge pull request #40165 from zoecarver/fix-extensions-across-modules
[cxx-interop] Fix two issues with extending nested types across modules.
2021-11-16 09:08:06 -08:00
zoecarver
6ba7a1ec1e [cxx-interop] Fix two issues with extending nested types across modules.
One fix allows extending nested records in other modules, the other fixes the same issue for namespaces.
2021-11-15 16:20:15 -08:00
Zoe Carver
fb88ace28b Merge pull request #40143 from apple/revert-40010-importSourceLoc
Revert "Implement ClangImporter importSourceLoc and importSourceRange"
2021-11-13 16:58:11 -08:00
Becca Royal-Gordon
7549278314 Allow imported types to add a Sendable conformance
...by using `__attribute__((swift_attr("@Sendable")))`. `@_nonSendable` will "beat" `@Sendable`, while `@_nonSendable(_assumed)` will not.

This commit also checks if `SwiftAttr` supports `#pragma clang attribute` and, if it does, defines `__SWIFT_ATTR_SUPPORTS_SENDABLE_DECLS` in imported headers so they know they can apply these attributes in an auditing style.
2021-11-12 23:13:29 -08:00
Alex Lorenz
1089959b0f [interop] clang name lookup should find declarations in inline namespaces 2021-11-12 17:40:38 -08:00
Zoe Carver
c6474b970d Revert "Implement ClangImporter importSourceLoc and importSourceRange (#40010)"
This reverts commit 8eb8263f81.
2021-11-11 12:09:55 -08:00
Nuri Amari
8eb8263f81 Implement ClangImporter importSourceLoc and importSourceRange (#40010)
Co-authored-by: Nuri Amari <nuriamari@fb.com>
2021-11-09 16:31:03 -08:00
Jan Svoboda
8979602fef Merge pull request #39810 from apple/jan_svoboda/search_path_remark_sloc
[ClangImporter] Pass `SourceLocation` to `lookupModule`
2021-10-22 14:54:17 +02:00
Zoe Carver
401f334b90 Merge pull request #38675 from zoecarver/lazy-importer-namespaces
[cxx-interop] Lazily import members of clang namespaces and records via requests.
2021-10-21 09:04:52 -07:00
Jan Svoboda
7f344cbf25 [ClangImporter] Pass SourceLocation to lookupModule 2021-10-21 14:24:11 +02:00
zoecarver
b8e52a7ad2 [cxx-interop] Lazily import members of Clang namespaces and records via requests.
Also adds a ClangImporter request zone and move some requests into it.
2021-10-20 14:52:43 -07:00
Ellie Shin
6f34844b49 Merge pull request #39705 from apple/es-module-alias-serialize
[Module aliasing] Serialize SIL and binaries with module real names for referenced or imported modules. Resolves rdar://83632529
2021-10-18 21:55:45 -07:00
zoecarver
0ca8dd364f [nfc][cxx-interop] Add three requests ClangDirectLookupRequest, CXXNamespaceMemberLookup, and ClangRecordMemberLookup.
None of these requests are used, so this is a non-functional change.
2021-10-13 16:31:09 -07:00
Zoe Carver
40422f021b Merge pull request #39664 from zoecarver/lazy-pt9-use-lookup-table
[cxx-interop] Add members to the LookupTable where possible.
2021-10-13 15:29:31 -07:00
zoecarver
eeeb27d66e [cxx-interop] Add members to the LookupTable where possible.
If possible, add imported members to the StructDecl's LookupTable rather than adding them directly as members. This will fix the issues with ordering that #39436 poorly attempted to solve during IRGen.

This also allows us to break out most of the test changes from #39436.
2021-10-13 11:53:58 -07:00
Daniel Rodríguez Troitiño
0392181c23 Merge pull request #39653 from NuriAmari/auto
NFC: Remove Decl* declarations made using auto
2021-10-12 18:11:35 -07:00
elsh
adf33e0bb9 Add doc comments
Rename test
2021-10-12 15:03:30 -07:00
elsh
96fb3d6112 [Module aliasing] Serialize binary with module real name
Resolves rdar://83632529
2021-10-12 13:59:34 -07:00
Mishal Shah
c2fd49cebb Merge pull request #39473 from apple/rebranch
Update swift:main to support llvm-project:stable/20210726 changes (Rebranch merge)
2021-10-11 09:00:51 -07:00
Zoe Carver
f189992189 Merge pull request #39431 from zoecarver/lazy-pt3-print-objc-module
[cxx-interop] Print decls in the __ObjC module.
2021-10-07 17:50:59 -07:00
Nuri Amari
03d4d11216 Remove Decl* declarations made using auto
A non functional change replacing auto with
Decl* for some declarations using ClangImporter::Implementation::importDecl.
Increases clarity and makes subsequent planned changes easier.
2021-10-07 11:15:07 -04:00
swift-ci
3f8fea8508 Merge remote-tracking branch 'origin/main' into rebranch 2021-10-06 10:17:29 -07:00
Artem Chikin
ae727e1348 Merge pull request #39509 from artemcm/FixExplicitPCMWarnings
Fix `'linker' input unused` warnings in Explicit Module Builds
2021-10-01 13:03:49 -07:00
Artem Chikin
aa31794049 [Clang Importer] Pass in clang executable argument even if -only-use-extra-clang-opts is specified.
Instead of *just* passing in `ExtraArgs`, we need to make sure to still form a command-line according to Clang's expectation.
2021-09-30 15:29:13 -07:00
swift-ci
c51550f30e Merge remote-tracking branch 'origin/main' into rebranch 2021-09-30 15:11:41 -07:00
Xi Ge
a4b4b1fa65 ClangImporter: don't import clang SPI attributes by default 2021-09-28 10:46:27 -07:00
swift-ci
3b702bf6e4 Merge remote-tracking branch 'origin/main' into rebranch 2021-09-24 11:54:10 -07:00
Egor Zhdan
e1c4ea50c8 Merge pull request #37806 from egorzhdan/clang-executable-path-reapply
ClangImporter: run Clang with a proper executable path (pt 2)
2021-09-24 21:46:03 +03:00
swift-ci
588a179e3d Merge remote-tracking branch 'origin/main' into rebranch 2021-09-24 10:13:18 -07:00
Zoe Carver
6467d0ec1a Merge pull request #39429 from zoecarver/lazy-pt1-clang-module-loader
[nfc][cxx-interop] Add three utilities to the `ClangModuleLoader`.
2021-09-24 13:04:03 -04:00
zoecarver
d13f43c31b [cxx-interop] Add three utilities to the ClangModuleLoader.
This adds `importDeclDirectly`, `findLookupTable`, `importName`, and `getEffectiveClangContext`. These are all needed for #38675.
2021-09-23 16:51:03 -07:00
zoecarver
3454f903bf [cxx-interop] Print decls in the __ObjC module.
This is one change from #38675.
2021-09-23 15:27:32 -07:00
Karoy Lorentey
e767873ea7 [ClangImporter] Explicitly enable cx16 on every platform 2021-09-22 21:00:18 -07:00
Karoy Lorentey
aa0aa5b12b [ClangImporter] Pass -mcx16 to Clang invocation for x86_64 Linux targets
The Swift runtime and the concurrency module both use -mcx16, so there seems to be little point in not enabling it for Swift code in general.

This allows packages like swift-atomics to rely on double wide atomics always being available.

https://bugs.swift.org/browse/SR-13781
2021-09-22 18:42:08 -07:00
swift-ci
a8dc9f7d6f Merge remote-tracking branch 'origin/main' into rebranch 2021-09-09 08:53:29 -07:00
zoecarver
6e9bf50996 [cxx-interop] Lazily load the result of imported functions.
Note: we only lazily load the result if it's a record, because otherwise it's trivial to load when importing the function. Also, we still eagerly import operator's results types.
2021-09-08 17:48:39 -07:00
swift-ci
e25cb8a958 Merge remote-tracking branch 'origin/main' into rebranch 2021-07-28 12:17:04 -07:00
Egor Zhdan
a8f126f7cd C++ Interop: import const methods as non-mutating
This change makes ClangImporter import some C++ member functions as non-mutating, given that they satisfy two requirements:
* the function itself is marked as `const`
* the parent struct doesn't contain any `mutable` members

`get` accessors of subscript operators are now also imported as non-mutating if the C++ `operator[]` satisfies the requirements above.

Fixes SR-12795.
2021-07-25 15:18:33 +03:00
swift-ci
67017f7f6d Merge remote-tracking branch 'origin/main' into rebranch 2021-07-24 03:53:49 -07:00
Egor Zhdan
cfc9483f1a C++ Interop: import namespaces redecls as separate extensions
Previously a namespace declaration was imported along with all of its redeclarations, and their members were added to a single Swift extension. This was problematic when a single namespace is declared in multiple modules – the extension belonged to only one of them.
For an example of this, try printing a module interface for `std.string`/`std.iosfwd` – it will be empty, even though the declarations from those modules are actually imported into Swift correctly.

This change makes sure that when we're importing different redeclarations of the same namespace, we're adding them as separate extensions to appropriate modules.
2021-07-23 23:38:46 +03:00