File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed
validation-test/SILOptimizer Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change 1+ // RUN: %target-swift-frontend \
2+ // RUN: %s \
3+ // RUN: -emit-sil -verify \
4+ // RUN: -sil-verify-all
5+
6+ func doStuffUniquely( with value: consuming [ Int ] ) {
7+ // If we received the last remaining reference to `value`, we'd like
8+ // to be able to efficiently update it without incurring more copies.
9+ var newValue = consume value
10+ newValue. append ( 42 )
11+ }
12+
13+ func test( ) {
14+ var x : [ Int ] = [ 1 , 2 , 3 ]
15+
16+ // x is appended to. After this point, we know that x is unique. We want to
17+ // preserve that property.
18+ x. append ( 5 )
19+
20+ // Pass the current value of x off to another function, that
21+ doStuffUniquely ( with: consume x)
22+
23+ // Reset x to a new value. Since we don't use the old value anymore,
24+ x = [ ]
25+ doMoreStuff ( with: & x)
26+ }
27+
28+ func doMoreStuff( with value: inout [ Int ] ) {
29+ }
You can’t perform that action at this time.
0 commit comments