@@ -241,11 +241,19 @@ pub trait ValueAnalysis<'tcx> {
241
241
242
242
/// The effect of a successful function call return should not be
243
243
/// applied here, see [`Analysis::apply_terminator_effect`].
244
- fn handle_terminator ( & self , terminator : & Terminator < ' tcx > , state : & mut State < Self :: Value > ) {
244
+ fn handle_terminator < ' mir > (
245
+ & self ,
246
+ terminator : & ' mir Terminator < ' tcx > ,
247
+ state : & mut State < Self :: Value > ,
248
+ ) -> TerminatorEdge < ' mir , ' tcx > {
245
249
self . super_terminator ( terminator, state)
246
250
}
247
251
248
- fn super_terminator ( & self , terminator : & Terminator < ' tcx > , state : & mut State < Self :: Value > ) {
252
+ fn super_terminator < ' mir > (
253
+ & self ,
254
+ terminator : & ' mir Terminator < ' tcx > ,
255
+ state : & mut State < Self :: Value > ,
256
+ ) -> TerminatorEdge < ' mir , ' tcx > {
249
257
match & terminator. kind {
250
258
TerminatorKind :: Call { .. } | TerminatorKind :: InlineAsm { .. } => {
251
259
// Effect is applied by `handle_call_return`.
@@ -257,8 +265,10 @@ pub trait ValueAnalysis<'tcx> {
257
265
// They would have an effect, but are not allowed in this phase.
258
266
bug ! ( "encountered disallowed terminator" ) ;
259
267
}
268
+ TerminatorKind :: SwitchInt { discr, targets } => {
269
+ return self . handle_switch_int ( discr, targets, state) ;
270
+ }
260
271
TerminatorKind :: Goto { .. }
261
- | TerminatorKind :: SwitchInt { .. }
262
272
| TerminatorKind :: Resume
263
273
| TerminatorKind :: Terminate
264
274
| TerminatorKind :: Return
@@ -270,6 +280,7 @@ pub trait ValueAnalysis<'tcx> {
270
280
// These terminators have no effect on the analysis.
271
281
}
272
282
}
283
+ terminator. edges ( )
273
284
}
274
285
275
286
fn handle_call_return (
@@ -290,19 +301,22 @@ pub trait ValueAnalysis<'tcx> {
290
301
} )
291
302
}
292
303
293
- fn handle_switch_int (
304
+ fn handle_switch_int < ' mir > (
294
305
& self ,
295
- discr : & Operand < ' tcx > ,
296
- apply_edge_effects : & mut impl SwitchIntEdgeEffects < State < Self :: Value > > ,
297
- ) {
298
- self . super_switch_int ( discr, apply_edge_effects)
306
+ discr : & ' mir Operand < ' tcx > ,
307
+ targets : & ' mir SwitchTargets ,
308
+ state : & mut State < Self :: Value > ,
309
+ ) -> TerminatorEdge < ' mir , ' tcx > {
310
+ self . super_switch_int ( discr, targets, state)
299
311
}
300
312
301
- fn super_switch_int (
313
+ fn super_switch_int < ' mir > (
302
314
& self ,
303
- _discr : & Operand < ' tcx > ,
304
- _apply_edge_effects : & mut impl SwitchIntEdgeEffects < State < Self :: Value > > ,
305
- ) {
315
+ discr : & ' mir Operand < ' tcx > ,
316
+ targets : & ' mir SwitchTargets ,
317
+ _state : & mut State < Self :: Value > ,
318
+ ) -> TerminatorEdge < ' mir , ' tcx > {
319
+ TerminatorEdge :: SwitchInt { discr, targets }
306
320
}
307
321
308
322
fn wrap ( self ) -> ValueAnalysisWrapper < Self >
@@ -359,9 +373,10 @@ where
359
373
_location : Location ,
360
374
) -> TerminatorEdge < ' mir , ' tcx > {
361
375
if state. is_reachable ( ) {
362
- self . 0 . handle_terminator ( terminator, state) ;
376
+ self . 0 . handle_terminator ( terminator, state)
377
+ } else {
378
+ TerminatorEdge :: None
363
379
}
364
- terminator. edges ( )
365
380
}
366
381
367
382
fn apply_call_return_effect (
@@ -378,11 +393,9 @@ where
378
393
fn apply_switch_int_edge_effects (
379
394
& mut self ,
380
395
_block : BasicBlock ,
381
- discr : & Operand < ' tcx > ,
382
- apply_edge_effects : & mut impl SwitchIntEdgeEffects < Self :: Domain > ,
396
+ _discr : & Operand < ' tcx > ,
397
+ _apply_edge_effects : & mut impl SwitchIntEdgeEffects < Self :: Domain > ,
383
398
) {
384
- // FIXME: Dataflow framework provides no access to current state here.
385
- self . 0 . handle_switch_int ( discr, apply_edge_effects)
386
399
}
387
400
}
388
401
0 commit comments