Skip to content

Commit 8d3dba9

Browse files
committed
Python: address bot reviews
1 parent f91c44a commit 8d3dba9

2 files changed

Lines changed: 11 additions & 15 deletions

File tree

  • python/ql
    • lib/semmle/python/dataflow/new/internal
    • test/library-tests/dataflow-new-ssa-vs-legacy

python/ql/lib/semmle/python/dataflow/new/internal/SsaImpl.qll

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ private module SsaImplInput implements SsaImplCommon::InputSig<Py::Location, Cfg
186186
certain = true
187187
)
188188
or
189-
// `del x` — removes the binding. Modelled as a certain write that
189+
// `del x` — removes the binding. modeled as a certain write that
190190
// makes any subsequent read invalid.
191191
exists(Cfg::NameNode n |
192192
bb.getNode(i) = n and
@@ -204,7 +204,7 @@ private module SsaImplInput implements SsaImplCommon::InputSig<Py::Location, Cfg
204204
certain = true
205205
or
206206
// `from X import *` — possibly rebinds every name in the importing
207-
// scope. Modelled as an uncertain write at the import-star's CFG
207+
// scope. modeled as an uncertain write at the import-star's CFG
208208
// position for every variable that lives in (or is referenced
209209
// from) the same scope as the import-star. Mirrors legacy ESSA's
210210
// `ImportStarRefinement` (see `essa/SsaDefinitions.qll`'s
@@ -405,7 +405,7 @@ class EssaNodeDefinition extends Ssa::SsaWriteDefinition {
405405
* assignments, import aliases (`import x` / `from m import x [as y]`),
406406
* `with ... as x`, and for-target bindings (where `getValue()` returns
407407
* the iter expression's CFG node). Excludes parameter bindings —
408-
* those are modelled by `ParameterDefinition`.
408+
* those are modeled by `ParameterDefinition`.
409409
*/
410410
class AssignmentDefinition extends EssaNodeDefinition {
411411
AssignmentDefinition() {
@@ -523,7 +523,7 @@ class PhiFunction extends PhiNode {
523523
Ssa::SsaDefinition getAnInput() { Impl::phiHasInputFromBlock(this, result, _) }
524524
}
525525

526-
/** Base class for all ESSA definitions (legacy-shaped). */
526+
/** An ESSA definition (legacy-shaped). */
527527
class EssaDefinition = Ssa::SsaDefinition;
528528

529529
/**
@@ -563,8 +563,8 @@ class EssaVariable extends Ssa::SsaDefinition {
563563
module AdjacentUses {
564564
/** Holds if `nodeFrom` and `nodeTo` are adjacent uses of the same SSA variable. */
565565
predicate adjacentUseUse(Cfg::NameNode nodeFrom, Cfg::NameNode nodeTo) {
566-
exists(SsaSourceVariable v, CfgImpl::BasicBlock bb1, int i1, CfgImpl::BasicBlock bb2, int i2 |
567-
Impl::adjacentUseUse(bb1, i1, bb2, i2, v, _) and
566+
exists(CfgImpl::BasicBlock bb1, int i1, CfgImpl::BasicBlock bb2, int i2 |
567+
Impl::adjacentUseUse(bb1, i1, bb2, i2, _, _) and
568568
nodeFrom = bb1.getNode(i1) and
569569
nodeTo = bb2.getNode(i2)
570570
)

python/ql/test/library-tests/dataflow-new-ssa-vs-legacy/CmpTest.ql

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* definitions for non-local reads, but legacy ESSA may still differ in corner cases).
1717
* - Module variables `__name__`, `__package__`, `$` (legacy ESSA
1818
* adds implicit bindings the new SSA does not).
19-
* - Exception-handler `as` bindings (depend on raise modelling).
19+
* - Exception-handler `as` bindings (depend on raise modeling).
2020
*
2121
* `def-only-new` mismatches would indicate the new SSA produces spurious
2222
* definitions; currently none are expected.
@@ -46,14 +46,10 @@ string legacyDefSig(EssaNodeDefinition def) {
4646
from string kind, string sig
4747
where
4848
kind = "def-only-new" and
49-
exists(NewSsa::EssaNodeDefinition def |
50-
sig = newDefSig(def) and
51-
not exists(EssaNodeDefinition legacyDef | sig = legacyDefSig(legacyDef))
52-
)
49+
sig = newDefSig(_) and
50+
not sig = legacyDefSig(_)
5351
or
5452
kind = "def-only-old" and
55-
exists(EssaNodeDefinition legacyDef |
56-
sig = legacyDefSig(legacyDef) and
57-
not exists(NewSsa::EssaNodeDefinition def | sig = newDefSig(def))
58-
)
53+
sig = legacyDefSig(_) and
54+
not sig = newDefSig(_)
5955
select kind, sig

0 commit comments

Comments
 (0)