Commit Graph

250 Commits

Author SHA1 Message Date
David Ungar
7d637c856c Merge pull request #12335 from davidungar/primaryFilesMode-Inputs-rebased
NFC: First step (refactoring) towards speeding up compilation w/ >1 primary file
2017-10-10 12:55:55 -07:00
David Ungar
47ee930a50 git-clang-format'ed 2017-10-08 23:56:03 -07:00
David Ungar
c1821755de NFC: First step (refactoring) towards speeding up compilation by having multiple primary files: Creates new class, FrontendInputs, to encapsulate InputFilenames, InputBuffers, and PrimaryInput, which were formerly in FrontendOptions. Add new instance variable, Inputs, to FrontendOptions in order to hold FrontendInputs.
Encapsulate uses of the variables in FrontendInputs with intention-describing functions. Move some code that sets these variables into FrontendInputs and FrontendOptions classes.

Create new FrontendInputs class to encapsulate InputFilenames, InputBuffers and PrimaryInput, which were formerly in Frontend.

Includes one change in SwiftEditor.cpp to resolve a merge conflict.
2017-10-08 10:20:37 -07:00
Xi Ge
f2ef42baed [migrator] When renaming a function decl, we should use underscore to represent empty external argument label. rdar://34569243 (#12221) 2017-10-02 12:31:09 -07:00
Robert Widmann
b77f2c147c Parse Shared
Add parser support for __shared and __owned as type attributes.  Also, extend parser diagnostics and tests to account for the new type attributes.
2017-07-23 21:47:25 -07:00
Xi Ge
4b8097235f [migrator] Update API change data after fixing SR-5498. (#11092) 2017-07-20 20:13:52 -07:00
Robert Widmann
4411223156 [NFC] Switch some more of the frontend to params 2017-06-30 10:24:52 -07:00
Harlan
e89e7f58b2 [Parse] [Syntax] Simplify TupleTypeRepr parsing and add attributes for Syntax (#8298)
* Simplify TupleTypeRepr parsing

This patch introduces a TupleTypeReprElement struct that holds the
locations for all relevant bits of tuple elements. It removes the
NameLoc and UnderscoreLoc arrays from TupleTypeReprElement in favor of
holding each of these on TupleTypeReprElement. These extra bits of info
are required for full-fidelity representation in the Syntax library.

* Remove TupleTypeReprBitfields and move EllipsisLoc out of TrailingObjects

* Update users of TupleTypeRepr

* Don't resize the elts if we're going to push_back

* getType -> getElementType

* Move ellipsis back into TrailingObjects.

* Move NumElements into TupleTypeReprBitfields
2017-06-27 10:54:47 -07:00
Xi Ge
476534d1e2 migrator: handle qualified replacement for member reference expression. rdar://32845918 (#10593)
Previously, we only handle dot syntax call expression for qualified
replacement, i.e. changing from A.a to B.b. This patch teaches the tool
to handle the migration of member reference expression tool.
2017-06-26 15:47:17 -07:00
David Farler
789bd3749f [Migrator] Use toLowercaseWord to lowercase SetterToProperty changes
Post-commit review follow-up:
This works better for properties that were all-caps, such as `URL`.

Thanks @harlanhaskins for the tip!

rdar://problem/32845968
2017-06-26 12:53:15 -07:00
David Farler
71e38d85d4 [Migrator] Make sure to lowercase properties in SetterToProperty
Previously we were only stripping `set` from the name and not
lowercasing the property.

rdar://problem/32845968
2017-06-23 16:37:16 -07:00
David Farler
12ff3794bc [Migrator] Don't run AST passes when in Swift 4 or later
AST passes assume that you are migrating from a version earlier
than Swift 4, where declaration references and type names may be
unconditionally renamed if their USRs match.

For example, this can happen for TypeMemberDiffItem entries where the
Objective-C USR is the same in Swift 3 and Swift 4, but the type is
spelled differently in Swift 4. A concrete example of this is:

`NSDocumentTypeDocumentAttribute` (Swift 3) ->
  `NSAttributedString.DocumentAttributeKey` (Swift 4).

Although this declaration is imported differently in Swift 4, its
Objective-C USR is `c:@NSDocumentTypeDocumentAttribute` for both.

rdar://problem/32604558
2017-06-23 14:04:07 -07:00
David Farler
9c1fa89d41 [Migrator] Remove closure shorthand prefixing.
In https://github.com/apple/swift/pull/10414, some SE-0110 features
were backed out, so the Migrator no longer needs to add `$0` shorthand
prefixing.

rdar://problem/32907276
2017-06-21 14:25:53 -07:00
David Farler
177718bf56 [Migrator] Remove some now unnecessary tuple destructuring
Some changes for SE-0110 were backed out in
https://github.com/apple/swift/pull/10414, so the migrator no longer
needs to add its own tuple destructuring.

rdar://problem/32513074
2017-06-20 17:57:48 -07:00
David Farler
fc769ee4bf [Migrator] Add a README for lib/Migrator
This describes the purpose and internals of lib/Migrator.

NFC.
2017-06-15 14:14:22 -07:00
Xi Ge
e577ebbdbd migrator: update api diff data by using Xcode 9M136v. 2017-06-14 14:24:36 -07:00
David Farler
2b0e04869c [Migrator] Expand tuple destructuring to support tuple input types
The migrator pass that converts single-argument function input types
doesn't handle the case when the function input has a label and is
therefore a tuple. Expand it to handle that possibility.

rdar://problem/32477319
2017-06-14 14:21:51 -07:00
David Farler
b7ca27b38f [Migrator] Remove remap file for primary input at the start of migration
If a file is run through the migration workflow a second or third time,
but fails to compile in its current state in Swift 4, it might be possible
for the previous remap file to get picked up, resulting in the old changes
getting applied twice or at the wrong offsets. At the start of the migration,
proactively remove the remap file to prevent this.

rdar://problem/32545844
2017-06-14 14:21:51 -07:00
Xi Ge
fe22ae96b1 migrator: update API diff data again by using Xcode 9M136b since we now include moved static members. rdar://32466196 2017-06-14 14:21:51 -07:00
David Farler
c2876dfb69 [Migrator] Migrate x.toIntMax() to Int64(x)
These protocol methods were hard-obsoleted in Swift 4.

rdar://problem/32437759
2017-06-14 14:21:51 -07:00
David Farler
e55191f7d5 [Migrator] Don't take redundant replacements during AST Passes
We already had this functionality in the FixitApplyDiagnosticConsumer,
but we also need it in the AST passes because different entries in the
API diff data may drive identical fix-its, namely a general type rename,
which can occur anywhere a DeclRef appears, but also for function overrides'
parameter type changes, which are context specific.

rdar://problem/32431533
2017-06-14 14:21:51 -07:00
Xi Ge
807eaca7a1 [migrator] Update API diff data by using Xcode 9M136a. 2017-06-14 14:21:51 -07:00
David Farler
df45a9ba6b [Migrator] Don't add -aarch64-use-tbi twice
Setting up an invocation adds -aarch64-use-tbi if the target is for
AArch64. In the fix-it passes, we inherit the frontend options which
already has it from the driver passing it down to the frontend.

rdar://problem/32284152
2017-06-14 14:21:51 -07:00
Xi Ge
9be5635c2a [migrator] Update API change data by using Xcode 9M135p. 2017-06-14 14:21:51 -07:00
Xi Ge
88c698c399 [migrator] Update api diff data to xcode 9L135e 2017-06-14 14:21:51 -07:00
David Farler
4069d81e55 [Migrator] Turn off buggy line-level diff in diff-match-patch
This code is too clever to survive and is causing crashes in the
migrator. It doesn't appear to be providing a noticeable performance
benefit, so disable line-level diffing and just do a fine-grained
diff throughout.

rdar://problem/32281108
2017-06-14 14:21:51 -07:00
David Farler
6c08f802a6 [Migrator] Don't issue rewrites when diagnostics seen more than once
The clang::RewriteBuffer can do weird things when seeing multiple
replacements where the replacement text is one character longer or
one character shorter than the range it is replacing.

rdar://problem/32234525
2017-06-14 14:21:51 -07:00
David Farler
e12e077331 [Migrator] Add specific tests for migration to Swift.abs
rdar://problem/31070486
2017-06-14 14:21:50 -07:00
David Farler
970127b745 [Migrator] Add special-case migration for NSOpenGLGetVersion
This was added in the AppKit overlay as a part of general
AppKit API improvements for Swift 4.

rdar://problem/32178777
2017-06-14 14:21:50 -07:00
Nathan Hawes
07db112f0c [Migrator] Update appkit tests and overlay.json for recently added transformations. 2017-06-14 14:21:50 -07:00
Nathan Hawes
317f69157d [Migrator] Update overlay.json with config for Appkit SDK changes not picked up by the differ
Also add tests covering these API changes. Changes that the migrator doesn't currently support are commented out.
2017-06-14 14:21:50 -07:00
David Farler
6972e1a71e [Migrator] Shift standalone removals
Xcode has some interesting behavior w.r.t. standalone removal
entries. In the previous migrator, there was an adjustment for
that, so port that over.

rdar://problem/31976029
2017-06-14 14:21:50 -07:00
Xi Ge
af3a119c01 [migrator] Populate API change scripts using Xcode 9A131. 2017-06-14 14:21:50 -07:00
Nathan Hawes
1d05066891 [migrator] Fix remap entries getting merged incorrectly in some cases. Resolves rdar://problem/31892850. 2017-06-14 14:21:50 -07:00
David Farler
3765dcae44 [Migrator] Fix remap printing
- Don't include inserts in the offset calculation
- Fix colon placement when printing JSON
- Consolidate adjacent insert/removal pairs into a single replacement,
  as this is what the remap applier expects.

rdar://problem/31872288
2017-06-14 14:21:50 -07:00
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