Skip to content

Commit 86cbf1b

Browse files
committed
Swift: Add comments.
1 parent 24f0eeb commit 86cbf1b

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

swift/ql/lib/codeql/swift/dataflow/internal/DataFlowPrivate.qll

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,19 +500,22 @@ predicate jumpStep(Node pred, Node succ) {
500500
}
501501

502502
predicate storeStep(Node node1, ContentSet c, Node node2) {
503+
// assignment to a member variable `obj.member = value`
503504
exists(MemberRefExpr ref, AssignExpr assign |
504505
ref = assign.getDest() and
505506
node1.asExpr() = assign.getSource() and
506507
node2.(PostUpdateNode).getPreUpdateNode().asExpr() = ref.getBase() and
507508
c.isSingleton(any(Content::FieldContent ct | ct.getField() = ref.getMember()))
508509
)
509510
or
511+
// creation of a tuple `(v1, v2)`
510512
exists(TupleExpr tuple, int pos |
511513
node1.asExpr() = tuple.getElement(pos) and
512514
node2.asExpr() = tuple and
513515
c.isSingleton(any(Content::TupleContent ct | ct.getIndex() = pos))
514516
)
515517
or
518+
// assignment to a tuple member `tuple.index = value`
516519
exists(TupleElementExpr tuple, AssignExpr assign |
517520
tuple = assign.getDest() and
518521
node1.asExpr() = assign.getSource() and
@@ -526,13 +529,15 @@ predicate storeStep(Node node1, ContentSet c, Node node2) {
526529
predicate isLValue(Expr e) { any(AssignExpr assign).getDest() = e }
527530

528531
predicate readStep(Node node1, ContentSet c, Node node2) {
532+
// read of a member variable `obj.member`
529533
exists(MemberRefExpr ref |
530534
not isLValue(ref) and
531535
node1.asExpr() = ref.getBase() and
532536
node2.asExpr() = ref and
533537
c.isSingleton(any(Content::FieldContent ct | ct.getField() = ref.getMember()))
534538
)
535539
or
540+
// read of a tuple member `tuple.index`
536541
exists(TupleElementExpr tuple |
537542
node1.asExpr() = tuple.getSubExpr() and
538543
node2.asExpr() = tuple and

0 commit comments

Comments
 (0)