Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d44ce4f

Browse files
committed
Python points-to: Performance improvement.
1 parent 15a7ac3 commit d44ce4f

1 file changed

Lines changed: 14 additions & 7 deletions

File tree

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

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,19 +1099,26 @@ module Expressions {
10991099

11001100
pragma [noinline]
11011101
predicate subscriptPointsTo(SubscriptNode subscr, PointsToContext context, ObjectInternal value, ControlFlowNode origin, ControlFlowNode obj, ObjectInternal objvalue) {
1102-
subscr.isLoad() and
1103-
obj = subscr.getObject() and
1104-
origin = subscr and
1105-
PointsToInternal::pointsTo(obj, context, objvalue, _) and
1106-
(
1102+
exists(ControlFlowNode index |
1103+
subscriptObjectAndIndex(subscr, context, obj, objvalue, index)
1104+
|
11071105
objvalue.subscriptUnknown() and
11081106
value = ObjectInternal::unknown()
11091107
or
11101108
exists(int n |
1111-
PointsToInternal::pointsTo(subscr.getIndex(), context, TInt(n), _) and
1109+
PointsToInternal::pointsTo(index, context, TInt(n), _) and
11121110
value = objvalue.(SequenceObjectInternal).getItem(n)
11131111
)
1114-
)
1112+
) and
1113+
origin = subscr
1114+
}
1115+
1116+
pragma [noinline]
1117+
private predicate subscriptObjectAndIndex(SubscriptNode subscr, PointsToContext context, ControlFlowNode obj, ObjectInternal objvalue, ControlFlowNode index) {
1118+
subscr.isLoad() and
1119+
obj = subscr.getObject() and
1120+
PointsToInternal::pointsTo(obj, context, objvalue, _) and
1121+
index = subscr.getIndex()
11151122
}
11161123

11171124
/** Track bitwise expressions so we can handle integer flags and enums.

0 commit comments

Comments
 (0)