Skip to content

Commit 67a9141

Browse files
committed
Swift: make AST printer consistency query more helpful
1 parent b9fe056 commit 67a9141

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

swift/ql/lib/codeql/swift/printast/Consistency.qll

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,28 @@
11
private import codeql.swift.printast.PrintAstNode
22

33
query predicate doubleChildren(
4-
PrintAstNode parent, int index, PrintAstNode child1, PrintAstNode child2
4+
PrintAstNode parent, int index, string label1, PrintAstNode child1, string label2,
5+
PrintAstNode child2
56
) {
67
child1 != child2 and
7-
parent.hasChild(child1, index, _) and
8-
parent.hasChild(child2, index, _)
8+
parent.hasChild(child1, index, label1) and
9+
parent.hasChild(child2, index, label2)
910
}
1011

11-
query predicate doubleIndexes(PrintAstNode parent, int index1, int index2, PrintAstNode child) {
12+
query predicate doubleIndexes(
13+
PrintAstNode parent, int index1, string label1, int index2, string label2, PrintAstNode child
14+
) {
1215
index1 != index2 and
13-
parent.hasChild(child, index1, _) and
14-
parent.hasChild(child, index2, _)
16+
parent.hasChild(child, index1, label1) and
17+
parent.hasChild(child, index2, label2)
1518
}
1619

17-
query predicate doubleParents(PrintAstNode parent1, PrintAstNode parent2, PrintAstNode child) {
20+
query predicate doubleParents(
21+
PrintAstNode parent1, string label1, PrintAstNode parent2, string label2, PrintAstNode child
22+
) {
1823
parent1 != parent2 and
19-
parent1.hasChild(child, _, _) and
20-
parent2.hasChild(child, _, _)
24+
parent1.hasChild(child, _, label1) and
25+
parent2.hasChild(child, _, label2)
2126
}
2227

2328
private predicate isChildOf(PrintAstNode parent, PrintAstNode child) {

0 commit comments

Comments
 (0)