Commit Graph

557 Commits

Author SHA1 Message Date
Slava Pestov
3a92d2fc53 AST: Remove legacy GSB-based GenericSignature query implementation 2022-01-12 12:33:34 -05:00
Nuri Amari
130f2de7fd Improve ClangImporter failure diagnostics
This patch introduces new diagnostics to the ClangImporter to help
explain why certain C, Objective-C or C++ declarations fail to import
into Swift. This patch includes new diagnostics for the following entities:

- C functions
- C struct fields
- Macros
- Objective-C properties
- Objective-C methods

In particular, notes are attached to indicate when any of the above
entities fail to import as a result of refering an incomplete (only
forward declared) type.

The new diangostics are hidden behind two new flags, -enable-experimental-clang-importer-diagnostics
and -enable-experimental-eager-clang-module-diagnostics. The first flag emits diagnostics lazily,
while the second eagerly imports all declarations visible from loaded Clang modules. The first
flag is intended for day to day swiftc use, the second for module linting or debugging the importer.
2022-01-02 12:43:59 -05:00
Slava Pestov
c1384f36a8 SIL: Add -disable-subst-sil-function-types flag to work around type lowering bugs 2021-12-15 12:14:34 -05:00
Holly Borla
69be7b17fc Merge pull request #40282 from hborla/existential-any
[SE-0335] Introduce existential `any`
2021-12-10 08:56:03 -08:00
Holly Borla
7cdda6dc80 [FrontendOptions] Add a frontend flag -enable-explicit-existential-types
to enable the 'any' keyword.
2021-12-09 09:26:12 -08:00
Slava Pestov
c1339240cd RequirementMachine: Add flags to enable and disable merged associated types
On by default, no change from current behavior. I'm going to try turning
this off (and hopefully ripping it out entirely) once I fix a few bugs.
2021-12-08 21:32:42 -05:00
Alex Hoppen
1739c23a9b Merge pull request #40158 from ahoppen/pr/cancel-code-completion
[SourceKit] Support cancellation of code completion like requests
2021-12-07 17:10:05 +01:00
Holly Borla
47b375fb3f Merge pull request #40361 from hborla/enable-structural-opaque-types
[SE-0328] Enable structural opaque result types.
2021-12-02 15:00:18 -08:00
Alex Hoppen
9042536323 [SourceKit] Move the cancellation flag from TypeCheckerOptions to ASTContext
We need to modify the pointer pointing to the cancellation flag when reusing an ASTContext for code completion. This is not possible by the previous design because `TypeCheckerOptions` was `const`. Moving the cancellation flag to `ASTContext` will also allow other stages of the compiler to honor a cancellation request.
2021-12-02 12:57:34 +01:00
Holly Borla
9196c9ad41 [FrontendOptions] Enable structural opaque result types and remove
the -enable-experimental-structural-opaque-types frontend flag.
2021-11-30 15:41:23 -08:00
Kuba (Brecka) Mracek
c89eca6c34 Enforce consistent usage of -experimental-hermetic-seat-at-link flag (#39986)
We've recently added the -experimental-hermetic-seal-at-link compiler flag,
which turns on aggressive dead-stripping optimizations and assumes that library
code can be optimized against client code because all users of the library
code/types are present at link/LTO time. This means that any module that's
built with -experimental-hermetic-seal-at-link requires all clients of this
module to also use -experimental-hermetic-seal-at-link. This PR enforces that
by storing a bit in the serialized module, and checking the bit when importing
modules.
2021-11-30 10:44:58 -08:00
Pavel Yaskevich
bc54bc6bb7 Revert "[TypeChecker] SE-0326: Enable multi-statement closure inference by default" 2021-11-29 17:26:08 -08:00
Slava Pestov
163293e6f9 RequirementMachine: Split up -requirement-machine-generic-signatures flag into -requirement-machine-{abstract,inferred}-signatures 2021-11-19 17:06:00 -05:00
Richard Wei
65bffd7ad7 Add _MatchingEngine and _StringProcessing modules.
These modules are part of the experimental declarative string processing feature. If accepted to the Standard Library, _StringProcessing will be available via implicit import just like _Concurrency, though _MatchingEngine will still be hidden as an implementation detail.

`_MatchingEngine` will contain the general-purpose pattern matching engine ISA, bytecode, and executor. `_StringProcessing` will contain regular expression and pattern matching APIs whose implementation depends on the matching engine..

Also consolidates frontend flag `-enable-experimental-regex` as `-enable-experimental-string-processing`.

Resolves rdar://85478647.
2021-11-19 09:27:33 -08:00
Pavel Yaskevich
b231cdeed4 [TypeChecker] SE-0326: Enable multi-statement closure inference by default 2021-11-15 18:32:40 -08:00
Michael Ilseman
2740e2707c Experimental Regex Strawperson (use Swift in the parser) (#40117)
[regex] Use Swift in the parser

Add in a strawperson use of Swift by the parser, for
future regex support.
2021-11-14 07:11:47 -07:00
Slava Pestov
d0a8abb533 RequirementMachine: Add -requirement-machine-generic-signatures flag
Just as with the others, this has three values: on, off, and verify.
Not hooked up for now.
2021-11-12 00:32:43 -05:00
Michael Gottesman
44bd180d85 [moveOnly] Add a frontend flag -enable-experimental-move-only to control usage of move only features.
These include _move and @_noImplicitCopy. I still need to wire up the parsing of
those behind this feature.

The reason that I am adding this now is that I am going to now need to make some
changes behind a feature flag and I have not yet needed to add one. The specific
reason I needed to add one here is to ensure that I properly guard inside _move
the call to Builtin.move so as to prevent a "cond_fail" incident.

P.S.: This work depends on experimental lexical lifetimes being enabled as well,
so I did that at the same time in this PR.
2021-10-27 18:45:33 -07:00
Nate Chandler
23a9a1d4c9 Moved lexical lifetime flag to SILOptions.
Previously, the flag was a LangOptioins.  That didn't make much sense because
this isn't really a user-facing behavior.  More importantly, as a member
of that type type it couldn't be accessed when setting up pass
pipelines.  Here, the flag is moved to SILOptions.
2021-10-13 13:47:44 -07:00
Slava Pestov
6ee74b35db RequirementMachine: Bump default step limit from 2000 to 4000 2021-10-11 23:06:19 -04:00
Slava Pestov
5fd48a08a1 Merge pull request #39629 from slavapestov/rqm-protocol-signatures
RequirementMachine: Wire up protocol requirement signature minimization
2021-10-09 22:30:05 -04:00
Slava Pestov
0e21d85325 RequirementMachine: Add -requirement-machine-protocol-signatures= flag
There are three settings, on, off and verify. Not hooked up quite yet.
2021-10-09 19:11:14 -04:00
Pavel Yaskevich
790b5499b9 Merge pull request #38577 from xedin/multi-statement-closure-type-checking
[TypeChecker] Incremental multi-statement closure type-checking (disabled by default)
2021-10-09 11:49:13 -07:00
Doug Gregor
e845af8fc2 Merge pull request #39550 from DougGregor/require-explicit-sendable
Add `-require-explicit-sendable` to warn about non-Sendable public types
2021-10-08 16:13:06 -07:00
Pavel Yaskevich
a1c0823f46 [AST] Add a flag to guard exprimental multi-statement closures feature 2021-10-08 10:08:00 -07:00
Alexis Laferrière
a34953ece9 [Sema] Intro flag to limit availability checks to the API
Intro the frontend flag `-check-api-availability-only` that limits
availability checking to the API and SPI. This mode doesn't check the
availability of non-inlinable function bodies and of non-ABI-public decl
signatures.

This mode goal is to check all that is printed in the swiftinterface
file. It should be used in place of the wider
`-disable-availability-checking` when generating an interface for
platforms with no binaries.

rdar://81679692
2021-10-07 17:14:55 -07:00
Doug Gregor
bc4ae04f1f Add -require-explicit-sendable to warn about non-Sendable public types
Introduce a compiler flag that warnings about any public types defined in
a module that are neither explicitly `Sendable` nor explicitly
non-`Sendable` (the latter of which has no spelling currently), which
is intended to help with auditing a module for Sendable conformances.
2021-10-06 12:30:57 -07:00
Richard Howell
140c02466a Add -prefix-serialized-debugging-options (#39555)
This commit adds a new frontend flag that applies debug path prefixing to the
paths serialized in swiftmodule files. This makes it possible to use swiftmodule
files that have been built on different machines by applying the inverse map
when debugging, in a similar fashion to source path prefixing.

The inverse mapping in LLDB will be handled in a follow up PR.

Second pass at #39138

Tests updated to handle windows path separators.

This reverts commit f5aa95b381.
2021-10-04 22:41:32 -07:00
Daniel Rodríguez Troitiño
d5246a5aa5 [windows][vs2017] Add missing <atomic> include.
Seems that VS2019 and other C++ standard libraries include <atomic> as
part of either <string> or <vector>, but not VS2017. When #38782 landed
a new usage of std::atomic started creating compilation problems in the
VS2017 builders (eg. https://ci-external.swift.org/job/oss-swift-windows-x86_64/8736/).

Including the <atomic> header solves the problem.
2021-10-04 17:59:23 -07:00
Saleem Abdulrasool
f5aa95b381 Revert "Add -prefix-serialized-debugging-options" (#39544)
Reverts #39138

This is causing a failure on Windows: https://ci-external.swift.org/job/oss-swift-windows-x86_64-vs2019/6659/consoleText
2021-10-01 11:19:44 -07:00
Richard Howell
58d67be645 Add ClangImporterOptions::getRemappedExtraArgs
This commit adds a function to remap the clang arguments passed
during compilation. This is intented to be shared across the
Swift compiler and LLDB to apply path remapping for debug info
paths.
2021-09-30 08:13:28 -07:00
Rintaro Ishizaki
fa04717bf5 Merge pull request #39395 from rintaro/sourcekit-completion-inits
[CodeCompletion] Remove two completion options from LangOptions
2021-09-29 09:52:51 -07:00
Xi Ge
0343108cec Merge pull request #39488 from nkcsgexi/enable-clang-spi
ClangImporter: don't import clang SPI attributes by default
2021-09-28 13:36:29 -07:00
Alex Hoppen
4521c99d56 Merge pull request #38782 from ahoppen/pr/sourcekit-cancellation
[SourceKit] Support cancellation of requests while an AST is being built
2021-09-28 20:08:14 +02:00
Xi Ge
a4b4b1fa65 ClangImporter: don't import clang SPI attributes by default 2021-09-28 10:46:27 -07:00
Egor Zhdan
e1c4ea50c8 Merge pull request #37806 from egorzhdan/clang-executable-path-reapply
ClangImporter: run Clang with a proper executable path (pt 2)
2021-09-24 21:46:03 +03:00
Slava Pestov
66299820f4 RequirementMachine: Enable by default 2021-09-23 23:15:48 -04:00
Alex Hoppen
7a80034e35 [SourceKit] Support cancellation of requests while an AST is being built
This commit refactors the way ASTs are being built in SourceKit and how `SwiftASTConsumer`s are served by the built ASTs. `SwiftASTManager.h` should give an overview of the new design.

This commit does not change the cancellation paradigm in SourceKit (yet). That is, subsequent requests with the same `OncePerASTToken` still cancel previous requests with the same token. But while previously, we were only able to cancel requests that haven’t started an AST build yet, we can now also cancel the AST build of the to-be-cancelled requests.

With this change in place, we can start looking into explicit cancellation of requests or other cancellation paradigms.
2021-09-23 11:53:45 +02:00
Rintaro Ishizaki
afc24dfd4b [CodeCompletion] Remove two completion options from LangOptions
"add inits to toplevel" and "call pattern heuristics" are only used in
code completion. Move them from LangOptions to CodeCompletionContext so
that they don't affect compiler arguments.
2021-09-22 16:49:50 -07:00
Alex Hoppen
998a7871f8 [Sema] Add cancellation flag to typechecker options
Once this flag is set, the type checker will bail out with a “expression to complex” error.
2021-09-22 12:01:00 +02:00
nate-chandler
67aab4245d Merge pull request #39303 from nate-chandler/lexical_lifetimes/respell_defined_as_lexical
[SIL] Changed spelling of lifetime flags.
2021-09-16 13:30:51 -07:00
Alexis Laferrière
2cd0d5e1d3 Merge pull request #37768 from xymus/swiftmodule-sdk
[Serialization] Restrict loading swiftmodule files to the SDK that built them
2021-09-14 08:53:49 -07:00
Nate Chandler
f833b68d3b [SIL] Changed spelling of lifetime flags.
Changed the frontend flag to -enable-experimental-lexical-lifetimes from
-enable-experimental-defined-lifetimes.

Changed the attribute on begin_borrow from [defined] to [lexical].
2021-09-14 08:49:30 -07:00
nate-chandler
e68b6a7f83 Merge pull request #39283 from nate-chandler/lexical_lifetimes/let/initial
[SILGen] Added [defined] lifetimes for lets behind flag.
2021-09-14 08:47:35 -07:00
Alexis Laferrière
c38d1773d2 [Serialization] Restrict loading swiftmodule files to the builder's SDK
Serialize the canonical name of the SDK used when building a swiftmodule
file and use it to ensure that the swiftmodule file is loaded only with
the same SDK. The SDK name must be passed down from the frontend.

This will report unsupported configurations like:

- Installing roots between incompatible SDKs without deleting the
swiftmodule files.
- Having multiple targets in the same project using different SDKs.
- Loading a swiftmodule created with a newer SDK (and stdlib) with an
older SDK.

All of these lead to hard to investigate deserialization failures and
this change should detect them early, before reaching a deserialization
failure.

rdar://78048939
2021-09-13 16:44:08 -07:00
Nate Chandler
d002471784 Added -enable-experimental-defined-lifetimes.
The new flag will guard work on the experimental implementation of
tracking lexical lifetimes in SIL.
2021-09-13 11:06:22 -07:00
Doug Gregor
599974367e Enable concurrency back-deployment in the compiler by default.
Remove the option that explicitly enables concurrency back-deployment,
and instead always enable its support in the compiler. Remove the use
of the extraneous CMake option as well.
2021-08-28 22:43:41 -07:00
Doug Gregor
f2995a3755 Optionally build the compiler and _Concurrency library for back deployment.
When enabling the build of the back-deployable concurrency library via
the build-script option `--back-deploy-concurrency`, also build the
compiler and (main) concurrency library to support older deployment targets.

Building the compiler for older deployment targets is effectively the
same as implicitly passing
`-Xfrontend -enable-experimental-back-deploy-concurrency`. That option
should probably go away.

Building the primary _Concurrency library for back-deployment means
setting the "SwiftStdlib 5.5" availability back to the earlier
deployment targets. This should have no effect on how the _Concurrency
library binary is built, but it does ensure that the right
availability annotations are in the _Concurrency module.
2021-08-26 08:49:44 -07:00
Doug Gregor
76c4ac8263 Add a temporary flag to stage in back-deployment of concurrency.
Add a frontend-only flag `-enable-experimental-back-deploy-concurrency`
to be used to stage in the back deployment of concurrency. At present,
all it does is lower the availability minimums for use of concurrency
features.
2021-08-23 12:55:58 -07:00
Slava Pestov
399a600e32 RequirementMachine: Add -debug-requirement-machine= flag to control debug output 2021-08-20 01:29:22 -04:00