Commit Graph

265 Commits

Author SHA1 Message Date
David Farler
8450d952bc [Migrator] Integrate diff-match-patch into the Migrator pipeline
After both the syntactic and fix-it passes have run, perform
a diff of the start and end states' texts and output the remap
file.

rdar://problem/30926019
2017-06-14 14:21:50 -07:00
Xi Ge
d234d96320 migrator: populate migrator data from Xcode 9A126. 2017-06-14 14:21:50 -07:00
Xi Ge
9e690bf501 migrator: Add API change data file for ios, tvos, and watchos. 2017-06-14 14:21:50 -07:00
Xi Ge
9f456b19a3 migrator: use the right method to get the location of return type. rdar://32545812
TypeLoc::getLoc() is not necessarily the start location of the type repr.
2017-06-02 15:17:24 -07:00
Xi Ge
0b8b0207e6 migrator: teach the tool to handle qualified replacement. rdar://32466196 2017-06-01 13:15:12 -07:00
Pavel Yaskevich
4d30bdb9c8 Merge pull request #9994 from xedin/rdar-32431736
[Diagnostics] Add a fix-it for optional to raw representable type conversion
2017-05-31 14:35:37 -07:00
David Farler
b419b4fdc6 Merge pull request #10007 from bitjammer/rdar-32433206-migrator-single-expr-closure-add-return
[Migrator] Add `return` keyword when adding temp bindings in single-e…
2017-05-31 14:18:56 -07:00
Pavel Yaskevich
c94fe94d5d [Diagnostics] Add a fix-it for optional to raw representable type conversion
Situations where there is a contextual RawRepresentable type is
used incorrectly would produce `<Type>(rawValue: )` fix-it only
in cases where neither or both sides of the expression are optional.
Let's fix that by adding a fix-it for optional to contextual raw
value type conversion.

Resolves: rdar://problem/32431736
2017-05-31 13:58:17 -07:00
David Farler
0a86e66f60 [Migrator] Add return keyword when adding temp bindings in single-expression closures
The migrator pass to add tuple destructuring that now needs to add a
`return` statement for closures that were once single-expression but are
no longer because of the added statement to do the binding.

rdar://problem/32433206
2017-05-31 13:37:35 -07:00
Xi Ge
824aaa11e2 swift-api-digester: detect the move of static members only.
This patch restricts the detection of moved members to be static members,
since only in this case we need to update qualified access to
them. The move of instance members will be either handled by rename or
we don't need to update anything at all.

Additionally, this patch introduces a sub-kind of type member diff item
called qualified replacement to describe the aforementioned case. However,
the migrator part has not started to honor this sub-kind yet.

rdar://32466196
2017-05-31 11:47:27 -07:00
Xi Ge
ee4293fea1 IDE Utils: For DeclNameViewer, we should use empty StringRef to represent empty argument label instead of using "_". (#9988) 2017-05-30 17:29:57 -07:00
practicalswift
57d0a407d1 [gardening] Fix spacing 2017-05-24 21:28:24 +02:00
Xi Ge
c7b4e36476 [migrator] Handle renaming from explicit argument label to empty argument label at call sites. rdar://32241559 (#9873) 2017-05-23 11:34:05 -07:00
Xi Ge
1019396663 [migrator] Handle getter function to property change in function overrides. (#9844)
We used to only migrate them in call sites, e.g. changing from
``p.getHeight()`` to ``p.Height``. However, with experimenting on more real-world
projects, we realize migrating overrides is equally important.

rdar://32265583
2017-05-22 16:11:53 -07:00
David Farler
09952ae4dd Merge pull request #9742 from bitjammer/rdar-32240138-crash-pre-fix-it-failed
[Migrator] Add null check when pre-fix-it passes fail
2017-05-18 15:24:08 -07:00
David Farler
d4c9eb1db7 [Migrator] Add null check when pre-fix-it passes fail
If code is irreparably broken when migrating, make sure to
check that the pre-fix-it compiler instance is `nullptr` and
bail if so.

rdar://problem/32240138
2017-05-18 14:26:10 -07:00
Nathan Hawes
33e78be29e Merge pull request #9711 from nathawes/rdar31969538-closure-body-migration
[Migrator] Migrate references to shorthand closure params (e.g. $0, $1) where affected by SE110
2017-05-17 16:11:55 -07:00
Nathan Hawes
5d60bfc75c [Migrator] Add doc comments and fix whitespace in TupleSplatMigratorPass.cpp 2017-05-17 15:31:10 -07:00
Nathan Hawes
63b40bdcd2 [Migrator] Migrate references to shorthand closure params (e.g. $0, $1) where affected by SE110
In Swift 3:
 1) a closure referring to $1 or above type checked against a function type that takes a single tuple argument with that arity
 2) a closure referring only to $0 (or $0.1 etc) type checked against a function type that takes multiple arguments
