Commit Graph

2523 Commits

Author SHA1 Message Date
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
Evan Wilde
4046f61ba9 VK_RValue -> VK_PRValue
Clang updated the naming in commit
aef5d8fdc7d0d348125d5ecf4a13be5888eb1654 in order to be more consistent
with c++11 category naming.
2021-07-08 16:48:10 -07:00
Egor Zhdan
340c85503e Merge pull request #38121 from egorzhdan/cxx-init-static
C++ Interop: avoid adding static members to the value constructor
2021-06-29 22:09:55 +03:00
Egor Zhdan
0aebf79676 C++ Interop: avoid adding static members to the value constructor
Value constructors for C++ structs shouldn't try to initialize static members of the struct.
2021-06-28 21:35:08 +03:00
Doug Gregor
7a1ab7aa79 Merge pull request #37970 from DougGregor/clang-swift-attr-for-modifiers 2021-06-22 07:57:01 -07:00
Doug Gregor
6ba26292b1 [Clang importer] Import Swift declaration modifiers from swift_attr.
In addition to importing Swift attributes spelled with the C
`__attribute__((swift_attr("...")))`, also import declaration modifiers,
including `nonisolated`.

Fixes rdar://79402200.
2021-06-17 10:25:42 -07:00
Becca Royal-Gordon
05b9aecf3b Don’t crash from circular swift_name attributes
If a swift_name attribute’s context referred to the same declaration it was attached to, or a different declaration whose own swift_name referred to the current one, we would recurse infinitely and eventually overflow the stack. This commit makes us instead detect the cycle, diagnose it with a warning, and drop the affected declaration.

Fixes rdar://79370809.
2021-06-15 18:58:37 -07:00