Commit Graph

265 Commits

Author SHA1 Message Date
David Ungar
a9819b6e60 Renaming FrontendInputs -> FrontendInputsAndOutputs
Fix comment in ArtsToFrontendOptionsConverter re getOutputFilenamesFromCommandLineOrFilelist
2018-01-30 18:54:38 -08:00
Andrew Breckenridge
e434c2461c [libMigrator] Generalize CMake symlink to work on Windows
This fixes a bug found while building Swift for Windows. The CMake invocation
assumed that the host system had a utility called `create_symlink`. That
assumption breaks down on Windows, where `copy` is the equivalent tool.
2018-01-30 10:39:22 -08:00
David Ungar
ec2a9573cc Rename FrontendInputs::AllFiles to AllInputs, getAllFiles to getAllInputs, etc. 2018-01-23 14:01:15 -08:00
David Zarzycki
408bf0d840 [AST] NFC: Migrate CompoundIdentTypeRepr to llvm::TrailingObjects 2017-12-30 10:56:37 -05:00
Pavel Yaskevich
4885fd4203 [Mangling/ABI] NFC: Fix Migrator tests to reflect label mangling changes 2017-12-18 15:45:50 -08:00
David Ungar
a2dca04092 Trivial changes 2017-12-11 22:58:57 -08:00
David Ungar
c1f81867d7 Merge pull request #13268 from davidungar/PR3A-rb
FrontendInputs data structure redo, rebased.
2017-12-11 20:44:10 -08:00
David Ungar
60827b4be3 Rename accessors to InputFile data. 2017-12-08 12:57:32 -08:00
David Ungar
28b206008f FrontendInputs data structure redo.
- Outlaw duplicate input files, fix driver, fix tests, and add test.
- Reflect that no buffer is present without a (possibly pseudo) named file.
- Reflect fact that every input has a (possible pseudo) name.
- Break up CompilerInstance::setup.

Don't bail on dups.
2017-12-05 17:28:03 -08:00
Rintaro Ishizaki
08ef4e324f [CMake] Add swift-syntax-generated-headers to the global dependencies 2017-12-05 17:03:12 +09:00
Nathan Hawes
f3e9685d88 [migrator] Fix missed dollar arg migration in closures relying on implicit destructuring of tuple type arg.
func foo(_: ((Int, Int)) -> Bool) {}
foo({ $0 > $1 }) // doesn't need migration
let x: ((Int, Int)) -> Bool = { $0 > $1 } // but this does
func bar() -> ((Int, Int)) -> Bool {
  return {$0 > $1} // and this does
}
2017-12-04 11:33:36 -08:00
Rintaro Ishizaki
183a7c66f2 [CMake] Add dependencies for swift-syntax-generated-headers (#13203)
rdar://problem/35725453
2017-12-01 19:37:27 +09:00
David Ungar
26537ea26c Address Jordan’s comments:
- Also be consistent about has vs have for Input predicates

Fix bug.
2017-11-18 14:00:32 -08:00
David Ungar
3f3d784144 Factor code from tools & move input conversion. 2017-11-14 20:48:59 -08:00
Slava Pestov
0715eaeaed AST: Move SourceEntityWalker to IDE 2017-11-13 22:10:41 -08:00
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