Skip to content

Commit 9358997

Browse files
committed
Python: Fix queries and tests
1 parent 047b585 commit 9358997

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

python/ql/src/Statements/RedundantAssignment.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ predicate same_value(Expr left, Expr right) {
3636
}
3737

3838
predicate maybe_defined_in_outer_scope(Name n) {
39-
exists(SsaVariable v | v.getAUse().getNode() = n | v.maybeUndefined())
39+
exists(SsaVariableWithPointsTo v | v.getAUse().getNode() = n | v.maybeUndefined())
4040
}
4141

4242
/*

python/ql/src/Variables/UndefinedGlobal.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,15 @@ predicate undefined_use_in_function(Name u) {
6262
not u.getEnclosingModule().(ImportTimeScope).definesName(u.getId()) and
6363
not exists(ModuleValue m | m.getScope() = u.getEnclosingModule() | m.hasAttribute(u.getId())) and
6464
not globallyDefinedName(u.getId()) and
65-
not exists(SsaVariable var | var.getAUse().getNode() = u and not var.maybeUndefined()) and
65+
not exists(SsaVariableWithPointsTo var | var.getAUse().getNode() = u and not var.maybeUndefined()) and
6666
not guarded_against_name_error(u) and
6767
not (u.getEnclosingModule().isPackageInit() and u.getId() = "__path__")
6868
}
6969

7070
predicate undefined_use_in_class_or_module(Name u) {
7171
exists(GlobalVariable v | u.uses(v)) and
7272
not u.getScope().getScope*() instanceof Function and
73-
exists(SsaVariable var | var.getAUse().getNode() = u | var.maybeUndefined()) and
73+
exists(SsaVariableWithPointsTo var | var.getAUse().getNode() = u | var.maybeUndefined()) and
7474
not guarded_against_name_error(u) and
7575
not exists(ModuleValue m | m.getScope() = u.getEnclosingModule() | m.hasAttribute(u.getId())) and
7676
not (u.getEnclosingModule().isPackageInit() and u.getId() = "__path__") and

python/ql/src/Variables/UndefinedPlaceHolder.ql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ private import semmle.python.types.ImportTime
1818

1919
/* Local variable part */
2020
predicate initialized_as_local(PlaceHolder use) {
21-
exists(SsaVariable l, Function f | f = use.getScope() and l.getAUse() = use.getAFlowNode() |
21+
exists(SsaVariableWithPointsTo l, Function f |
22+
f = use.getScope() and l.getAUse() = use.getAFlowNode()
23+
|
2224
l.getVariable() instanceof LocalVariable and
2325
not l.maybeUndefined()
2426
)
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import python
2+
private import LegacyPointsTo
23

3-
from SsaVariable var
4+
from SsaVariableWithPointsTo var
45
where var.maybeUndefined()
56
select var.getDefinition().getLocation().getStartLine(), var.toString()

0 commit comments

Comments
 (0)