Commit Graph

178 Commits

Author SHA1 Message Date
Saleem Abdulrasool
f12f0ccd01 test: adjust Migrator tests (NFCI)
This adjusts the test diffing to ignore the whitespace changes across
different platforms.  `raw_fd_ostream` will write out `OF_Text` files
with the platform's line endings, which may differ from the source
file's.
2020-01-13 18:45:45 -08:00
Slava Pestov
9626340d4b Sema: Remove unused -fix-string-to-substring-conversion flag 2019-03-14 22:08:43 -04:00
Xi Ge
2be1ca0c8a migrator: add ! to property access whose definition changes from nonnull to nullable. rdar://48090648 2019-02-14 15:28:52 -08:00
Karoy Lorentey
6af814d76c [test] Test new fix-it for NSObject.hashValue overrides 2019-01-23 19:44:01 -08:00
Argyrios Kyrtzidis
c472c90df2 Merge pull request #21888 from akyrtzi/migrate-index-where
[migrator] Migrate '.index(where:)' to '.firstIndex(where:)'
2019-01-15 15:36:45 -08:00
Argyrios Kyrtzidis
90f2207b70 [migrator] Migrate '.index(where:)' to '.firstIndex(where:)'
rdar://47296913
2019-01-15 14:32:51 -08:00
Xi Ge
f8dd31b8fa migrator/test: disable fixits while testing rename migration pass.
The migration under testing is entirely driven by migration scripts. Having
fixits enabled may cause red herring.
2019-01-15 11:42:54 -08:00
Xi Ge
c6a64a9a21 migrator: handle function's return type changes from nonnull to nullable. rdar://47265255
Adding exclamation brings an optional type back to its original nonnull
version.
2019-01-14 14:15:07 -08:00
Nathan Hawes
43c2f27783 [Refactoring][Migrator] Fix rename of callsites with a trailing closure argument
A label range of 0 length was being reported as the label of trailing closure
arguments, just before the opening '{'.

For the rename refactoring, this meant that if the corresponding parameter had
an external label (e.g. 'a') the occurrence would be treated as not matching the
expected symbol name, and so not be updated at all.

For the migrator, when renaming a function with an unlabelled closure for its
last parameter to have a label, it would incorrectly insert the new label in
front of the opening '{' on all of that function's callsites with trailing
closures.

Resolves rdar://problem/42162571
2018-12-19 16:24:14 -08:00
swift-ci
fad03f690f Merge pull request #21437 from nkcsgexi/mig-enhance 2018-12-19 13:44:16 -08:00
Xi Ge
83382c5f94 migrator: rename a property declaration if the framework property it overrides has been renamed. 2018-12-19 11:58:22 -08:00
Xi Ge
4164600bed migrator: set up placeholder migration scripts for swift 4.2 2018-12-18 11:49:14 -08:00
Xi Ge
97257c5d16 migrator: rename index(of:) to firstIndex(of:) for swift 5. 2018-12-17 15:38:16 -08:00
Mark Lacey
018498fb2f Merge pull request #16942 from bjhomer/bjhomer/optional-try-flattening
Flatten nested optionals resulting from try? and optional sub-expressions
2018-11-16 11:14:05 -08:00
BJ Homer
f166b0da3d Make the try? migration simpler and more reliable.
We were trying to get fancy rewriting cases where multiple 'if let' clauses were
used to unwrap a double optional, but in testing that turned out to be too
unreliable. Now we simply detect any 'try?' expressions whose behavior will change,
and add an explicit 'as OldType' to the expression, in order to preserve the original
behavior.
2018-11-14 01:10:00 -07:00
BJ Homer
c371c06450 Add basic tests for 'try?' migration. 2018-11-12 09:43:15 -07:00
Ted Kremenek
46510a5eba Bump compiler version to Swift 5.
Main pieces:

