File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed
swift/ql/test/library-tests/dataflow/capture Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -137,3 +137,40 @@ func sideEffects() {
137
137
f ( )
138
138
sink ( x) // $ hasValueFlow=sideEffects
139
139
}
140
+
141
+ class S {
142
+ var bf1 = 0
143
+ var bf2 = 0
144
+ func captureOther( ) {
145
+ var other = S ( )
146
+ var f = { x in
147
+ other. bf1 = x;
148
+ } ;
149
+
150
+ // no flow
151
+ sink ( bf1) ;
152
+ sink ( other. bf1) ;
153
+ sink ( other. bf2) ;
154
+
155
+ f ( source ( " captureOther " , 2 ) ) ;
156
+
157
+ sink ( other. bf1) ; // $ hasValueFlow=captureOther
158
+ sink ( other. bf2) ;
159
+ }
160
+
161
+ func captureThis( ) {
162
+ var f = { [ self ] x in
163
+ self . bf1 = x;
164
+ bf2 = x;
165
+ } ;
166
+
167
+ // no flow
168
+ sink ( bf1) ;
169
+ sink ( self . bf2) ;
170
+
171
+ f ( source ( " captureThis " , 2 ) ) ;
172
+
173
+ sink ( bf1) ; // $ MISSING: hasValueFlow
174
+ sink ( self . bf2) ; // $ MISSING: hasValueFlow
175
+ }
176
+ }
You can’t perform that action at this time.
0 commit comments