Commit Graph

1572 Commits

Author SHA1 Message Date
Egor Zhdan
00b327f1ed [cxx-interop] Do not try linking with swiftstd
This fixes an ld warning:
```
ld: warning: Could not find or use auto-linked library ‘swiftstd’
```

`swiftstd` was renamed to `swiftCxxStdlib`. We were still trying to link with `swiftstd` for some time to allow building with hosttools and to keep the CI green, however a new toolchain was released since the module was renamed, so this is no longer needed.

rdar://107412807
2023-03-30 11:43:50 +01:00
Allan Shortlidge
98b4e79d62 IRGen: Implement 'complete' unavailable decl optimization.
Part of rdar://106674022
2023-03-27 11:40:54 -07:00
Joe Groff
df3f332f9d IRGen: Hide type metadata records for noncopyable types from discovery by existing runtimes.
We'd still like to try to be forwardly compatible with future runtimes
that do properly handle noncopyable types, so emit them in a separate section from
copyable type records for now. This should prevent `_typeByName` from letting
someone get a hold of a noncopyable type's metatype as a (copyable) `Any.Type` and
then trying to use it to copy uncopyable values.
2023-03-08 13:18:56 -08:00
Richard Wei
98c2a837d2 [Macros] Always visit macro-produced decls as auxiliary decls
Always use `Decl::visitAuxiliaryDecls` to visit decls produced by macros, including peer macros and declaration macros. Use name-driven expansion for peer macros. Remove `MacroExpansionDecl::getRewritten()`.

Also make `ExpandMacroExpansionDeclRequest` cache the buffer ID (similar to other macros) instead of an array of decls.
2023-03-04 23:48:21 -08:00
Mishal Shah
aced44a84b Merge pull request #63187 from apple/rebranch
Merge `rebranch` into `main` to support `stable/20221013` llvm-project branch
2023-03-03 11:01:34 -08:00
Mishal Shah
e256b56545 Merge branch 'main' into rebranch 2023-03-02 18:25:09 -08:00
Ellie Shin
1a5882e373 Merge branch 'main' into es-declctx 2023-03-02 15:54:23 -08:00
Ellie Shin
7d23db3646 Create PackageUnit class, and Package entries to DeclContext / ASTHierarchy
Previously enum AccessLimitKind was
added to distinguish access scopes b/t package and public while keeping
DeclContext null but it proved to be too limiting. This PR creates package specific entries for DeclContext and
ASTHierarchy. It create a new class PackageUnit that can be set as the parent DeclContext of ModuleDecl. This PR
contains addition of such entries but not the use of them; the actual use of them will be in the upcoming PRs.