- Bump swift-version to 5
- Remove -swift-version 3 support
2018-11-06 14:38:55 -08:00
Xi Ge
87ed4b4488 [test] Remove Swift 3 flags from various tests. 2018-10-09 16:09:41 -07:00
Rintaro Ishizaki
203a253687 [Parse/Migrator] Drop Swift3 migration support for type(of:) (#17932)
In Swift3, shadowning type(of:) was impossible, because it was a parser
magic. In Swift4, type(of:) is resolved as normal function in stdlib so
it can be shadowed. 'TypeOfMigratorPass' was a targeted migrator pass
that prepend 'Swift.' to 'type(of:)' so that it refers Swift.type(of:)
stdlib builtin function.
2018-08-01 08:22:28 -07:00
Argyrios Kyrtzidis
7d1d0950cb [migrator] Handle AppKit protocol migrations
This is https://github.com/apple/swift/pull/18226 but with a fix for the test to be macos specific.
rdar://42480588
2018-07-27 15:43:29 -07:00
Karoy Lorentey
aff1b03b82 [migrator] Fix offset in no_duplicate_aarch64_use_tbi test
A recent commit caused an offset drift.

rdar://problem/42631862
2018-07-27 15:43:49 +01:00
Pavel Yaskevich
f0d1f0bc66 Revert "migrator: handle AppKit protocol migrations. rdar://42480588" 2018-07-27 00:04:23 -07:00
Xi Ge
a8d43cc344 migrator: handle AppKit protocol migrations. rdar://42480588 2018-07-26 16:57:48 -07:00
swift-ci
d684dacc1a Merge pull request #18197 from nkcsgexi/mig-test-mig-2 2018-07-24 17:18:47 -07:00
Xi Ge
d668d4d1fa migrator/test: remove swift 3 flag for several tests. 2018-07-24 16:28:44 -07:00
Xi Ge
fedf531b2a migrator/test: remove -swift-version=3 flag from the test. 2018-07-23 16:09:07 -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
Doug Gregor
945c09b1cc [Type checker] Improve diagnostics when an optional value is not unwrapped.
When we determine that an optional value needs to be unwrapped to make
an expression type check, use notes to provide several different
Fix-It options (with descriptions) rather than always pushing users
toward '!'. Specifically, the errors + Fix-Its now looks like this:

    error: value of optional type 'X?' must be unwrapped to a value of
        type 'X'
      f(x)
        ^
    note: coalesce using '??' to provide a default when the optional
        value contains 'nil'
      f(x)
        ^
          ?? <#default value#>
    note: force-unwrap using '!' to abort execution if the optional
        value contains 'nil'
      f(x)
         ^
         !

Fixes rdar://problem/42081852.
2018-07-13 11:02:04 -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
Mark Lacey
5e75b1ad3b Remove -swift-version 3 from a handful of tests and update them appropriately.
These are all tests that would otherwise fail if the expression type
checker support for Swift 3 is removed.

I've moved some of the code from deleted Migrator tests into new
Constraints tests that verify that we do not support the constructs.
2018-07-04 20:58:21 -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
Slava Pestov
b7d0a7931f Merge pull request #17321 from slavapestov/swift4-default-tests
Run tests with -swift-version 4
2018-06-20 07:37:57 -07:00
Doug Gregor
a66df57aaf [Mangling] Update SILGen and IRGen tests for mangling change. 2018-06-19 23:24:38 -07:00
Slava Pestov
5d2752f7d2 Run tests with -swift-version 4 by default
Some test now fail, so add an explicit -swift-version 3.
2018-06-19 23:24:19 -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
Mark Lacey
6fc63bc93f Merge pull request #16930 from rudkx/re-enable-wrap_optional
[Migrator] Re-enable wrap_optional.swift test.
2018-06-01 07:50:21 -07:00
Mark Lacey
01ae11769c [Migrator] Re-enable wrap_optional.swift test.
This had to be reworked a bit to deal with the fact that IUOs are no
longer a distinct type and there were uses of IUOs that are not
supported after SE-0054.

Fixes: rdar://problem/37040141
2018-05-31 14:43:11 -07:00
Nathan Hawes
42b22fbe38 [migrator] Add -api-diff-data-dir option to override the default location for the migrator's platform + version specific api diff json files
This is useful for testing the migrator with different versions of the api diff data.
2018-05-31 09:23:24 -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
Huon Wilson
ba150e9240 Merge pull request #16786 from huonw/tbdgen
More TBDGen: force-load, conformance witness details, test header clean-up, more purposeful handling of accessors.
2018-05-24 12:37:15 +10:00