Commit Graph

21 Commits

Author SHA1 Message Date
Michael Gottesman
9e13779702 [ownership] Remove most -enable-sil-ownership from SILGen now that %target-swift-emit-silgen does it automatically.
I did this using a sed pattern and verified by hand that I was only touching
target-swift-emit-silgen lines.
2018-12-13 11:54:54 -08:00
Ben Cohen
b4a23adcf0 [stdlib] Update Array.subscript to use _modify (#19154)
* Switch Array to use subscript _modify

* Add _modify to ContiguousArray

* XFAIL linux failing test
2018-09-07 10:36:58 -07:00
John McCall
1bc0a5b2fc Pass along the base value in the end_access writeback for diagnostics.
rdar://44147745
2018-09-05 17:02:29 -04:00
John McCall
dd77a2037e Pass the indices for writeback-conflict diagnostics on coroutines.
To do this, I had to introduce a way to unsafely copy an argument
list for the purposes of diagnostics.

rdar:://43802132
2018-08-31 04:20:47 -04: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
Michael Gottesman
f926ab5251 [silgen] Update 12 more tests to have ownership enabled. 2017-10-25 13:35:17 -07:00
John McCall
0d4e0a961d Fix the writeback-conflict diagnostic to look through access markers.
We're now double-diagnosing some things that are caught by both
SILGen and static enforcement; we can fix that later, but I want to
unblock this problem first.
2017-04-24 02:02:47 -04:00
Manav Gabhawala
7928140f79 [SE-0046] Implements consistent function parameter labels by discarding extraneous parameter names and adding _ where necessary 2016-04-06 20:21:58 -04:00
Daniel Duan
780b58a9a5 [Parser] update tests for 'inout' syntax adjustment 2016-02-26 01:33:22 -08:00
fabriziodemaria
1b5e201a15 Fix typo
sophisitication > sophistication
2015-12-04 01:38:52 +01:00
David Farler
93b6962478 Warn when using 'var' bindings in function parameters
These will no longer be allowed in a future Swift release.

rdar://problem/23172698
2015-11-03 17:24:20 -08: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
Dmitri Hrybenko
19642a8b8f Restore a test for writeback conflict SIL diagnostics for a container
without addressors

Swift SVN r22462
2014-10-02 09:58:30 +00:00
John McCall
1fa4f422ba Use mutable addressors for Array, now that doing so
doesn't prevent us from using a getter for immutable
accesses.

rdar://17270560

Swift SVN r22421
2014-10-01 05:20:43 +00:00
Chris Lattner
e466b4621b revert r20658, restoring us back to producing the "inout writeback to computed property"
error when detecting an inout writeback problem.


Swift SVN r20681
2014-07-29 18:12:51 +00:00
Chris Lattner
4d03ef63f7 Rip out my previous work that produced perplexing "inout writeback to
computed property" errors when SILGen could determine that there was
an inout writeback alias, and have the code instead perform CSE of the
writebacks directly.

This means that we produce more efficient code, that a lot of things
now "just work" the way users would expect, and that the still erroneous
cases now get diagnosed with the "inout arguments are not allowed to 
alias each other" error, which people have a hope of understanding.

There is still more to do here in terms of detecting identical cases,
but that was true of the previous diagnostic as well.




Swift SVN r20658
2014-07-28 23:55:14 +00:00
Chris Lattner
0db920b1c4 Reject obvious inout argument aliases with a good diagnostic, for example:
t2.swift:4:11: error: inout arguments are not allowed to alias each other
 swap(&x, &x)
          ^~
t2.swift:4:7: note: previous aliasing argument
 swap(&x, &x)
      ^~

This can (and arguably should) also be handled with a later diagnostic pass, but
handling it in SILGen gives us full range emission capability.



Swift SVN r20469
2014-07-24 05:11:28 +00:00
Chris Lattner
5f06ae4fb6 Teach the inout aliasing diagnostic that a certainly narrow class of AST expression (which
lower to different SILValue's are actually identical.  These are the expression involved
in turning an integer literal into an expression.  This is totally a hack in that we assume
that all "convertFromIntegerLiteral" are side effect free, but is close enough to be useful
for this diagnostic.  The right answer is to implement real attributes to model this 
(rdar://15587352).

That said, this diagnostic is pretty useful as it is.  For example, the SwiftWTF blog post
(http://swiftwtf.tumblr.com/post/91934970718/xcode-6-beta-3) has two examples.  The first
one passes this diagnostic unscathed because there is no inout aliasing problem: "a" is a
physical lvalue, not a logical one and a[1] doesn't alias a[2].  

However, the second example is now rejected with an error message of:

t.swift:12:18: error: inout writeback through subscript occurs in multiple arguments to call, introducing invalid aliasing
swap(&aa[0][1], &aa[0][2])
                 ^~~~~ ~
t.swift:12:7: note: concurrent writeback occurred here
swap(&aa[0][1], &aa[0][2])
      ^~~~~ ~

This is a violation even though "aa" is physical lvalue, because "aa[0]" is a logical
lvalue and we can now detect that the two instances of "aa[0]" are identical (because
we can tell the two 0's are identical).  I'm still not thrilled with the diagnostic, but
I think this will help stem a common source of problems in practice.

As more lvalues become physical or get auto-CSE'd (either with better SILGen CSE, with 
physical i addressors, etc) this diagnostic will automatically track SILGen.



Swift SVN r20377
2014-07-23 05:57:10 +00:00
Chris Lattner
aac2a6c876 Start teaching the inout writeback diagnostic to handle subscripts. The first step is to
handle cases where the index lowers to exactly identical SILValue's.  This is presently 
pretty uncommon (except in the moderately common case of a direct reference to a "let Int"), 
but is a nice base case.

The diagnostic we now get is:

t.swift:5:23: error: inout writeback through subscript occurs in multiple arguments to call, introducing invalid aliasing
  swap(&array[i][j], &array[i][i])
                      ^~~~~~~~ ~
t.swift:5:9: note: concurrent writeback occurred here
  swap(&array[i][j], &array[i][i])
        ^~~~~~~~ ~

based on the fact that "i" lowers to the same SILValue.



Swift SVN r20376
2014-07-23 05:14:00 +00:00
Chris Lattner
5279e948d9 adjust the inout writeback note to be hopefully understandable by mere mortals while also
being googlable and stack overflowable.


Swift SVN r20374
2014-07-23 04:40:17 +00:00
Chris Lattner
d473159814 Implement the start of a diagnostic to detect cases where inout aliasing violations are
introduced, as these are obvious miscompilations and clearly mystifying to our user base.

This is enough to emit diagnostics like this:

writeback_conflict_diagnostics.swift:58:70: error: inout writeback aliasing conflict detected on computed property 'c_local_struct_property'
  swap(&c_local_struct_property.stored_int, &c_local_struct_property.stored_int)
                                             ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
writeback_conflict_diagnostics.swift:58:33: note: concurrent writeback occurred here
  swap(&c_local_struct_property.stored_int, &c_local_struct_property.stored_int)
        ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~

which isn't great, but is better than nothing (better wording is totally welcome!).

This doesn't handle subscripts (or many other kinds of logical lvalue) at all yet, so 
it doesn't handle the swift WTF case, but this is progress towards that.



Swift SVN r20297
2014-07-22 05:37:42 +00:00