but neither compiles in Swift 4.

This patch migrates shorthand references for
  1) by prefixing "0." in front of the existing references, e.g. "$1" to "$0.1"
  2) by removing the leading 0. if one existing or substituting a tuple of the correct arity if it doesn't, e.g. "$0.1" to "$1" and "$0" to "($0, $1, $2)"

Resolves rdar://problem/31969538
2017-05-17 14:16:47 -07:00
David Farler
65e4ba7bb7 Merge pull request #9677 from bitjammer/rdar-32228948-migrator-add-objc-note-fixit-filter
[Migrator] Allow make_decl_objc diagnostic note into the FixitApplyDi…
2017-05-17 12:54:19 -07:00
David Farler
a46127a20e Allow make_decl_objc diagnostic note into the FixitApplyDiagnosticConsumer
This allows the migrator to pick up fix-its from notes such as:

“Argument of #selector refers to instance method '___' that is not
exposed to Objective-C”

Add some more testing for minimal/complete workflows, and upstream
the cross-file fix-it test.

rdar://problem/32228948
2017-05-17 12:13:59 -07:00
Argyrios Kyrtzidis
7cf46b0974 [migrator] Do proper lookup and avoid prefixing typeof(of:) if the only found name is the stdlib one.
rdar://32229317
2017-05-16 22:34:01 -07:00
David Farler
43094c6615 [Migrator] FixitApplyDiagnosticConsumer: Ignore diags with invalid SourceLocs
Some diagnostics showing up during migration may not have valid source
locations, so we obviously can't map that onto a buffer onto which we'd
apply a fix-it.

rdar://problem/32213595
2017-05-16 18:02:06 -07:00
Xi Ge
058d7f62e8 [migrator] Various quality improvement on type-hoist API migrations. rdar://32186526 (#9600) 2017-05-14 19:25:01 -07:00
David Farler
0baa7c6dd8 [Migrator] Migrate Static member abs function calls to Swift.abs
These are deprecated in Swift 3, but are hard obsoleted in Swift 4.

