Commit Graph

2529 Commits

Author SHA1 Message Date
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
Ben Barham
e7e9b57051 Replace @completionHandlerAsync with @available(*, renamed:)
Instead of a new attribute `@completionHandlerAsync`, allow the use of
the existing `renamed` parameter of `@available` to specify the
asynchronous alternative of a synchronous function.

No errors will be output from invalid names as `@completionHandlerAsync`
had, but if a function is correctly matched then it will be used to
output warnings when using the synchronous function in an asynchronous
context (as before).

Resolves rdar://80612731
2021-07-29 09:14:44 +10:00
Hamish Knight
72d4d9f1e9 [AST] Add some 'create' factory methods
This provides consistency with other AST nodes,
and will be useful for implementing ArgumentList
construction in the future.
2021-07-28 23:14:44 +01:00
Hamish Knight
c70f280e4a [AST] Add CallExpr::createImplicitEmpty
Add a convenience constructor for an implicit
nullary call. This will become more useful when
the argument parameter starts taking an
ArgumentList.
2021-07-28 23:14:43 +01:00
swift-ci
e25cb8a958 Merge remote-tracking branch 'origin/main' into rebranch 2021-07-28 12:17:04 -07:00
Egor Zhdan
e2985b64e8 Merge pull request #38618 from egorzhdan/cxx-mutating
C++ Interop: import const methods as non-mutating
2021-07-28 21:53:48 +03:00
swift-ci
7f01be19e6 Merge remote-tracking branch 'origin/main' into rebranch 2021-07-27 14:34:28 -07:00
Robert Widmann
a1b668b381 Merge pull request #38613 from CodaFi/extended-family-gathering
Nuke IgnoreNewExtensions From High Orbit
2021-07-27 14:32:39 -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
Robert Widmann
babe52f512 Nuke IgnoreNewExtensions From High Orbit
This flag was always a hack to get clients that were not properly
handling circular constructions (module loading, associated type
inference) to stop crashing. Technically, it is unsound, but by sheer
coinicidence of the structure of the name lookup requests and the cache
faulting here we have never observed that unsoundness in the wild.
2021-07-23 15:35:24 -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
swift-ci
aa831950b4 Merge remote-tracking branch 'origin/main' into rebranch 2021-07-19 07:36:06 -07:00
Egor Zhdan
60a195e972 Merge pull request #38439 from egorzhdan/cxx-string-npos
C++ Interop: improve skipping already imported struct members
2021-07-19 10:27:30 +03:00
Egor Zhdan
fc2dc6aa17 C++ Interop: improve skipping already imported struct members
This fixes the issue that prevents `std::string::size_type` from being imported into Swift: `size_type` is imported before its parent struct, and  we're skipping it when importing the struct afterwards.

This is caused by an out-of-line decl for `std::string::npos`:
```cpp
template<class _CharT, class _Traits, class _Allocator>
_LIBCPP_FUNC_VIS
const typename basic_string<_CharT, _Traits, _Allocator>::size_type
               basic_string<_CharT, _Traits, _Allocator>::npos;

```
When importing `npos`, we first import `size_type`, which triggers the issue.
2021-07-17 14:45:22 +03:00
Evan Wilde
c75d19845f Merge pull request #38326 from etcwilde/ewilde/swift-rebranch
[Swift Rebranch] Cherry-picking swift changes from next branch
2021-07-12 13:24:29 -07:00
Doug Gregor
06bbc70b3e Module printing and serialization support for @unchecked Sendable 2021-07-11 12:29:54 -07:00
Doug Gregor
29f5d7a64a [SE-0302] Implement '@unchecked Sendable' syntax.
Parse and provide semantic checking for '@unchecked Sendable', for a
Sendable conformance that doesn't perform additional semantic checks
for correctness.

Part of rdar://78269000.
2021-07-11 12:29:53 -07:00