Commit Graph

4080 Commits

Author SHA1 Message Date
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
Valeriy Van
e5d772d824 Fix bug missing return in operator= 2022-12-19 13:37:15 +02:00
swift-ci
7aff7ce661 Merge remote-tracking branch 'origin/main' into rebranch 2022-12-16 00:13:50 -08:00
Doug Gregor
33589de62f Experimentally emit diagnostics from the new Swift parser
Introduce the experimental feature `ParserDiagnostics`, which emits
diagnostics from the new Swift parser *first* for a source file. If
that produces any errors, we suppress any diagnostics emitted from the
C++ parser.
2022-12-15 21:24:44 -08:00
swift-ci
843e115364 Merge remote-tracking branch 'origin/main' into rebranch 2022-12-15 21:13:40 -08:00
Doug Gregor
f467ef4d37 [Source manager] Start tracking generated-source info in the source manager
Establish the relationship for generated sources, whether for macro
expansions or (via a small stretch) replacing function bodies with
other bodies, in the source manager itself. This makes the information
available for diagnostic rendering, and unifies a little bit of the
representation, although it isn't used for much yet.
2022-12-14 23:02:27 -08:00
swift-ci
dcfb01cfb3 Merge remote-tracking branch 'origin/main' into rebranch 2022-12-13 09:16:29 -08:00
Alexis Laferrière
276281ded8 Merge pull request #62476 from xymus/module-interface-export-as
[ModuleInterface] Ignore export_as in private swiftinterface
2022-12-13 09:12:44 -08:00
swift-ci
446f63fdc1 Merge remote-tracking branch 'origin/main' into rebranch 2022-12-13 07:53:58 -08:00
Alex Hoppen
58aaa4f111 Merge pull request #62522 from ahoppen/ahoppen/rename-completion
[IDE] Rename CodeCompletion to IDEInspection in cases where the code path no longer exclusively applies to code completion
2022-12-13 16:40:28 +01:00
swift-ci
8cd5fcdadd Merge remote-tracking branch 'origin/main' into rebranch 2022-12-13 03:33:22 -08:00
Ben Rimmington
620ba334fb [SE-0368] StaticBigInt: support older compilers (#62541) 2022-12-13 11:15:48 +00:00
Alex Hoppen
fe2ae72ad2 [IDE] Rename CodeCompletion to IDEInspection in cases where the code path no longer exclusively applies to code completion
The code completio infrastructure is also being used for cursor info now, so it should no longer be called code completion.

rdar://103251187
2022-12-13 11:41:05 +01:00
Alexis Laferrière
ab38752d33 [ModuleInterface] Ignore export_as in private swiftinterface
Introduce a new behavior when printing references to modules with an
`export_as` definition. Use the `export_as` name in the public swiftinterface
and the real module name in the private swiftinterface.

This has some limits but should still be an improvement over the current
behavior. First, the we use the `export_as` names only for references to clang
decls, not Swift decls with an underlying module defining an `export_as`.
Second, we always print the `export_as` name in the public swiftinterface,
even in the original swiftinterface file when the `export_as` target is likely
not know, so that generated swiftinterface is still broken.

This behavior is enabled by the flags `-enable-experimental-feature ModuleInterfaceExportAs`
or the `SWIFT_DEBUG_USE_EXPORTED_MODULE_NAME_IN_PUBLIC_ONLY` env var. We may
consider turning it on by default in the future.

rdar://98532918
2022-12-12 14:58:19 -08:00
swift-ci
7260f916bd Merge remote-tracking branch 'origin/main' into rebranch 2022-12-12 09:17:24 -08:00
Artem Chikin
44a8f99d19 [DependencyScanning] Count target variant, clang target, and sdk versions as components of scanning context hash
Resolves rdar://103093122
2022-12-09 09:24:44 -08:00
swift-ci
91ca44d294 Merge remote-tracking branch 'origin/main' into rebranch 2022-12-07 11:33:42 -08:00
Artem Chikin
990b95e9d8 [Dependency Scanning] Key into a global (shared) dependency scanning cache via context hash
Introduces a concept of a dependency scanning action context hash, which is used to select an instance of a global dependency scanning cache which gets re-used across dependency scanning actions.
2022-12-06 08:26:28 -08:00
swift-ci
efef52a86e Merge remote-tracking branch 'origin/main' into rebranch 2022-11-28 09:33:40 -08:00
Erik Eckstein
ab1b343dad use new llvm::Optional API
`getValue` -> `value`
`getValueOr` -> `value_or`
`hasValue` -> `has_value`
`map` -> `transform`

The old API will be deprecated in the rebranch.
To avoid merge conflicts, use the new API already in the main branch.

rdar://102362022
2022-11-21 19:44:24 +01:00