Commit Graph

137 Commits

Author SHA1 Message Date
Anthony Latsis
3cf3d62a5d [NFC][test] Clean up overlooked dead auxiliary test files after...
...https://github.com/swiftlang/swift/pull/81280.
2025-05-07 16:13:49 +01:00
Anthony Latsis
b0b0cff317 [NFC][test] Move scattered DiagnosticVerifier tests into subdirectory 2025-05-07 02:34:46 +01:00
Anthony Latsis
4f4141fea8 Frontend: Obsolete -fixit-all and -emit-fixits-path
With `ARCMigrate` and `arcmt-test` removed from clang in
https://github.com/llvm/llvm-project/pull/119269 and the new code
migration experience under way (see
https://github.com/swiftlang/swift-evolution/pull/2673), these options
are no longer relevant nor known to be in use. They were introduced
long ago to support fix-it application in Xcode.

For now, turn them into a no-op and emit a obsoletion warning.
2025-05-07 02:30:30 +01:00
Stefan Gränitz
c4b0bae6e4 Use target-specific substitutions for target-specific RUN-lines (#79998)
Target-specific run-lines should use the respective target-specific substitutions
2025-03-15 00:40:59 +01:00
Allan Shortlidge
0ac8cd35d2 Sema: Allow resilient modules to add enum elements without breaking clients.
In the implementation of https://github.com/swiftlang/swift/pull/73472,
warnings about uncovered cases were upgraded to errors in switches covering
enums with an `@unknown default` case. This change was a mistake; it should not
be source breaking for a resilient library to add new cases to a non-frozen
enum.

Resolves rdar://138488976.
2024-10-23 12:41:31 -07:00
Alex Hoppen
577727ad55 Remove DiagnosticsEditorMode
Migrate the last diagnostic to be independent of `DiagnosticEditorMode` and remove that option.

rdar://133111163
2024-08-14 11:24:31 -07:00
Alex Hoppen
7d7eb6e61d [Sema/IDE] Emit same diagnostics for missing switch cases independent of editor mode 2024-08-12 14:01:22 -07:00
Luciano Almeida
ddeb1929c4 [DiagnosticQol][SR-14505] Use DeclDescriptive kind in missing return data flow diagnostics (#36952)
* [Diagnostics] Use DeclDescriptiveKind on data flow diagnostics to improve diagnostic message

* [tests] Add regression tests to SILOptimizer/return.swift

* [tests] Adapt other tests to changes of SR-14505

* [Diagnostics] Adapt message for missing return diagnostics, remove article

* [Diagnostics] Adapt message for missing return diagnostics to have a note with fix

* [tests] Adjust tests in validation suit
2021-04-20 08:16:32 -03:00
maustinstar
3913c31688 [SR-11711] Single-expression returns for #if declarations within closures 2020-11-03 12:48:05 -05:00
maustinstar
37b17338e5 [SR-11711] Single-expression returns for #if declarations within functions 2020-11-03 12:47:39 -05:00
Varun Gandhi
a1716fe2a6 [Diagnostics] Update compiler diagnostics to use less jargon. (#31315)
Fixes rdar://problem/62375243.
2020-04-28 14:11:39 -07:00
omochimetaru
a07b35ab03 [Diagnostics] Improve {{none}} fix-it verifier (#30791)
* [Diagnostics] Improve {{none}} fix-it verifier

* split two conditions

* define "none" constant

* support plural

* use Twine and add comment for replacement range

* check if {{none}} is at the end

* use noneMarkerStartLoc

* update second {{none}} error message

Co-Authored-By: Owen Voorhees <owenvoorhees@gmail.com>

* update test case for second {{none}}

* fix test case for new {{none}} check

* Use named struct

* set const

Co-authored-by: Owen Voorhees <owenvoorhees@gmail.com>
2020-04-09 15:32:14 -07:00
omochimetaru
3ccec26390 [Diagnostics] Fix range of fix-its in verify mode 2020-03-19 18:47:57 +09:00
Pavel Yaskevich
0cd44a83a7 [ConstraintSystem] Don't record general contextual mismatch if there are restrictions present
If there are any conversion restrictions present while trying to repair
failures related to contextual type, let's give `simplifyRestrictedConstraintImpl`
a chance to run and fix the problem.

Resolves: rdar://problem/59773317
2020-03-02 11:07:31 -08:00
Robert Widmann
911e749e4e [Sema] Suggest #selector(self.foo) instead of #selector(TypeName.foo) when possible
When inside a declaration or extension of TypeName, humans usually don't write
the full typename like #selector(TypeName.foo), but instead prefer the neater
form #selector(self.foo). The compiler has enough information to do this too.

Fixes rdar://problem/2528469
2019-11-11 12:35:03 -08:00
Andrew Litteken
d7e977bf68 adding space engine changes
adding full spaceengine changes

using clang-format

adding argument name size comparison

adding space engine changes

adding full spaceengine changes

using clang-format

adding argument printing to interleave function

updating tests for new print formatting

removing extra checks from constructor subspace checking

adding alternate path if the argument and space lenght are the same

clang format

adding FIXME for code performance

adding fixme for showing constructor

switching direction of beginningparenthesis
2019-10-03 15:57:24 -05:00
mishal_shah
1e38fc3030 Update master to build with Xcode 11 beta, macOS 10.15, iOS 13, tvOS 13, and watchOS 6 SDKs 2019-06-03 22:50:02 -07:00
Ben Cohen
e9d4687e31 De-underscore @frozen, apply it to structs (#24185)
* De-underscore @frozen for enums

* Add @frozen for structs, deprecate @_fixed_layout for them

* Switch usage from _fixed_layout to frozen
2019-05-30 17:55:37 -07:00
Nate Chandler
859ffdc477 Used expected-error to test fixit. 2019-04-24 09:59:54 -07:00
Nate Chandler
4f269fc6c0 Added diagnostic for dangling expression at end.
If the final expression in a function or closure which is missing a
return has the appropriate type, rather than producing the usual
diagnostic about a missing return, produce a diagnostic with a fixit to
insert a return before thatn final expression.

h/t Nate Cook
2019-04-24 09:59:54 -07:00
Slava Pestov
1159af50d9 Rename -enable-resilience to -enable-library-evolution and make it a driver flag
Fixes <rdar://problem/47679085>.
2019-03-14 22:24:26 -04:00
Robert Widmann
6115ed9f7c Test for SR-6652, SR-6316 2018-12-15 23:21:18 -05:00
Slava Pestov
a44125eb91 These tests no longer need -swift-version 3 2018-10-31 15:29:18 -04:00
Robert Widmann
2fb5afb755 Remove the @_downgrade_exhaustivity_check hack
This hack was only needed for Swift 3 mode in a narrow case.  Flush it out of the compiler so we can simplify the space engine.
2018-08-24 10:54:43 -07:00
gregomni
9b9e6183f1 One more test fix 2018-08-16 13:14:37 -07:00
Huon Wilson
75934be398 [Parse] Fixit for inserting 'if' for 'else ... {' all on one line.
Fixes rdar://problem/33023297.
2018-08-09 20:08:11 +10:00
Doug Gregor
6a8d3211aa [Type checker] Move ad-hoc isObjC/isDynamic checking to finalization.
Whenever we visit a declaration via the DeclChecker, add it to the
list of declarations to finalize. This makes sure that we can centralize
the notion of “finalize for SILGen” and that it will be called for
everything in the source file being processed.
2018-07-25 20:55:13 -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
Jordan Rose
7c689c322e Prefer @unknown default over @unknown case _ in diagnostics
(and fix-its)
2018-04-05 17:54:49 -07:00
Jordan Rose
ceb51eea80 Clean up fix-it generation for missing cases, esp. with '@unknown'
- Combine the common logic for editor mode and non-editor mode.
- Do a better job minimizing fix-its.
- If '@unknown' is the only missing case, put `fatalError()` in the
  Xcode placeholder, since that's what the compiler would have done.
2018-04-05 16:35:15 -07:00
Jordan Rose
41286bc676 Make JSON fix-it outputs be per-primary in batch mode. (#14995)
This means moving the output path into SupplementaryOutputPaths, and
using the same sort of diagnostic dispatching that serialized
diagnostics use. This is part of what's needed to run the migrator
in batch mode.
2018-03-09 11:58:54 -08:00
Timur Islamgulov
56d1d6bbd3 Sema: Add a fix-it for integer literal to option set conversion. (#13899)
If expression type is IntegerLiteralExpr and value is equal to '0',
suggest '[]' as a replacement.

Resolves: rdar://problem/20704317 / SR-6716.
2018-01-12 13:34:49 -08:00
Huon Wilson
787736d6b8 [Sema] Suggest #selector(self.foo) instead of #selector(TypeName.foo) when possible.
When inside a declaration or extension of TypeName, humans usually don't write
the full typename like #selector(TypeName.foo), but instead prefer the neater
form #selector(self.foo). The compiler has enough information to do this too.

Fixes rdar://problem/25284692 .
2017-06-23 14:55:53 -07:00
Xi Ge
bc73e4310e Sema: missing switch case fixits should print payload names explicitly instead of printing underscores. rdar://32121806 (#10409) 2017-06-20 14:13:37 -07:00
Xi Ge
b6d753067b FixCode: Add a new line between switch label and the code placeholder. rdar://32121847 (#9576) 2017-05-13 12:21:48 -07:00
Robert Widmann
ce6862731f Improve multi-file decompositions through validation 2017-05-02 00:31:03 -04:00
Robert Widmann
39494b2ba2 Rearrange test code for exhaustiveness 2017-04-28 02:06:39 -04:00
Maxim Moiseev
767e8f31ac Merge pull request #3796 from apple/new-integer-protocols
New integer protocols
2017-04-17 16:46:09 -07: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
Max Moiseev
b9fb3badc8 Merge remote-tracking branch 'origin/master' into new-integer-protocols 2017-03-22 12:30:24 -07:00
Xi Ge
b4cf37bf7d Sema: several improvements on missing switch cases diagnostics. (#8026)
1. Make sure the actions taken by fixits are reflected in diagnostics messages.
2. Issue missing cases diagnostics at the start of the switch statement instead of its end.
3. Use <#code#> instead of <#Code#> in the stub.
2017-03-10 19:32:37 -08:00
Max Moiseev
835b8809d2 Merge branch 'master' into new-integer-protocols 2017-03-07 16:18:54 -08:00
Xi Ge
8ec3bd3c0a [FixCode] When fixing missing enum elements in a switch statement, print associated payloads as well. (#7899) 2017-03-03 13:07:35 -08:00
Xi Ge
daac020c61 Sema: Reject empty switch statements during type checking so that we can issue fixits to fill the unhandled switch cases. (#7766) 2017-02-25 08:01:13 -08:00
Xi Ge
d12d3c18ca FixCode: add a fixit to insert the missing enum element cases in switch statements. (#7759)
This doesn't work on entirely empty switch block because we reject such statement during parsing.
2017-02-24 18:09:30 -08:00
Max Moiseev
d128ed42b0 Merge remote-tracking branch 'origin/master' into new-integer-protocols 2017-01-19 14:16:32 -08:00
Max Moiseev
a167238d1d Fixing more tests 2017-01-12 15:54:56 -08:00
Matthew Carroll
0e09bbbb83 [DiagnosticsQoI] SR-3359: Add a fix-it to remove @discardableResult on functions that return Void or Never (#6681)
This commit adds a fix-it to remove @discardableResult on functions that return Void or Never. The fix-it is at the warning level. A test was added to verify that the fix-it removes the @discardableResult. This issue was reported in SR-3359:
https://bugs.swift.org/browse/SR-3359

Changes:
TypeCheckAttr.cpp: implemented AttributeChecker::visitDiscardableResultAttr to add a fix-it to remove @discardableResult on functions returning Void or Never.

DiagnosticsSema.def: Added a warning with a diagnostic message.

LoggingWrappers.swift.gyb, HashedCollections.swift.gyb: Removed @discardableResult on functions returning Void.

fixits-apply-all.swift, fixits-apply-all.swift.result: Added tests to verify that @discardableResult is removed from functions returning Void or Never.
2017-01-11 15:12:36 -08:00
Doug Gregor
e97ab635ea [Constraint solver] Separate bridging conversions from other conversions.
Previously, bridging conversions were handled as a form of "explicit
conversion" that was treated along the same path as normal
conversions in matchTypes(). Historically, this made some
sense---bridging was just another form of conversion---however, Swift
now separates out bridging into a different kind of conversion that is
available only via an explicit "as". This change accomplishes a few
things:

* Improves type inference around "as" coercions. We were incorrectly
  inferring type variables of the "x" in "x as T" in cases where a
  bridging conversion was expected, which cause some type inference
  failures (e.g., the SR-3319 regression).

* Detangles checking for bridging conversions from other conversions,
  so it's easier to isolate when we're applying a bridging
  conversion.

* Explicitly handle optionals when dealing with bridging conversions,
  addressing a number of problems with incorrect diagnostics, e.g.,
  complains about "unrelated type" cast failures that would succeed at
  runtime.

Addresses rdar://problem/29496775 / SR-3319 / SR-2365.
2016-12-21 13:46:14 -08:00
David Farler
b7d17b25ba Rename -parse flag to -typecheck
A parse-only option is needed for parse performance tracking and the
current option also includes semantic analysis.
2016-11-28 10:50:55 -08:00