rdar://problem/31070486
2017-05-14 16:55:34 -07:00
Xi Ge
ff2622734e migrator: handle the special migration cases of NSOpenGLSetOption/NSOpenGLGetOption. rdar://32178753 (#9591) 2017-05-14 13:00:03 -07:00
Xi Ge
65b9043eb1 migrator: handle function hoist API changes and several its varieties. rdar://31234806 (#9544) 2017-05-12 21:34:06 -07:00
Xi Ge
fb77682b5a [Migrator] Add a stub for authored API change list to handle API changes that are not detected automatically. (#9477) 2017-05-10 21:51:25 -07:00
practicalswift
a42cb6c009 [gardening] Fix inconsistent headers 2017-05-10 22:53:59 +02:00
swift-ci
c352f98ae9 Merge pull request #9428 from practicalswift/gardening-20170509b 2017-05-09 15:01:08 -07:00
practicalswift
8c40c65c80 [gardening] Fix typos. 2017-05-09 21:50:04 +02:00
Nathan Hawes
0410f17c1b [Migrator] Fix optional types not being updated correctly in some cases
If the replacement type was a function type or protocol-constrained type (e.g.  'Class & Proto) and the existing type had a postfix ? or !, we weren't wrapping the replacement in parens. This would result in an incorrect/ambiguous new type. This patch wraps the replacement in parens if it contains an & or ->, the existing type has a trailing ? or !.

Resolves rdar://problem/32082269.
2017-05-09 12:08:13 -07:00
David Farler
0774db030f [Migrator] Separate AST Pass implementations
The SyntacticMigratorPass is getting Too Big To Fail and covers
multiple migrations. There was already an early exit to not run
the pass if APIDigesterDataStorePath wasn't supplied, so SE-0110
tuple splat fix-its weren't getting run. This manifested in Migrator
tests not printing migrated contents on Linux.

New: ASTMigratorPass
Renamed: SyntacticMigratorPass -> APIDiffMigratorPass
New: TupleSplatMigratorPass

These implementations are entirely hidden and can only be invoked
by a swift::migrator function.

rdar://problem/32025974
2017-05-05 23:35:13 -07:00
David Farler
f697075abb [Migrator] Add Swift. prefix to type(of:) expressions in Swift 3
This changed to be resolved by overload resolution in Swift 4, and so
can suddenly be shadowed by similarly named properties and functions
that are visible at the expression's location. When in Swift 3 mode, if
there is a visible declaration named "type", add the `Swift.` prefix to
disambiguate in Swift 4 mode.

rdar://problem/31997321
2017-05-05 15:49:39 -07:00
Argyrios Kyrtzidis
e3026b97e1 Merge pull request #9281 from akyrtzi/migrator-handle-tuple-mismatches
[migrator] Add an AST pass to handle tuple mismatches
2017-05-04 11:46:27 -07:00
Argyrios Kyrtzidis
1b6e001a19 [migrator] Add an AST pass to handle tuple mismatches
Migrates code that compiles fine in Swift 3 but breaks in Swift 4 due to
changes in how the typechecker handles tuple arguments.
2017-05-04 07:26:00 -07:00
practicalswift
a9c03845cc [gardening] Use consistent headers 2017-05-04 15:24:35 +02:00
practicalswift
d4b36a8949 [gardening] Fix spacing 2017-05-04 15:23:47 +02:00
David Farler
e92ad3bb96 Merge pull request #9197 from bitjammer/rdar-31926195-migrator-everyone-deserves-a-second-chance
[Migrator] Make performing a fix-it run return the instance used
2017-05-02 23:19:59 -07:00
David Farler
a2f48ff8c2 [Migrator] Make performing a fix-it run return the instance used
This CompilerInstance will be used if a fix-it run created an
error-free AST that we can continue to use in the AST passes.

rdar://problem/31926195
2017-05-02 21:37:17 -07:00
Nathan Hawes
0d97d55eae [migrator] Don't walk into user-specified (and possibly generic) type aliases when applying API type changes 2017-05-02 16:23:58 -07:00
Xi Ge
39c550fc40 [Migrator] Handle function decl renames. rdar://31766131 (#9157) 2017-05-02 10:53: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
Argyrios Kyrtzidis
40c89048ba [index] Make sure that we index implicit constructors
These can be explicitely referenced so we should index their definitions as well
2017-04-29 19:14:03 -07:00
David Farler
bf52ff032a [Migrator] Conservative and Minimal @objc inference workflows
Based on recommendations in SE-0160, there are two migration workflows:

- Conservative: Maintain @objc visibility that was inferred in Swift 3
  by adding @objc to all declarations that were implicitily visible to
  the Objective-C runtime. This is invoked in the migrator by adding the
  -migrate-keep-objc-visibility flag.
- Minimal: Only declarations that must be visible to Objective-C based
  on their uses (or in cases like dynamic vars) are migrated.

rdar://problem/31876357
2017-04-28 18:28:34 -07:00
Nathan Hawes
4ff254de97 Move canDeclProvideDefaultImplementationFor() from libIDE into libIndex 2017-04-27 23:23:45 -07:00
Nathan Hawes
8ad6aa4e0d [migrator] Add pass for API type changes
This handles optionality changes and type rewrites in function param and return types and constructor param and failability types.
Resolves rdar://problem/31766010
2017-04-27 22:19:52 -07:00
Xi Ge
14781598cb [Migrator] Handle getter/setter to property access migration. rdar://31766311 (#9083) 2017-04-27 16:33:57 -07:00
David Farler
d4cf06ab2a [Migrator] Only replace primary file with input buffer
In the Migrator, the AST passes (effectively syntactic edits only)
run before the fix-it passes. We try to reuse as much as possible
from the original CompilerInvocation, but we need to replace the
primary input. Nuking all of the inputs is a bit foolish :-).

rdar://problem/31858212
2017-04-27 10:30:28 -07:00
David Farler
bf37eb7f34 Merge pull request #9062 from bitjammer/migrator-remap-additional-output
[Migrator] Make remap file an additional output
2017-04-27 01:40:26 -07:00