Commit Graph

4049 Commits

Author SHA1 Message Date
Kavon Farvardin
9d65c9e81e enable move-only and move-only classes in production builds 2023-01-24 16:01:23 -08:00
Michael Gottesman
e2b5c03c77 [frozen-multi-map] Add the ability to "unfreeze" the multi-map so one can add incrementally more elements to the multi-map.
For those unfamiliar, this map is a vector of pairs that we stable sort by the
key when we "freeze" it so we can run map operations upon the keys. This allows
one to accumulate into the multi-map and then once one has finished
accumulating, perform these map operations.

While doing some work in the move checker, I thought I would need the ability to
incrementally update a multi-map by appending more entires. Due to the design,
supporting this is as simple as unfreezing the map. This results in one being no
longer able to run map operations without hitting an assert. When one freezes
again, the stable sort will put the new entries in the appropriate place in the
already sorted initial part of the array.

Turns out I didn't need this, but seemed useful, so I am upstreaming it.
2023-01-24 15:28:11 -08:00
swift-ci
57fbdaf64c Merge remote-tracking branch 'origin/main' into rebranch 2023-01-24 07:14:58 -08:00
swift-ci
ca1f3f7a54 Merge pull request #63179 from kavon/moveonly-structs-or-enums
Limit `@_moveOnly` to structs and enums
2023-01-24 07:05:24 -08:00
Erik Eckstein
87ed8b4dc3 Merge remote-tracking branch 'origin/main' into rebranch 2023-01-24 08:58:16 +01:00
Kavon Farvardin
1356694043 experimentally allow move-only classes
A lot of existing regression tests rely on there
being some form of move-only classes, despite
them being something that will not be available
to users (and not complete).

This change introduces a `MoveOnlyClasses`
experimental feature so that those tests don't
need to be fully rewritten just yet. You need to
include `-enable-experimental-feature MoveOnlyClasses` along with
`-enable-experimental-move-only` to get move-only classes.
2023-01-23 22:33:27 -08:00
Alexis Laferrière
a0ee5c5312 Merge pull request #63116 from xymus/deser-safety-by-default
[Serialization] Enable deserialization safety by default
2023-01-23 17:18:48 -08:00
Holly Borla
8b9be30783 [Macros] Add a new macro role for synthesized member macros. 2023-01-22 21:19:21 -08:00
Doug Gregor
bdf1183757 [Diagnostics] Add a swift-syntax diagnostic style
The SwiftDiagnostics module within swift-syntax has a diagnostic
pretty-printer that does a nice rendering of the source code with
diagnostics placed inside gaps between the code lines.
Introduce another `-diagnostic-style` argument, `swift-syntax`,
to bridge from the pretty-printed C++ diagnostics over to the
swift-syntax diagnostics engine.
2023-01-21 23:09:56 -08:00
Doug Gregor
31a3d8e329 Introduce infrastructure to dump generated source buffers into temporary files 2023-01-19 21:30:22 -08:00
Alexis Laferrière
af70cc5464 [Serialization] Enable deserialization safety by default
rdar://99495048
2023-01-19 10:50:55 -08:00
Alastair Houghton
5b348006cb [Basic] Fix TaggedUnion to work around VS2019 ICE.
MSVC doesn't like the `std::enable_if<>` in the second argument.
Since we already have a `template<>` just above, move it there.
2023-01-16 15:20:52 +00:00
swift-ci
d2d8b07634 Merge remote-tracking branch 'origin/main' into rebranch 2023-01-15 16:34:43 -08:00
Holly Borla
1b74d6cfcc [SourceManager] Distinguish between the various macro roles in
GeneratedSourceInfo::Kind.
2023-01-15 10:11:00 -08:00
swift-ci
e55fa383d6 Merge remote-tracking branch 'origin/main' into rebranch 2023-01-13 16:15:24 -08:00
Doug Gregor
91ee109c2f [Macros] Start expanding accessor macros attached to a storage declaration.
Accessor macros are attached macros (written with attribute syntax)
that can generate accessors for a property or subscript. Recognize
custom attributes that are accessor macros when written on a storage
declaration, and expand those macros.

