Commit Graph

289 Commits

Author SHA1 Message Date
Joe Groff
b00ea61945 SILGen: Lower keypath references to other modules' properties and subscripts as external keypath components.
This way we'll link against the key path component the other module provides instead of making fragile assumptions about its current implementation. Since external keypath lowering isn't fully implemented elsewhere in the compiler, this is enabled behind a staging flag.

external keypath staging
2018-02-23 12:58:19 -08:00
Xi Ge
37f352fe41 sourcekitd: build Swift syntax tree more lazily than collecting parsed tokens. (#14578)
Before this patch, we have one flag (KeepSyntaxInfo) to turn on two syntax
functionalities of parser: (1) collecting parsed tokens for coloring and
(2) building syntax trees. Since sourcekitd is the only consumer of either of these
functionalities, sourcekitd by default always enables such flag.
However, empirical results show (2) is both heavier and less-frequently
needed than (1). Therefore, separating the flag to two flags makes more
sense, where CollectParsedToken controls (1) and BuildSyntaxTree
controls (2).

CollectingParsedToken is always enabled by sourcekitd because
formatting and syntax-coloring need it; however BuildSyntaxTree should
be explicitly switched on by sourcekitd clients.

resolves: rdar://problem/37483076
2018-02-13 16:27:12 -08:00
Mark Lacey
37009b0d8b [ConstraintSystem] Remove constraint propagation.
The current implementation isn't really useful in the face of generic
overloads. It has never been enabled by default, and isn't useful to
keep around if it is disabled. If we ever want to bring it back,
we know where to look!
2018-02-12 21:30:39 -08:00
Xi Ge
71af76a87e libSyntax: optionally emit diagnostics for unknown expressions and declarations. (#13973)
With more syntax nodes being specialized, we'd like this
straight-forward way to pinpoint unknown entities. This diagnostics
is only issued in -emit-syntax frontend action and swift-syntax-test
invocation.
2018-01-16 16:14:57 -08:00
Slava Pestov
6af8d18a00 IRGen: Remove -enable-class-resilience staging flag 2018-01-03 00:26:10 -08:00
Greg Parker
c677a5dc11 [IRGen][runtime] Prepare to change the is-Swift bit in class metadata. (#13595)
Swift class metadata has a bit to distinguish it from non-Swift Objective-C
classes. The stable ABI will use a different bit so that stable Swift and
pre-stable Swift can be distinguished from each other.

No bits are actually changed yet. Enabling the new bit needs to wait for
other coordination such as libobjc.

rdar://35767811
2017-12-22 00:52:00 -08:00
swift-ci
adf83617ec Merge pull request #13526 from DougGregor/remove-conditional-conformances-flag 2017-12-19 11:17:44 -08:00
Doug Gregor
5c831a71ee Revert "[SE-0143] Put conditional conformances behind an "experimental" flag."
This reverts commit b59c30c1af.
2017-12-18 22:54:31 -08:00
Ben Langmuir
93956eb34b [code-complete] Put call-pattern heuristics under a flag
The original hope was we could make these heuristics really good, but
since that is not currently in sight (and may never be), we want to be
able to turn them off.  For now, just plumb through an internal flag to
control the behaviour.  A future change will customize the behaviour in
SourceKit.

rdar://31113161
2017-12-15 13:23:44 -08:00
Graydon Hoare
3726e69852 [NamedLazyMemberLoading] Flip flag polarity: on by default, optionally off. 2017-12-01 16:52:25 -08:00
Arnold Schwaighofer
eba12a7c3e Revert "Finish and default-enable named lazy member loading" 2017-12-01 07:25:54 -08:00
swift-ci
7e6f7e1c04 Merge pull request #12843 from graydon/force-on-named-lazy-member-loading 2017-12-01 02:32:10 -08:00
Graydon Hoare
3de4297c91 [NamedLazyMemberLoading] Flip flag polarity: on by default, optionally off. 2017-11-30 22:01:05 -08:00
Ted Kremenek
e04c7fd00a Merge pull request #12964 from graydon/if-target-environment
#if targetEnvironment(simulator)
2017-11-28 19:39:44 -08:00
Doug Gregor
b59c30c1af [SE-0143] Put conditional conformances behind an "experimental" flag.
Conditional conformances aren't quite ready yet for Swift 4.1, so
introduce the flag `-enable-experimental-conditional-conformances` to
enable conditional conformaces, and an error when one declares a
conditional conformance without specifying the flag.

Add this flag when building the standard library (which will vend
conditional conformances) and to all of the tests that need it.

Fixes rdar://problem/35728337.
2017-11-28 16:01:51 -08:00
Graydon Hoare
3807b3fa1e [Parse] Add platform conditional targetEnvironment(simulator) 2017-11-28 13:51:01 -08:00
Xi Ge
6af5d3c0bf libSyntax: rename KeepTokensInSourceFile to KeepSyntaxInfoInSourceFile. 2017-11-03 18:39:01 -07:00
Doug Gregor
6007783fa5 [AST Verifier] Eliminate “sharding” of AST verification.
The only client of this (the parse_stdlib) tests didn’t need it and
are no longer using it.
2017-11-01 16:07:25 -07:00
Graydon Hoare
6bb5ce3d1e [NamedLazyMemberLoading] Add -enable-named-lazy-member-loading option 2017-10-20 22:48:42 -07:00
Adam Nemet
9b9805420d Add optimization remarks
This allows reporting successful and unsuccessful optimizations similar to
clang/llvm.

This first patch adds support for the
options -Rpass=<pass-name-regex> -Rpass-missed=<pass-name-regex>.  These allow
reporting successful/unsuccessful optimization on the compiler output for passes
specified by the regex.  I've also added one missed and one passed remark type
to the inliner to test the infrastructure.

Clang also has the option of collecting these records in an external YAML data
file.  This will be added in a later patch.

A few notes:
* The goal is to use this facility for both user-lever "performance" warnings
and expert-level performance analysis.  There will probably be a flag in the
future differentiating the verbosity.

* The intent is match clang/llvm as much as it makes sense.  On the other hand I
did make some changes.  Unlike in llvm, the emitter is not a pass which
simplifies things.  Also the remark class hierarchy is greatly simplified since
we don't derive from DiagnosticInfo.  We also don't derive from Diagnostic to
support the streaming API for arbitrary named-value pairs.

* Currently function names are printed mangled which should be fixed.
2017-10-20 12:41:37 -07:00
Calvin Hill
aee81d272f Add Initial platform support for Haiku. (#11583) 2017-09-22 21:06:56 -04:00
Joe Groff
2ba8f57514 Remove staging flag for unimplemented key path components.
All the originally-planned component kinds are now implemented.
2017-09-15 11:55:35 -07:00
Xi Ge
87ce54e3f2 Re-apply "Paser: IfConfigDecl should reflect the underlying source. rdar://34315827" 2017-09-12 12:59:25 -07:00
Xi Ge
2a07534bc1 Revert "Paser: IfConfigDecl should reflect the underlying source. rdar://34315827"
For test failure witnessed in bots: https://ci.swift.org/job/oss-swift-incremental-RA-osx/462/
2017-09-12 12:49:02 -07:00
Xi Ge
bfe6a64708 Paser: IfConfigDecl should reflect the underlying source. rdar://34315827 2017-09-12 11:58:49 -07:00
Pavel Yaskevich
fcd0069d8d [ConstraintSolver] NFC: Increase default shrinking termination threshold
We've found in practice that multiple different types of expressions
are still going to benefit from shrinking continuing even when it
couldn't simplify up to 10 sub-expressions.
2017-09-08 14:37:20 -07:00
Xi Ge
34e2aec662 Parser: use parser to generate a refined token stream to help syntax coloring. (#11809)
This patch allows Parser to generate a refined token stream to satisfy tooling's need. For syntax coloring, token stream from lexer is insufficient because (1) we have contextual keywords like get and set; (2) we may allow keywords to be used as argument labels and names; and (3) we need to split tokens like "==<". In this patch, these refinements are directly fulfilled through parsing without additional heuristics. The refined token vector is optionally saved in SourceFile instance.
2017-09-08 10:28:19 -07:00
Robert Widmann
75a83da03e Implement SE-0075: CanImport
This implementation required a compromise between parser
performance and AST structuring.  On the one hand, Parse
must be fast in order to keep things in the IDE zippy, on
the other we must hit the disk to properly resolve 'canImport'
conditions and inject members of the active clause into the AST.
Additionally, a Parse-only pass may not provide platform-specific
information to the compiler invocation and so may mistakenly
activate or de-activate branches in the if-configuration decl.

The compromise is to perform condition evaluation only when
continuing on to semantic analysis.  This keeps the parser quick
and avoids the unpacking that parse does for active conditions
while still retaining the ability to see through to an active
condition when we know we're moving on to semantic analysis anyways.
2017-08-28 18:35:06 -04:00
Slava Pestov
771584a269 AST/Basic: Add isSwiftVersionAtLeast() check
Recently support was added for '-swift-version 5' to the frontend.

Right now we only have an isSwiftVersion3() check which returns 'true'
if the version is 3, and returns 'false' if it is 4 or 5. This was used
during Swift 4.0 development to guard various legacy behaviors that we
wish to deprecate.

Going forward, when do not want to add isSwiftVersion4() and
isSwiftVersion5() checks, because they're too fragile; if a new
behavior is introduced in Swift 5 that we wish to disable in Swift 3
and Swift 4 mode, checking for isSwiftVersion5() is insufficient,
because eventually Swift 6 will roll around, and presumably one would
expect the new behavior to take effect in Swift 6 mode as well.

I think a better solution is a 'isSwiftVersionAtLeast()' check, which
checks if the major version number is greater than or equal to the
given value.

We could refactor the existing 'isSwiftVersion3()' checks to instead
do '!isSwiftVersionAtLeast(4)', but I'm going to hold off on doing that
for now.
2017-08-26 01:18:15 -07:00
Kuba (Brecka) Mracek
d046f3f959 Set _swift_reportFatalErrorsToDebugger to true by default and remove all the staging parts (frontend flag, irgen changes). (#11329) 2017-08-03 15:23:23 -07:00
Doug Gregor
469e9e08a5 SE-0157: Enable recursive protocol constraints by default.
We don't know if they work in general, but specific cases of recursive
protocol constraints are working, and enabling them doesn't break
anything.
2017-07-26 20:57:24 -07:00
Pavel Yaskevich
4f8872598b [ConstraintSolver] NFC: Add option to control early termination of shrinking phase
Currently we have a number of unsolved disjunctions hard-coded to 5,
which breaks some existing code by terminating shrinking too early.
This patch makes it a command-line option so users have control over
what that threshold can be.

Resolves: rdar://problem/33433595
2017-07-20 12:44:48 -07:00
Mark Lacey
ed23eb3761 Revert "SE-0157: Enable recursive protocol constraints by default."
This reverts commit afbdbae9d9.

Commit ded45a6e1c more than triples the
type checking time when building Swift.o, so I am going to revert that ,
and it looks like this needs to be reverted as well if that commit is
reverted.
2017-07-13 16:05:03 -07:00
Doug Gregor
afbdbae9d9 SE-0157: Enable recursive protocol constraints by default.
We don't know if they work in general, but specific cases of recursive
protocol constraints are working, and enabling them doesn't break
anything.
2017-07-13 13:01:11 -07:00
Doug Gregor
70b75491a0 SE-0157: Add a frontend flag -enable-recursive-constraints.
Introduce `-enable-recursive-constraints` to disable the error about
direct recursion within a protocol definition. The implementation of
recursive protocol constraints is incomplete, but might be useful for
experimentation.
2017-07-12 14:55:55 -07:00
Doug Gregor
f03685b6d0 Introduce a command-line option to limit the # of typo corrections.
Typo correction can be particularly expensive, so introduce a
command-line flag to limit the number of typo corrections we will
perform per type-checker instance. Default this limit to 10.

Addresses rdar://problem/28469270 to some extent.
2017-07-10 11:40:35 -07:00
Kuba (Brecka) Mracek
4b88da2a2c Use the debugger hook, reportToDebugger, for all calls to _swift_stdlib_reportFatalError[InFile]. Only do this when a hidden frontend flag, -report-errors-to-debugger, is used. (#10617) 2017-06-29 09:12:26 -07:00
Jordan Rose
5c1967397b Update and re-enable the diagnostics for unstable runtime names.
This time, the warnings only fire when the class in question directly
conforms to NSCoding. This avoids warning on cases where the user has
subclassed something like, oh, UIViewController, and has no intention
of writing it to a persistent file.

This also removes the warning for generic classes that conform to
NSCoding, for simplicity's sake. That means
'@NSKeyedArchiverEncodeNonGenericSubclassesOnly' is also being
removed.

Actually archiving a class with an unstable mangled name is still
considered problematic, but the compiler shouldn't emit diagnostics
unless it can be sure they are relevant.

rdar://problem/32314195
2017-06-05 17:32:26 -07:00
Jordan Rose
4a46d47a05 Disable diagnostics about problem NSCoding-conforming classes for now. (#9808)
Adoption so far shows that the criteria we set up here are too broad.
This is particularly problematic for subclasses of NS/UIView and the
like that might never be encoded at all.

rdar://problem/32306355
2017-05-20 14:26:30 -07:00
Joe Groff
faa6bc72f0 Sema: Reject unimplemented key path components during resolveKeyPathExpr.
This is a bit more robust and user-friendly than hoping more brittle recovery in SILGen or IRGen for unsupported components kicks in. rdar://problem/32200714
2017-05-15 16:10:59 -07:00
Jordan Rose
e0c248c932 Turn on deserialization recovery by default. (#9486)
I'm still leaving a -disable-deserialization-recovery flag in there
just in case.
2017-05-11 08:47:59 -07:00
Joe Groff
c398788efb Merge pull request #9303 from jckarter/enable-keypaths
Switch on key paths.
2017-05-05 09:13:31 -07:00
Joe Groff
cf6cc484c0 Switch on key paths.
Enabling the global subscript degrades some diagnostics (rdar://problem/31724211).
2017-05-05 08:32:41 -07:00
David Farler
be86bcac1d [Migrator] Suggest String <-> Substring conversions
Some APIs that expected a String now expect a Substring and vice
versa. To ease the transition, emit fix-its on conversion errors
between these types that the migrator can pick up.

When converting from Substring -> String, suggest wrapping in
`String.init`.

When converting from String -> Substring, suggest appending the
void subscript `[]`. (This isn't implemented yet so this is
hidden behind a flag).

This can possibly be generalized later when converting between
some sequence and its subsequence, such as Array and ArraySlice,
for example.

rdar://problem/31665649
rdar://problem/31666638
2017-05-04 16:40:56 -07:00
Doug Gregor
66b11cbc3d [SE-0160] Make deprecated @objc inference warnings opt-in.
The warnings about deprecated @objc inference in Swift 3 mode can be a
bit annoying; and are mostly relevant to the migration workflow. Make
the warning emission a three-state switch:

* None (the default): don't warn about these issues.
* Minimal (-warn-swift3-objc-inference-minimal): warn about direct
  uses of @objc entrypoints and provide "@objc" Fix-Its for them.
* Complete (-warn-swift3-objc-inference-complete): warn about all
  cases where Swift 3 infers @objc but Swift 4 will not.

Fixes rdar://problem/31922278.
2017-05-01 16:25:50 -07:00
Slava Pestov
e3b68e7bdd Remove -enable-experimental-subclass-existentials staging flag 2017-04-27 20:46:37 -07:00
Joe Groff
cdb54ccadf Put keypaths behind a flag. 2017-04-19 20:39:11 -07:00
John McCall
b233e872dc Fix the type-checker's recursive value type checking.
Track the types we've seen instead of the type declarations we've
passed through, which eliminates some holes relating to generic types.
Detect infinite expansions by imposing an arbitrary limit.

Fixes rdar://30355804
2017-04-12 15:55:45 -04:00
Slava Pestov
de323b5bef Sema: Update resolveType() for subclass existentials
If the -enable-experimental-subclass-existentials staging flag
is on, resolveType() now allows protocol compositions to contain
class types. It also diagnoses if a composition has more than one
superclass requirement.

Also, change diagnostics that talked about 'protocol composition'
to 'protocol-constrained type'.

Since such types can now contain a superclass constraint, it's not
correct to call them protocol composition.

"Protocol-constrained type" isn't quite accurate either because
'Any' has no protocols, and 'AnyObject' will have no protocols but
a general class constraint; but those are edge cases which won't
come up in these diagnostics.
2017-04-10 17:11:07 -07:00
Jordan Rose
e7d1027e8a Merge pull request #8580 from jrose-apple/enable-experimental-deserialization-recovery
[Serialization] Proof-of-concept: drop overriding methods if the base is missing
2017-04-10 13:57:33 -07:00