Skip to content

Commit 9fe7bb3

Browse files
committed
Rust: Address PR comments
1 parent 2cf043c commit 9fe7bb3

File tree

3 files changed

+34
-34
lines changed

3 files changed

+34
-34
lines changed

rust/ql/lib/codeql/rust/dataflow/Ssa.qll

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,4 +337,37 @@ module Ssa {
337337

338338
override Location getLocation() { result = this.getBasicBlock().getLocation() }
339339
}
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+
}
340373
}

rust/ql/lib/codeql/rust/dataflow/internal/DataFlowImpl.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ module Node {
289289

290290
override Location getLocation() { result = cfgScope.getLocation() }
291291

292-
override string toString() { result = "lambda self in " + cfgScope }
292+
override string toString() { result = "closure self in " + cfgScope }
293293
}
294294

295295
abstract class ArgumentNode extends Node {

rust/ql/lib/codeql/rust/dataflow/internal/SsaImpl.qll

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -467,39 +467,6 @@ class PhiReadNode extends DefinitionExt, Impl::PhiReadNode {
467467
override Location getLocation() { result = Impl::PhiReadNode.super.getLocation() }
468468
}
469469

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-
503470
private module DataFlowIntegrationInput implements Impl::DataFlowIntegrationInputSig {
504471
class Expr extends CfgNodes::AstCfgNode {
505472
predicate hasCfgNode(SsaInput::BasicBlock bb, int i) { this = bb.getNode(i) }

0 commit comments

Comments
 (0)