Commit Graph

266 Commits

Author SHA1 Message Date
Xi Ge
a8d43cc344 migrator: handle AppKit protocol migrations. rdar://42480588 2018-07-26 16:57:48 -07:00
Slava Pestov
5213f80e7e IDE: Remove uses of AbstractFunctionDecl::getParameterLists() 2018-07-22 20:56:56 -07:00
Xi Ge
c738e90a5b migrator: ensure we collect post-migration fixits from the compiler. rdar://40925061 2018-07-18 13:11:17 -07:00
Xi Ge
f83ccd6438 migrator: handle changed parameter declarations by introducing bridging local variables.
When users override a SDK function whose parameter types have been changed,
we should introduce a local variable in the body of the function definition
to shadow the changed parameter. Also, a proper conversion function should
be applied to bridge the parameter to the local variable.

rdar://41828411
2018-07-11 13:41:37 -07:00
Xi Ge
c40ebd1d2d migrator: support migration of raw representable initializer calls without explicit labels. rdar://41740103
Some raw representable struct from SDK can be initialized without
explicit labels (rawValue:). When their types have been changed to type
alias, we should migrate the initializer calls to the argument alone.
2018-07-03 11:44:21 -07:00
Xi Ge
8e0e779cc2 migrator: handle the composite change of updating type alias to raw-representable and rename the referenced variables simultaneously. rdar://41732485 2018-07-02 12:13:20 -07:00
Xi Ge
46a1142b7f Merge pull request #17644 from nkcsgexi/global-name
migrator: handle member variables change to global ones. rdar://41658300
2018-07-02 09:25:44 -07:00
Xi Ge
c23d1a89a4 migrator: ensure we update unresolved member access correctly to global names. rdar://41658300 2018-06-29 17:29:53 -07:00
Xi Ge
4ed9f9a9a6 migrator: support the migration from member variables to global ones. rdar://41658300 2018-06-29 16:35:51 -07:00
Nathan Hawes
50f9c94ac8 [migrator] Migrate UIApplicationMain
In Swift 4.2 the second parameter of UIApplicationMain exactly matches the type
of CommandLine.unsafeArgv so it can be called as below:

UIApplicationMain(CommandLine.argc, CommandLine.unsafeArgv, ...)

This is how it was intended to be in Swift 4 as well, but the types had
optionality differences, so callers instead had to do something like the below
example from the Firefox-iOS project:

let pointer = UnsafeMutableRawPointer(CommandLine.unsafeArgv).bindMemory(
    to: UnsafeMutablePointer<Int8>.self, capacity: Int(CommandLine.argc))
UIApplicationMain(CommandLine.argc, pointer, ...)

This migration simply replaces the the second argument with
CommandLine.unsafeArgv if the first argument is CommandLine.argc.

There is an open issue for providing a deprecated version with the old type so
we simply leave as is any callers that don't pass argc for the first argument.

Resolves rdar://problem/40045693.
2018-06-28 18:46:41 -07:00
Xi Ge
9a0196e991 migrator: avoid adding conversion functions when expression types change as well.
When inserting conversion functions around expressions, we should check
whether the type of the expression is a recognized name alias that is
known to be changed to raw-value representable type. We should avoid
inserting conversion functions in this case because doing so causes
build errors.

resolves: rdar://40463990
2018-06-25 14:44:58 -07:00
Nathan Hawes
f76c87acf8 [migrator] Upstream overlay3/4.json and associated tests.
These being downstream only made them easy to break (and they did).

Resolves rdar://problem/41353459
2018-06-22 18:36:31 -07:00
Xi Ge
859d918a78 Re-apply "[migrator] migrator: avoid inserting base name while renaming
if users' member access doesn't specify the base name. rdar://40373279"

