Commit Graph

740 Commits

Author SHA1 Message Date
Doug Gregor
8b198d95be [Clang importer] Eliminate the use of lookupDirect when getting all members.
Loading of the members of a C(++) struct/class can occur while doing a
direct lookup, so triggering a second direct lookup inside there can
introduce a request-evaluator cycle. Reimplement this operation to be
more like the way we lazily populate Objective-C classes and protocols,
walking through the record members in order and importing their
variants, then adding those. This eliminates a bunch of extraneous
lookup work, keeps the members in order (see the test case change),
and eliminates the potential for cycles.
2021-12-03 15:43:57 -08:00
swift-ci
1e3397c855 Merge remote-tracking branch 'origin/main' into rebranch 2021-11-29 20:52:56 -08:00
Doug Gregor
16f32fd50a Eliminate support for @MainActor(unsafe) Clang attribute.
The `@MainActor(unsafe)` attribute could be provided for C declarations
via the Clang `swift_attr` attribute. However, this facility was never
used outside of tests, and has been superceded by `@MainActor` with the
inferred `@_predatesConcurrency`.
2021-11-29 15:05:18 -08:00
swift-ci
844c9e802c Merge remote-tracking branch 'origin/main' into rebranch 2021-11-28 21:53:03 -08:00
Becca Royal-Gordon
1695d61664 [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-19 11:34:01 -08:00
Becca Royal-Gordon
d2d786a76a [NFC] Add ClangImporter header diagnostic helper 2021-11-19 11:34:01 -08:00
swift-ci
8a3731cad8 Merge remote-tracking branch 'origin/main' into rebranch 2021-11-19 09:55:20 -08:00
Saleem Abdulrasool
4d44953691 Revert "Support __available__((swift_attr("@Sendable")))" 2021-11-19 07:40:24 -08:00
swift-ci
3a5bb8b2bc Merge remote-tracking branch 'origin/main' into rebranch 2021-11-19 01:33:47 -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
Doug Gregor
962c1148f9 Remove Clang Importer support for @_unsafeSendable/@_unsafeMainActor. 2021-11-18 09:53:54 -08:00
Ben Barham
11f28196bc Merge pull request #40168 from bnbarham/rebranch-failures
[rebranch] Fix compilation failures
2021-11-17 08:50:11 +10: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
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
Ben Barham
a6f99a08c4 [rebranch][ClangImporter] Update hashExtension to use HashBuilder
llvm-project updated `hashExtension` in
655bea4226b401a11164f99c6344e38d8742b8e4 to use a `HashBuilder` rather
than `hash_code`. Update use in ClangImporter.
2021-11-13 15:33:09 +10: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
swift_jenkins
602f3252e8 Merge remote-tracking branch 'origin/main' into next 2021-10-06 18:21:40 -07: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
swift_jenkins
839dc9b098 Merge remote-tracking branch 'origin/main' into next 2021-09-28 15:23:56 -07:00
Xi Ge
a4b4b1fa65 ClangImporter: don't import clang SPI attributes by default 2021-09-28 10:46:27 -07:00
swift-ci
f9db717379 Merge remote-tracking branch 'origin/main' into rebranch 2021-08-28 14:33:15 -07:00
swift_jenkins
0c8a0bfb30 Merge remote-tracking branch 'origin/main' into next 2021-08-28 14:21:16 -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
Stephen Canon
d3c7f02f78 Resolve merge conflicts for github main -> next automerger. 2021-08-06 12:33:00 -04:00
Arnold Schwaighofer
5a83172a55 Merge remote-tracking branch 'upstream/main' into rebranch 2021-08-05 12:04:56 -07:00
Slava Pestov
4e1c2b2e47 Serialization: Serialize the list of associated types in a protocol
This allows ProtocolDecl::getAssociatedTypeMembers() on a serialized
ProtocolDecl to avoid deserializing the full member list.
2021-07-31 00:25:22 -04:00
swift-ci
67017f7f6d Merge remote-tracking branch 'origin/main' into rebranch 2021-07-24 03:53:49 -07:00
swift_jenkins
88f497ca96 Merge remote-tracking branch 'origin/main' into next 2021-07-24 03:41:34 -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_jenkins
7c57f421f2 Merge remote-tracking branch 'origin/main' into next 2021-06-17 16:42:22 -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
gsecula
6f8a640c73 [RTTI] Updated ModuleFileExtension constructor
Constructor call of ModuleFileExtension has been updated to allow the
toolchain to build.
Previously this constructor call was passed a bogus value as a
workaround in response to clang change https://reviews.llvm.org/D96155.
The workaround was added in commit 2dfe3551a3.
Due to clang update https://reviews.llvm.org/D97702, ModuleFileExtension
no longer requires constructor parameters.
I was unable to verify this fix works due to other problems in next
branch.
2021-05-04 18:59:01 -04:00
swift_jenkins
dba122882b Merge remote-tracking branch 'origin/main' into next 2021-04-02 12:08:27 -07:00
Kavon Farvardin
ab47660d75 allow ObjC methods with completion handlers be imported as effectful properties
either as an `async` or `async throws` property, by marking it
with swift_async_name("getter:PROPERTY_NAME()") where `PROPERTY_NAME`
will be the name of the property it will be imported as.

This is in lieu of being imported as an async method. It's still
imported as an `@objc` method as well.
2021-04-02 08:33:22 -07:00
swift_jenkins
e5827a10f5 Merge remote-tracking branch 'origin/main' into next 2021-03-31 16:01:04 -07:00
Doug Gregor
f02a01e4f2 Add @_unsafeMainActor corresponding to @MainActor 2021-03-31 09:40:41 -07:00
Doug Gregor
ed7372b92b [Clang importer] Import @_unsafeSendable on C function/ObjC method params 2021-03-31 09:40:04 -07:00
Doug Gregor
b68f8555b3 [Concurrency] Introduce "unsafe" @Sendable and @MainActor parameters.
Introduce the notion of "unsafe" @Sendable parameters, indicated by the
hidden @_unsafeSendable parameter attribute. Closure arguments to such
parameters are treated as @Sendable within code that has already
adopted concurrency, but are otherwise enert, allowing them to be
applied to existing concurrency-related APIs to smooth the transition
path to concurrency.

Additionally, introduce the notion of an "unsafe" @MainActor closure,
for cases where we have determined that the closure will execute on
the main actor but it (also) isn't part of the type system.

Pattern-match uses of the Dispatch library's DispatchQueue to infer
both kinds of "unsafe" as appropriate, especially (e.g.) matching the pattern

  DispatchQueue.main.async { ... }

to treat the closure as unsafe @Sendable and @MainActor, allowing such
existing code to better integrate with concurrency.

Implements rdar://75988966.
2021-03-31 09:40:03 -07:00
swift_jenkins
7f49cd955a Merge remote-tracking branch 'origin/main' into next 2021-03-30 13:01:09 -07:00
Egor Zhdan
d0879b9e3b Merge pull request #36365 from egorzhdan/cxx-operator-subscript
C++ Interop: import subscript operators
2021-03-30 22:57:44 +03:00
Arnold Schwaighofer
027119fecb Merge remote-tracking branch 'upstream/main' into next 2021-03-29 12:33:25 -07:00
Doug Gregor
5f71e52146 [Clang import] Apply main-thread annotations from parameters to types.
Import a main-thread annotation on a function/method parameter in
(Objective-)C as a `@MainActor` function type.
2021-03-24 22:28:29 -07:00
Robert Widmann
d6d9db3ef6 Merge pull request #34871 from compnerd/noiam
Importer: remove `ImportAsMember` inference support
2021-03-22 17:45:08 -07:00
swift_jenkins
263d035960 Merge remote-tracking branch 'origin/main' into next 2021-03-22 13:40:46 -07:00
Saleem Abdulrasool
714eaefc78 Importer: remove ImportAsMember support
This functionality is not actively in use and the last usage of this has
been removed.  Remove the infrastructure that is no longer in need.
2021-03-22 08:53:56 -07:00
Egor Zhdan
586c675286 C++ Interop: import subscript operators
This change adds support for calling `operator[]` from Swift code via a synthesized Swift subscript.

Fixes SR-12598.
2021-03-21 19:25:41 +03:00
Doug Gregor
4ae526284b [Clang importer] Don't trivially infinitely recurse 2021-03-20 21:01:49 -07:00
Doug Gregor
e316a8ef90 [Importer] While pretty-printing decls for diagnostics, don't emit diagnostics.
The diagnostics system doesn't allow a diagnostic to be emitted while
another diagnostic is in flight. Doing so will cause an assertion in
the diagnostics machinery.

There's a longstanding cycle here when diagnostics emission
pretty-prints declarations that are imported from a Clang module, and
the Clang Importer emits a diagnostic. Squash this cycle forcefully,
dropping the diagnostic that the Clang importer would emit.
2021-03-19 09:33:55 -07:00