Resolves rdar://106155600
2023-03-02 13:20:51 -08:00
Arnold Schwaighofer
c1d08fb719 IRGen: Rename the colocation section for type descriptor data to __constg_swiftt
To indicate this is constant data rather then code as the `textg` would
imply.
2023-03-02 10:54:42 -08:00
Arnold Schwaighofer
1dfc30eb1f Merge remote-tracking branch 'origin/main' into rebranch 2023-02-27 09:18:56 -08:00
Arnold Schwaighofer
43510bc1fd Merge pull request #63897 from aschwaighofer/colocate_type_descriptors
IRGen: Put type descriptors in their own section to collocated them
2023-02-25 13:09:07 -08:00
Dario Rexin
96d988a431 [Runtime] Move bytecode layout handling into runtime (#63901)
rdar://105904548
2023-02-25 10:18:45 -08:00
Arnold Schwaighofer
8a7b8dc39c IRGen: Put type descriptors in their own section to collocated them
rdar://104697150
2023-02-25 07:51:30 -08:00
Dario Rexin
a8d4d57f11 [IRGen] Generate compressed representation of value witnesses (#63813)
rdar://105837040

* WIP: Store layout string in type metadata

* WIP: More cases working

* WIP: Layout strings almost working

* Add layout string pointer to struct metadata

* Fetch bytecode layout strings from metadata in runtime

* More efficient bytecode layout

* Add support for interpreted generics in layout strings

* Layout string instantiation, take and more

* Remove duplicate information from layout strings

* Include size of previous object in next objects offset to reduce number of increments at runtime

* Add support for existentials

* Build type layout strings with StructBuilder to support target sizes and metadata pointers

* Add support for resilient types

* Properly cache layout strings in compiler

* Generic resilient types working

* Non-generic resilient types working

* Instantiate resilient type in layout when possible

* Fix a few issues around alignment and signing

* Disable generics, fix static alignment

* Fix MultiPayloadEnum size when no extra tag is necessary

* Fixes after rebase

* Cleanup

* Fix most tests

* Fix objcImplementattion and non-Darwin builds

* Fix BytecodeLayouts on non-Darwin

* Fix Linux build

* Fix sizes in linux tests

* Sign layout string pointers

* Use nullptr instead of debug value
2023-02-24 15:40:28 -08:00
swift-ci
6a6e06f04d Merge remote-tracking branch 'origin/main' into rebranch 2023-02-23 19:53:16 -08:00
Alex Lorenz
ee6017334c [interop] ensure we correctly handle copy constructor invokes 2023-02-22 15:46:19 -08:00
Alex Lorenz
355f00c5bd [interop] ensure that call to a C++ constructor traps on uncaught exception 2023-02-22 10:59:58 -08:00
Alex Lorenz
8998f9769a [interop] trap on uncaught C++ copy constructor exceptions 2023-02-22 10:59:53 -08:00
swift-ci
08bc6ec292 Merge remote-tracking branch 'origin/main' into rebranch 2023-02-17 12:35:58 -08:00
L-j-h-c
913dcd62b8 [Gardening] fix typos across docs and codebase
fix typos across docs and codebase
2023-02-17 23:55:16 +09:00
swift-ci
7c43a3c5a3 Merge remote-tracking branch 'origin/main' into rebranch 2023-02-02 06:35:07 -08:00
Egor Zhdan
06c963ba8e Merge pull request #62776 from buttaface/cxx
[cxx-interop][android] Exclude Android from the list of platforms to link against the swiftstd library
2023-02-02 14:24:15 +00:00
swift-ci
668dde7e39 Merge remote-tracking branch 'origin/main' into rebranch 2023-01-26 08:53:43 -08:00
Egor Zhdan
ee6b9b2a67 [cxx-interop] Disallow import std, require import CxxStdlib
`CxxStdlib` will now be the only accepted module name for the C++ standard library module in Swift.
2023-01-26 14:15:56 +00:00
swift-ci
e0b16dbdf4 Merge remote-tracking branch 'origin/main' into rebranch 2023-01-25 16:07:15 -08:00
Egor Zhdan
500873000b [cxx-interop] Link with CxxStdlib binary if it is available
The C++ standard library module `std` is being renamed to `CxxStdlib`, and `swiftstd` binary is being renamed to `swiftCxxStdlib`.
This change teaches IRGen to link with the newly renamed binary.
2023-01-24 19:06:14 +00:00
Erik Eckstein
87ed8b4dc3 Merge remote-tracking branch 'origin/main' into rebranch 2023-01-24 08:58:16 +01:00
Nuri Amari
0f266b8919 Merge pull request #63081 from apple/conditional-runtime-records-fix
Fix -conditional-runtime-records crash on @objc protocols
2023-01-21 10:31:08 -08:00
swift-ci
2e477fd38b Merge remote-tracking branch 'origin/main' into rebranch 2023-01-20 14:13:44 -08:00
Ellie Shin
37af51dc4c Merge branch 'main' into es-pkg-acl 2023-01-19 16:18:17 -08:00
Ellie Shin
1c66d02f92 Add package access level to enum AccessLevel
Resolves rdar://104198440
2023-01-19 15:54:18 -08:00
Nuri Amari
e2a95df9b3 Fix -conditional-runtime-records crash with @objc annotated protocols 2023-01-19 09:10:56 -08:00
swift-ci
d2d8b07634 Merge remote-tracking branch 'origin/main' into rebranch 2023-01-15 16:34:43 -08:00
Holly Borla
3f462f0f43 [Decl] Add MissingDecl to use for parser recovery. 2023-01-15 09:55:15 -08:00
swift-ci
a4d74d5716 Merge remote-tracking branch 'origin/main' into rebranch 2023-01-10 22:14:47 -08:00
Richard Wei
f17b7c48bf [Macros] Freestanding declaration macros
Add support for freestanding declaration macros.

- Parse `@declaration` attribute.
- Type check and expand `MacroExpansionDecl`.

Known issues:
- Generic macros are not yet handled.
- Expansion does not work when the parent decl context is `BraceStmt`. Need to parse freestanding declaration macro expansions in `BraceStmt` as `MacroExpansionDecl`, and add expanded decls to name lookup.
2023-01-10 19:09:11 -08:00
Erik Eckstein
712fd7922b Merge remote-tracking branch 'origin/main' into rebranch 2023-01-09 08:48:47 +01:00
Pavel Yaskevich
55a6b3442f [IRGen] RuntimeMetadata: Reference type descriptors indirectly when required
Type descriptors cannot always be referenced directly (i.e. when
a type is declared in a different module), so let's use
`getAddrOfLLVMVariableOrGOTEquivalent` facility that knows how
to handle that correctly.

Resolves: rdar://problem/103878515
2023-01-04 14:19:20 -08:00
Butta
a86b25aa84 [cxx-interop][android] Exclude Android from the list of platforms to link against the swiftstd library 2022-12-26 00:13:53 +05:30
swift-ci
f476abf4a1 Merge remote-tracking branch 'origin/main' into rebranch 2022-12-20 17:13:36 -08:00
Pavel Yaskevich
b83b0943b5 [SILDeclRef] RuntimeMetadata: Add a special kind for runtime attribute generator
A new `RuntimeAttributeGenerator` is used to reference runtime
attribute generator functions synthesized by SILGen.
`#function` magic literal points to the declaration that declaration
attribute is attached to.
2022-12-20 09:45:01 -08:00
Pavel Yaskevich
5442d30866 [IRGen] RuntimeMetadata: Emit runtime discoverable attributes section
Each entry relates an attribute declaration to a list of all
declarations it's associated with together with a generator
function to acquire instance of the attribute value.
2022-12-20 09:45:01 -08:00
swift-ci
7cec431480 Merge remote-tracking branch 'origin/main' into rebranch 2022-12-19 16:24:07 -08:00
Arnold Schwaighofer
5004cee9b0 Merge pull request #62686 from aschwaighofer/testing_debacle
IRGen: Don't treat internal but visible via testable import classes as having fragile layout
2022-12-19 16:08:03 -08:00
Arnold Schwaighofer
20ff4dfc57 IRGen: Don't treat internal but visible via testable import classes as having fragile layout
That does not work if there is a resilient class in the hiearchy from a
different module than the testable imported one.  Rather treat an
internal but testable imported class as having resilient metadata.

The scenario that does not work assuming we can build a fragile layout
is the following.

FrameworkA is resilient and defines a public class `Base` with a stored field.
FrameworkB is resilient and defines an internal class `Sub` that inherits from
the class `Base` in FrameworkA and adds some fields. FrameworkB is compiled
with enable-testing.
The test case testable imports FrameworkB and accesses a field in the
internal class `Base` from FrameworkB. The test case only has access to
FrameworkA's public swiftinterface file and therefore does not know
`Base`'s layout.  The layout computation for `Sub` cannot take the field
from `Base` into account and things fail silently.

rdar://103323275
2022-12-19 07:35:56 -08:00
swift-ci
e668a49808 Merge remote-tracking branch 'origin/main' into rebranch 2022-12-17 08:34:07 -08:00
Slava Pestov
5485e54ef9 IRGen: Remove unused function 2022-12-16 16:24:48 -05:00
swift-ci
2a6e9d30eb Merge remote-tracking branch 'origin/main' into rebranch 2022-12-14 19:54:28 -08:00
swift-ci
7631ac7210 Merge remote-tracking branch 'origin/main' into rebranch 2022-12-14 16:34:23 -08:00
Adrian Prantl
06a54432ab Sink isFixedBuffer into DebugTypeInfo and ensure the enclosed types aren't
emitted with the size of the fixed buffer.
2022-12-14 14:18:28 -08:00