Commit Graph

1369 Commits

Author SHA1 Message Date
Allan Shortlidge
b563dc0736 Frontend: Replace the abi magic value accepted by -target-min-inlining-version with a min magic value instead. The new value corresponds to the OS versions in which Swift was introduced. The introduction OS is a better floor for availability checking than the OS in which Swift became ABI stable because inlinable functions may reference clang declarations which have availability between Swift's introduction and ABI stability and framework developers ought to get diagnostics for unguarded use of those APIs in inlinable code. 2022-03-14 19:26:36 -07:00
Slava Pestov
95f122f105 RequirementMachine: Add -enable-requirement-machine-loop-normalization flag 2022-03-08 22:47:22 -05:00
Slava Pestov
a0b71e9a68 Enable -requirement-machine-abstract-signatures=verify by default 2022-03-07 23:20:41 -05:00
Allan Shortlidge
e25b822f7a Merge pull request #41673 from tshortli/inlining-availability-checking
Add -target-min-inlining-version to aid type checking for inlinable functions in resilient libraries
2022-03-07 17:30:59 -08:00
Becca Royal-Gordon
bbcd980aff Add flag for minimum inlining version 2022-03-04 10:54:52 -08:00
Andrew Trick
ab31239ace Add a comment about lexical lifetimes to CompilerInvocation.
Otherwise, it's hard for me to tell who's in charge of setting the
default.
2022-03-03 15:08:26 -08:00
Erik Eckstein
1dfb3b1a2a cross-module-optimization: be more conservative when emitting a TBD file.
If we are emitting a TBD file, the TBD file only contains public symbols of this module.
But not public symbols of imported modules which are statically linked to the current binary.
This prevents referencing public symbols from other modules which could (potentially) linked statically.
Unfortunately there is no way to find out if another module is linked statically or dynamically, so we have to be conservative.

Fixes an unresolved-symbol linker error.
rdar://89364148
2022-03-03 11:42:07 +01:00
Slava Pestov
e8d240699e RequirementMachine: Add fourth 'check' option to 'on'/'off'/'verify' flags
This compares the results like 'verify' and prints output if there is
a mismatch, but does not assert.
2022-02-26 23:04:29 -05:00
Slava Pestov
8e09ba8b45 RequirementMachine: Introduce 'concrete contraction' pre-processing pass before building rewrite system
See the comment at the top of ConcreteContraction.cpp for a detailed explanation.

This can be turned off with the -disable-requirement-machine-concrete-contraction
pass, mostly meant for testing. A few tests now run with this pass both enabled
and disabled, to exercise code paths which are otherwise trivially avoided by
concrete contraction.

Fixes rdar://problem/88135912.
2022-02-25 11:48:38 -05:00
Slava Pestov
48a882899b Merge pull request #40492 from slavapestov/rqm-enable-protocol-verify
RequirementMachine: Enable -requirement-machine-protocol-signatures=verify by default
2022-02-25 10:45:10 -05:00
Xi Ge
1115332ab9 ModuleInterface: add a frontend flag to skip printing import statement corresponding to a module name.
Related: rdar://63465931
2022-02-24 15:33:26 -08:00
Slava Pestov
0e600d1384 RequirementMachine: Enable -requirement-machine-protocol-signatures=verify by default 2022-02-24 14:26:08 -05:00
Pavel Yaskevich
8cfdb9999c Merge pull request #41436 from xedin/allow-specialization-from-default-expr
[TypeChecker] Allow inference from default expressions in certain scenarios (under a flag)
2022-02-24 08:57:42 -08:00
Karoy Lorentey
e24bb55abf Merge pull request #41449 from lorentey/custom-traps
[IRGen] Allow configuring a panic function to call instead of trapping
2022-02-21 12:46:33 -08:00
Pavel Yaskevich
cd61b35e37 [Frontend] Add a flag for experimental type inference from default expressions 2022-02-21 09:59:05 -08:00
Saleem Abdulrasool
d526dcf309 Merge pull request #41431 from compnerd/externally-consumed-internally
IRGen: internalize symbols with `-static`
2022-02-21 09:12:11 -08:00
Anthony Latsis
b0043966cd Merge pull request #40269 from AnthonyLatsis/assoc-inference-system
AssociatedTypeInference: Initial refactoring of abstract type witness inference
2022-02-20 15:51:58 +03:00
Saleem Abdulrasool
98bd2dba57 IRGen: internalize symbols with -static
This pipes the `-static` flag when building a static library into IRGen.
This should have no impact on non-Windows targets as the usage of the
information simply removes the `dllexport` attribute on the generated
interfaces.  This ensures that a library built with `-static` will not
re-export its interfaces from the consumer.  This is important to ensure
that the consumer does not vend the API surface when it statically links
a library.  In conjunction with the removal of the force load symbol,
this allows the generation of static libraries which may be linked
against on Windows.  However, a subsequent change is needed to ensure
that the consumer does not mark the symbol as being imported from a
foreign module (i.e. `dllimport`).
2022-02-18 19:42:08 +00:00
Doug Gregor
0215216c00 Add "disable" counterpart to -enable-experimental-opened-existential-types 2022-02-18 11:22:57 -08:00
Doug Gregor
196a4d2e4b SwiftOnoneSupport creates different specializations with opened existentials
Implicitly disable implicit opening of existentials for SwiftOnoneSupport
because it generates different specializations.
2022-02-18 11:22:57 -08:00
Doug Gregor
1e1b3427c3 Experimental support for implicitly opening existential arguments.
When calling a generic function with an argument of existential type,
implicitly "open" the existential type into a concrete archetype, which
can then be bound to the generic type. This extends the implicit
opening that is performed when accessing a member of an existential
type from the "self" parameter to all parameters. For example:

    func unsafeFirst<C: Collection>(_ c: C) -> C.Element { c.first! }

    func g(c: any Collection) {
      unsafeFirst(c)   // currently an error
                       // with this change, succeeds and produces an 'Any'
    }

