Commit Graph

17 Commits

Author SHA1 Message Date
Fred Riss
259d78a350 Adapt to llvm.org StringRef API change 2020-03-13 19:08:22 +01:00
Owen Voorhees
8a6711769e [Diagnostics] Refactor DiagnosticConsumer interface
DiagnosticInfo now holds all the information needed to consume
a diagnostic, so remove unneeded parameters from handleDiagnostic.
2019-10-29 13:52:12 -07:00
David Ungar
44daa88ebd Format 2019-04-03 12:53:31 -07:00
David Ungar
9cc3a4a9d8 Rename defaultDiagnosticLoc to bufferIndirectlyCausingDiagnostic. 2019-04-03 12:52:49 -07:00
David Ungar
c139c5909a Pass defaultDiagnosticLoc to handleDiagnostic, not currentPrimaryInput. 2019-04-02 22:27:55 -07:00
David Ungar
c90d9e69b6 Format 2019-04-02 00:43:59 -07:00
David Ungar
7a0e0ffc8a Store current primary in diagnostic engine, pass it down via handleDiagnostic. Unformmated. 2019-04-02 00:43:28 -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
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
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
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
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
David Farler
58feafc88a [Migrator] Remove unused MigratorOptions in FixitApplyDiagnosticConsumer
This isn't needed right now.
2017-04-26 12:45:22 -07:00
David Farler
72e8642a05 [Migrator] Refactor fixit filter from JSONFixitWriter to common code
This filter is used for both applying fix-its during the normal
migration flow and by the -emit-fixits-path output for a normal
-typecheck frontend invocation, for example.

rdar://problem/30926261
2017-04-20 17:10:06 -07:00
David Farler
9701d94f15 [Migrator] Add adapter for clang lib/Edit textual edits
This adds an adapter class that wraps Clang's lib/Edit
Commit and EditedSource classes for use in the initial
"syntactic" passes. Once the passes have completed,
the resulting source file is then passed to the Swift compiler
fix-it passes.

rdar://problem/30926261
2017-04-20 10:54:22 -07:00
practicalswift
a029589093 [gardening] Use consistent headers 2017-04-18 19:51:08 +02:00
David Farler
303a3e5824 Start the Migrator library
The Swift 4 Migrator is invoked through either the driver and frontend
with the -update-code flag.

The basic pipeline in the frontend is:

- Perform some list of syntactic fixes (there are currently none).
- Perform N rounds of sema fix-its on the primary input file, currently
  set to 7 based on prior migrator seasons.  Right now, this is just set
  to take any fix-it suggested by the compiler.
- Emit a replacement map file, a JSON file describing replacements to a
  file that Xcode knows how to understand.

Currently, the Migrator maintains a history of migration states along
the way for debugging purposes.

- Add -emit-remap frontend option
  This will indicate the EmitRemap frontend action.
- Don't fork to a separte swift-update binary.
  This is going to be a mode of the compiler, invoked by the same flags.
- Add -disable-migrator-fixits option
  Useful for debugging, this skips the phase in the Migrator that
  automatically applies fix-its suggested by the compiler.
- Add -emit-migrated-file-path option
  This is used for testing/debugging scenarios. This takes the final
  migration state's output text and writes it to the file specified
  by this option.
- Add -dump-migration-states-dir

  This dumps all of the migration states encountered during a migration
  run for a file to the given directory. For example, the compiler
  fix-it migration pass dumps the input file, the output file, and the
  remap file between the two.

  State output has the following naming convention:
  ${Index}-${MigrationPassName}-${What}.${extension}, such as:
  1-FixitMigrationState-Input.swift

rdar://problem/30926261
2017-04-17 16:25:02 -07:00