Commit Graph

2546 Commits

Author SHA1 Message Date
Becca Royal-Gordon
d2d786a76a [NFC] Add ClangImporter header diagnostic helper 2021-11-19 11:34:01 -08:00
Becca Royal-Gordon
0842795eb5 [NFC] Let SynthesizedProtocolAttrs be @unchecked
This is not yet used by anything.
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
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
Becca Royal-Gordon
8751658f6c Make NS_ENUM &c. Sendable even when audited
An explicit swift_attr("@_nonSendable") will override it (except for ns_error_domain where the type is embedded in another type that's forced to be Sendable), but swift_attr("@_nonSendable(_assumed)") will not.
2021-11-12 23:13:29 -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
Becca Royal-Gordon
de768e8fda [ClangImporter] Import SwiftAttrs early
This change applies SwiftAttr attributes as soon as possible after creating an instance of a Decl, rather than waiting until the declaration is "finished". That makes sure the attributes can influence the declaration very early in its lifecycle, and in particular, before its conformance table is initialized.

Mostly NFC in this commit (other than affecting the order that attributes are printed in), but necessary for future changes in this PR.
2021-11-12 23:12:38 -08:00
Becca Royal-Gordon
b372ff61af [NFC] Add ClangImporter header diagnostic helper 2021-11-12 23:12:38 -08:00
Becca Royal-Gordon
953ffc3c8d [NFC] Let SynthesizedProtocolAttrs be @unchecked
This is not yet used by anything.
2021-11-12 23:12: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
Robert Widmann
22405cefea Plumb the "Is Type Sequence" Bit Through the Surface AST 2021-11-08 13:48:30 -08:00
Slava Pestov
f38f25a3de AST: Factor out AbstractGenericSignatureRequest into a new buildGenericSignature() function
This is slightly cleaner.
2021-10-30 00:35:59 -04:00
zoecarver
a5c0eb0e9c [cxx-interop] Fix lazy loading for result types.
When applying attributes, don't check the result type of the Swift function, so that we can get the benefits of lazy loading.
2021-10-25 14:40:22 -07: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
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
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
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
Josh Learn
f433ac2d58 Allow importing templated functions when template args do not appear
in the function signature by adding explicit metatype parameters to
the function signature.
2021-10-06 13:35:12 -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
0f56ea59e3 Merge remote-tracking branch 'origin/main' into rebranch 2021-09-24 09:33:57 -07:00
Zoe Carver
3e07369ede Merge pull request #39434 from zoecarver/lazy-pt6-class-template-dce
[nfc][cxx-interop] Remove dead code in `VisitClassTemplateDecl`.
2021-09-24 12:28:30 -04:00
Zoe Carver
b159a8f969 Merge pull request #39433 from zoecarver/lazy-pt5-factor-out-validation
[nfc][cxx-interop] Factor validation logic out into lower visitors.
2021-09-24 12:28:11 -04:00
zoecarver
c0a2c7819e [nfc][cxx-interop] Remove dead code in VisitClassTemplateDecl.
This is now handled in the namespace visitor. It will eventually be handled directly in the SILModulePrinter.

Refs #38675.
2021-09-23 15:52:33 -07:00
zoecarver
62ee63d69a [nfc][cxx-interop] Factor validation logic out into lower visitors.
This just moves the same logic around. It shouldn't modify any actual functionality.

Refs #38675.
2021-09-23 15:47:55 -07:00
swift-ci
11c0f355a6 Merge remote-tracking branch 'origin/main' into rebranch 2021-09-23 13:53:22 -07:00
zoecarver
d14281f643 [cxx-interop] Allow function templates with defaulted template type parameters to be called.
If a defaulted template type parameter is not used in the function's
signature, don't create a corresponding generic argument for that
template type. This allows us to call function templates with defaulted
template type parameters. This is very common in the standard library
for things like enable_if which is used to disable various
functions/overloads with SFINAE.

The biggest part of this change is going forward not all function
templates will be imported as generic functions in Swift. This should
work OK but we may discover there was some logic which only looked for
generic function when dealing with function templates.
2021-09-22 11:11:16 -07:00
swift-ci
a8dc9f7d6f Merge remote-tracking branch 'origin/main' into rebranch 2021-09-09 08:53:29 -07:00
Zoe Carver
f2f8bac056 Merge pull request #39134 from zoecarver/lazy-load-function-result-type
[cxx-interop] Lazily load the result of imported functions.
2021-09-09 11:44:21 -04: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
cb32b553de Merge remote-tracking branch 'origin/main' into rebranch 2021-09-04 11:32:57 -07:00
Hamish Knight
47754822c7 [CodeSynthesis] Adopt ArgumentList
Most of this should be fairly mechanical, the
changes in PlaygroundTransform are a little more
involved though.
2021-09-01 18:40:26 +01:00
swift-ci
f9db717379 Merge remote-tracking branch 'origin/main' into rebranch 2021-08-28 14:33:15 -07:00
Xi Ge
3616872c28 Merge pull request #39068 from nkcsgexi/73902734
ClangImporter: teach clang importer to import Clang SPI symbols and model them similarly as Swift SPIs
2021-08-28 14:20:25 -07:00
Xi Ge
36f25c3130 ClangImporter: teach clang importer to import Clang SPI symbols and model them similarly as Swift SPIs
For clang symbols marked with SPI_AVAILABLE, we add SPIAccessControlAttr to them so they will be
considered as SPIs in the AST. To be able to use all these symbols, we also add an implicit SPI import
statement for all clang modules. All clang SPIs belong to the same SPI group named "OBJC_DEFUALT_SPI_GROUP" because clang
currently doesn't support custom SPI group.

rdar://73902734
2021-08-28 11:11:09 -07:00
swift-ci
5fe1881a91 Merge remote-tracking branch 'origin/main' into rebranch 2021-08-27 21:53:32 -07:00
Rintaro Ishizaki
49547a5378 [NFC][Basic] Import llvm::isa_and_nonnull to 'swift' namespace
Just for convenicence.

* Replace `llvm::isa_and_nonnull` with imported `isa_and_nonnull`
* Repalce some `EXPR && isa<T>(EXPR)` with `isa_and_nonnull<T>(EXPR)`
2021-08-27 11:36:21 -07:00
swift-ci
0770c932e8 Merge remote-tracking branch 'origin/main' into rebranch 2021-08-14 20:13:37 -07:00
Egor Zhdan
4a414052c9 ClangImporter: NFC: simplify importFullName calls
This is just a cleanup of `importFullName` invocations, discussed here: https://github.com/apple/swift/pull/37695#discussion_r675859664

This change makes `importFullName` return a pair of a canonical & alternative names instead of having one of them passed as a parameter.
2021-08-11 23:08:54 +03:00
swift-ci
f40f2a5831 Merge remote-tracking branch 'origin/main' into rebranch 2021-07-29 15:52:41 -07:00
Ben Barham
0ccf43d4e4 Merge pull request #38688 from apple/add-available-to-getters
[ClangImporter] Add @available(*, renamed:) to imported async getters
2021-07-30 08:42:21 +10:00
swift-ci
ecd2566295 Merge remote-tracking branch 'origin/main' into rebranch 2021-07-29 05:53:06 -07:00
Hamish Knight
ebdae7ca00 Merge pull request #38504 from hamishknight/construction-site 2021-07-29 13:43:12 +01:00
Ben Barham
0389ea5b4e [ClangImporter] Add @available(*, renamed:) to imported async getters
The attribute was missing from functions with getters as their async
alternative. Only getters are imported like this, so no need to check
for the other accessors.

Resolves rdar://80612566
2021-07-29 15:07:23 +10:00
swift-ci
2d0de01eac Merge remote-tracking branch 'origin/main' into rebranch 2021-07-28 20:53:04 -07:00