Skip to content

Commit e513af1

Browse files
committed
Swift: add CFG and PrintAst consistency queries, enabling them in CI
1 parent fca5fb6 commit e513af1

File tree

13 files changed

+31
-55
lines changed

13 files changed

+31
-55
lines changed

swift/actions/run-ql-tests/action.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ runs:
2626
--check-repeated-labels \
2727
--check-redefined-labels \
2828
--check-use-before-definition \
29+
--consistency-queries "${{ github.workspace }}/swift/ql/src/consistency" \
2930
--compilation-cache "${{ steps.query-cache.outputs.cache-dir }}" \
3031
${{ inputs.flags }} \
3132
swift/ql/test
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
private import codeql.swift.printast.PrintAstNode
2+
3+
query predicate doubleChildren(
4+
PrintAstNode parent, int index, PrintAstNode child1, PrintAstNode child2
5+
) {
6+
child1 != child2 and
7+
parent.hasChild(child1, index, _) and
8+
parent.hasChild(child2, index, _)
9+
}
10+
11+
query predicate doubleIndexes(PrintAstNode parent, int index1, int index2, PrintAstNode child) {
12+
index1 != index2 and
13+
parent.hasChild(child, index1, _) and
14+
parent.hasChild(child, index2, _)
15+
}
16+
17+
query predicate doubleParents(PrintAstNode parent1, PrintAstNode parent2, PrintAstNode child) {
18+
parent1 != parent2 and
19+
parent1.hasChild(child, _, _) and
20+
parent2.hasChild(child, _, _)
21+
}
22+
23+
private predicate isChildOf(PrintAstNode parent, PrintAstNode child) {
24+
parent.hasChild(child, _, _)
25+
}
26+
27+
query predicate parentChildLoops(PrintAstNode parent, PrintAstNode child) {
28+
isChildOf(parent, child) and isChildOf*(child, parent)
29+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import codeql.swift.printast.Consistency

swift/ql/test/library-tests/ast/no_double_children.expected

Whitespace-only changes.

swift/ql/test/library-tests/ast/no_double_children.ql

Lines changed: 0 additions & 8 deletions
This file was deleted.

swift/ql/test/library-tests/ast/no_double_indexes.expected

Whitespace-only changes.

swift/ql/test/library-tests/ast/no_double_indexes.ql

Lines changed: 0 additions & 8 deletions
This file was deleted.

swift/ql/test/library-tests/ast/no_double_parents.expected

Whitespace-only changes.

swift/ql/test/library-tests/ast/no_double_parents.ql

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)