Commit Graph

38 Commits

Author SHA1 Message Date
Jamie
58166fc162 [SILGen]: diagnose unreachable opened existentials
updates unreachable code handling in SILGenStmt.cpp to diagnose
opened existentials that were previously ignored.

resolves: https://github.com/apple/swift/issues/73649
2024-05-19 23:26:54 -05:00
Anthony Latsis
08588b91d0 Gardening: Migrate test suite to GH issues: SILGen (2/2) 2022-09-04 09:35:41 +03:00
Robert Widmann
2c936fb7f6 Ignore All 'Unreachable' Decls That Don't Carry Expressions
We were just ignoring types here, but local functions don't matter. In
fact, if a local decl survives to SILGen, we only really care if it
carries some expression or statement itself - so pattern bindings are
the real stars here.

Re-resolves rdar://76269551 and SR-14449
2021-07-22 14:59:45 -07:00
Josh Learn
45b670c740 [SR-13639][Diag] Don't diagnose local type declarations as unreachable
Local types can be used earlier within a scope than they were declared.
We currently diagnose these type declarations as unreachable when they
appear after a return, even though they may have been used prior to
the return statement. This change stops that diagnostic.

Resolves SR-13639, rdar://69845495
2020-10-29 15:53:49 -07:00
Suyash Srijan
6a7b38d7ef [SILGenPattern] Silence redundant unreachable enum case warning (#33336) 2020-08-22 01:58:44 +01:00
Michael Gottesman
f854547c55 [ownership] Enable ownership verification by default.
I also removed the -verify-sil-ownership flag in favor of a disable flag
-disable-sil-ownership-verifier. I used this on only two tests that still need
work to get them to pass with ownership, but whose problems are well understood,
small corner cases. I am going to fix them in follow on commits. I detail them
below:

1. SILOptimizer/definite_init_inout_super_init.swift. This is a test case where
DI is supposed to error. The only problem is that we crash before we error since
the code emitting by SILGen to trigger this error does not pass ownership
invariants. I have spoken with JoeG about this and he suggested that I fix this
earlier in the compiler. Since we do not run the ownership verifier without
asserts enabled, this should not affect compiler users. Given that it has
triggered DI errors previously I think it is safe to disable ownership here.

2. PrintAsObjC/extensions.swift. In this case, the signature generated by type
lowering for one of the thunks here uses an unsafe +0 return value instead of
doing an autorelease return. The ownership checker rightly flags this leak. This
is going to require either an AST level change or a change to TypeLowering. I
think it is safe to turn this off since it is such a corner case that it was
found by a test that has nothing to do with it.

rdar://43398898
2019-03-25 00:11:52 -07:00
Michael Gottesman
0dfaa19f9f [ownership] Rename enable-sil-ownership => verify-sil-ownership.
I have been meaning to do this change for a minute, but kept on putting it off.
This describes what is actually happening and is a better name for the option.
2019-03-18 01:31:44 -07:00
Alex Hoppen
560c22b18e [tests] Verify the libSyntax tree on SILGen tests
The SILGen testsuite consists of valid Swift code covering most language
features. We use these tests to verify that no unknown nodes are in the
file's libSyntax tree. That way we will (hopefully) catch any future
changes or additions to the language which are not implemented in
libSyntax.
2018-04-27 09:33:03 -07:00
Pavel Yaskevich
7034ef92b6 Revert "Stricter enforcement of the "large space" heuristic" 2018-01-14 19:37:44 -08:00
Robert Widmann
43f06afef2 Defer analysis of large switch bodies
This presents a regression in diagnostic quality that is definitely
worth it not to lie to SILGen about whether a switch is covered or not.

At the same time, disable SIL’s unreachable diagnostic for ‘default’
clauses which would previously cause a warning to be emitted if the
default was proven to be unreachable.  This analysis is incomplete
anyways and can be done by Sema in the future if we desire.
2017-12-13 16:22:48 -05:00
Michael Gottesman
f926ab5251 [silgen] Update 12 more tests to have ownership enabled. 2017-10-25 13:35:17 -07:00
Doug Gregor
d6bd66e254 Add fixed test case for SR-6141 / rdar://problem/35008570. 2017-10-17 09:52:10 -07:00
Robert Widmann
bbdc5461a9 Diagnose unreachable optional evaluation exprs
OptionalEvaluationExprs are always implicit and were
being let through SILGen's unreachable diagnostics
branch.  Decompose the structure to check to see if its
contents are not implicit expressions.  If that is the
case, then diagnose them.

Resolves SR-5763.
2017-09-11 18:03:28 -04:00
Robert Widmann
4e2f36c763 Lift case redundancy checks into Sema 2017-05-01 01:32:02 -04:00
Doug Gregor
823c24b355 [SE-0112] Rename ErrorProtocol to Error.
This is bullet (5) of the proposed solution in SE-0112, and the last
major piece to be implemented.
2016-07-12 10:53:52 -07:00
Chris Lattner
f51fcdbbb6 stop using deprecated constructs. 2016-04-17 10:20:12 -07:00
Max Moiseev
a7339e67ac Merge remote-tracking branch 'origin' into swift-3-api-guidelines 2015-12-22 11:36:07 -08:00
Chris Lattner
0224f2d858 Convert more tests off of ++ and -- 2015-12-21 18:07:37 -08:00
Max Moiseev
2f7b64e475 Merge remote-tracking branch 'origin' into swift-3-api-guidelines 2015-12-21 12:02:13 -08:00
Daniel Duan
239c6629e9 Remove trailing semi-colons in .swift files 2015-12-20 21:12:11 -08:00
Doug Gregor
cd1c106e35 Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2015-12-18 15:45:48 -08:00
Max Moiseev
3fe0c60d7f Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2015-12-17 11:00:02 -08:00
gregomni
392a1ff0ed Deprecation warnings for C-style for loops
Warns of deprecation, checks all the appropriate bits to see if we can
do an automatic fix, and generates fix-its if that is valid.

Also adds a note if the loop looks like it ought to be a simple
for-each, but really isn’t because the loop var is modified inside the
loop.
2015-12-17 10:58:59 -08:00
Daniel Duan
ebb0c3a204 replaced single-line ++/-- with +=/-= 2015-12-15 09:05:37 -08:00
Dmitri Gribenko
feacbc4433 Rename ErrorType to ErrorProtocol 2015-12-09 17:12:19 -08:00
Chris Lattner
8cdf88cd8c fix <rdar://problem/21088517> throw in an initializer causes bogus error
a false positive (with no location information) when an init immediately throws.


Swift SVN r28965
2015-05-23 16:03:32 +00:00
Slava Pestov
42d7c7251c SILGen: better diagnostic for code after break and throw
Swift SVN r28689
2015-05-18 00:26:19 +00:00
Chris Lattner
e517ad9182 Fix unreachable code handling to properly diagnose things like:
throw x 
whatever()  

as being unreachable after the throw.



Swift SVN r28680
2015-05-17 15:13:35 +00:00
Dmitri Hrybenko
0a1f7c09df Revert "Fix unreachable code handling to properly diagnose things like:"
This reverts commit 28678.  It broke the IDE/complete_exception.swift
test.

Swift SVN r28679
2015-05-17 12:27:57 +00:00
Chris Lattner
5ead9764bd Fix unreachable code handling to properly diagnose things like:
throw x
  whatever()

as being unreachable after the throw.



Swift SVN r28678
2015-05-17 05:56:02 +00:00
Chris Lattner
7059871abf Convert some 'var' bindings to 'let' when they are not mutated, some
var/let bindings to _ when they are never used, and use some values that
are only written.  This is a testsuite cleanup, NFC. More to come.


Swift SVN r28406
2015-05-11 00:20:55 +00:00
Chris Lattner
a475a3326f implement <rdar://problem/19786845> Warn on "let" and "var" when no data is bound in a pattern
We warn like this:
t.swift:3:12: warning: 'let' pattern has no effect; sub-pattern didn't bind any variables
      case let .Bar: println("bar")
           ^~~ ~~~~



Swift SVN r27747
2015-04-26 04:38:13 +00:00
Chris Lattner
7c189eb5bb improve diagnostic and add test for unreachable default.
Swift SVN r26678
2015-03-28 05:45:36 +00:00
Chris Lattner
0b2312edfe diagnose unreachable cases in switches, fixing:
<rdar://problem/20253447> `case let Case` without bindings incorrectly matches other cases




Swift SVN r26675
2015-03-28 04:31:38 +00:00
Dmitri Hrybenko
3b04d1b013 tests: reorganize tests so that they actually use the target platform
Most tests were using %swift or similar substitutions, which did not
include the target triple and SDK.  The driver was defaulting to the
host OS.  Thus, we could not run the tests when the standard library was
not built for OS X.

Swift SVN r24504
2015-01-19 06:52:49 +00:00
Argyrios Kyrtzidis
628567bfe5 [Frontend] Make it erroneous if no frontend action is specified when invoking the frontend, and update tests.
Swift SVN r21584
2014-08-29 19:17:37 +00:00
Ted Kremenek
fad874708e Adjust test cases.
Swift SVN r17964
2014-05-12 22:01:52 +00:00
Anna Zaks
16774496fd [SILGen] Emit warnings when SILGen fails to emit unreachable code.
Previously, we just did not emit SIL for unreachable code from these examples.

Swift SVN r9949
2013-11-05 01:17:14 +00:00