Previously, we saw that unconditionally omitting type names can lead to
build errors (rdar://40458118). This revised fix omits type names only when
the new member name is identical to the old one.
2018-06-19 12:46:02 -07:00
Xi Ge
90303d12a6 migrator: handle the reversion of raw representable changes. rdar://39498127 2018-06-15 16:51:57 -07:00
Xi Ge
6433bc59e7 migrator: avoid migrating synthesized initializer calls. rdar://40860228 2018-06-11 15:30:38 -07:00
Xi Ge
55495ec267 migrator: avoid inserting round-trip conversion functions.
By postponing the insertion of conversion function calls, we can filter
out the expressions that require more than one helper function wrapper.

resolves: rdar://40979943
2018-06-11 15:08:26 -07:00
Xi Ge
7312fea3b2 migrator: emit error messages when migration scripts are missing.
We used to assert migration scripts exist. This patch further
decouples these scripts and the compiler by treating missing scripts
as a regular compiler error.

Related: rdar://40538097
2018-05-25 11:25:32 -07:00
Xi Ge
c8752d1570 [migrator] Revert "migrator: avoid inserting base name while renaming if users' member access doesn't specify the base name. rdar://40373279"
We've seen cases where using dot member names cause build errors. Thus, we revert this QOL fix.

rdar://40458118
2018-05-22 13:58:08 -07:00
Xi Ge
27b1621f90 migrator: avoid inserting base name while renaming if users' member access doesn't specify the base name. rdar://40373279 2018-05-18 12:36:10 -07:00
Xi Ge
6a83c51cf8 migrator: use raw type names from migration scripts instead of hard-coding them. 2018-05-16 17:56:48 -07:00
Nathan Hawes
61d7193814 [migrator] Treat the top-level argument parens of function types as an index level in the ChildIndexFinder
The APIDiffMigrator pass was ignoring them in all cases, but function type
argument parens are significant and the API differ includes them as an index
level in the generated json. This was causing a segmentation fault when trying
to migrate anything inside a function type argument. E.g given the function
below:

func member(_ x: ([Any]?) -> Void) {}

to migrate Any to Int, the API differ produces an index into the signauture of
1:1:0:0:0, meant to indicate Any. The APIDiffMigratorPass was interpreting this
incorrectly, however:

1: The type of first parameter of member: ([Any]?) -> Void
   Migrator agreed.
1: The type of the function type's argument: ([Any]?)
   Migrator saw this as [Any]? due to the parens not being an index level
0: The 0th child of the paren type: [Any]?
   Migrator saw the 0th child of the optional, [Any]
0: the 0th child of the optional type, [Any]
   Migrator saw the 0th child of the array, Any
0: the 0th child of the array type, Any
  Migrator tried to look up the 0th child of Any, causing a crash.

Resolves rdar://problem/40225476.
2018-05-15 12:05:21 -07:00
swift-ci
aa5cb47fec Merge pull request #16598 from nkcsgexi/migrator-arg-rename-hoist 2018-05-14 12:31:48 -07:00
Xi Ge
343d84ba35 migrator: handle argument renames when a global function is hoisted to a static member function. rdar://40145590 2018-05-14 11:33:25 -07:00
Xi Ge
0f71331d73 migrator: avoid inserting helper function call for nil expression. rdar://40173366 2018-05-11 17:24:52 -07:00
swift-ci
9aead6bff3 Merge pull request #16507 from nkcsgexi/avoid-reinsert-function 2018-05-10 13:54:57 -07:00
Xi Ge
b302bd30db migrator: avoid inserting helper functions if a function with the same name exists in the source file. rdar://40108285 2018-05-10 13:20:47 -07:00
Xi Ge
d89b716cf1 migrator: handle composite changes that're necessary to both side of an assignment expression. rdar://40106370 2018-05-10 12:08:00 -07:00
Xi Ge
ca3bf34daf Merge pull request #16479 from nkcsgexi/api-digester-type-change-diff
swift-api-digester: we should further detect if the declared type of a hoisted variable has been changed. rdar://40076924
2018-05-09 17:34:06 -07:00
Xi Ge
740e336e02 migrator: make sure we can handle the composite change of rename and string representable update. radr://40076924 2018-05-09 15:53:51 -07:00
Ben Langmuir
2e1f3afe05 Merge pull request #16460 from benlangmuir/mig-type-rename
[migrator] Handle simple renames for TypeDecl
2018-05-08 16:01:47 -07:00
Ben Langmuir
1bceacf7b8 [migrator] Handle simple renames for TypeDecl
Previously we only handle VarDecl, but it ought to work for types as
well.
2018-05-08 14:32:15 -07:00
Xi Ge
aef79e9b03 migrator: update type name in constructor call if the type becomes nested. rdar://40042252 2018-05-08 14:28:00 -07:00
Nathan Hawes
d5d058a768 [migrator] Only enable Swift 3 ObjC inference warnings when migrating from Swift 3
They were always enabled, meaning migrating from Swift 4 -> 4.2 would pick up
the associated fixits and add @objc unnecessarily in many places.

Resolves rdar://problem/39951671
2018-05-03 13:34:45 -07:00
Rintaro Ishizaki
fbad8891c5 [Migrator] Use Version::getCurrentLanguageVersion() as latest version 2018-04-27 15:36:22 +09:00
Rintaro Ishizaki
ec3a3df023 [Migrator] Use RewriteBuffer::InsertText() for applying insertion
Apparently, ReplaceText() on the same location replaces the replaced
text. Using InsertText() fixes the problem.

rdar://problem/39518867
2018-04-26 19:40:38 +09:00
Huon Wilson
18683f305d Merge pull request #15587 from huonw/minmax
[Sema] Perform name lookup in outer scopes in some cases involving conditional conformances
2018-04-20 22:33:07 +10:00
Xi Ge
3ee07be5ba migrator: handle the migration of string enum variable references. 2018-04-18 14:24:19 -07:00
Xi Ge
5db971de0e migrator: handle assignment of attribute dictionary and others.
When users' codebase assigns an attribute dictionary that used to be of
type [String: Any], this migration inserts a helper function call on the source of
the assignment to bridge the type.
2018-04-18 11:11:27 -07:00
Xi Ge
6a4df3e820 migrator: handle return value migration introduced by string enum changes.
This patch migrates the function call whose return type used to "String" and
now becomes "StringRepresentableStruct".
2018-04-17 15:18:33 -07:00
Xi Ge
7cf8bf4d55 migrator: correct a typo in the inserted helper function. NFC 2018-04-16 13:36:00 -07:00
Xi Ge
65eaccb2fa migrator: teach the tool to handle ArrayMemberUpdate and OptionalArrayMemberUpdate attributes emitted from swift-api-digester.
This bridges the function call arguments that used to be of type [String] and
now become [StringRepresentableStruct].
2018-04-16 13:30:53 -07:00
Xi Ge
a138744e45 migrator: teach the tool to handle OptionalDictionaryKeyUpdate attributes emitted from swift-api-digester.
For a function call used to take [String: Any]? as argument and now
takes [StringRepresentableStruct: Any]?, a helper function is inserted
to help the bridging of types.
2018-04-16 10:57:36 -07:00
Xi Ge
4c10f16c0e migrator: teach the tool to handle DictionaryKeyUpdate attribute on arguments.
When a user's code calls a function that used to take [String: Any] as
argument and now takes [StringRepresentableStruct: Any], this migration
inserts a helper function to convert the argument to the
expected type.
2018-04-13 16:55:19 -07:00
Xi Ge
4c4e4d2b79 migrator: handle simple attribute assignment and reference.
This patch migrates simple attribute assignment and reference when the
attribute used to be of type String and later became StringRepresentable struct.

Related: rdar://38192995
2018-04-12 11:54:28 -07:00
Huon Wilson
fe00f53e48 [AST] Use flags instead of booleans for UnqualifiedLookup. 2018-04-09 10:58:49 +10:00
Xi Ge
4705e0790c swift-api-digester: rename SDK nodes internally. NFC 2018-04-05 15:55:41 -07:00
Xi Ge
916e162b8d migrator: remove stale migration scripts and tests. (#15663) 2018-04-01 08:37:00 -07:00
Xi Ge
991cc77d48 migrator: teach the driver to support multiple migration script sets. (#15637)
To support migration from both Swift 3 and 4, this patch
teaches the driver to pick up the right set of migration scripts
according to the given Swift version. We also pushed some placeholder script
files for migration from Swift 4. This patch also brings the migrator
up-to-date by avoiding migration if the Swift version is already 4.2.
2018-03-31 12:37:49 -07:00
Huon Wilson
e307e54098 [AST] Explicitly track things marked __owned. 2018-03-08 12:36:24 +11:00
David Ungar
d3f16229c0 Tweaks to shorten performCompile* a bit more.
# Conflicts:
#	lib/FrontendTool/FrontendTool.cpp
2018-02-05 17:47:47 -08:00