File tree Expand file tree Collapse file tree 3 files changed +34
-34
lines changed
rust/ql/lib/codeql/rust/dataflow Expand file tree Collapse file tree 3 files changed +34
-34
lines changed Original file line number Diff line number Diff line change @@ -337,4 +337,37 @@ module Ssa {
337
337
338
338
override Location getLocation ( ) { result = this .getBasicBlock ( ) .getLocation ( ) }
339
339
}
340
+
341
+ /**
342
+ * An SSA definition inserted at a call that may update the value of a captured
343
+ * variable. For example, in
344
+ *
345
+ * ```rust
346
+ * fn capture_mut() {
347
+ * let mut y = 0;
348
+ * (0..5).for_each(|x| {
349
+ * y += x
350
+ * });
351
+ * y
352
+ * }
353
+ * ```
354
+ *
355
+ * a definition for `y` is inserted at the call to `for_each`.
356
+ */
357
+ private class CapturedCallDefinition extends Definition , SsaImpl:: UncertainWriteDefinition {
358
+ CapturedCallDefinition ( ) {
359
+ exists ( Variable v , BasicBlock bb , int i |
360
+ this .definesAt ( v , bb , i ) and
361
+ SsaImpl:: capturedCallWrite ( _, bb , i , v )
362
+ )
363
+ }
364
+
365
+ /**
366
+ * Gets the immediately preceding definition. Since this update is uncertain,
367
+ * the value from the preceding definition might still be valid.
368
+ */
369
+ final Definition getPriorDefinition ( ) { result = SsaImpl:: uncertainWriteDefinitionInput ( this ) }
370
+
371
+ override string toString ( ) { result = "<captured exit> " + this .getSourceVariable ( ) }
372
+ }
340
373
}
Original file line number Diff line number Diff line change @@ -289,7 +289,7 @@ module Node {
289
289
290
290
override Location getLocation ( ) { result = cfgScope .getLocation ( ) }
291
291
292
- override string toString ( ) { result = "lambda self in " + cfgScope }
292
+ override string toString ( ) { result = "closure self in " + cfgScope }
293
293
}
294
294
295
295
abstract class ArgumentNode extends Node {
Original file line number Diff line number Diff line change @@ -467,39 +467,6 @@ class PhiReadNode extends DefinitionExt, Impl::PhiReadNode {
467
467
override Location getLocation ( ) { result = Impl:: PhiReadNode .super .getLocation ( ) }
468
468
}
469
469
470
- /**
471
- * An SSA definition inserted at a call that may update the value of a captured
472
- * variable. For example, in
473
- *
474
- * ```rust
475
- * fn capture_mut() {
476
- * let mut y = 0;
477
- * (0..5).for_each(|x| {
478
- * y += x
479
- * });
480
- * y
481
- * }
482
- * ```
483
- *
484
- * a definition for `y` is inserted at the call to `for_each`.
485
- */
486
- class CapturedCallDefinition extends Definition , Impl:: UncertainWriteDefinition {
487
- CapturedCallDefinition ( ) {
488
- exists ( Variable v , BasicBlock bb , int i |
489
- this .definesAt ( v , bb , i ) and
490
- capturedCallWrite ( _, bb , i , v )
491
- )
492
- }
493
-
494
- /**
495
- * Gets the immediately preceding definition. Since this update is uncertain,
496
- * the value from the preceding definition might still be valid.
497
- */
498
- final Definition getPriorDefinition ( ) { result = uncertainWriteDefinitionInput ( this ) }
499
-
500
- override string toString ( ) { result = "<captured exit> " + this .getSourceVariable ( ) }
501
- }
502
-
503
470
private module DataFlowIntegrationInput implements Impl:: DataFlowIntegrationInputSig {
504
471
class Expr extends CfgNodes:: AstCfgNode {
505
472
predicate hasCfgNode ( SsaInput:: BasicBlock bb , int i ) { this = bb .getNode ( i ) }
You can’t perform that action at this time.
0 commit comments