Commit Graph

9 Commits

Author SHA1 Message Date
Ben Barham
747be5899b [Frontend] Do not output swiftinterface when there has been errors
When allowing errors with
-experimental-allow-module-with-compiler-errors, do not output the
.swiftinterface when there has been errors. There's no real need to
output them for invalid modules, so this avoids module interface
printing having to have checks for normally-impossible cases.

Resolves rdar://78039608.
2021-05-20 11:48:05 +10:00
Ben Barham
c1e4362dfd [Serialization] Do not assert when inherited type is null
When compiling with allow errors, it's possible to have invalid
inherited types - both null and ErrorType.

Cleaned up the tests a little - moved the majority of
Frontend/allow-errors.swift into separate files in
Serialization/AllowErrors and use split_file.py instead of #defines.

Resolves rdar://78048470
2021-05-15 16:35:23 +10:00
Ben Barham
4ec4520e0b Merge pull request #36968 from bnbarham/swift-serialization-crash
[Serialization] Add some checks for invalid types
2021-04-21 09:08:28 +10: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
Ben Barham
f876e0cd1a [Serialization] Add some checks for invalid types
When allowing errors there's various cases where an invalid type is used
during serialization:
  - Invalid explicit conformances on an extension
  - Superclass with invalid generic type

Add checks to skip these to avoid crashing.

Resolves rdar://75379780.
2021-04-20 13:39:46 +10:00
Ben Barham
a17593f026 [Frontend] Always output swiftdeps when allowing errors
A module is always output when allowing errors, make sure to output its
dependencies as well.
2021-03-25 16:19:09 +10:00
Ben Barham
ce70727e6f [Deserialization] Output a diagnostic for invalid decls or types
47b068d445 output a diagnostic if a
deserialized decl was invalid (checking `Decl::isInvalid`). It had two
major issues:
  1. It incorrectly output diagnostics for valid modules
  2. It did not catch call invalid declarations

(1) is caused by `isInvalid` falling back to checking the storage for
accessors when the interface type hasn't already been computed (a
fallback to prevent a cycle due to `SimpleDidSetRequest` typechecking
the body). Since the `VarDecl` hasn't finished deserializing, it returns
`true` for its `isInvalid` check (even though it would later return
`false`).

For (2), only `ValueDecl`s would ever be invalid, since other
declarations use a bit in `Decl` to check for validity. As that's not
serialized, those would always be valid in deserialization.

To avoid both these issues, instead output a flag for each declaration
representing whether it is invalid (or not). Read that during
deserialization and output a diagnostic if it is invalid. To be extra
sure that a diagnostic is always output on an error, also output one
when deserializing any `ErrorType`. This ensures that SILGen does not
run when allowing errors (and an error is present), as it is likely to
crash when presented with an invalid AST.

Resolves rdar://74541834
2021-03-03 12:12:20 +10:00
Ben Barham
47b068d445 [Serialization] Emit an error on deserializing an invalid declaration
When running in the allow errors mode
(-experimental-allow-module-with-compiler-errors), modules may contain
invalid declarations. The rest of the compiler pipeline, however,
expects to have valid declarations unless diagnostics have emitted an
error. Emit an error while deserializing to maintain this assumption.

Note that these errors will not have a useful location, unless there's a
corresponding `.swiftsourceinfo`. This isn't a problem for the intended
use case in IDEs, where diagnostics outside the current file would be
ignored anyway.

Since reading declarations is lazy, SILGen (and thus SIL diagnostics)
can still run as long as any invalid declarations weren't referenced in
the compiling module.

Resolves rdar://74325388
2021-02-18 11:28:22 +10:00
Ben Barham
241559dc88 [Serialization] Add an option to output modules regardless of errors
Adds a new frontend option
"-experimental-allow-module-with-compiler-errors". If any compilation
errors occur while generating the .swiftmodule, this mode will skip SIL
entirely and only serialize the (likey invalid) AST.

This existence of this option during generation is serialized into the
resulting .swiftmodule. Errors found in deserialization are only allowed
if it is set.

Primarily intended for IDE requests (eg. indexing and code completion)
to ensure robust cross-module results, despite possible errors.

Resolves rdar://69815975
2020-11-10 14:47:22 +10:00