This is very much a work in progress, and the result of the expansion
isn't yet parsed or wired into the AST.
2023-01-13 10:12:25 -08:00
swift-ci
a47a551761 Merge remote-tracking branch 'origin/main' into rebranch 2023-01-12 14:25:23 -08:00
Max Desiatov
7ccb605386 Basic/type_traits: use __is_identifier for some feature checks (#62993)
* Basic/type_traits: use `__is_identifier` for some feature checks

When building on Alpine with Musl `__has_feature(is_trivially_constructible)` does not work, even though `__is_trivially_constructible` is defined and `__has_trivial_constructor` is deprecated. Same for `__is_trivially_destructible` and `__has_trivial_destructor` respectively.

* Basic/type_traits: use `__has_feature` or `__has_keyword`

That potentially makes these checks more future-proof in case more edge cases are introduced on different platforms.
2023-01-12 22:08:06 +00:00
Alexis Laferrière
4507307b35 Merge pull request #62982 from xymus/deser-safety-step2
[Serialization] Misc prep for the deserialization safety feature
2023-01-12 13:42:28 -08:00
Max Desiatov
fe373aa971 Basic/type_traits: use __has_feature or __has_keyword
That potentially makes these checks more future-proof in case more edge cases are introduced on different platforms.
2023-01-12 16:30:58 +00:00
Max Desiatov
2be8bdd5ed Basic/type_traits: use __is_identifier for some feature checks
When building on Alpine with Musl `__has_feature(is_trivially_constructible)` does not work, even though `__is_trivially_constructible` is defined and `__has_trivial_constructor` is deprecated. Same for `__is_trivially_destructible` and `__has_trivial_destructor` respectively.
2023-01-12 15:37:01 +00:00
Alexis Laferrière
faeb226ac5 [Serialization] Update doc on EnableDeserializationRecovery
Integrate reviewer's comment in a previous PR.
2023-01-11 15:14:30 -08:00
swift-ci
a0dd2fd882 Merge remote-tracking branch 'origin/main' into rebranch 2023-01-11 14:06:36 -08:00
Doug Gregor
9e76023546 Add BuiltinCreateTaskGroupWithFlags feature and use it to guard the builtin 2023-01-11 13:47:28 -08:00
swift-ci
bafd157ddf Merge remote-tracking branch 'origin/main' into rebranch 2023-01-09 08:20:12 -08:00
Erik Eckstein
712fd7922b Merge remote-tracking branch 'origin/main' into rebranch 2023-01-09 08:48:47 +01:00
Michael Gottesman
b81fc00305 [frozen-multi-map] Add the ability to iterate through the internal storage of the map once we have been frozen.
The intention is that this can be used once we are no longer accumulating into
the multi-map.
2023-01-08 14:04:21 -08:00
Michael Gottesman
3bac57d9ac Merge pull request #62907 from gottesmm/pruned-liveness-fixes
[pruned-liveness] Make some small fixes that only are exposed when working with multi-bit code
2023-01-08 00:06:29 -08:00
Saleem Abdulrasool
9a7555cd70 Merge pull request #62868 from apple/maxd/has-trivial-constructor
include/swift/Basic: fix deprecation warnings
2023-01-07 08:49:33 -08:00
Alexis Laferrière
4e69160b92 Merge pull request #62886 from xymus/deser-safety-infra
[Serialization] Prepare the infrastructure for the deserialization safety feature
2023-01-06 21:08:24 -08:00
Michael Gottesman
4981527e2d [frozen-multi-map] Add the ability to determine if all values of all keys have been deleted from the mult-map.
This is useful to validate that a multi-map has been completely consumed as one
erases values from it.
2023-01-06 20:57:39 -08:00
Michael Gottesman
5bd2725c23 [basic] Add an operator<<(llvm::raw_ostream &os, const SmallBitVector &) implementation.
For some reason LLVM doesn't provide this. I have written a few versions of this
in the Swift codebase. Makes sense to factor it out before I make another one.
2023-01-06 20:57:39 -08:00
Alexis Laferrière
d1343c86fb [Frontend] Intro flags to control deserialization safety
Deserialization safety remains off by default at the moment.
2023-01-06 12:02:47 -08:00
Doug Gregor
514a05297e Drop the original buffer ID from GeneratedSourceInfo.
Nobody is using it, and this information is recoverable from the original
source range.
2023-01-06 11:17:29 -08:00
Doug Gregor
5c217bd17c Add source buffers pretty-printed for diagnostics to serialized diagnostics
When emitting a diagnostic that references a declaration that does not
itself have a source location (e.g., because it was synthesized or
deserialized), the diagnostics engine pretty-prints the declaration
into a buffer so it can provide caret diagnostics pointing to that
declaration.

Start marking those buffers as "generated source buffers", so that we
emit their contents into serialized diagnostics files. This will allow
tools that make use of serialized diagnostics to also show caret
information.
2023-01-06 11:17:29 -08:00
Max Desiatov
e5ab9b4ab0 include/swift/Basic: fix deprecation warnings
These are deprecation warnings
```
include/swift/Basic/type_traits.h:49:29: warning: builtin __has_trivial_constructor is deprecated; use __is_trivially_constructible instead [-Wdeprecated-builtins]
  static const bool value = __has_trivial_constructor(T);
                            ^
include/swift/Basic/type_traits.h:61:29: warning: builtin __has_trivial_destructor is deprecated; use __is_trivially_destructible instead [-Wdeprecated-builtins]
  static const bool value = __has_trivial_destructor(T);
                            ^
2 warnings generated.
```
2023-01-05 16:47:36 +00:00
swift-ci
5e59444588 Merge pull request #62835 from DougGregor/macros-experimental-in-prod
Allow the "macros" experimental feature to be enabled in production compilers
2023-01-04 13:50:48 -08:00
Joe Groff
3ffbc45329 Merge pull request #62743 from jckarter/mangler-structural-opaque-type-issues
Mangler: Fix substitution ordering when mangling opaque return types.
2023-01-04 10:50:58 -08:00
Doug Gregor
74a5b6adbd Allow the "macros" experimental feature to be enabled in production compilers
Now that we have a macro in the standard library, we need production
compilers to be able to build the standard library.

Fixes rdar://103868067.
2023-01-04 08:33:21 -08:00
Joe Groff
6263956225 Mangler: Fix substitution ordering when mangling opaque return types.
When a declaration has a structural opaque return type like:

  func foo() -> Bar<some P>

then to mangle that return type `Bar<some P>`, we have to mangle the `some P`
part by referencing its defining declaration `foo()`, which in turn includes
its return type `Bar<some P>` again (this time using a special mangling for
`some P` that prevents infinite recursion). Since we mangle `Bar<some P>`
once as part of mangling the declaration, and we register substitutions for
bound generic types when they're complete, we end up registering the
substitution for `Bar<some P>` twice, once as the return type of the
declaration name, and again as the actual type. This would be fine, except
that the mangler doesn't check for key collisions, and it picks
substitution indexes based on the number of entries in its hash map, so
the duplicated substitution ends up corrupting the substitution sequence,
causing the mangler to produce an invalid mangled name.

Fixing that exposes us to another problem in the remangler: the AST
mangler keys substitutions by type identity, but the remangler
uses the value of the demangled nodes to recognize substitutions.
The mangling for `Bar<current declaration's opaque return type>` can
appear multiple times in a demangled tree, but referring to different
declarations' opaque return types, and the remangler would reconstruct
an incorrect mangled name when this happens. To avoid this, change the
way the demangler represents `OpaqueReturnType` nodes so that they
contain a backreference to the declaration they represent, so that
substitutions involving different declarations' opaque return types
don't get confused.
2023-01-03 09:33:07 -08:00
swift-ci
990588a938 Merge remote-tracking branch 'origin/main' into rebranch 2023-01-03 07:24:05 -08:00
Doug Gregor
0c5436211c Merge pull request #62768 from DougGregor/macro-omnibus 2023-01-03 07:13:16 -08:00
swift-ci
1a625f2706 Merge remote-tracking branch 'origin/main' into rebranch 2023-01-03 01:13:18 -08:00
Doug Gregor
0407610162 [Macros] Don't parse the macro expansion buffer twice.
Each macro expansion buffer was getting parsed twice: once by
ParseSourceFileRequest (which is used by unqualified name lookup) and
once to parse the expression when type-checking the expanded macro.
This meant that the same code had two ASTs. Hilarity ensures.

Stop directly invoking the parser on macro-expanded code. Instead, go
through ParseSourceFileRequest *as is always the right way*, and dig
out the expression we want.
2023-01-02 21:22:04 -08:00
Pavel Yaskevich
529269946d [AST] Drop ResultBuilderASTTransform feature flag 2022-12-21 12:18:02 -08:00
Pavel Yaskevich
697dfbae96 [TypeChecker] Enable result builder AST transform by default 2022-12-21 10:31:30 -08:00
swift-ci
c4d4b9af7a Merge remote-tracking branch 'origin/main' into rebranch 2022-12-20 10:14:49 -08:00
Robert Widmann
3d3611356c Merge pull request #62675 from valeriyvan/SuccessorMap-missing-return
Fix bug missing return in operator=
2022-12-20 11:14:23 -07:00
swift-ci
c78bb3e289 Merge remote-tracking branch 'origin/main' into rebranch 2022-12-19 08:53:58 -08:00
Erik Eckstein
21d39ba524 use the new llvm::Optional API
fixes warnings in rebranch
2022-12-19 14:04:43 +01:00