This avoids many common sources of errors of the form

    protocol 'P' as a type cannot conform to the protocol itself

which come from calling generic functions with an existential, and
allows another way "out" if one has an existention and needs to treat
it generically.

This feature is behind a frontend flag
`-enable-experimental-opened-existential-types`.
2022-02-18 11:22:56 -08:00
Karoy Lorentey
2966dce3d9 [IRGen] Allow configuring a panic function to call instead of trapping
Add a new frontend option (called `-trap-function <name>`, similar to Clang’s existing `-ftrap-function`) that specifies a function to call instead of trapping.

When the option is used, the compiler will emit a call to the specified function every time it would have otherwise emitted a trap instruction. The function must have no parameters and it must never return.

rdar://89125883
2022-02-17 23:19:08 -08:00
Holly Borla
c2594d1338 [FrontendOptions] Remove the -enable-explicit-existential-types flag. 2022-02-17 17:54:59 -08:00
Doug Gregor
27056a0ed7 Enable SE-0341 "Opaque Parameter Declarations" by default.
This proposal has been accepted, so enable it by default and update
some diagnostics to stop implying that this feature cannot be used.
2022-02-17 13:57:45 -08:00
Anthony Latsis
ceb123b5e9 AssociatedTypeInference: Add -dump-type-witness-systems flag to enable debug output 2022-02-16 00:56:08 +03:00
Slava Pestov
e2e088e082 RequirementMachine: Remove merged associated types from completion 2022-02-07 18:57:45 -05:00
Slava Pestov
0060592b85 RequirementMachine: Add concrete nesting depth check
Configured with -requirement-machine-max-concrete-nesting= frontend flag.
2022-02-07 08:20:59 -05:00
Slava Pestov
634ca55764 RequirementMachine: Rework completion limits a bit
- Rename StepLimit to MaxRuleCount, DepthLimit to MaxRuleLength
- Rename command line flags to -requirement-machine-max-rule-{count,length}=
- Check limits outside of PropertyMap::buildPropertyMap()
- Simplify the logic in RequirementMachine::computeCompletion()
2022-02-07 08:20:59 -05:00
Nuri Amari
fda0b8053d Merge pull request #40903 from NuriAmari/default-diagnostics
Enable lazy ClangImporter diagnostics by default
2022-02-04 11:42:47 -05:00
Slava Pestov
aa67c8bf8a Parametrized => parameterized 2022-02-03 13:27:24 -05:00
Robert Widmann
f5b4092a32 Merge pull request #41172 from CodaFi/special-sauce 2022-02-03 09:19:07 -08:00
Kuba (Brecka) Mracek
ee7e04822c Add a -reflection-metadata-for-debugger-only flag that emits reflection metadata but does not link them from runtime data structures (#40853) 2022-02-03 05:53:31 -08:00
Robert Widmann
25ab410896 Implement (Sugared) Bound Generic Extensions
A scoped-down version of #39307. Implement extension of bound generic types. The important bit here is in TypeCheckGeneric where we now use the underlying type of a typealias and its associated nominal type decl when we're generating substitutions for the extended type.

Put this behind a new experimental flag

-enable-experimental-bound-generic-extensions

Resolves SR-4875
Resolves rdar://17434633
2022-02-02 17:05:23 -08:00
Kuba (Brecka) Mracek
17c5d6f0de Add a flag to disable compile-time preallocated instantiation caches (for type metadata and protocol conformances) (#41148) 2022-02-02 12:06:16 -08:00
Nuri Amari
7ec861fbd9 Enable lazy ClangImporter diagnostics by default
Replace the existing `-enable-experimental-clang-importer-diagnostics`
flag with an opt-out version entitled `-disable-experimentalc-clang-importer-diagnostics`.
Enable the beviour previously hidden behind the old flag by default.
2022-02-01 18:43:49 -05:00
Pofat
96231e2d5f Support -file-compilation-dir (#40735)
This PR adds a new flag -file-compilation-dir, which does the same thing as -ffile-compilation-dir in Clang.

swiftc -g -ffile-compilation-dir=. path/to/foo.swift gives us identical debug info paths regardless of what location we compiled the file from. It's useful to debug correctly using object files built on different machines in different locations.
There's also a long-existed TODO comment.

Resolves SR-5694
2022-01-27 20:56:10 -08:00
Doug Gregor
11a027714d Add frontend flag -enable-experimental-opaque-parameters 2022-01-26 14:47:12 -08:00
Slava Pestov
327a508648 Frontend: Add -enable-parametrized-protocol-types flag 2022-01-25 22:02:59 -05:00
Evan Wilde
794d0e0b9a Merge pull request #40832 from etcwilde/ewilde/async-top-level
A first pass at concurrency in top-level code
2022-01-21 13:24:51 -08:00
Richard Wei
59ad670c0c Merge pull request #40799 from rxwei/pairwise-buildblock
[ResultBuilders] `buildBlock(combining:into:)` for pairwise combination.
2022-01-19 17:11:38 -08:00
Richard Wei
b6e679f22c [ResultBuilders] buildBlock(combining:into:) for pairwise combination.
Allow a user-defined `buildBlock(combining:into:)` to combine subexpressions in a block pairwise top to bottom. To use `buildBlock(_combining:into:)`, the user also needs to provide a unary `buildBlock(_:)` as a base case. The feature is being gated under frontend flag `-enable-experimental-pairwise-build-block`.

This will enable use cases in `RegexBuilder` in experimental declarative string processing, where we need to concatenate tuples and conditionally skip captureless regexes.  For example:

```swift
let regex = Regex {
  "a" // Regex<Substring>
  OneOrMore("b").capture() // Regex<(Substring, Substring)>
  "c" // Regex<Substring>
  Optionally("d".capture()) // Regex<(Substring, Substring?)>
} // Regex<Tuple3<Substring, Substring, Substring?>>
let result = "abc".firstMatch(of: regex)
// MatchResult<(Substring, Substring, Substring?)>
```

In this example, patterns `"a"` and `"c"` have no captures, so we need to skip them. However with the existing result builder `buildBlock()` feature that builds a block wholesale from all subexpressions, we had to generate `2^arity` overloads accounting for any occurrences of captureless regexes. There are also other complexities such as having to drop-first from the tuple to obtain the capture type. Though these features could in theory be supported via variadic generics, we feel that allowing result builders to pairwise combine subexpressions in a block is a much simpler and potentially more useful approach.

With `buildBlock(_combining:into:)`, the regex builders can be defined as the following, assuming we have variadic generics:

```swift
enum RegexBuilder {
  static func buildBlock() -> Regex<Substring>
  static func buildBlock<Match>(_ x: Regex<Match>) -> Regex<Match>
  static func buildBlock<
    ExistingWholeMatch, NewWholeMatch, ExistingCaptures..., NewCaptures...
  >(
    _combining next: Regex<(NewWholeMatch, NewCaptures...)>,
    into combined: Regex<(ExistingWholeMatch,  ExistingCaptures...)>
  ) -> Regex<Substring, ExistingCaptures..., NewCaptures...>
}
```

Before we have variadic generics, we can define overloads of `buildBlock(_combining:into:)` for up to a certain arity. These overloads will be much fewer than `2^arity`.
2022-01-18 05:14:08 -08:00
Slava Pestov
3a92d2fc53 AST: Remove legacy GSB-based GenericSignature query implementation 2022-01-12 12:33:34 -05:00
Evan Wilde
130f5caf48 Add experimental-async-top-level flag
Protect this feature behind a feature flag until it's ready for
prime-time.
2022-01-11 11:04:43 -08: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
Alex Hoppen
669e3f34a6 Merge pull request #40155 from ahoppen/pr/improve-module-search-path-lookup
[Serialization] Improve module loading performance
2021-12-20 18:09:17 +01:00
nate-chandler
e31c155f78 Merge pull request #40555 from nate-chandler/copy_propagation/rename-disabled-flags
Clarified copy-prop/lexical-lifetime flags.
2021-12-16 15:28:26 -08:00
Nate Chandler
08bd7c5c99 Replaced -disable-copy-prop with multi-var.
Replaced the -disable-copy-propagation flag with
-enable-copy-propagation=false where the latter is a new multi-var
-enable-copy-propagation= which can take one of three values:
- true
- requested-passes-only
- false
2021-12-15 21:36:53 -08:00
Nate Chandler
e881e2accd Base LexicalLifetimes dflt on SILOpts::CopyProp.
Previously, the default value for SILOptions::LexicalLifetimes was based
on a copy propagation behavior (which can then be overridden by the
flags for lexical lifetimems) only when the copy propagation was
explicitly specified.  Instead, set base the default value for this
option (SILOptions::LexicalLifetimes) on the effective copy propagation
behavior (i.e. SILOptions::CopyPropagation) regardless of whether an
explicit behavior has been specified.

Doing so will ensure that the desired behavior occurs as the default
behavior for copy-propagation changes, but for now this change is NFC.
2021-12-15 21:36:46 -08: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
nate-chandler
660929dff5 Merge pull request #40539 from nate-chandler/copy_propagation/rename-options
[NFC] Tweaked SILOptions fields for copy propagation.
2021-12-14 07:56:04 -08:00