Skip to content

Commit c2f9189

Browse files
committed
Python: Make a few more expressions point-to the 'unknown' value to improve reachability by about 1%.
1 parent d0a7614 commit c2f9189

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

python/ql/src/semmle/python/pointsto/PointsTo.qll

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1390,6 +1390,14 @@ module Expressions {
13901390
)
13911391
}
13921392

1393+
pragma [noinline]
1394+
private boolean comparesToUnknown(CompareNode comp, PointsToContext context, ControlFlowNode operand, ObjectInternal opvalue) {
1395+
(comp.operands(operand, _, _) or comp.operands(_, _, operand)) and
1396+
PointsToInternal::pointsTo(operand, context, opvalue, _) and
1397+
opvalue = ObjectInternal::unknown() and
1398+
result = maybe()
1399+
}
1400+
13931401
pragma [noinline]
13941402
private predicate equalityTest(CompareNode comp, PointsToContext context, ControlFlowNode operand, ObjectInternal opvalue, ObjectInternal other, boolean sense) {
13951403
exists(ControlFlowNode r |
@@ -1520,6 +1528,8 @@ module Expressions {
15201528
or
15211529
result = containsComparisonEvaluatesTo(expr, context, subexpr, subvalue)
15221530
or
1531+
result = comparesToUnknown(expr, context, subexpr, subvalue)
1532+
or
15231533
result = isinstanceEvaluatesTo(expr, context, subexpr, subvalue)
15241534
or
15251535
result = issubclassEvaluatesTo(expr, context, subexpr, subvalue)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
| 1189 |
1+
| 1185 |

0 commit comments

Comments
 (0)