Skip to content

Commit 210387a

Browse files
committed
Adds bulk of modernizations
1 parent 2df3fe8 commit 210387a

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

python/ql/src/Expressions/IsComparisons.qll

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ predicate invalid_to_use_is_portably(ClassValue c) {
3535
}
3636

3737
predicate simple_constant(ControlFlowNode f) {
38-
exists(Object obj | f.refersTo(obj) | obj = theTrueObject() or obj = theFalseObject() or obj = theNoneObject())
38+
exists(Value val | f.pointsTo(val) | val = Value::named("True") or val = Value::named("False") or val = Value::named("None"))
3939
}
4040

4141
private predicate cpython_interned_value(Expr e) {
@@ -66,14 +66,14 @@ private predicate universally_interned_value(Expr e) {
6666

6767
predicate cpython_interned_constant(Expr e) {
6868
exists(Expr const |
69-
e.refersTo(_, const) |
69+
e.pointsTo(_, const) |
7070
cpython_interned_value(const)
7171
)
7272
}
7373

7474
predicate universally_interned_constant(Expr e) {
7575
exists(Expr const |
76-
e.refersTo(_, const) |
76+
e.pointsTo(_, const) |
7777
universally_interned_value(const)
7878
)
7979
}
@@ -108,14 +108,14 @@ predicate invalid_portable_is_comparison(Compare comp, Cmpop op, ClassValue cls)
108108
)
109109
and
110110
/* OK to use 'is' when comparing items from a known set of objects */
111-
not exists(Expr left, Expr right, Object obj |
111+
not exists(Expr left, Expr right, Value val |
112112
comp.compares(left, op, right) and
113-
exists(ImmutableLiteral il | il.getLiteralObject() = obj) |
114-
left.refersTo(obj) and right.refersTo(obj)
113+
exists(ImmutableLiteral il | il.getLiteralObject() = val) |
114+
left.pointsTo(val) and right.pointsTo(val)
115115
or
116116
/* Simple constant in module, probably some sort of sentinel */
117117
exists(AstNode origin |
118-
not left.refersTo(_) and right.refersTo(obj, origin) and
118+
not left.pointsTo(_) and right.pointsTo(val, origin) and
119119
origin.getScope().getEnclosingModule() = comp.getScope().getEnclosingModule()
120120
)
121121
)
@@ -124,7 +124,7 @@ predicate invalid_portable_is_comparison(Compare comp, Cmpop op, ClassValue cls)
124124
not exists(Expr left, Expr right, AstNode origin |
125125
comp.compares(left, op, right) and
126126
enum_member(origin) |
127-
left.refersTo(_, origin) or right.refersTo(_, origin)
127+
left.pointsTo(_, origin) or right.pointsTo(_, origin)
128128
)
129129
}
130130

0 commit comments

Comments
 (0)